How to create a symlink within browserFS - javascript

I'm trying to create a symlink inside of BrowserFS.
I can confirm that BrowserFS can read sym links just fine... (I tested by making a zip file and loading it in, and doing fs.readFile and all is A-OK)
However, when I try to create a sym link via fs.symlink, I get an Error, I assume this is meaning it is not supported.
Can any of the folks out there that may use browserFS know how to propertly create, or any workarounds for creating symlinks?
One idea is to create the contents of a symlink and set file modes, but I had a hard time finding the exact way to do that. Any help appreciated!
I've included a codesandbox in case anyone is interested! https://codesandbox.io/s/43wroyjy9w

Related

How to automatically make array of all files in website folder?

Let's say I have a folder of about 100 images on my website called "IMG"
Now let's say I have a div element: <div id="templateDiv"></div>
Using javascript, how would I add all images from "IMG/" into that div without adding <img src="IMG/IMGNAME.jpg"> for every image?
Sorry, I'm not very good at explaining.
Just ignore the fact that would take ages to load.
EDIT
Ok my bad explanation skills have made me change my question.
How do I automatically make array of all files in website directory?
Okay, your question is incredibly unclear, but from reading all your other comments and things, it seems you simply want to get an array that contains the filename of every file in a directory? If that's what you want, then it won't be possible (I don't believe) since only the server knows which files are where, and you can't request the contents of a directory from a server using JavaScript.
However if you were using Node.js on a local directory, then it could be done. But I don't believe that's your case.
That being said, you have three alternative options:
Name every image file 1.png, 2.png, 3.png, etc. Then use a for loop and get each one using (i + 1) + ".png"
If you can't rename the files, but the files are named via user input, you could collect the user's input at the time of file creation and add the name of the newly created file into another file/an array/localStorage so that it could be retrieved later.
If you can't rename the files, but the filenames are also never known to the program that needs them, then you could create an array of all the filenames (manually) and iterate over that to find all the files that you want.
Please, somebody let me know if I'm wrong and if there actually is a way to make a request to a server that tells the client all the files in a directory. That seems incredibly unlikely though.
Another potential solution just came to mind. You could write a PHP script (or Node.js or any server-side language, really) that scans a directory, creates a list of all the filenames there, and then sends that back over HTTP. Then you could simply make an XMLHttpRequest to that PHP file and have it do the work. How does that sound?

Making a DuckDuckHack Instant Answer work on own site

I'm trying to see whether it's possible to use the code from DuckDuckHack Instant Answers outside of the context of the main DuckDuckGo website. After all, an Instant Answer is mostly a standalone component that consists of some HTML, CSS and Javascript and should be relatively self-contained and reusable.
Since the DuckDuckHack project is in maintenance mode, it seems to be a bit difficult to obtain information: the Slack and Forum mentioned on the Developer Guide have been disabled. I tried to find out whether other people tried to make Instant Answers work in other contexts, but I couldn't find anything. There are tutorials on writing Instant Answers, such as this using Perl and the DuckPAN tools. I tried to get an existing Instant Answer to work using those tools but I failed to get it to work properly (not sure whether they are still maintained).
Since those tools seem to be a bit heavyweight, I thought it could be possible to bypass them completely and try to just use the HTML, CSS and JS from the Instant Answer directly.
I've given the Calculator a first shot. I identified the relevant source code in the duckduckgo/zeroclickinfo-goodies repository's directory share/goodie/calculator. The HTML seems to be in the content.handlebars, and then there's calculator.css and calculator.js. I created a plain HTML file, put the HTML from content.handlebars in there and included references to the CSS file and the JS file. At first, the CSS wouldn't work because the CSS rules don't apply without adding some more wrapper divs that can be easily found when inspecting the DuckDuckGo site with the calculator Instant Answer visible. After adding those wrapper divs, the calculator UI appears more or less intact. However the buttons of the UI do not work at all yet.
Looking at the Javascript console I get this error:
Uncaught ReferenceError: DDH is not defined
at calculator.js:1
Apparently an object DDH is required by calculator.js, however I have no idea what that object should be and how I could create it.
Does anybody know how this DDH variable gets usually initialized or more generally how to make this work? Any reference to projects reusing the code from DuckDuckHack for their own sites would also be highly appreciated.
I think the details of how the DDH object is put together might not be exposed through the open-source portion of DDG.
I've also made some attempts to repurpose some of the built-in DDG IA functionality (e.g. get programmatic access to the many, useful instant answers unavailable through their API).
In the process, I cloned the goodie repo and poked around. The pattern seems to be that for most goodies the payload to be displayed is DDH.<goodie>.content. In my local copy of the goodie repo:
$ grep -rE 'DDH' ./lib/
./lib/DDG/Goodie/Conversions.pm: content => 'DDH.conversions.content'
./lib/DDG/Goodie/Conversions.pm: content => 'DDH.conversions.content'
./lib/DDG/Goodie/Game2048.pm: content => 'DDH.game2048.content'
./lib/DDG/Goodie/PublicDNS.pm: list_content => 'DDH.public_dns.content',
./lib/DDG/Goodie/JsBeautifier.pm: content => 'DDH.js_beautifier.content'
./lib/DDG/Goodie/SassToCss.pm: content => 'DDH.sass_to_css.content'
./lib/DDG/Goodie/Constants.pm: title_content => 'DDH.constants.title_content'
...
On the javascript side of things, you'd find the corresponding .js files in the share/goodie directory, as you did for the calculator goodie.
The <goodie>.js files seem to introduce DDH.<goodie> namespaces (typically right at the top of the file) and define DDH.<goodie>.build functions. This procedure is referenced in the goodie-display docs (see the section titled Setting Goodie Display Options on the Front end therein).
Nowhere in the docs, though, is it documented how the content property of DDH.<goodie> is put together. I cloned the docs repo and grepped for DDH, revealing nothing to that effect.
None of the .js files in the share/goodie folder of the goodie repo, though, seem to give a clue as to how DDH.<goodie>.content is assembled either. Indeed, some of those .js files do not even contain the string content. For a listing of all share*.js files that do contain the string content, I did (in the local copy of the goodie repo):
$ find ./share -name "*.js" |xargs grep -l 'content'
./share/goodie/countdown/countdown.js
./share/goodie/text_converter/text_converter.js
The other .js files do not contain that string at all..
Edit
On the other hand though, I see you did manage to get the calculator going with some modifications to the .js file (e.g. by inserting that missing DDH namespace).

How to remove custom javascript reference from Drupal 7 subtheme

Following the guide on managing javascript in Drupal 7 I added a "myjs.js" file in my sites/all/themes/mytheme/js folder, and included a line in the mytheme.info file (scripts[] = js/myjs.js). When I view page source on my site I can see the file is loaded.
Following a number of issues, I tried to back out of this. I removed the scripts[] line in the mytheme.info file, and deleted the js file from the js folder. So, theoretically, my drupal 7 site should have no knowledge of my custom js file, right?
Well, after numerous clearing of caches, hard reload of browser, even stop/restart my xampp server, whenever I view source on my site I see that file is still referenced as being loaded.
Must be a database thing? Where else would Drupal store and therefore persist my reference?
I also tried adding a new js file in the .info file (e.g., "js/newjs.js") and after clearing cache I never see the new file. Only the old, original file is there.
I'm using a bootstrap subtheme, and have checked both bootstrap.info and of course mytheme.info and there is NO reference to the myjs.js file anywhere.
This is exasperating. Any thoughts where I might look (database record, e.g.,).
THanks.
Found the problem. I'm using AMPP as localhost server. When I first set this up I installed the D7 on my D: drive...or so I thought. I'm not sure exactly how AMPP works but I found there is another installation on my C drive in the Systems folder. Therefore, I have two installs, and thought I was working on the D drive version all this time. Oddly, both of them are "almost" in synch....so at some point recently the D drive version was running, but now it's the C. I never did a restore so have no idea whether the C drive is/was a "clone" of the D drive install. Whatever. Feel so stooopid. I guess the key learning is when everything should be working but isn't, and if odd things are happening, look for the simple-stoopid things you might have done. Chris G was almost on point...I had uploaded the js and .info files, but to the D drive!

How to get a value in bootstrapper with wix?

I'm working on an installer and specifically with the bootstrapper I'm trying to grab a path from a bundle.wxs I have setup. The bundle itself is just a bunch of property variables. In it, I have access to the path I need to get. However, I'm not sure how to get that path from the bundle. I have a localization file that I would ideally call to get the information, inferring that the localization file would be the one accessing the bundle to get the value. Anyone know how to do this nicely? I've attempted to use pre-processed variables to do it, but it hasn't worked so far.
Thanks!

PyCharm JavaScript References Across .js Files

I'm currently stumped about a problem I'm facing where I can't reference functions and variables from one JavaScript file to the next. I've tried adding all of the JavaScript files as a library in File->Settings->JavaScript->Libraries but with no success - I still get the gray underline for references with, for instance, a hover-over message that reads "Unresolved function or method ".
The strange thing is if I move a copy of the JavaScript files outside of the subversioned project directory and then add that project-external reference to File->Settings->JavaScript->Libraries then the references are found but this solution is not satisfactory because these JavaScript files are updated via subversioning daily (we're in development)
Does anybody have any insight to my problem? If I am not going about this the right way then let me know. What I ultimately want to be able to do is reference variables and functions from specfic JavaScript files across all my JavaScript files so that I can easily follow references (ctrl+leftclick) to insure the parts are fitting together properly.
Thanks!
(P.S. I'm using PyCharm 2.5)

Categories