w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Using sed in bash script to replace LaTeX aliases
Code for GNU sed: sed -r '/^%/d;s#.*({\w+})({.*})#1 2#;s#\#\\#g;s#(S+)s(S+)#\|1|s|1|2|g#' file1|sed -f - file2 $ cat file1 % a ewcommand{ao}{$^{18}$O} ewcommand{aodso}{$^{18}$O/$^{16}$O} % b ewcommand{ea}{egin{equation}} ewcommand{eaa}{egin{eqnarray}} % c ewcommand{cthree}{C$_3$} ewcommand{cfour}{C$_4$} ewcommand{coz}{CO$_2$} $ cat file2 This is my test {ao} {aodso} my test is this Does it work {ea} {eaa} test test test work work work {cthree} {cfour} This is my test my test is this {coz} $ sed -r "/^%/d;s#.*({\w+})({.*})#1 2#;s#\#\\#g;s#(S+)s(S+)#\|1|s|1|2|g#" file1|sed -f - file2 This is my test {$^{18}$O} {$^{18}$O/$^{16}$O} my test is this Does it work {egin{equation}} {egin{eqnarray}} test test test work work work {C$_3$} {C$_4$} This is my test my test is th

Categories : Bash

Is there a bash builtin that works like which but respects aliases and resolves stuff from $PATH?
You can try the following: ls `alias | /usr/bin/which --read-alias notfalse | tail -1` By the way, I have my own aliased which which is this: alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

Categories : Bash

How do profile pictures work?
You can put pictures in a database (using a BLOB field), but I wouldn't, due to the performance hit. Store the images on the filesystem with PHP, and just store the ID of the picture in the database.

Categories : PHP

Exporting system.profile from MongoDB doesn't work
From database-profiling-and-sharding: You cannot enable profiling on a mongos instance. To enable profiling in a shard cluster, you must enable profiling for each mongod instance in the cluster. Also see mongoexport only exports one shard's worth of data (although this bug is fixed since 1.9.1 and you use a much later version) So try to mongoexport directly from the mongod instance that holds the system.profile collection you want. **UPDATE** A second approach is to not use mongoexport but to take the collection directly from the mongo shell (since you are able to see the collection from inside the mongo shell). To do that first write the following script and save it to print-profile.js c = db.system.profile.find(); while(c.hasNext()) { printjson(c.next()); } then execut

Categories : Mongodb

will this INSERT profile work with my Mysql InnoDB oriented DB?
If you are asking if MySql can handle 40k inserts then, assuming space is available and the machine is reasonable, then this would be no problem. We have systems inserting hundreds of thousands of rows in a day.

Categories : Mysql

