I'm trying to link a custom library to a document that will be copied and shared with many people. I want to have all documents link to the latest version of the library, so when I modify the library I don't have to access all the documents to change the link.
This is the scenario:
I created a simple single function library (e.g. library TestLib, function foo()), and saved a first version of it. Then I've created a SpreadSheet with a script that generates a user menu that calls function TestLib.foo(). I've linked version 1 of the library to the script. Now I want to make several copies of the document, one for each people who will need it. The problem is that these documents are linked to version 1 of the library. If I made a change to the library and create a version 2, I have to manually re-link all documents to the new version. That's gonna be lot of work...
Is there a way to have the script to always link to the latest version?
NOTE: the library project is shared in read-only mode (people won't collaborate with the code. They just call foo() from the menu when needed).
Thank!
MIX
I made a new test, trying to overtake the version "limitation" problem.
The idea is a little complicated, but promising. The spreadsheet calls a function in library LinkLib: this library will be saved in a single version and the source code will never modified. The library function simply calls a function on another library (MainLib), whom source code can change over time. Spreadsheet doesn't need to change the version of the linked library (there will never be new version of BaseLib source code), while BaseLib can change the version of MainLib linked if I made changes in MainLib's source code..
The problem is: changing the version of a linked resource is treated as a source code modification. So you need to save a new version of BaseLib to actually use an updated version of MainLib's function.
Hope this mess is somewhat clear...
It makes sense that the described version management behave like this. But damn, I'm still stuck with this problem...
this is possible but with a risk. simply use "development mode" for all documents using the library. whenever you update the library it will include the new code automatically.
the risks are that you will have to be careful to never save an intermediate/partial change as all changes need to not break anything. this can be tricky and is best to have a separate library copy to use when making and testing changes. once tested you may copy all files and "save all" together so the script doesnt have partial saves.
basically you lose the development facilities of using versions.
read more about library development mode in the official docs.
Related
If I move ComponentFoo.js from folder X to folder Y, than a bunch of import statements break. Looking into this it seems there are many solutions for typescript, but what about js / es6? If I move a file in the editor, it should find all the import statements and update them to the new location. Is this possible?
Old post, but this might help some Googlers. This feature can be enabled and disabled in User Settings. For Javascript and Typescript, it's called "Updated Imports On File Move".
I had apparently disabled it and just figured the feature was broken :X
VS Code has built-in support for this for both javascript and typescript since VS Code 1.24.
For JavaScript specifically, you need to make sure VS code's language support can find all the references to the file so that imports referring symbols in that can be updated properly. Definitely create a jsconfig.json for your project, and also consider enabling semantic checking for JavaScript so that VS Code shows when imports are not being properly resolved
If your project is configured properly but files are not being updated, make sure you are running the latest VS Code insiders build and report an issue if it still doesn't work
for flutter developers you should move files one by one. vscode doesn't support multi file moving with refactor yet.
Just use IntelliJ. It handles all kinds of refactoring perfectly. I'm a huge fan of VS Code, but refacotoring is definetly not one of it's stengths. Some imports don't get detected, and the imports can get modified in a weird way. For example, I had an import like this:
import { myStore} from 'src/common/stores/myStore';
When moving the file of myStore.ts to a different folder, VS Code constructed this bull**it:
import { myStore} from 'src/common/composables/myStoreStore';
The line above is no typo!
Btw I'm using vetur, maybe thats causing it, I don't know ...
Good evening,
I am currently developing a way to import machine created data from a csv sheet into a database.
The question I have is, is there a way to react to a change in a csv file with Lua.
The file gets a line in this format:
17162H,"801234500001",9/23/2016 12:33:30 PM,"INV"
Every time a scanner is finishing a scan process, added under the old lines, but there is no direct connection to the database, to trigger the script.
It doesn't matter if the change is detected via different file size, foldersize (of the folder that contains the file) or a change within the file information (like date of last opening), but I can't open and read in it permanently due performance reasons.
Also this is the first time I ask here, so sorry for my clunky way, I'll try to improve myself with that over time.
Take a look at linotify, it has lua bindings for inotify and looks like it should do the trick, using the "modify" event to trigger your script.
I use LibUV based variant in my spylog apllication
Usage:
file_monitor(path_to_file, {eol = '\r?\n'}, function(line)
...
end)
If you need to run this on Windows, you can use winapi library, which supports file watchers. Here is an example of how it's used in one of my projects; you'll need to call winapi.sleep() to allow time for the check to trigger.
I'm creating a Google Apps Script that's kind of a quiz marker / email merger in one. I've got everything working but my code is pretty long because I find myself having to use procedural coding. This is mostly because I don't know how to use the editor to include a class / library.
I've viewed the Crash Course Video by Kalyan on using the Script Editor, but it didn't answer my question. I've also scoured the internet with no luck.
If you look in the top left of this screenshot, you'll see I have Code.gs and test.gs:
I have all my code in the Code.gs file, but I want to include test.gs in Code.gs. Once I figure out how to do that, I'd like to create a couple of simple classes to organize my functions a bit better (and possibly re-use my classes later).
Thanks in advance!
To clarify Zig Mandel's answer and add to it:
All .gs files that are located in the same Script Project have global access to each other. That is to say that a function that you define in test.gs is accessible by Code.gs if they are in the same Script Project
You can create your own library of code. To do this you would simply create another Script Project, then go to Resources -> Manage libraries..., and add the project key of your original project (that contains the Code.gs and test.gs files). The project key is located in File -> Project properties.
The second bullet point is a good way to organize your code. If you have the same code that you are reusing throughout many Script Projects, then you want to put those functions into one Script Project and create a library out of them, as I explained above.
You already included the code. Should work as is. You can also look at the apps script docummentation and learn to use libraries for code reuse:
https://developers.google.com/apps-script/guide_libraries.
This makes development easier but for best performance you should include them all in your project before publishing like you did this time.
Part of the problem may be the order of execution. The .gs files are executed in order of creation. Copying Code.gs, deleting the original, then running functions from the new copy may fix your problem.
<?!= include('JavaScript.html'); ?>
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
Now I have AppA finished. but I want to make AppB,AppC. and AppB,AppC share most of the code in AppA(including xaml, asset, code,etc.). only a few changes for the AppB,AppC respectively.I mean, the 3 apps can be installed on the same windows phone separately with different icons.
Does anybody know how to build AppB,AppC referring AppA in code?
thanks.
Either extract as much as you can in a shared/common project or use "Add as Link" to include files from AppA into AppB and AppC.
Note that XAML files don't support conditional compilation so they must be identical for all projects in order to link them. You can potentially extract XAML differences into App.xaml StaticResources (identical keys) in order to make them identical and link them.
Sharing XAML is very reasonable when targeting the same platform.
You can also link cs files even if they are similar (few changes) by using conditional compilation.
Partial classes can also spare you the conditional compilation ceremony in many cases.
Finally Resource files are very good candidate for reuse. If you decide to put them on a shared library remember to wrap the generated Resource class in another public one with a public constructor shown here in order to avoid the internal constructor issue.
You can put all your code in an external class library. As far as I know though your assets and pages need to exist in each project.
If you want to share code and assets between multiple assemblies, you can create a class library for Windows Phone and put all the code inside it. When you need to use that library, simply link it in your target applications.
When you want to navigate to a page in your library, use the following syntax:
NavigationService.Navigate(new Uri("/AssemblyName;component/page.xaml", UriKind.Relative));
I am developing a package in R
When I am debugging a particular function or set of functions, what is the best way to test the function?
Do I have to either use source('function.R') or R CMD build each time I want to check my changes?
(extra credit for associated emacs ess key-bindings)
See also http://github.com/hadley/devtools/ which provides some tools to make this task easier.
for example, after making changes to source code, you build, install, and reload a package with the function install():
library(devtools)
install("package_name")
devtools also makes it easier to:
Reload complete package:
load_all("pkg")
Create or update documentation using roxygen2
document("pkg")
run all scripts in /inst/test/:
test("pkg")
build and R CMD check:
check("pkg")
Take a look at ?insertSource, which is a new function in R 2.12.0, plus the other functions in the See Also section of that help page. Also, check out ?assignInNamespace if your package has a Namespace.
The above presumes you are talking about updating and debugging R sources, not compiled code.
I generally have used the source() route to load new versions of functions I am improving/debugging, alongside the usual R debugging tools. But I haven't got Namespaces in my packages as yet. My fingers have gotten quite used to the C-c C-l keybinding in emacs+ess for sourcing a buffer over the years.
You might want to have a look at the 'mvbutils' package. I use it to live-edit my packages all the time; I can add, remove, and edit functions and documentation while the package is loaded, and the changes are reflected both in the loaded version, in the installed version (so they're kept in the next R session), and [when I tell it] in the "source package". I only re-build via R CMD when I want to distribute a zipped version to someone else. To test code, I use the 'debug' package, which works fine on a loaded package.
I even use 'mvbutils' to live-edit 'mvbutils', which can be a bit hairy sometimes.
The 'mvbutils' documentation could really do with a full demo of this in action, but in theory the existing doco should show you how to proceed.
Can't help you with Emacs, sorry...
I had got the same issue and I solved it while using RStudio.
In the editor, I check the option "Source on save" for my R file that contains function. As I'm used to save my file each time I edit it (a good habit I think), the corresponding functions loaded in my R workspace is always up to date.