Changing working directory in Erlang shell under Windows - erlang

I have Erlang installed on my WinXP machine. Becouse so, I use it by a "werl.exe". The problem is, that I would like to change a default folder that werl starts in. I cannot find option that would let me do that, although I know there must be something like that.
Could anybody help ?

If you want to change directory at run time in the emulator then use the built in function cd as below..
72> cd("c:/Sandbox/erl").
c:/Sandbox/erl
ok
Note: You need to use the forward slash and not backward slash as you would normally do in windows.

You can specify initial settings in a .erlang file
It should be located C:\Program Files (x86)\erlX.X.X\usr.erlang (where X.X.X is the version number...)
If there isn't any then feel create one (note: you'll likely need to run your editor with administrative privileges to create the .erlang file in the appropriate location).
Here is a simple example for the content:
io:format("C:/Program Files (x86)/erl5.10.4/usr/.erlang\n").
io:format(" ______ _ \n").
io:format("| ____| | | \n").
io:format("| |__ _ __| | __ _ _ __ __ _ \n").
io:format("| __| | '__| |/ _` | '_ \\ / _` |\n").
io:format("| |____| | | | (_| | | | | (_| |\n").
io:format("|______|_| |_|\\__,_|_| |_|\\__, |\n").
io:format(" __/ |\n").
io:format(" |___/ \n\n").
shell_default:cd("C:/Documents/MyErlangProjects").
Notice the use of *nix-like forward-slashes (i.e. "/") rather than the typical Windows convention of using back-slashes (i.e. "\").
It can be tested by running an erlang shell and on startup it will print this cool ASCII stuff :). Beware, the cool ascii stuff doesn't mean a valid working directory was specified!
Of course the main important line is the last one:
shell_default:cd("C:/Documents/MyErlangProjects"). where you specify which directory you want to start with as the current working directory.
Enjoy.

Thank you all.
It was just as easy as typing a desired path in the "Start in" option in the "preferences" of shortcut to werl.exe.

If you want to run Erlang in many different projects in different directories I found the easiest most basic solution is to create separate .bat files in each directory. Clicking on one will then run Erlang in the right directory. This makes it easy to set environment variables for Erlang, ERL_LIBS is a good one. It also makes it easy to use different versions at the same time, one .bat file for each version.

Related

Filecoin Textileio Powergate Not Enough Miners from Reputation Module to Satisfy The Constraints Error

I am running WSL Ubuntu 20.04 (Version 2 with Docker Desktop Support) within Windows 10 Pro Version 21H1
The steps are as follows:
git clone https://github.com/textileio/powergate.git
cd powergate/
cd docker/
nano docker-compose.yaml where I added "["lotus", "daemon", "--import-snapshot", "https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car"]" between lines 32 and 33.
make up
Waited for the node to finish importing and then syncing.
^C then make down then deleted the line "["lotus", "daemon", "--import-snapshot", "https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car"]" from docker-compose.yaml
make up
Now that the node was running I typed cd .. so I was in the repo's root directory, then make install-pow
with the pow command in my GOPATH I typed pow to make sure pow was linked fine to powd. It was.
pow admin users create
copied the token and ran export POW_TOKEN=<token copied to here>
Then pow wallet addrs and funded the address
I went to the directory behind the folder of my static website which is about 5GB in size.
I typed pow data stage <my-static-site-folder>
After it was finished staging and printed out the CID I typed pow config apply --watch <CID waited a long time while it said the job was executing and then I got...
---------------------------------------+--------------------------------+-------+-------+--------------
<job id here> | JOB_STATUS_FAILED executing | | |
| cold-storage config: making | | |
| deal configs: getting miners | | |
| from minerselector: getting | | |
| miners from reputation | | |
| module: not enough miners from | | |
| reputation module to satisfy | | |
| the constraints | | |
I don't understand what the problem is. I repeated the pow config apply --watch <CID command each time adding the --override flag with several different modifications to a custom config file. The content did appear briefly on IPFS (not Filecoin), but after I continued running the config apply command the site went down from IPFS.
This problem can be fixed by adding miners to the "trustedMiner" entry in the config file because pow doesn't necessary detect miners that fit your specs.
I went to a Filecoin miner info aggregation site (I used "https://filrep.io/") and added miners to the trustedMiner section of the config file used in the apply command to start a Filecoin deal.
For example the "trustedMiners" line in your config file should look like this:
"trustedMiners": ["<Miner Id>", "<Miner Id>","<Miner Id>", "<Miner Id>", ...],
with however many miners you want to add.
Then you would execute the command:
pow config apply --watch <CID> -o -c new-config-file.json
Btw the --watch flag is optional as it just allows you to see the status of the deal in real time.