How to make "HTTS redirect" work on WebSphere Application Server Liberty Profile?
I suspect the problem is in your security-constraint. Looking at it I would suggest changing your url-pattern to be: /helloworld rather than: /Hello If you want to match multiple resources you can use wildcards such as: /* - matches everything /helloworld/* - matches everything that has helloworld/ in the url path *.jsp - matches all files with a jsp extension

Categories : Ssl

VisualVM cannot profile; connects and other tabs work but Sampler tab gives:"Failed to create JMX connection"
Do you use SSL authentication? If don't want to use it, try to replace -Dcom.sun.management.jmxremote.local.only=false with -Dcom.sun.management.jmxremote.ssl=false

Categories : Amazon

iOS Facebook get user's profile image randomly opens profile homepage instead of permission dialog
This is how I would collect the User Profile picture, although there are plenty of ways to do this: I would use a notification (or any other method) to notify once the user is signed in, then call a method to collect the Facebook Profile picture. Once they are logged in you can pass their facebook Id to a value. (kUserFacebookIDKey) NSLog(@"Downloading user's profile picture"); // Download user's profile picture NSURL *profilePictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", self.kUserFacebookIDKey]; NSURLRequest *profilePictureURLRequest = [NSURLRequest requestWithURL:profilePictureURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0f]; // Facebook profile picture cache policy: Expires in 2 weeks [NSURLCo

Categories : IOS

How to display profile friends' avatars of a specific profile user?
I suppose that fid in user_friends table is related to an user_accounts id select ua.avatars from user_friends uf inner join user_accounts ua on uf.fid = ua.id inner join pages p on p.uid = uf.uid where p.pid = <somepid> or probably clearer select ua.avatars from pages p inner join user_friends uf on uf.uid = p.uid inner join user_accounts ua on ua.id = uf.fid where p.pid = <somepid>

Categories : Mysql

XCode--When do I sign with developer provisioning profile vs distribution profile?
Failed to get task sounds like you're trying to run this build via Xcode on device. If that's the case, you want to use a development profile, not a distribution profile (AdHoc). If you're attempting to create an enterprise release build, you'll want to select your target and choose the iOS device option, then use Product > Archive to create a release build.

Categories : IOS

Why does XCode switch the profile from automatically selected one to the iOS Team Profile
After much nashing of teeth and hair pulling finally tracked down the cause of this, dont you just love xcode error msgs. Although the correct mobile provision was automatically selected in Debug line of the code signing section, the sub selection line "Any iOS SDK" had the team profile selected somehow. Changing this to match the automatic selection solved the problem.

Categories : Iphone

Decode a high profile H.264 stream to baseline profile
The Profile is an encoding setting, not a decoding setting. If you have a video in Main profile, and want it in Baseline, you must decode then re-encode (This is call transcode). The problem is that your device can not decode Main profile in hardware. You can decode in software, but that will likely be slow (possibly slower than real time) and kill the battery. You best bet is it transcode the video first on a PC, or a cloud transcoding service before sending to the device.

Categories : Android

bash: kill $$ not work?
I'm not sure why one would like to kill the current shell. Nevertheless... kill PID would send SIGTERM when no signal is specified. bash ignores SIGTERM and SIGQUIT in the absence of any traps. You'll achieve the desired effect if you were to say kill -9 $$ or kill -SIGKILL $$ Quoting from the manual: When Bash is interactive, in the absence of any traps, it ignores SIGTERM (so that ‘kill 0’ does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). When Bash receives a SIGINT, it breaks out of any executing loops. In all cases, Bash ignores SIGQUIT.

Categories : Linux

bash script tc -d [:punct:] does not work
It's a quoting issues, your shell is interpreting $ and ! because you are using double quotes. You need to use single quotes to avoid any character being interpreted with bash: $ echo 'asdaftafiatfiat!!!~~~$$$$tt' | tr -d [:punct:] asdaftafiatfiattt

Categories : Bash

Can't get vim-ruby to work correctly on Git Bash
Do you have filetype plugin indent on (especially indent) in your vimrc? Also note that vim own indentation script for ruby may come in your way, be sure the installation path for vim-ruby plugin appears before default path. By the way, what files did you copy and where? You should have ~/vimfiles/indent/ruby.vim with this content after installation.

Categories : Ruby

bash - why won't command substitution work?
Store your command arguments in an array and run it like this: #!/bin/bash yesterday=$(date +"%Y-%m-%d %H:%M:%S" -d "1 day ago") # 2013-09-04 01:15:51 now=$(date +"%Y-%m-%d %H:%M:%S" ) #2013-09-05 01:15:51 echo -e "INPUTS: Today: $now, Yesterday: $yesterday" cmd=(curl -s -u scott:tiger -d url=http://localhost:8080 -d "start=$yesterday" -d "end=$now" -d "async=y" "http://192.168.1.46:8080/cmd/doSendMinimalToServer") output=$("${cmd[@]}") echo "Output from executing cmd variable: $output" Also I think you could use date '+%F %T' for simplicity.

Categories : Bash

Quotes within Bash Shell variable do not work, why?
This is a product of how the shell handles arguments. The first thing the shell does is substitute variables. Quotes that were used in the variable definition are not preserved here. Then it chunks them into arguments, based on either quotes or, if these are not present, word boundaries. Quotes that were quoted when they were first used are escaped at that time, and consequently cannot define word boundaries. Consequently, the arguments passed to git in your first example are: log --pretty=format:"%h - %an, %ar : %s" In the later example, the arguments passed to git are: log --pretty=format:"%h - %an, %ar : %s"

Categories : Bash

my first bash shell function doesn't work
Once you've written the functions, they only visible inside the script file itself. For them to be visible outside it, you need to tell the script to export the functions to the environment. Try adding export -f quit and export -f hello after your function definitions. Let's clear up confusion with the ./ and $ operators. The first operator ./ is used when you want to call a script in the current directory. For example, if you've defined your script in some file script.sh, then you could call it with ./script.sh (make sure you have execute permissions - you can add them with chmod +x script.sh). The second operator $ is used to look at environment variables. These are variables which are defined by default in the bash shell, or variables which you have defined and exported to the shell

Categories : Bash

How to get a bash parameter substitution to work properly?
Use lowercase variable names. $PATH and $USER are special. To parse the string, you can use a regular expression: [[ $var =~ (.*)@(.*):(.*) ]] user=${BASH_REMATCH[1]} host=${BASH_REMATCH[2]} path=${BASH_REMATCH[3]} Update: For a possibly missing user, you can change it to [[ @$var =~ (.*)@(.*):(.*) ]] user=${BASH_REMATCH[1]#@}

Categories : Regex

String concatenation does not work in Bash cygwin
I believe I know what this is. The file is a dos file and not unix. If you use vim you can: vim file :set ff=unix :x Or if you do not want to use vim, this from the command line: dos2unix file

Categories : String

Bash test with no options appears to work, but why?
You're correct. From the test(1) man page: -n STRING the length of STRING is nonzero STRING equivalent to -n STRING

Categories : Bash

How do making processes with & (in bash) and killing them work?
You're killing the backgrounded process two.sh, but not two.sh and its child three.sh. This question: Best way to kill all child processes has more info on killing child processes.

Categories : Bash

Setting wget --header= in bash doesn't work
You have to use double quotes when using the variable. Otherwise it will be expanded into multiple words. On the other hand, there is no need to quote the variable value twice. The following should work: header='--header=User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11' wget "$header" http://website.com -O index Edit: If you want to use variables for several arguments, use arrays: args=(-d '--header=User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11') wget "${args[@]}" http://website.com -O index

Categories : Linux

Why doesn't bash history expansion work in functions?
This question has been asked here: use "!" to execute commands with same parameter in a script but in brief you need to set -o history set -o histexpand in your script to enable history expansion.

Categories : Linux

Bash script using "ldapscripts" package does not work from cron
Could it be that the script is dependent on the ${USER} variable usually offered by shells? Checking /usr/sbin/ldapid you find: # Current user [ -z "$USER" ] && end_die 'Could not guess current user (no $USER variable set)' _USER="$USER" else _USER="$2" Try something like: * * * * * USER=myuser ldapid Or since you are running from a script: #!/bin/bash USER=$(/usr/bin/whoami) /usr/sbin/ldapid Or the following (as it seems like ldapid accepts user as first argument #!/bin/bash /usr/sbin/ldapid username

Categories : Bash

Bash: compgen How to get rid of Warning message [option may not work as you expect]?
From man bash compgen [option] [word] Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, and write the matches to the standard output. When using the -F or -C options, the various shell variables set by the programmable completion facilities, while available, will not have useful values. As this shows, you probably have some variable set to alter the behaviour of the bash completion facilities and the option -F to compgen ignores those variables and values, informing you of this with the above warning. References: [1] http://linux.die.net/man/1/bash

Categories : Bash

How to edit profile ? (using devise and has a model Profile but edit method is giving error)
Not sure what your controller looks like, but you can explicitly tell rails where to find the profile_id. something like this: <li><%= link_to "Profile".html_safe, edit_profile_path(current_user, profile_id: @profile) %></li> Edit: #<Class:0xb459b8c> is the whole user class, not an instance which is why you can't call profiles on it. try this: @user = current_user @profile = @user.profiles.find(params[:profile_id]) Edit 2: According to your original question: the problem is, I have put an edit link in application.rb <li><%= link_to "Profile".html_safe, edit_profile_path(current_user) %></li> but it is giving error Couldn't find Profile with id=10 so instead of searching for id=2, it is looking at user_id, how to fix

Categories : Ruby On Rails

ROR how to use YML aliases?
You can pass in variables to the translation. In en.YML en: aliases: - &test test_passed some: "bla-bla %{test} bla-bla-bla %{test2}" In view <%= t('some', :test => test_value, :test2 => test2_value) %>

Categories : Ruby On Rails

Namespace aliases in Oxygene
Yes that is possible, just define it like you would define a type. For example: namespace ConsoleApplication37; interface type ConsoleApp = class public class method Main(args: array of String); end; someOtherName = System.Timers.Timer; implementation class method ConsoleApp.Main(args: array of String); begin var t1 := new someOtherName; end; end.

Categories : Dotnet

referring to aliases outside subselect
I'm not sure I 100% understand your question, but if I'm reading things correctly, you should just need to alias the outside table like so: Select t.EventId, t.DeviceId, (select last(value) from Events as E where E.EventCode = 1 and E.DeviceID = t.DeviceID and E.EventId<t.EventId) AS LastSetValue, (select last(value) from Events as E where E.EventCode = 1 and E.DeviceID = t.DeviceID and E.EventId<t.EventId) AS FromEventID, (select sum(value) from Events as E where E.EventCode = 2 and E.DeviceID = t.DeviceID and E.EventId between

Categories : SQL

IIS 7 aliases/rewrites between two applications
Like Lex said in IIS.NET since the request doesn't ever reach IIS you cannot modifyupdate it in anyway. However, have you considered setting up a separate virtual directory or application within IIS named (app1alias) that just points to this location (app1) ?

Categories : Asp Net

Python module name aliases?
http://docs.python.org/2/tutorial/modules.html You can try to remove "." from sys.path just before this import (but don't forget to prepend it back once you are done, otherwise you won't be able to imnport your other local modules).

Categories : Python

Table aliases in SQL query
SELECT clause is missing for subquery R1. And you probably no longer need WHERE conditions in your outer select. You applied them in R2. But for sure, you're no longer can reference EA columns in outer select. Only R1 and R2 aliases available in your outer query. That being said I believe your query should look something like this SELECT R1.EC_Date, R1.JO_Num, R1.EC_Intitule, R1.EC_Sens, R1.EC_RefPiece, R1.EC_Piece, R1.CG_Num, R1.EC_Reference, R1.JM_Date, R1.EC_Jour, R2.EC_Lettrage, R2.EC_Pointage FROM ( SELECT * -- you has been missing SELECT here FROM F_COMPTEA CA JOIN F_ECRITUREA EA ON CA.CA_Num = EA.CA_Num JOIN F_ECRITUREC EC ON EA.EC_No = EC.EC_No ) R1 JOIN ( S

Categories : SQL

Command aliases in my script
Use a function instead: if [[ $TYPE == d ]]; then function cp { command cp -r "$@" } fi And when in Bash, [[ ]] is recommended over test or [ ]. Also quote please quote your variables properly between "" to prevent word splitting and unexpected pathname expansion. Other caveats: exit -1 ## exit can only accept 8-bit integral values from 0 to 255. -1 here is orthodox and is equivalent to 255. You should quote the variables here or use [[ ]]: if [[ ! -e $FROM_DIR && ! -d $FROM_DIR ]] || [[ ! -e $TO_DIR && ! -d $TO_DIR ]] if [ "-$TYPE" "$filename" ] ## for custom operators, test is better: test "-$TYPE" "$filename" cp "$filename" "$TO_DIR/${filename##*/}-$DATE.bkup" for filename in "$FROM_DIR"/* Lastly make sure you run y

