Trouble with visualizer.pl - state

I'm trying to use visualizer.pl to visualize the dynamics of multi-state system
my function file:
f1 := x2
f2 := x1+x2*x3
f3 := x3^2+x1+x2+1
I used the following command as mentioned in "readme.txt" 
perl visualizer.pl -p 1.txt 3 3
since prime := 3 and num_nodes :=3
but I got this error
educ#educ-VirtualBox:~/Desktop/visualizer$ perl visualizer.pl -p 1.txt 3 3
Errors found in the input file. See below for description:
ERROR: Incorrect start of function declaration in function 1.
Errors with input file..ending program at visualizer.pl line 162, > line 1.
State Space Visualizer
Version 1.0 beta
-------------------------------------
The State Space Visualizer is a tool for the visualization of the dynamics of multi-state, discrete models of biological networks.
More information about package:
https://web.archive.org/web/20110815084457/http://dvd.vbi.vt.edu/tutorial.html
https://web.archive.org/web/20120320172453if_/http://dvd.vbi.vt.edu/visualizer.zip

Use = to separate your functions, and remove spaces around the =. Your input file should thus be:
f1=x2
f2=x1+x2*x3
f3=x3^2+x1+x2+1
I know that it's not consistent with the readme, but it's consistent with the content of visualizer.pl, and it works.
If, once that's done, the script visualizer.pl fails with:
sh: 1: kghostview: not found
You can fix it by installing ghostview (sudo apt install gv on Debian), and replacing the line system("kghostview out.ps &"); by system("gv out.ps &"); at the end of visualizer.pl.

Related

Getting "unmarshal failed" when trying to create first website post in Hugo after installation

