w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
bash "clear" command behaving strangely after git-credential-osxkeychain installation
(1) There is the /usr/bin/clear (which you want) and the /usr/local/bin/clear (which you don't want). which clear returns the one which would be executed; which -a clear returns both. Since the command first found when searching the directories in $PATH is executed, and /usr/local/bin precedes /usr/bin here, it's /usr/local/bin/clear. (2) You can fix this e. g. by reversing the order of /usr/local/bin and /usr/bin in $PATH, or by deleting or renaming /usr/local/bin/clear. (3) The front part of $PATH (/Users/NAME/.rvm/gems/ruby-2.0.0-p195@rails3tutorial2ndEd/bin:/Users/NAME/.rvm/gems/ruby-2.0.0-p195@global/bin:/Users/NAME/.rvm/rubies/ruby-2.0.0-p195/bin:/Users/NAME/.rvm/bin:) seems to come from the .rvm script; the rear part of $PATH (/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr

Categories : GIT

How to clear json object using javascript or jQuery
Just reset the variable back to {}; cfamFwdDtls = {}; // or cfamFwdDtls = new Object; And this is the moment when you start thinking: "Whoooa, I can't believe it's that easy." Just for fun: You could also take the long way (100x less efficient): for (var key in cfamFwdDtls) { delete cfamFwdDtls[key]; } DON'T YOU DARE USE THIS METHOD

Categories : Javascript

Is it possible to have bash script output multiple lines over the same lines without 'clear'?
That's how you can do it: while true; do date sensors | grep "temp1" sensors | grep "Core" acpi sleep 1 for i in {1..4}; do # clear four lines above tput cuu1 # up by one line tput el # clear that line done done Use man tput for more info. To see the list of capabilities use man terminfo Edit: Here is a hack that I came up with to avoid blinking: while true; do echo -n "$(date)"; tput el; echo echo -n "$(sensors | grep "temp1")"; tput el; echo echo -n "$(sensors | grep "Core")"; tput el; echo echo -n "$(acpi)"; tput el; echo sleep 1 tput cuu 4 # tput -S <<< $'cuu1 cuu1 cuu1 cuu1' # that's how you pass several actions to tput, but instaed of cuu1 several times use 'cuu N' done And of course

Categories : Bash

Remove sub-quoting in string
If you have XML then use it to loop at every <quote>. When you have it in loop you can use strip_tags() to remove subquotes. You can use SimpleXML for that. There's no need to use "crazy regexp" This link shows how to remove item with specific attribiute you can use it to fit your needs.

Categories : PHP

Rails clear flash notice after JSON response
I too am using angularjs with rails. The way I am handling error messages from the server (rails) is to use angular route changing events. Since you are dealing with flash messages from the server, it's really the same concept. In my angular app where I display errors (in your case flash messages) I use an ng-show with a variable, e.g., <div ng-show="showMessages" class="alert"> {{myMessages}} // obviously here you may have an ng-repeat or similar </div> In my main angular controller I am setting $scope.showMessages (either true or false). At this point it's the same issue. In my controller I use the following callback to see when the route has changed. When it's changed I can set $scope.showMessages to false. $scope.$on('$routeChangeStart', function (scope, next, curr

Categories : Ruby On Rails

quoting string in perl while substitution
Use another substitution delimiter, ie s| vs s/ perl -p -i -e "s|K6D2wlawNtxOMrTOiEwnz12Y1qvn|TO_DATE('03/31/2013 02:00:00', 'MM/DD/YYYY HH24:MI:SS')|" file

Categories : Perl

Tcl switch statement and -regexp quoting?
The problem you describe here is simple to solve: The difference between switch and regexp is that switch takes actually a list. So if we print the first element of the list {^s*foo {puts "match"}} with % puts [lindex {^s*foo {puts "match"}} 0] ^s*foo it results in something that we don't want. List constructing is a little bit complex, if you are not sure, use an interactive Tcl shell that constructs one for you with list. Edit: Indeed, it is an intresting desin choice, but this applies to everything in Tcl. For example expr uses an minilanguage designed for arithmetic expressions. It is up to the command what it shall do with it's arguments. Even language constucts like if, for, while are just commands that treats one of the arguments as expression, and the other arguments as scrip

Categories : Regex

All arguments into files with correct quoting using "$@"
To see what's interpreted by Bash, use: bash -x ./script.sh or add this to the beginning of your script: set -x You might want add this on the parent script.

Categories : Shell

Macro variable quoting error with SAS
I find it easiest to use datastep quoting functions, largely because I'm terrible at real macro quoting. %let viewname=MKTVIEWS.imei_ref; %let xrc=0; %let xmsg= ; options symbolgen mprint; proc sql; create table results (viewname char(40), xrc numeric, xmsg char(200)); insert into results (viewname, xrc, xmsg) values ( %sysfunc(quote(&viewname)) , &xrc , %sysfunc(quote(%superq(xmsg))) ); quit; Does that accomplish what you're hoping?

Categories : Sas

JSON If Confirm message ok , session clear than return to MainPage
function showmypopup() { if (confirm("Are you sure you want to exit?")) { $.ajax({ url: "/Home/Exit", type: "POST", dataType: "json", contentType: 'application/json', success: function (mydata) { $("#Page").html(mydata); }, error: function () { $("#Page").html("Fail"); } }); }else return false; } And you should make a call from your link a href="#" id="exit-link" onclick="showmypopup()">Exit

Categories : Json

indirectly quoting macro in traditional mode
Using the cpp that comes with GCC (4.8.1 tested), and the code (example.c): #define foo bar #define quoteme_(x) "x" #define quoteme(x) quoteme_(x) quoteme(foo) The relevant part of the output from cpp -traditional example.c is: "foo" (and you can use single quotes in the replacement for quoteme_(x) similarly to obtain 'foo'). This is what you observed in the question. AFAIK, there isn't a way to get 'bar' or "bar" out of the traditional preprocessor system. The pre-standard (traditional) systems were not standardized, and there were details where different systems behaved differently. However, macro arguments were expanded after replacement, rather than before as in C89 and later, which is what leads to the result you're seeing.

Categories : Misc

Reduce double-quoting of variable containing spaces?
Is there any way to just double-quote it "once and for all" so I do not have to do it every single time? No. You must double-quote every usage of a variable (except for special cases, see Mat’s answer) which may contain spaces. There’s no way around it. This is unusual and a bit annoying, but you get used to it pretty quickly.

Categories : String

single quoting values using sql to create macro variable
Try this: proc sql; select catt("'", code, "'") into :procedures separated by ', ' from procedures; quit; Also fix the where option in set statement: set &indata(where=(code in (&procedures)));

Categories : Sas

What is the correct escaping or quoting of whitespace in a classpath (!path) element in FitNesse?
Ok, so the first thing to note is that this phenomena does not happen on Windows. FitNesse automatically encloses classpath elements contained whitespace with double-quotes, as already noted in the question. The command which FitNesse generates is: java -cp fitnesse.jar:"/home/stewart/white space test/example-1.0.0-SNAPSHOT/target/test-classes":"/home/stewart/white space test/example-1.0.0-SNAPSHOT/target/classes":/home/stewart/.m2/repository/org/fitnesse/fitnesse/20121220/fitnesse-20121220.jar fit.FitServer linux-desktop 9123 10 On Windows, this would be: java -cp fitnesse.jar:"C:white space testexample-1.0.0-SNAPSHOT arget est-classes":"C:white space testexample-1.0.0-SNAPSHOT argetclasses":C:.m2 epositoryorgfitnessefitnesse20121220fitnesse-20121220.jar fit.FitServer windows-desktop

Categories : Java

python/bash variable expansion in for loop for json array
When calling os.environ.get, you should not include the $ prefix, that's part of shell variable syntax. You should write os.environ.get('MESSAGE'+str(i))).

Categories : Python

Confusion between "#define clear()" and "std::wstring::clear()"
The reason is because the preprocessor basically does a search-and-replace on all macros that are defined. And it's done before the compiler proper gets the code, and it does not know anything about namespaces, classes or scope in general. So if you have e.g. #define clear() something and then use wstr.clear(); The preprocessor will replace the clear() so that the compiler sees wstr.something;

Categories : C++

How to clear the bottom of an image like clear left / right
Based on your image, you can realize the layout by using the the following HTML: <div class="contentpart"> <a href="#"> <img src="http://placehold.it/300x200"> </a> Donec adipiscing, lorem non euismod venenatis... </div> and applying the following CSS rules: .contentpart { border: 1px dotted gray; display: table; } .contentpart a { display: table-cell; vertical-align: top; padding-right: 20px; } You can see the demo at: http://jsfiddle.net/audetwebdesign/wknjA/ How This Works You can use CSS tables to get the text to stay in a single column without wrapping it in a block element. Apply display: table to the parent block and display: table-cell to the a tag. You can have some control over white space by

Categories : CSS

BASH: Convert multi lined (JSON) block into a single line string
You need to be using a dedicated command line JSON parser for this e.g. underscore: With underscore installed you can do: cat data.json | underscore select '.description, .statistics first-child'| tr -d '[]' EDIT: Sed only solution (use it with caution): sed -rn '/"description": *"Reads 95%",/,/],/{/statistics|description/!{1h; 1!H;};/],/{x;s/ * *|^ *|],//gp;};}' out # gives 304000,0,8.7931875,7.948696618436826,6907.677974959667,13594.0

Categories : Json

Mindboggling Regular Expression to convert Whitespace-Comma-Whitespace input string to an array. Quoting must be supported
I finally have developed a solution for this problem which involved a few PHP statements utilizing regular expressions. Below is the final function. This function is part of a class which is why it begins with "public". public function SearchString_ToArr($SearchString) { /* Purpose Used to parse the specified search string into an array of search terms. Search terms are delimited by <0 or more whitespace><optional comma><0 or more whitespace> Parameters SearchString (string) = The search string we're working with. Return (array) Returns an array using the following rules to parse the specified search string: - Each search term from the search string is converted to a single element in the returned array.

Categories : PHP

Java clear console error: java.io.IOException: Cannot run program "clear"
There's pretty much nothing in the console related API to do a clear screen. But, I think you can achieve the same effect through println()s. A lot of putty clients clear the page like that and then scroll up. private static final int PAGE_SIZE = 25; public static void main(String[] args) { // ... clearScreen(); } private static void clearScreen() { for (int i = 0; i < PAGE_SIZE; i++) { System.out.println(); } }

Categories : Java

Why does the child of an eval call from bash get orphaned once the parent bash script dies?
This is normal and expected. You sent a signal (presumably SIGTERM) to parent-script and it died, but no signal was sent to another-script. It keeps on running. This is different than what happens when the parent-script job is running interactively on a terminal and you type ^C (or ^Z). In that case, a SIGINT signal is automatically sent to the whole foreground process group. Since another-script is un the same process group as parent-script (by default), they both get the signal and they both die. If you want another-script to die automatically when its parent dies in any other context than when it's a job running in a terminal with job control, you have a few options. parent-script can trap the SIGTERM signal. In the signal handler, it kills its child, and then exits itself. This, o

Categories : Linux

Redirecting standard input in Bash implies that Bash executes a default action?
exec 6<&0 0</tmp/lines.txt; exec 0<&6 6<&- Turns out that bash still executes what remains in the command specified or script before it reads input for commands again that's why your file /tmp/lines.txt is not read since exec 0<&6 6<&- is run before it. Please refer back to the previous solution if you want to execute commands in /tmp/lines.txt before exec 0<&6- is executed. Also it might have not been obvious but you could use . or source to achieve same output: . /tmp/lines.txt source /tmp/lines.txt

Categories : Bash

execute user inputed Windows (or bash) commands from batch (or bash) file?
Do you need a full bash prompt? Or would something like this be enough? #!/bin/bash echo -n "Enter cmd: " read COMMAND echo ${COMMAND} | bash Also, in a script, you can just execute bash and get a full prompt in the current environment.

Categories : Bash

Capture output of a bash command, parse it and store into different bash variables
You can use awk and bash arrays: arr=( $(awk -F ':' '$1 == "inet addr"{sub(/ .*/, "", $2); print $2}' < <(ifconfig)) ) Then you can do: read IPETH0 IPLO <<< ${arr[@]}

Categories : Linux

Pass a full bash script line to another bash function to execute
optout is a command like any other, and so must be preceded by any local modifications to the environment. The command that optout runs will inherit that environment. CC=${BUILD_TOOL_CC} optout ./configure ${ZLIB_CONFIGURE_OPT} --prefix=${CURR_DIR}/${INSTALL_DIR} By the way, this is just one of the problems you are likely to encounter with your optout function. You cannot run arbitrary command lines in that fashion, only a simple command followed by zero or more arguments (and I would expect there are some exceptions to even that restricted set, as well).

Categories : Linux

BASH: how to define an array as environment variable before calling a bash script
Incredibility weird.... I have never seen that before. It looks like the array is not passed to the subshell. One way around this is to source the script instead of executing it: declare -a MYARR=( 1 2 ); . ./myscript.sh

Categories : Arrays

Redirecting standard input in Bash implies that Bash exits
That makes bash read commands from /tmp/lines.txt redirecting its input in the process. There would no longer be any input to process after all those commands in the file so the shell just exits after it, just like executing a shell script. If you want to not let bash exit after the commands in /tmp/lines.txt were processed, make sure that you could put back its input like: exec 6<&0 < <(cat /tmp/lines.txt; echo; echo "exec <&6";) Which send both inputs of /tmp/lines.txt as commands and also exec <&6 that would put back input from &6 encapsulated by process substition. And a cleaner approach: exec 6<&0 < <(cat /tmp/lines.txt; echo; echo "exec <&- <&6 6<&-";) Or simply: exec 6<&0 < <(cat /tmp/lines.txt; e

Categories : Bash

BASH | Adding elements in all files of a specific directory bash
This can make it: for file in /your/dir/* do echo "<end>" >> "$file" done In case you have some dirs inside, you may get the error bash: XX: Is a directory. To avoid seeing them, you can add 2>/dev/null to the end of the echo command: echo "<end>" >> "$file" 2>/dev/null Or even better (thanks Barmar), check if they are files: [ -f "$file" ] && echo "<end>" >> "$file" Which is a short way of doing an if-condition: if [ -f "$file" ]; then echo "<end>" >> "$file" fi

Categories : Bash

Cygwin Installation: Package: bash; bash.sh exit code 1
The /dev directory is missing and cygwin fakes it, which makes it read-only. The following code: cd /etc/postinstall/ ./000-cygwin-post-install.sh.done ./bash.sh ... solved that error for me.

Categories : Bash

escaping bash 'test' keywork in a bash script
test is a Bash builtin command, not a keyword or reserved word. This means Bash will only interpret it if it is the first token in a command, like test blah In python manage.py test Bash will just pass it as a parameter to python (that is, it will execute python with two parameters, manage.py and test); you don't need to escape it. In general, Bash doesn't have reserved words in the sense of C-like languages. The only things you need to escape are whitespace (which Bash uses to separate params), and certain symbols including $(&|; which Bash uses for its variables and command separators.

Categories : Bash

Can One Bash Script Launch Multiple Other Bash Scripts?
Run them in the background, just like you would in an interactive shell. command1 & command2 & command3 & wait # Wait for all background commands to finish The commands can be just about anything, not just other bash scripts.

Categories : Linux

'Globalize' Bash functions inside of a bash script
You can use this command in your startup.bash: source lib.bash the source command runs the file in the current shell environment, unlike using bash lib.bash (or . lib.bash) which creates a new, separate environment for that script (and only that script) and is why the function is not carried over. (source)

Categories : Linux

What is more efficient: vector.clear() or if(vector.empty()) clear();?
An empty vector is a valid vector. So the operation a.clear(); is valid on an empty vector. Test for emptiness before clear is unnecessary and time consuming, so the first one is more efficient.

Categories : C++

Run a bash including a variable in the "bash XXX.sh" command
You can take advantage of shell parameter expansion to smoothly read variables from the environment of the parent process, if it's that what you want to achieve. Look at the following script named test.sh: #!/bin/bash VARIABLE=${VARIABLE:="default value"} echo $VARIABLE If you start it with the line $ ./test.sh it outputs default value But if you invoke test.sh with the line $ VARIABLE="custom Value" ./test.sh it outputs custom value But make sure that the variable assignment is at the beginning of the line. Otherwise it is passed to test.sh as command line argument. The used form of parameter expansion ${parameter:=word} is described in the bash reference manual as: If parameter is unset or null, the expansion of word is assigned to parameter. The value of param

Categories : Bash

BASH | How to get the number of fields of one line in bash (using cut ?)
You can say: $ echo "field1;field2;field3;field4;" | grep -o ";" | wc -l 4 Alternatively, $ tr -dc ';' <<< "field1;field2;field3;field4;" | wc -c 4 EDIT: In order to loop over the fields, you can say: $ IFS=';' read -ra field <<< "field1;field2;field3;field4;" $ for i in "${field[@]}"; do echo $i; done field1 field2 field3 field4

Categories : Linux

execl("/bin/bash","bash","-l","-c","env",NULL), what's wrong?
Edit note: This is a full rewrite of the original example code, since the OP posted the code and I realized it causes bash to block on standard output instead of input as I originally thought. The reason is bash output is redirected to a pipe, with nothing reading from the pipe until the child exits. Before you execl(), reopen STDIN_FILENO from /dev/null, and STDERR_FILENO to /dev/null. When STDOUT_FILENO (standard output) is redirected to a pipe, you cannot just wait() for the child to exit: you must actively read from the pipe while the child process runs. Consider this example program. It takes one command-line parameter, the user name. (Without any parameters or just -h or --help it outputs short usage information.) It obtains the struct passwd corresponding to that user name, creat

Categories : C

json database get image setting data for json using while loop carousel type jquery json
Look for a jquery carousel plugin. http://vandelaydesign.com/blog/tools/jquery-carousel-plugins/ http://www.webdesigntunes.com/freebies/30-amazing-free-jquery-slider-and-carousel-plugins-of-2013/ Edit: does this help? $data = array(); $x = 0; while ($test = mysql_fetch_array($query)) { $data[$x]['content'] = "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='{$test['image']}' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>"; $data[$x]['content_button'] = "<div class='thumb'><img src='{$test['thumb']}' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"; $x++; } echo json_encode($data);

Categories : PHP

python json.loads / json.load truncates nested json objects?
JSON doesn't care about the keys for objects, but the json.load and json.loads convert to a Python object using this conversion table. JSON objects are turned into python dict's, which means you can't have repeated keys.

Categories : Python

BASH - If $TIME between 8am and 1pm do.., esle do.. Specifying time variables and if statements in BASH
In this case, you just need to look at the hour. Also, bash has syntax to specify the radix of a number, so you don't have to worry about 08 and 09 being invalid octal numbers: H=$(date +%H) if (( 8 <= 10#$H && 10#$H < 13 )); then echo between 8 and 1 elif (( 13 <= 10#$H && 10#$H < 23 )); then echo between 1 and 11 else echo go to bed fi "10#$H" is the contents of the variable, in base 10.

Categories : Mysql

JSON.NET: Serialize json string property into json object
You need a converter to do that, here is an example: public class RawJsonConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { writer.WriteRawValue(value.ToString()); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { throw new NotImplementedException(); } public override bool CanConvert(Type objectType) { return typeof(string).IsAssignableFrom(objectType); } public override bool CanRead { get { return false; } } } Then decorate your class with it: public class Foo { public int Id; [JsonConverter(typeof(RawJsonConverter))] public string RawData; } Then, when you use:

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.