torch.CharStorage doesn't read data from a file when size isn't provided

I'm trying to replicate the example provided here. In my case, though, when I do the torch.CharStorage('hello.txt') I get [torch.CharStorage of size 0]. Here's the full output
$ echo "Hello World" > hello.txt
$ th
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ | Type ? for help
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch
th> x = torch.CharStorage('hello.txt')
[0.0001s]
th> x
[torch.CharStorage of size 0]
I also noticed that when I do torch.CharStorage('hello.txt', false, 11) the data is read correctly. However, in documentation the shared and size parameters are specified as optional. Is it the case that the documentation is not up to date or am I doing something wrong?
You appear to be running into distro bug #245, introduced by commit 6a35cd9. As stated in torch7 bug #1064, you can work around it by either updating your pkg/torch submodule to commit 89ede3b or newer, or rolling it back to commit 2186e41 or older.

How do I get the right libjpeg dylib for Lua?

So, I am running torch on OSX (See error in bold below):
______ __ | Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ |
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch
th> package.cpath = package.cpath .. ";/usr/local/Cellar/jpeg/8d/lib/?.dylib"
[0.0000s]
th> require 'image'
true
[0.0120s]
th> image.lena();
/Users/<user>/torch/install/share/lua/5.1/trepl/init.lua:319: error loading module 'libjpeg' from file '/usr/local/Cellar/jpeg/8d/lib/libjpeg.dylib':
dlsym(0x7fd564000320, luaopen_libjpeg): symbol not found
warning: <libjpeg> could not be loaded (is it installed?)
[0.0229s]
th>
Specifically this line:
error loading module 'libjpeg' from file '/usr/local/Cellar/jpeg/8d/lib/libjpeg.dylib':
dlsym(0x7fd564000320, luaopen_libjpeg): symbol not found
warning: could not be loaded (is it installed?)
Seems like I don't have the right dylib? If so, where do I get it?
this happens when there's two libjpeg's installed on your machine, and one conflicts with another.
start torch like this:
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
th
it should hopefully work with this.

"fd:6: hGetLine: end of file" in Cryptol

I've compiled and installed both cvc4 from source code. Cvc4 was downloaded and installed as suggested, and Cryptol was downloaded from it's git repository. The sandboxing, and installation finished without error (with GHC 7.8.3 x86_64). The issue occurs only after invoking cryptol, and issuing a :prove True. Here is everything:
athan#namek ~/lib> cryptol
_ _
___ _ __ _ _ _ __ | |_ ___ | |
/ __| '__| | | | '_ \| __/ _ \| |
| (__| | | |_| | |_) | || (_) | |
\___|_| \__, | .__/ \__\___/|_|
|___/|_| version 2.1.0 (8898348)
Loading module Cryptol
Cryptol> :prove True
cryptol: fd:6: hGetLine: end of file
athan#namek ~/lib>
Any help with this would be tremendous. To me, it feels like there's a shared library not found. Would that cause this issue? Thank you.
Summarizing the conversation in the comments:
The "end of file" error mentioned in the question is commonly attributed to the prover of interest (CVC4 in this case) being only "partially installed" - in my cases this was always an issue with shared libraries that could be discovered by invoking the binary (cvc, boolector, etc) from the command line. The ticket for the bug where the REPL would terminate is on Cryptol's github. Fortunately, this issue was fixed in upstream SBV and will appear in Cryptol's fork of SBV soon.
WRT AthanClark's particular case it is still unknown why and how CVC4 was failing when invoked by Cryptol - possibilities include cryptol invoking a different binary than the one we are expecting or environmental differences, such as the LD_LIBARARY path variable. Either way, it sounds like he was able to use an alternative prover (boolector) successfully.
EDIT: If you can produce Athan's bug, where CVC works outside of SBV and not inside of SBV... and you live in Portland then shoot me a message, show up at my office and show me, I'd be interested.

How to create xpi file with 7Zip?