I'm following the instructions at Hugo's Quickstart guide (https://gohugo.io/getting-started/quick-start/) but I keep getting this error message when I try to create a post:
unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
I've posted some lines of my code below. The error message appears at the bottom. Could anyone help point out what I am doing wrong?
C:\Users\Scott\quickstart\MyHugoBlog\themes>git init
Initialized empty Git repository in C:/Users/Scott/quickstart/MyHugoBlog/themes/.git/
C:\Users\Scott\quickstart\MyHugoBlog\themes>git submodule add https://github.com/dashdashzako/paperback.git
Cloning into 'C:/Users/Scott/quickstart/MyHugoBlog/themes/paperback'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 194 (delta 3), reused 9 (delta 1), pack-reused 178 eceiving objects: 53% (103/194)
Receiving objects: 100% (194/194), 466.30 KiB | 5.62 MiB/s, done.
Resolving deltas: 100% (93/93), done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory
C:\Users\Scott\quickstart\MyHugoBlog\themes>echo theme = \"paperback\" >> config.toml
C:\Users\Scott\quickstart\MyHugoBlog\themes>hugo new posts/my-first-post.md
Error: "C:\Users\Scott\quickstart\MyHugoBlog\themes\config.toml:1:1": unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
It looks like you're following instructions meant for Unix-like systems on Windows. This command isn't doing what you want:
echo theme = \"paperback\" >> config.toml
Using Bash on Linux, for example, this appends
theme = "paperback"
to your config.toml file, creating it if necessary. That's what Hugo expects to find in the file.
However, using cmd.exe on Windows I get the backslashes included:
theme = \"paperback\"
And using PowerShell, I get something even stranger:
theme
=
\paperback\
Neither of these looks like valid TOML to me, and both contain extraneous backslashes as referenced in your error message. I suggest you simply edit config.toml using your favourite text editor and add the expected
theme = "paperback"
line manually.
The issue on my end was that the file wasn't created as UTF-8
Delete the config.toml file and recreate it manually on your text editor, then paste the content like: theme = "ananke"
should work

How to give argument for webcam

I am using command line argument and by question is related to my last question as i want to check it through webcam but when i give command line argument regarding camera operation (0),
it give me error on it as invalid argument 0.
This my explained last question but in that question i am using image path, but now i want to open webcam functionality for testing. This is the Sample Program i am using for testing and checking result.
To use default camera, you need to not pass -i argument.
This command line works for me:
path\\to\\cascade\\facefinder -m 128 -M 1024 -a 0.0 -q 5.0 -c 1.1 -t 0.1
All but first arguments are optional.

sublimerepl getenv failing

I'd like to use the SiblimeREPL package with Sublime Text. When I try to start a REPL, I get
SublimeREPL: obtaining sane environment failed in getenv()
Check console and 'getenv_command' setting
WARN: Falling back to SublimeText environment
This happens regardless of which REPL I try to start. (I tried Ruby, Python, and Clojure.) I tried Sublime Text 2 and Sublime Text 3 with the same results. This is on Mac OS X, if that matters.
I looked in the package settings, where I see
"getenv_command": ["/bin/bash", "--login", "-c", "env"],
If I run "/bin/bash --login -c env" at a Terminal prompt, I get my environment listed.
What do I need to change in order to get a successful getenv_command?
I had the same problem as ssgam. The problem line for me is in the getenv method. It calls subprocess.check_output(getenv_command), which doesn't exist in python 2.6, which ST2 seems to use.
The trick is, it only calls subprocess.check_output() if getenv_command is truthy, and defaults to os.environ.copy() otherwise. So to get ssgam's fix without modifying the SublimeREPL package, in Preferences > Package Settings > SublimeREPL > Settings - User, do something like this:
{
"getenv_command": false
}
I investigated this issue a little bit deeper and it seems SublimeText 3 is also affected. In my case the problem is related to bash-completion feature, in particular COMP_WORDBREAKS environment variable.
Use the following command to show the contents of COMP_WORDBREAKS:
$ echo "$COMP_WORDBREAKS"
will output
"'><=;|&(:
You can also use:
$ echo $COMP_WORDBREAKS
but note that with the second command (without quotes), you'll not see that
the variable also contains a line feed character.
The problem here is the line feed character which breaks output parsing in getenv_command feature. If you extract part of the source code for SublimeREPL you can get real error message from python interpreter.
Traceback (most recent call last):
File "main.py", line 71, in getenv
env = dict(line.split('=', 1) for line in lines)
ValueError: dictionary update sequence element #6 has length 1; 2 is required
You can match element #6 with the position of COMP_WORDBREAKS in env listing.
Solution (first that came to my mind)
I can't tell at the moment what is real impact on bash-completion feature after following solution is applied and of course SublimeREPL hopefully should be fixed accordingly. Please comment my answer to fill in missing knowledge.
We may want to remove disturbing characters to get rid of the error.
First let's identify those characters
$ echo -n "${COMP_WORDBREAKS}" | od -t x1c
will output
0000000 20 09 0a 22 27 3e 3c 3b 7c 26 28 3a
\t \n " ' > < ; | & ( :
0000014
so we have three to remove. The simplest way is to add to your .bashrc following line:
COMP_WORDBREAKS="${COMP_WORDBREAKS#???}"
Voila! No more error message.
My final thought is about removed characters. I'm not fully in how bash-completion works and I'm aware of that modifying COMP_WORDBREAKS can affect other scripts using it. For now you can always change it ad-hoc.
I hope this helped.
Cheers
Found it. Fixed it. SublimeREPL assumes that running getenv_command will produce SOLELY the output from running env, and every line will contain an equals sign. But my .bash_profile echos some stuff to stdout.
The solution was to wrap my .bash_profile output in a
if [[ $- == *i* ]]
to not produce extra output besides the executed command.
TLDR;
Replace:
env = dict(line.split('=', 1) for line in lines)
in ~/.config/sublime-text-3/Packages/SublimeREPL/repls/subprocess_repl.py with
env = dict(line.split('=', 1) for line in lines if '=' in line)
(Thanks #MichaelOhlrogge for the shorter syntax)
Why this works
#develucas's solution helped me solve my issue. I didn't have the problem he was describing, but his investigation helped.
In my case, the login shell had a greeting. So, bash --login -c env (the command specified in SublimeREPL.sublime-settings file under the getenv_command option) was printing something like this:
Hello, parth!
USER=parth
SHELL=/bin/bash
.
.
.
It turns out that SublimeREPL uses the output of this command to load the environment variables - as mentioned in the comment above the getenv_command setting:
// On POSIX system SublimeText launched from GUI does not inherit
// a proper environment. Often leading to problems with finding interpreters
// or not using the ones affected by changes in ~/.profile / *rc files
// This command is used as a workaround, it's launched before any subprocess
// repl starts and it's output is parsed as an environment
"getenv_command": ["/bin/bash", "--login", "-c", "env"],
The code that parses this output is like this (in the ~/.config/sublime-text-3/Packages/SublimeREPL/repls/subprocess_repl.py file for ST3):
def getenv(self, settings):
"""Tries to get most appropriate environent, on windows
it's os.environ.copy, but on other system's we'll
try get values from login shell"""
getenv_command = settings.get("getenv_command")
if getenv_command and POSIX:
try:
output = subprocess.check_output(getenv_command)
lines = output.decode("utf-8", errors="replace").splitlines()
env = dict(line.split('=', 1) for line in lines)
return env
except:
import traceback
traceback.print_exc()
error_message(
"SublimeREPL: obtaining sane environment failed in getenv()\n"
"Check console and 'getenv_command' setting \n"
"WARN: Falling back to SublimeText environment")
# Fallback to environ.copy() if not on POSIX or sane getenv failed
return os.environ.copy()
The env = dict(line.split('=', 1) for line in lines) line causes an issue, because the first line in the bash --login -c env output has no =. So I modified this line to ignore the lines that don't have an = sign:
env = dict(line.split('=', 1) for line in lines if '=' in line)
And this solved the issue for me. Don't forget the restart Sublime Text after modifying this file.
changing COMP_WORDBREAKS does not work for me ...
i'm using ST2, and the exception was thrown at check_output().
also, name completions at the command line fails, after changing COMP_WORDBREAKS.
in my case, i changed subprocess_repl.py's env() method:
[wind]$ diff subprocess_repl.py.20151117.173317 subprocess_repl.py
160c160,161
< updated_env = env if env else self.getenv(settings)
---
> # updated_env = env if env else self.getenv(settings)
> updated_env = env if env else os.environ.copy()
[wind]$
would be interesting to find out why the problem started appearing suddenly ...
hth,cheers,
sam
The answer from #develucas mostly works for me with ST3 with OSX El Capitan except I had to put
export COMP_WORDBREAKS="${COMP_WORDBREAKS#???}"
Note the export. However, if I do this, tab completion no longer works.
I had the same problem, it was my .bash_profile that had some utility outputs, such as a welcome message etc.
These outputs are parsed by SublimeREPL to try to extract environment variables from the output of the env command, and the extraneous text lines mixed together provoked the error.
(I'd like to make a PR to SublimeREPL to try to make that phase more robust, it should not depend on particular .bash_profile implementations!)

OSX bash scripting

I don't do much shell scripting but I want to essentially do this:
run the command "grunt check" about 30 times (the process takes 60 seconds).
Do a regex on the output of that command for "Some random error message. Failed." Where "Failed" is the thing I'm searching for but I want to capture the whole sentence.
Write the associated line to a file.
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 30 ]; do
command grunt check
// ERROR = regex(/\/Failed./)
// WRITE ERROR TO FILE
let COUNTER=COUNTER+1
done
for ((cr=0; cr<30; cr++))
do
grunt check | grep Failed
done > outfile.txt
counter=0
while [ $counter -lt 30 ]; do
grunt check | grep Failed
let counter=counter+1
done > some file
The above uses a pipeline to capture the output of the grunt command and sent it to grep. grep searches through the output and prints any lines that contain the word Failed. Any such lines are then sent to a file named somefile.
As a minor point, I have converted COUNTER to lower case. This is because the system uses upper case environment variables. If you make a practice of using lower case ones then you won't accidentally overwrite one. (In this particular case, there is no system variable named COUNTER, so you are safe.)
Another method for counting to 30:
You might find this simpler:
for counter in {1..30}; do
grunt check | grep Failed
done > somefile
The {1..30} notation provides the numbers from one to thirty. It is a bash feature so don't try to use it on a bare-bones POSIX shell.
To get more context
If you would like to see more context around the error message, grep offers several options to help. To see both the line matching "Failed" and the line before, use -B:
for counter in {1..30}; do
grunt check | grep -B 1 Failed
done >somefile
Similarly, -A can be used to display lines after the match. -C will display lines both before and after the match.

LLDB: List source code

My single most used gdb command is l followed by n followed by l -.
How can I get the same in lldb?
I am not satisfied with having to type some line number just to see the code somewhere. I want to see where I am in the code, after dumping a ton of variables out to the terminal. And I used to use l - to go back to look at where I am, since subsequent calls to l will scroll me down (lldb also does this, but crucially does not respond to l -).
Perhaps I am missing something and there is some sort of "mode" i can put it in, which will show the corresponding source location in a separate buffer all the time. That would be nice, but I'm not even asking for that.
In Xcode 4.6, lldb's l alias is a simple shortcut for source list.
In the top of tree sources, this has been improved to behave more like gdb. If you look at source/Interpreter/CommandInterpreter.cpp over at http://lldb.llvm.org/ you'll see that l is now a regular expression command alias with these cases:
if (list_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$", "source list --line %1") &&
list_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "source list --file '%1' --line %2") &&
list_regex_cmd_ap->AddRegexCommand("^\\*?(0x[[:xdigit:]]+)[[:space:]]*$", "source list --address %1") &&
list_regex_cmd_ap->AddRegexCommand("^-[[:space:]]*$", "source list --reverse") &&
list_regex_cmd_ap->AddRegexCommand("^-([[:digit:]]+)[[:space:]]*$", "source list --reverse --count %1") &&
list_regex_cmd_ap->AddRegexCommand("^(.+)$", "source list --name \"%1\"") &&
list_regex_cmd_ap->AddRegexCommand("^$", "source list"))
With these cases, you will get behavior like this:
Show current frame:
(lldb) f
#0: 0x0000000100000f2b a.out`main + 27 at a.c:15
12
13
14
-> 15 puts ("hi"); // line 15
16
17 puts ("hi"); // line 17
18 }
show previous ten lines:
(lldb) l -
5
6
7
8
9 puts ("hi"); // line 9
10
11
You can also use the stop-line-count-after and stop-line-count-before settings to control how much source context is displayed at frame stops.
Note that you can create your own regular expression command alias in your ~/.lldbinit file with the same behavior as the top-of-tree lldb's l. See help command regex for the syntax and an example.
LLDB: [How to] List source code
ie: For anyone looking for "How do I make lldb show which line I am on again? (since my recent commands have covered it up)", it is simply f. Type f to see where you are at in the code again.
f
OR
frame select
Source: LLDB: List source code
See also the help menu in lldb:
help f
shows the following:
(lldb) help f
Select the current stack frame by index from within the current thread (see
'thread backtrace'.)
Syntax: f <cmd-options> [<frame-index>]
Command Options Usage:
f [-r <offset>] [<frame-index>]
-r <offset> ( --relative <offset> )
A relative frame index offset from the current frame index.
This command takes options and free-form arguments. If your arguments resemble option
specifiers (i.e., they start with a - or --), you must use ' -- ' between the end of
the command options and the beginning of the arguments.
'f' is an abbreviation for 'frame select'
The bottom of that help menu shows that "f is an abbreviation for frame select".
Note that in gdb, the equivalent command is simply:
f
OR
frame
user#hostname> lldb -o "image lookup -rvn file" -o "quit" "Name of exec-file" | grep "CompileUnit"
user#hostname> lldb -o "image lookup -rvs file" -o "quit" "Name of exec-file" | grep "CompileUnit"