Download repository from Github - yeoman

I'm trying to learn Yeoman, but find the official documentation severely lacking. I've found the remote() function which appears to download a GIT repository but whatever I do I can't get it to work without throwing errors.
Here's what I have:
this.remote('powerbuoy', 'SleekWP', 'master', function (err, remote) {
if (err) {
this.log(err);
return err;
}
remote.copy('.', this.destinationPath('wp-content/themes/sleek/'));
}.bind(this));
What I'm hoping would happen here is that the https://github.com/powerbuoy/SleekWP/ repo is downloaded and moved to wp-content/themes/sleek/. What happens instead is I get:
fs.js:603
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EISDIR: illegal operation on a directory, read
Is there a better documentation or a tutorial explaining all these basics somewhere? I'd love to know how to copy files without each copy being printed to the console too for example. This all seems pretty basic but http://yeoman.io/authoring/ is very sparse.

Ok, so apparently the solution was to use remote.bulkDirectory() instead of remote.copy().
Edit: However, reading the "documentation" (can barely be called that) it says that "You should never use this method, unless there's no other solution." (http://yeoman.io/generator/actions_actions.html)
So if anyone knows of the proper way to do this I'd love to know.
I switched to the fs-extra package and used cacheRoot() and destinationRoot() to copy the directory instead:
fs.copy(this.cacheRoot() + '/username/Project/branch/', this.destinationPath('destination/path/')

Related

catalogue.RegistryError: [E893] Could not find function 'spacy.copy_from_base_model.v1' in function registry 'callbacks'

I'm a Spacy's new user and I'm trying to run this ner_demo_update project and I got this error :
catalogue.RegistryError: [E893] Could not find function 'spacy.copy_from_base_model.v1' in function registry 'callbacks'. If you're using a custom function, make sure the code is available. If the function is provided by a third-party package, e.g. spacy-transformers, make sure the package is installed in your environment.
I'll like to know if someone has face the same issue.
copy_from_base_model.v1 is a new function, introduced in spaCy v3.0.6. Are you perhaps running an older version of spaCy? If so, can you try updating it? This will likely resolve your error.
See also: https://github.com/explosion/spaCy/discussions/7985

Open file with default application from Vala?

What's the best way to open a file in the default application from Vala?
A bit like how xdg-open works.
I found some existing code in another application, but later on I also found this
GLib.AppInfo.launch_default_for_uri method.
A simple example:
var file = File.new_for_path (file_path);
if (file.query_exists ()) {
try {
AppInfo.launch_default_for_uri (file.get_uri (), null);
} catch (Error e) {
warning ("Unable to launch %s", file_path);
}
}
If you're using GTK, then you've also got Gtk.gtk_show_uri_on_window(), which uses the GLib stuff under the hood.
As far as I know there is only one implementation of the relevant freedesktop.org standards.
That is the reference implementation in xdg-utils:
https://www.freedesktop.org/wiki/Software/xdg-utils/
The tools are written in shell script, for example here is the source code for xdg-open:
https://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-open.in
So by far the easiest way is to just call the xdg-open script via Process.spawn_async and friends.
If you insist on using a library function you would have to implement a standard conforming library yourself.
Update:
There are quite a few libraries in various languages that implement some of the freedesktop.org standards, for example here is a list on GitHub:
https://github.com/topics/xdg
For example here is a similar tool to xdg-open written in D:
https://github.com/FreeSlave/mimeapps/blob/master/source/mimeapps.d
What I didn't find so far is a Vala / GLib or plain C library that could easily be used from a Vala application.
Update 2:
Actually it turns out there is something for that purpose in GLib (or more precisely in Gio):
https://valadoc.org/gio-2.0/GLib.AppInfo.launch_default_for_uri_async.html
https://developer.gnome.org/gio/stable/GAppInfo.html
So you should be able to use the GLib.AppInfo.launch_default_for_uri_async method.

Ctypes mozilla unknown error

In a mozille extension I run:
SecSess.Logger.info("ctypes test");
Components.utils.import("resource://gre/modules/ctypes.jsm");
SecSess.Logger.info("1");
this.lib = ctypes.open("libcrypto.so");
SecSess.Logger.info("2");
var a = new Uint8Array(1<<10);
SecSess.Logger.info("3");
var ptr = new ctypes.uint8_t.ptr(a.buffer);
SecSess.Logger.info("4");
Why this ugly logging after each step you might ask? Well this code fails without showing me an error. (or at least I can't find the error message)
This is printed:
ctypes test
1
2
3
So the 5th log message is never printed which means the following statement never completes:
var ptr = new ctypes.uint8_t.ptr(a.buffer);
This is a simplified version of some old code I have to work with and which I also found online as being valid. However it doesn't work. This add-on wasn't developped using the new SDK with jpm. Quite frankly I don't know how and when it was developped but I need to run some tests on it. It comes with a few source files ordered in a components and a modules directory and a chrome.manifest and install.rdf in the root. I copied these files to the extension directory of Mozilla in order for it to work. The extension executes but there seems to be a problem with ctypes. Aren't ctypes fully supported anymore or are these old style add-on no longer valid for the modern Firefox?
Regards,
Roel
I think they landed a a patch to disallow making a pointer from buffers. I'll double check.
Edit:
Ah per this: https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers, you don't have to wrap it with a ctypes.uint8_t.ptr just pass it like a.buffer to wherever you need it. :)

How do exceptions during Rhino readFile work?

I have this code running inside Rhino under Linux. The file doesn't exist.
try {
var u = readFile("/tmp/wtf");
print(u);
} catch (e) {
print("error!");
}
The code in the 'catch' doesn't run, even though the file definitely isn't there. I just get a blank value assigned to 'u'. Is this normal?
Are there other situations (besides a file missing) where the catch would run?
Could I differentiate an empty file from a missing one without invoking some other function? (I realize Rhino gives me access to most of the standard Java libaries).
Just want to confirm that readFile is always synchronous?
I can't find anything much on SO or MDN about how readFile works. Any insight appreciated.

LaTeX Failed to Parse(Unknown Error) on MediaWiki

On my wiki implemented by the MediaWiki interface, I am receiving a Failed to Parse (Unknown Error) for the LaTeX in the page. I checked the LocalSettings.php file, and I have set the proper variable($wgUseTeX) to true.
If it helps, the error message before this was a Failed to Parse(Missing texvc executable), but I "fixed" it to the best of my knowledge by running "make" inside the math directory and installing the texvc executable there. I tested texvc and it works on the commandline.
Could there be anything that I am missing?
aptitude install ocaml
cd /math
make clean
make
Found the answer here: MediaWiki Forums LaTeX Error
It seems that I had to clear the math directory except for the original files, rebuild ocaml, and finally rebuild texvc.
Adding this to LocalSettings solved it for me. Just needed to make the directory calls accurate. Tedious.
$wgUseTeX = true;
$wgUploadDirectory = "{$IP}/images";
$wgUploadPath = "{$wgScriptPath}/images";
$wgMathPath = "{$wgUploadPath}/math";
$wgMathDirectory = "{$wgUploadDirectory}/math";
$wgTmpDirectory = "{$wgUploadDirectory}/tmp";
$wgTexvc = "{$IP}/math/texvc";
Have a look at the README file, paying particular attention to "Ensure that the temporary and math directories exist and can be written to by the user account the web server runs under; if you don't control the server, you may have to make them world-writable."
If that does not help, edit render.ml, comment out the block that says "Commenting this block out will aid in debugging", and re-run make. This will leave all temporary files (including the TeX log) so that you can hopefully see what went wrong.

Resources