I would like to pack my firefox extension as xpi file. I tried by adding it to archive and name it as filename.xpi
But when i try to install it on firefox am getting "package corrupted" message. Is there any way i can create a valid xpi file ?
I have installed cygwin and tried to execute zip command to create xpi file. But got zip is not a command error.
Can somebody guide me to get it done ?
If you are on windows (to install cygwin it looks like you do), you can use the windows built in tool:
Select the contents of the extension (remember, don't select the outside folder).
Right Click
Send to
Compressed (zipped) folder
Then just replace the .zip for .xpi in the filename
Looks like your problem is on completing the point 1. correctly. Select only the contents of the extension. Not the folder that contains it.
So basically your zip file should have following structure:
my_extension.zip
|- install.rdf
|- chrome.manifest
|- <chrome>
and NOT this structure:
my_extension.zip
|- <my_extension>
|- install.rdf
|- chrome.manifest
|- <chrome>
I experienced the same problems today and found the error to be that the add-on was obviously not signed by Mozilla, causing Firefox to refuse the installation. Up until recently, it was possible to by-pass this security check by setting xpinstall.signatures.required to false in about:config. However, as of Firefox 46, signing is mandatory and no by-pass is provided any longer, see https://blog.mozilla.org/addons/2016/01/22/add-on-signing-update/ This means that one has to either downgrade to a previous version or use a non release channel version to test one's addons :(
Also, here's how I pack an extension for Firefox with command line 7z:
cd /the/extension/folder/
7z a ../<extension_name>.xpi * -r
(where 'a' stands for "add/create" and "-r" for recursive)
Or to update the extension with the file(s) we just edited:
cd /the/extension/folder/
7z u ../<extension_name>.xpi * -r
("u" for update the archive's content)
Two methods, using the GUI 7zFM.exe, or a command line or batch file.
1.0) GUI method. Assuming 7-Zip is installed with shell integration so you see 7-Zip show up in the context-menu (right-click of selected files) of Windows Explorer.
1.a) Go into the folder of your add-on.
1.b) Select all the files and folders you want to include in the .xpi. Assuming you don't have any files you want to ignore down in any sub-folders. If you do, you might want to use the command line option.
1.c) Right-click on the list of selected files, find the 7z icon, choose the Add to archive... option.
1.d) A dialog pops up. Edit the location and name of the zip file, change to .zip to .xpi, etc.
1.e) Note if you create the .xpi in the same folder, don't re-archive it in the future, as your add-on will fail horribly. You never want an .xpi ending up inside your .xpi by accident. I usually just create it in the parent folder, by adding ..\ to the beginning of the file name, e.g. ..\addon-1.2.3-fx.xpi
1.f) 7-Zip has a lot of powerful compression options, not all of which Firefox can handle. Choose settings which Firefox is able to process. Refer to image.
2.0) Command Line method. Assuming you're in Windows, and know how to open a command prompt, change drives and directories (a.k.a. folders).
2.a) CD to your add-on directory.
2.b) Use the most basic 7-Zip command line.
"C:\Program Files\7-Zip\7z.exe" a -tzip addon-1.2.3-fx.xpi *
2.c) You can get a smaller file by finding the exact command line options which correspond to the above GUI, namely:
"C:\Program Files\7-Zip\7z.exe" a -tzip -mx=9 -mm=Deflate -mfb=258 -mmt=8 "addon-1.2.3-fx.xpi" *
Note that there is no Dictionary size = 32kb option when using Deflate Compression method. Otherwise, the options are in order and correspond to the GUI.
|-----------------------|---------|--------------|
| Option / Parameter | GUI | Command line |
|-----------------------|---------|--------------|
| Archive format | zip | -tzip |
| Compression level | Ultra | -mx=9 |
| Compression method | Deflate | -mm=Deflate |
| Dictionary size | 32 KB | (none) |
| Word size | 258 | -mfb=258 |
| Number of CPU threads | 8 | -mmt=8 |
|-----------------------|---------|--------------|
| Additional Parameters | | |
|-----------------------|---------|--------------|
| Recurse into Folders | (none) | -r |
| Multiple passes | (none) | -mpass=15 |
| Preserve Timestamps | (none) | -mtc=on |
| Ignore files in list | | -x#{ignore} |
|-----------------------|---------|--------------|
Notes:
i) The multi-thread option (-mmt=8) is specific to my system which has 8 cores. You will need to lower this to 6 or 4 or 2 or 1 (i.e. remove option) if you have fewer cores, etc, or increase if you have more. Won't make much difference either way for a small extension.
ii) The option to recurse into folder may or may not be the default, so specifying this option should ensure proper recursion.
iii) The option to preserve windows timestamps (creation, access, modification) should default to on anyways, so may not be needed.
iv) The ignore files in list option is any file which has a list of files and wildcards of files you wish to exclude.
2.d) Advanced topic #1: ignore file list (examples)
|----------------|------------------------------------|
| What to Ignore | Why to Ignore |
|----------------|------------------------------------|
| TODO.txt | Informal reminders of code to fix. |
| *.xpi | In case you forget warning above! |
| .ignore | Ignore the ignore file list. |
| ignore.txt | Same thing, if you used this name. |
|----------------|------------------------------------|
"C:\Program Files\7-Zip\7z.exe" a -tzip -mx9 -mm=Deflate -mfb=258 -mmt=8 -mpass=15 -mtc=on "addon-1.2.3-fx.xpi" * -x#ignore.txt
2.e) Advanced topic #2: Batch file (Windows CMD.EXE), assuming fairly recent windows, i.e. from the 21st century. This can be as simple and rigid, or complex and flexible as you care to make it. A general balance is to assume you will be in the Command Prompt, in the top level directory of the add-on you are working on, and that you have intelligently named that directory to have the same basename of the .xpi file e.g. D:\dev\addon-1.2.3-fx directory for the addon-1.2.3-fx.xpi add-on xpi. This batch file makes this assumption, and dynamically figures out the correct basename to use for the .xpi.
#ECHO OFF
REM - xpi.bat - batch file to create Mozilla add-on xpi using 7-Zip
REM - This finds the folder name, and discards the rest of the full path, saves in an environment variable.
FOR %%* IN (.) DO SET XPI=%%~nx*
REM - Uncomment the DEL line, or delete .xpi file manually, if it gets corrupted or includes some other junk by accident.
REM DEL "%XPI%.xpi"
REM - Command line which does everything the GUI does, but also lets you run several passes for the smallest .xpi possible.
"C:\Program Files\7-Zip\7z.exe" a -tzip -r -mx=9 -mm=Deflate -mfb=258 -mmt=8 -mpass=15 -mtc=on "%XPI%.xpi" * -x#ignore.txt
REM - Cleanup the environment variable.
SET XPI=
When pack extension using 7z, compress into .zip and then rename to .xpi, dont compress i
Do as per the following while using 7z
Select only the inner contents and not the outer folder.
Enter the filename as filename.xpi and choose archive format as zip in the prompt that appears while zipping.
You will find a valid xpi file created.
Use the created xpi for installing your extension on firefox.
It works!
Just zip all the files and folders inside my_extension folder and change the resulting zipped file's extension to my_extension.xpi
/my_extension
|- defaults/
|- locale/
|- resources/
|- install.rdf
|- ... (other files and folders)
Installation of xpi file created from zipped file of my_extension folder will result error as
"This add-on could not be installed because it appears to be corrupt." error
I try myself to build a zip in several ways because I was convinced I do something wrong 'cause all i got was "package corrupted" stuff .
well.. not anymore and I do not even need to load it from Load temporary add-on (now i drag and drop the xpi file from the desktop over Waterfox and I install it as legit xpi file!
How I do that?
'Cause I try myself the github stuff I load it first in Load temporary add-on (url:about:debugging#addons) the xpi file using the method used by user314159 with the .bat file method that use 7zip.
after you load that you should read somewhere something similar to:
Extension ID
86257e65ca311ee368ffcee50598ce25733a049b#temporary-addon
then all you should do is add inside manifest.json modifying the "applications" :
"applications": {
"gecko": {
"strict_min_version": "54.0a1",
"id": "86257e65ca311ee368ffcee50598ce25733a049b#temporary-addon"
}
},
after this push Remove to uninstall the temporary addon then you should build the xpi again like you did before
now is a normal xpi file SIGNED what you can install normal ! (here is works without modifying anything else)
I use Waterfox x64 i's seems to be problems to Firefox
the answer is you should upload your extension on the hub then to use mozilla signing api
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Distribution
Create file config.js
Insert code into config.js
//
try {
Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
.eval("SIGNED_TYPES.clear()");
}
catch(ex) {}
Move config.js to application work folder, eg: C:\Program Files\Mozilla Firefox\
Create config-prefs.js and write code into:
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");
Place config-pres.js to C:\Program Files\Mozilla Firefox\defaults\pref\
Restart Firefox
Look result

Resources