Categories : Linux

Reflection on type aliases
I think normalize method on Type may help you: Expands type aliases and converts higher-kinded TypeRefs to PolyTypes. Functions on types are also implemented as PolyTypes. Example: (in the below, is the type constructor of List) TypeRef(pre, , List()) is replaced by PolyType(X, TypeRef(pre, , List(X))) Having a type t you can also do something like t.map(_.normalize). This will normalize t as well as all types that are part of definition of t (e.g. type arguments). So effectively this will get rid of any aliases that occur anywhere in t.

Categories : Scala

Equivalent of `using` aliases for `template`s
Best way I know to remove template is made simple warper that will do it for you: template<typename Meta, typename U> using apply = typename Meta::template Template<U>; and every where you previously used template<typename> class Template replace it with typename Meta. template<typename Meta> void do_more_stuff() { apply<Meta, int>::func(); //=== Meta::template Template<int>::func(); } template<typename T> void do_stuff() { do_more_stuff< my_meta<T> >(); do_more_stuff< my_meta<T> >(); };

Categories : C++

Default Profile Image after delete current profile image in PHP
Have another table with fields userid, isset - ( with default value of 1 for all users) If user clicks the remove profile pic( wishes to have the default pic) , change the value in isset to 0 for the respective user. Check this table everytime before fetching the latest image from the profile pics table. Alternatively you can have the isset field in the profile pics table itself. This would require you to change the isset value of every occurrence of the user's profile pic if he wishes to have the default pic.

Categories : PHP

Rails public profile creation and determining whether profile is public or not
How about this: User Model after_update :update_public_status! def update_public_status! required_fields_present = [ name, state, city, high_school, recruit_year, birthday, stat(:height), stat(:weight) ].all? if required_fields_present make_public! else make_private! end end def make_public! update_attribute :public, true update_attribute :removed_from_listing, false end def make_private! update_attribute :public, false update_attribute :removed_from_listing, true end

Categories : Ruby On Rails

Display LinkedIn profile photo and user profile using LinkedIn API
I found the solution for my question, it should change the LinkedIn API call to be: - (void)profileApiCall { // NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~"]; NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry,picture-url,location:(name),positions:(company:(name),title),specialties,date-of-birth,interests,languages)"]; OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url consumer:oAuthLoginView.consumer token:oAuthLoginView.accessToken callback:nil signatureProvider:nil]; NSLog(@"the request is %@",request); [request setValue:@"json" forHTTPHeaderField:@"

Categories : Objective C

mysql join aliases same table
You are using the wrong key in your contact joins. You should use contact_id instead of rec_id: SELECT recordings.title,contactsauthors.name AS authorname,contactsowners.name AS ownername FROM recordings JOIN recordings_authors AS authors ON recordings.id=authors.rec_id JOIN contacts AS contactsauthors ON authors.contact_id=contactsauthors.id -- here ----------------------------------> ^^^^^^^^^^ JOIN recordings_owners AS owners ON recordings.id=owners.rec_id JOIN contacts AS contactsowners ON owners.contact_id=contactsowners.id -- here --------------------------------> ^^^^^^^^^^ WHERE recordings.id=1

Categories : Mysql



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