Posts

Showing posts from August, 2012

mysql - PDO Exception with Laravel 4 php artisan migrate command on EC2 AWS -

i have ubuntu 12.04 instance on ec2 in aws , laravel 4 project uploaded there. trying run php artisan migrate, reason cannot connect mysql server through command. able mysql db on sql pro find using ssh (using elastic ip host). ssh server using elastic ip. i error when run php artisan migrate: [pdoexception] sqlstate[hy000] [2003] can't connect mysql server on '**.***.***.**' (11 1) migrate [--bench[="..."]] [--database[="..."]] [--path[="..."]] [--package[="..."]] [--pretend] [--seed] where starts represent "elastic ip", host use connect mysql in sql pro. in database.php config file, connecting using: 'mysql' => array( 'driver' => 'mysql', 'host' => '*elastic ip*', &#

How to edit HTML in Google Drive? -

i have hosted html file created on pc (along stylesheet) on google drive using script described here . i have given out link , seems working fine (no reported issues i've sent to). i have discovered minor omission file, need add sentence. should ridiculously easy on pc, open on notepad! i can't find way edit on google drive, connected apps viewer , docs. the viewer, name suggests, let me view html, , docs app won't let me save original file. obviously download upload again, experience give me different url. is there way me while keeping link same, have given address out? currently can't. can preview html files, preview code or preview rendered content, cannot natively edit code. have 2 options: use third party extension, such neutron drive or drive notepad . install google drive desktop app , edit files locally , save. changes uploaded automatically.

Migrating complex SVN repository to GIT -

i have svn repository more 100 projects , want migrate git now. how svn repository looks like: customer_1/prj_1 (trunk, branches, tags) customer_1/prj_2 (trunk, branches, tags) customer_1/prj_n (trunk, branches, tags) ... customer_2/prj_1 (trunk, branches, tags) customer_2/prj_2 (trunk, branches, tags) customer_2/prj_n (trunk, branches, tags) ... customer_n/prj_1 (trunk, branches, tags) customer_n/prj_2 (trunk, branches, tags) customer_n/prj_n (trunk, branches, tags) via svn can checkout: the entire repository containing customers , projects all projects of single customer a specific customer's project i still need these 3 ways of access using git, branching , tagging single customer projects , not entire repository. in svn different customer projects have different stable releases being stored in "tags" directory each project. need differentiate between customer project releases in git well. i have converted svn repository single git repository (using

imap - Reading mails using JavaMail -

this question more behavior. have been using both pop3 , imap access mails in gmail using javamail api. noticed , wanted clarify doubts regarding same. i retrieving unseen mails inbox. there couple of unread mails , retrieved them using pop3. switched on imap , read same inbox , able retrieve same 2 mails. i've been using javamail , encountered kind of behavior , wanted know if expected behavior? you read mail, did not delete or change anything, when read again still there , unchanged. that's all.

google bigquery c# API enum -

i'm trying work bigquery, c# api , complex types. i have object like public class myobject { public myotherobject someproperty { get; set; } } public class myotherobject { public string innerproperty { get; set; } public myenum otherinnerproperty { get; set; } } the field in table corresponding myotherobject record , innerproperty string field , otherinnerproperty string field. working tabledatainsertallrequest.rowsdata , when try "map" in json property (which dictionary<string,object> ) property myotherobject corresponding field, error thrown because (i assume) otherinnerproperty, enum, cannot converted string. any idea how deal enums in particular case ? thanks. edit: can have field corresponding "otherinnerproperty" integer field in bq table, i'd rather have otherinnerproperty.tostring() , string value in table... i don't know if you've solved issue, had problem , solved follows: when create serv

php - How to turn off multiple statements in postgres? -

i think idea turn off multiple statements prevent type of sql-injection. example of multiple statements: $query = "update authors set author=upper(author) where id=1;"; $query .= "update authors set author=lower(author) where id=2;"; $query .= "update authors set author=null where id=3;"; pg_query($conn, $query); is possible prevent multiple statements in posgresql settings or example using posgre's related php code? or maybe there way of parsing sql queries before passing them pg_query in order detect queries consists of more 1 statement? no, there no way disable multi-statements in postgresql. nor, far know, there way in php pg or pdo postgresql drivers. they aren't problem anyway. disabling multi-statements might (slight) sql injection harm mitigation , wouldn't real protection. consider writeable ctes, example, or qualifier removal attacks. instead, protect code in first place. rigorously use parameterized statements

java - Android: how to create a bitmap from a string? -

i have text in string i'd save image. right have following code: private void saveimage(view view){ string mpath = environment.getexternalstoragedirectory().tostring() + "/" + "spacitron.png"; string spacitron = "spacitron"; bitmap bitmap = bitmapfactory.decodebytearray(spacitron.getbytes(), 0, spacitron.getbytes().length*5); outputstream fout = null; file imagefile = new file(mpath); try { fout = new fileoutputstream(imagefile); //this line throws null pointer exception bitmap.compress(bitmap.compressformat.jpeg, 90, fout); fout.flush(); fout.close(); } catch (filenotfoundexception e) { } catch (ioexception e) { } } this not create bitmap , instead throws null pointer exception. how can save string bitmap? create canvas object , draw text on canvas. save canvas bitmap bitmap todisk = bitmap.createbitmap(w,h,bitmap.config.argb_8888); canvas

java - while validation, i need element name in "exception" -

this java class file. import javax.xml.xmlconstants; import javax.xml.transform.source; import javax.xml.transform.stream.streamsource; import javax.xml.validation.*; import org.xml.sax.saxexception; import java.io.*; public class jaxp_1 { public static void main(string [] args) throws exception { source schemafile = new streamsource(new file("xsd/img.xsd")); source xmlfile = new streamsource(new file("xml/imgone.xml")); schemafactory schemafactory = schemafactory.newinstance(xmlconstants.w3c_xml_schema_ns_uri); schema schema = schemafactory.newschema(schemafile); validator validator = schema.newvalidator(); try{ validator.validate(xmlfile); system.out.println(xmlfile.getsystemid()+ " valid"); system.out.println(); } catch (saxexception e) { system.out.println(schemafile.getsystemid() + " not valid"); system.out.println("reason: " + e.getmessage()); } } } this

user interface - GUI uiwait/uiresume fig Matlab -

i have matlab gui takes input in p array different functions different methods, question how can terminates uiwait when input of p array taken, such when function of input terminated successfully. i'm trying put uiresume doesn't work on side. my code (main function): function varargout = gui(varargin) if nargin == 0 fig = openfig(mfilename,'reuse'); handles = guihandles(fig); guidata(fig, handles); uiwait (fig); if nargout > 0 varargout{1} = fig; end elseif ischar(varargin{1}) try if (nargout) [varargout{1:nargout}] = feval(varargin{:}); else feval(varargin{:}); end catch end end i don't code supposed do. in case: uiresume has placed somewhere in callback of gui you're opening, since you're above code stops running in uiwait line. so, might have "ok"-button on gui callback à la: function ok_button_callback(object, evt

java - Bitstamp {"error": "API key not found"} Code Response: 200 -

i trying place balance request bitstamp in java, wrote following code getting error: {"error": "api key not found"} code response: 200 anyone has idea? the key , secret ones correctly provided exchange wonder if making mistake along way. import java.io.bufferedreader; import java.io.dataoutputstream; import java.io.ioexception; import java.io.inputstreamreader; import java.net.url; import java.net.urlencoder; import java.security.keymanagementexception; import java.security.nosuchalgorithmexception; import java.util.linkedhashmap; import java.util.map; import javax.crypto.mac; import javax.crypto.spec.secretkeyspec; import javax.net.ssl.httpsurlconnection; import javax.xml.bind.datatypeconverter; public class main { public static void main(string[] args) { string key = "apikeydemo"; string secret = "apisecretdemo"; integer nonce = 100; string id = "123456"; string message = nonce.tostring() + id +

set capture size for camera android -

i want set capture size camera in android. want user capture image using size alone irrespective of screen size. see approach in instagram application in android 4.x versions. i used following code, shows camera error. camera camera = camera.open(); parameters params = camera.getparameters(); list<camera.size> sizes = params.getsupportedpicturesizes(); params.setpicturesize(sizes.get(1).width, sizes.get(1).height);//height-480,width-640 camera.setparameters(params); anyone please me. in advance.

linux - How redirect nohup stdout to stdin -

is there way redirect nohup output stdin instead of nohup.out ? i've tried: nohup echo hello > /dev/stdin 2>&1 & but not trick. the nohup command purposefully detaches stdin, there nothing expects read in itself, , think after in question, redirecting output of nohup stdin next command. (well has read stdin, , ain't nohup .) further, posix mandates output goes nohup.out file in working directory, if file can opened. can wire stdin of following commands nohup.out file. instance: $ nohup echo hello 2>/dev/null; read var 0<nohup.out; echo "var=$var" var=hello

python - How to load columns from text file with numpy -

i have text file rows , each row has 3 floats separeted space. interested load 2nd , 3rd column. typed: b=np.loadtxt('file.txt',delimiter=(' '),usecols=(1,2)) but getting error: syntaxerror: non-keyword arg after keyword arg

java - Xor starting with the significant bit -

int a= 21;//10101 int b = 269;//100001101 a^b 10101 100001101 --------- 100011000 but want do 10101 100001101 --------- 001011101 is there way without changing original numbers? you can shift a align b on left. sample code below works example not handle overflows etc. should give starting point though. int = 21; int b = 269; int shift = integer.numberofleadingzeros(a) - integer.numberofleadingzeros(b); int c = (a << shift) ^ b; system.out.println(integer.tobinarystring(c)); // 1011101

layout - Android set ImageView's width as a ratio of another element (given the id) -

i have imageview: <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/pbc" android:layout_below="@id/ryc"/> is possible set it's width percentage of of element of id "@id/ryc" i've done in android:layout_below ?if so, how? thanks you need set width in activity, following code (just change yourpercentage percentage want)(i have added id imageview, can change it): xml: <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/pbc" android:id="@+id/pbcimageview" android:layout_below="@id/ryc"/> activity: float perc = yourpercentage / 100; imageview imgview = (imageview) findviewbyid(r.id.ryc); imageview pbcimageview = (imageview) findviewbyid(r.id.pbcimageview); pbcimageview.setwidth(imgview.getwidth() * p

Python Regex Sub - Use Match as Dict Key in Substitution -

i'm translating program perl python (3.3). i'm new python. in perl, can crafty regex substitutions, such as: $string =~ s/<(\w+)>/$params->{$1}/g; this search through $string , , each group of word characters enclosed in <>, substitution $params hashref occur, using regex match hash key. what best (pythonic) way concisely replicate behavior? i've come along these lines: string = re.sub(r'<(\w+)>', (what here?), string) it might nice if pass function maps regex matches dict. possible? thanks help. you can pass callable re.sub tell match object. s = re.sub(r'<(\w+)>', lambda m: replacement_dict.get(m.group()), s) use of dict.get allows provide "fallback" if said word isn't in replacement dict, i.e. lambda m: replacement_dict.get(m.group(), m.group()) # fallback leaving word there if don't have replacement i'll note when using re.sub (and family, ie re.split ), when speci

freebasic - Free Basic Calculator Issue -

i have attempted create calculator freebasic. problem line 9 in code? line 6 says dim choice default , not allowed while line 9 tells me variable isn't declared. 1 declare sub main 2 declare sub add 3 declare sub subtract 4 main 5 sub main 6 dim choice 7 print "1.add" 8 print "2.subtract" 9 input "what choice" ; choice your source code quite incomplete. example, misses data types. in freebasic choose between several data types depending on kind of data want store ( integer , double , string, ...). moreover, did not define how sub programs should work. didn't give code procedure "subtract" should do. here's working example of small calculator: ' these 2 functions take 2 integers (..., -1, 0, 1, 2, ...) , ' return 1 integer result. ' here find procedure declarations ("what inputs , outputs ' exist?"). implementation ("how these procedures ' work?") follows @ end of program.

ruby on rails - Unknown action The action 'linkedin' could not be found for Devise::OmniauthCallbacksController -

i'm trying implement open authorization within rails app users can log in linkedin accounts. when click on link go linkedin authorization page, , confirm linkedin credentials, error within app: unknown action action 'linkedin' not found devise::omniauthcallbackscontroller i'm positive issues lies within routes file. many tutorials call following line added: devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" } however, have line here custom devise logins: devise_for :users, :controllers => { :registrations => "registrations" } i tried switching them didn't work (as expected). there way combine 2 statements? thanks! issue omniauth_callbacks_controller: the action 'linkedin' not found omniauthcallbackscontroller class omniauthcallbackscontroller < applicationcontroller class omniauthcallbackscontroller < devise::omniauthcallbackscontroller def linkedin auth =

android - How to make dialog look same in all versions from 2.2 to 4.4 and also in all tablets -

how make dialog same in versions 2.2 4.4 , in tablets.i had created dialog perfect in 4.2 , want same dialog in 2.3 also.how make dialog same in versions 2.2 4.4 , in tablets.i had created dialog perfect in 4.2 , want same dialog in 2.3 also. public class mainactivity extends activity { private context context; private textview textview; private dialog dialog; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); context = mainactivity.this; alertdialog.builder alertdialog = new alertdialog.builder( mainactivity.this); layoutinflater inflater = mainactivity.this.getlayoutinflater(); alertdialog.setview(inflater.inflate(r.layout.dialog_textview, null)); // setting positive "yes" button alertdialog.setpositivebutton("call", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialo

2d - What's frame per sec in spritesheet animation in unity3d 4.3? -

Image
what's frame per sec in spritesheet animation in unity3d 4.3? or can set manually? want know if have 30 frames, how time take finish spritesheet animation. sprite sheet animation in unity 4.3 that, animation. means can control it. an excellent tutorial on subject this one michael h.c. cummings. once have created animation (by dragging frames of animation scene), might find animation playing far fast. believe default 60 frames per second. doesn't mean need create animation contain 60 frames each second. can adjust this. go animator window animation , adjust samples. if animation you've created consists of 12 frames per second, set 12. after animation should work fine.

Compiling Godot with SCons -

today want build open source godot project ( http://www.godotengine.org/wp/ ) on windows 7. give attention compiling instructions ( http://www.godotengine.org/wiki/doku.php?id=compiling_windows ) when use scons in command line, this: fatal error lnk1112: module machine type 'x86' conflicts target machine type 'x64' this problem described here: [ linking problem: fatal error lnk1112: module machine type 'x64' conflicts target machine type 'x86' ( linking problem: fatal error lnk1112: module machine type 'x64' conflicts target machine type 'x86' ) but have question. know, have define architecture type of environment variable in sconstruct file (i can post here, if want). unfortunately doesn't work thought. at first edited line, environment variable initialized: env_base=environment(tools=custom_tools,env = {'path' : os.environ['path']},target_arch='x86'); i added target_arch='x86'.

php - How to create unique registration number -

i trying unique admission number every student. counting number of rows in database , displaying value in student admission number. if enter student details , after submission saved in database , when delete , if again want enter new student details taking same register number deleted .i want unique registration numbers. please me unique numbers should not repeated. you can use feature of auto_increment property of mysql if have numeric registration number field.

Starting / Stopping php script running in background from browser -

i'm pretty new php. first time actually, apologize in advance if question sounds dumb. i have php script fetches data external api , updates database regularly. know best way use cron job. however, using infinite loop sleeps particular time between each update. now, need allow user (admin) start / stop script , allow them change time interval between each update. admin through ui. best way this? how execute script in background when user clicks start , how stop script? thanks. i think ideal solution following: have background job run cronjob every minute (instead of loop can cause memory leaks). php not designed daemon. set db flag in cronjob on/off, everytime runs checks if on or off, if off exists if on continue. in ui turn flag on or off depending on admin needs. i think best way go (and easiest).

php - Dynamic site title -

i created dynamic site. works fine, have 1 problem. how can have invidiual title each page (in html tag). hope understand mean. take @ index.php <html> <?php include_once 'config.php'; include_once 'includes/mysqlconnect.php'; $url_slash=$_server['request_uri']; $url= rtrim($url_slash, '/'); //$url = basename($url); ?> <head> <meta charset="utf-8"> <title>kascraft | *********</title> //here need variable or other display title each site <link rel="stylesheet" type="text/css" href="<?php echo $domain;?>themes/reset.css"> <link rel="stylesheet" type="text/css" href="<?php echo $domain;?>themes/<?php echo $theme;?>.css"> </head> <body class="body"> <div class="container-all"> <?php incl

jquery - Laravel 4 controller method call from Ajax -

since no means ajax guru, have come here see if lead me in right direction information on trying do. have scoured looking information either don't understand reading, or it's not looking do. honestly, don't know if trying possible, yeah... basically, trying accomplish putting application in maintenance mode admin section of site. using jquery .click() function update #div, want call function controller @ same time. so here goes... my jquery right is: $('#on').click(function () { $('#turnedon').addclass('green'); $.cookie('maint', 'maintenance', { expires: 365 }); //alert('you have put app in maintenance mode.'); $.ajax({ method: 'get', // should use post? or get? wanting run function when .click() function run url: '/admins', // not sure should used url since want call function error: function(e){ alert( 'error ' + e );

Python to search a string for the first occurrence of any item in a list -

i have parse few thousand txt documents using python, right i'm getting code working one. i trying find first time month (january, february, march, etc) appears in document, , return position of first month. every document has @ least 1 month in it, have many months. this works currently, seems cumbersome: mytext = open('2.txt','r') mytext = mytext.read() january = mytext.find("january") february = mytext.find("february") march = mytext.find("march") april = mytext.find("april") may = mytext.find("may") june = mytext.find("june") july = mytext.find("july") august = mytext.find("august") september = mytext.find("september") october = mytext.find("october") november = mytext.find("november") december = mytext.find("december") monthpos = [january, february, march, april, may, june, july, august, september, october, november, december] mon

python - Split a string into N equal parts? -

this question has answer here: split string sized chunks 5 answers i have string split n equal parts. for example, imagine had string length 128 , want split in 4 chunks of length 32 each; i.e., first 32 chars, second 32 , on. how can this? import textwrap print textwrap.wrap("123456789", 2) #prints ['12', '34', '56', '78', '9'] note: careful whitespace etc - may or may not want. """wrap single paragraph of text, returning list of wrapped lines. reformat single paragraph in 'text' fits in lines of no more 'width' columns, , return list of wrapped lines. default, tabs in 'text' expanded string.expandtabs(), , other whitespace characters (including newline) converted space. see textwrapper class available keyword args customize wrapping b

How to verify an XPath expression in Chrome Developers tool or Firefox's Firebug? -

Image
how can verify xpath? i using chrome developers tool inspect elements , form xpath. verify using chrome plugin xpath checker, not give me result. better way verify xpath. i have tried using firebug inspect bug , using firepath verify. firepath verify xpath. my last option use selenium webdriver confirm xpath. chrome this can achieved 3 different approaches (see blog article here more details): search in elements panel below execute $x() , $$() in console panel, shown in lawrence's answer third party extensions (not necessary in of cases, overkill) here how search xpath in elements panel: press f12 open chrome developer tool in "elements" panel, press ctrl + f in search box, type in xpath or css selector, if elements found, highlighted in yellow. firefox install firebug install firepath press f12 open firebug switch firepath panel in dropdown, select xpathor css type in locate

bash: how to execute a line from a file? -

i guess easy couldn't figure out. have command history file , i'd grep line , execute it. how do it? for example: in file command.txt file, there is: wc -l *txt| awk '{ofs="\t";print $2,$1}' > test.log suppose above line last line, want this tail -1 command.txt | "execute" i tried use tail -1 command.txt | echo but no luck. can tell me how make work? thanks! just use command substitution bash -c "$(tail -1 command.txt)"

single page application - Securing internal REST service call via JavaScript -

i have public spa calling backend rest service via javascript. how can secure rest service accept calls spa , no other clients or users? any way can think secure involving storing kind of secret, because spa written in javascript can view source. the common practice securing api combination of api-key & using ssl (https) here links point in right direction: theoretical: http://www.slideshare.net/jfaustin/securing-your-api (from slide 17 onward) https://security.stackexchange.com/questions/18684/how-to-implement-an-api-key-mechanism practical: (.net) http://blogs.msdn.com/b/rjacobs/archive/2010/06/14/how-to-do-api-key-verification-for-rest-services-in-net-4.aspx also, pluralsight ( http://www.pluralsight.com/training ) has amazing videos (unfortunately paid membership) on topic & more! hope helps

javascript - jQuery: navigate to another page by clicking a button -

i'm learning javascript , jquery. i'm trying build simple web page buttons navigate page upon click via switch-case statement. i've added local jquery script .html file, nothing seems happen when click buttons. demo can found here: http://jsfiddle.net/vmyly/ the html code is: <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> $("input[type='button']").click(function() { switch(this.id) { case 'x': window.location.href = "http://google.com"; break; case 'y': window.location.href = "http://yahoo.com"; break; case 'z': window.location.href = "http://stackoverflow.com"; break; } }); </head> <body> <input type="button" value="google" style=&qu

Add `data android:scheme="file"` to home widget -

i have home widget follow. <receiver android:name="org.yccheok.gui.widgetmyappwidgetprovider" android:exported="true" > <intent-filter > <action android:name="android.intent.action.media_mounted" /> <data android:scheme="file"/> <action android:name="android.appwidget.action.appwidget_update" /> <action android:name="android.appwidget.action.appwidget_enabled" /> <action android:name="android.appwidget.action.appwidget_deleted" /> <action android:name="android.appwidget.action.appwidget_disabled" /> <action android:name="android.appwidget.action.appwidget_options_changed" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /> </receiver> i wish widget abl

delphi - How to free an object from within one of its own methods? -

is there way safely free object within 1 of own methods? (i don't need nil objects variable) var msg: tamessage; begin msg := tamessage.create(); msg.processanddone; end; and want tamessage.processanddone() method destroy object (in above case msg ) because won't need object after calling processanddone method, , don't want call free or destroy each time right after call processanddone (for sake of code clarity). i know setting tthread's freeonterminate property actual freeing process handled wrapper called threadproc calls thread's execute within. if last act of processanddone call destroy , or free , fine. if processanddone calls methods, or refers members, after has been destroyed, it's no good. , of course, you'd need put try/finally inside processanddone make sure destruction happens. but said, should not this. patterns exist clarity, , benefit of other readers. whenever see obj := tmyobject.create; we expect se

php - Fatal error: Cannot re-assign auto-global variable _POST -

i can't access wp (version3.4.2) admin. says mentioned above fatal error: cannot re-assign auto-global variable _post in /home/xxx/public_html/wp-content/themes/rtthemes16/rt-framework/classes/admin.php on line 540. the line 540 : function rt_check_sidebar_array($_post){ if(is_array($_post)){ $start_unset_count = 0; foreach($_post $key => $value){ if(stristr($key, '_sidebar_name') == true && $value=="") { unset($_post[$key]); $start_unset_count = 1; } if($start_unset_count>0){ unset($_post[$key]); $start_unset_count++; } if($start_unset_count==6){ $start_unset_count = 0; } } } $newpost == $newpost ? $newpost : $_post; return $_post; } any insights? :) since php 5.4, cannot use superglobal p

web applications - Cordova iOS with Spotify iOS SDK - Trigger Auth -

i'm developing web apps based on cordova, have problem: want include spotify in new app. spotify has ios sdk (beta) beginner tutorial . worked fine (on app load start auth). now implement in webapp using cordova.exec(); (not on load - auth on button click (triggered javascript). i've generated cordova plugin - worked. , can trigger method via cordova.exec(); . this method triggered: - (bool)startspotifyauth:(cdvinvokedurlcommand*)command { // create sptauth instance; create login url , open nsurl *loginurl = [[sptauth defaultinstance] loginurlforclientid:kclientid declaredredirecturl:[nsurl urlwithstring:kcallbackurl] scopes:@[@"login"]]; // opening url in safari close application launch may trigger ios bug, wait bit before doing so. // [uiapplication performselector:@selector(openurl:) withobject:loginurl afterdelay:0.1]; nslog(@"*** got in debug console ***"); // ask sptauth if url given spotify authentication call

java - Basically I want to replace the unwanted repeated characters words with their correctly spelled words -

i want take text file input , read words , check each word englishwordslist , if words misspelled (like unwanted repeated characters)then replace word correct word in same file. if word beautifullllll code works fine..it writes beautiful file if word beautttifulll code not work properly.first i'm removing repeated characters in word cross-checking wordslist if not present allowing 1 successive repetition of character.since beautttifulll has more 1 character repeated output beauttifull not in dictionary. please me this. import java.io.*; public class ownspell { public static string result(string input, boolean doubleletter){ string pattern = null; if(doubleletter) pattern = "(.)(?=\\1{2})"; else pattern = "(.)(?=\\1)"; return input.replaceall(pattern, ""); } public static int checkingdic(string word) throws ioexception,filenotfoundexception { fileinputstream fstream=new fileinputstream("g:/englishwordslist.txt");

php - Seperate row in column with SQL query -

i have row with (name1, name2, name3, name4) and row with (2, 3, 4, 5, 7) i need present data in 2 columns, name number in same place this: names | numbers -------------------- name1 2 name2 3 name3 4 name4 5 i tried subsrting_index repaet same number @ first i think in mysql might done in way similar this: create table t (names char(255), numbers char(255)); insert t(names, numbers) values('name1,name2,name3,name4', '2,3,5,7'); select substring_index(substring_index(t.names, ',', idx), ',', -1), substring_index(substring_index(t.numbers, ',', idx), ',', -1) t, (select 1 idx union select 2 union select 3 union select 4) r here complete sqlfiddle sure, subquery generating number sequence should adjusted case. there number of examples on stackoverflow how achieve particular task. update: here example how handle 10000 elements in row. select substring_index(substring_index(t.nam

android - Instrumentation run failed due to 'java.lang.IllegalAccessError' in Robotium test project with actionbar sherlock -

i've added actionbarsherlock dependency robotium test project ... , each time try run tests, below error occurs test run failed: instrumentation run failed due ' java.lang.illegalaccesserror' any ?! i faced similar issues during instrumentation got error class ref in pre-verified class resolved unexpected implementation after log of struggle , solve problem . problem occurred due android-support-v4.jar. jar default created in lib folder of android project. jars added lib folder used during compilation time runtime instrumentation project. when running instrumentation, target application started using android-support-v4.jar bundled in instrumentation project instead of own android-support-v4.jar. causes pre-verified class exception during runtime (as version differ). to solve issue moved out android-support-v4.jar out of lib folder , put in different folder (say libforcompile) , add external jar (project properties -> java build path --> librar

cmd - Command line commands not executing? -

Image
hello have no idea why no commands execute in cmd. i tried executing ping http://google.com , tells me it's not recognized? thanks. your path statement has changed. type path , see shows in fresh command window

jQuery Validator with custom method -

i totally new jquery , need add validation form. have select box 3 types of credit card options - visa, mastercard , amex. have text box entering security code on credit card. however, security code required if amex selected. the select box named "cardtype" , textbox named "securitycode" so if amex selected nothing entered securitycode textbox, want 1 of jquery red errors appear beneath textbox when tries submit form. i know has validator.addmethod not know how begin add main.js file. $.validator.addmethod("securitycode", function(value, element) { var card_type = $("input[name='cardtype']").val(); if(card_type == "amex" && !$.trim(value) ) { return false; } else { return true; } }, "please ad security code&qu

api - Unix time stamp or string with time zone? -

i web rest api service i've decided return datetime data string timezone looks this: "somedate":"2012-01-23t22:52:37.039+02:00" wonder, how idiomatic it? if returned unix time stamp, more sensible? personally, prefer using unix timestamps in situations because timezone agnostic , leaves timezone interpretation entirely client. additionally, depending on client, it's less code parse unix timestamp date date string, that's ancillary consideration.

browser - Identify JavaScript synchronous execution block -

can't find discussion around that. in javascript, there way detect i'm running different functions in same execution block or have executed function in current execution block? basically need optimize browser code avoiding run twice in same synchronous block. i'm doing this: var issaved = false; function saveuistate() { if(issaved === true) { return; } // heavy dom processing ... issaved = true; settimeout(function() { // reset flag in execution block issaved = false; }, 0); } but i'm not guaranteed flag reset before next execution block. although node's process.nexttick more appropriate, i'm more looking way identify execution block: var lastexecutionblockid; function saveuistate() { if(lastexecutionblockid === executionblockid) { return; } lastexecutionblockid = executionblockid; ... } you may want research mediator pattern, think in situation. subscribe calls

Java get response code from URL -

while (it.isvalid()) { simpleattributeset s = (simpleattributeset) it.getattributes(); linkurls = (string) s.getattribute(html.attribute.href); if (linkurls != null) { system.out.println(linkurls); } it.next(); } this loop shows urls. how display getresponsecode () each address? must done in loop? can write such code? not know how go it. you're going need open urls, warned relative or protocol-relative (unless library you). once rebuild url, do url url = new url(urlstr); // might idea validate connection type before casting httpurlconnection connection = (httpurlconnection)url.openconnection(); connection.getresponsecode();

python - queryset filter month returns empty -

edit : dropped , waited few days started working! how upgrade 1.6 took while 'propagate'! shrugs . chimed in! the queryset filter month not seem working correctly. have bunch of objects in database model called note field pub_date storing datetime object. want retrieve note objects month. here test did: >>> blogengine.models import note >>> n = note.objects.all()[0] >>> n.pub_date datetime.datetime(2014, 3, 8, 21, 15, 14, tzinfo=<utc>) >>> note.objects.filter(pub_date__year = 2014) [<note: note object>, <note: note object>] >>> note.objects.filter(pub_date__month =3) [] as can see year works correctly, giving me 2 objects year=2014 , month lookup returns nothing though there object month can seen first example object n . happens other datetime lookups day or minute . python = 2.7.5 django 1.6.2 so dropped , waited few days started working! how upgrade 1.6 took while 'propagate'!

syntax - Assignment in conditional not permitted in Python? -

why code if = "hello": pass invalid in python? = "hello" expression value rvalue. it's valid in languages c or php. opinions? this intentionally made illegal in python allowing huge source of error , making illegal minor inconvenience. see the design , history faq my experience in python right. miss not being able this.

Image size influence comparing histograms OpenCV -

i'm using comparehist() function compare histograms of 2 images. my question is: size of image has considerable influence on results? should resize images or normalize histograms before comparing? i'm using cv_comp_correl method. you have normalize histograms before comparision. imagine have non noramlized histograms, e.g. 1 of them has bins values in interval [0..1000] , other in [0..1]. how can compare them? of course every mathematical operation addition makes no sense, because result of addition? then in practice size of image not matters. in practice means if hava image , scale lets 2 times , you've got image b, if compute hist(a) , hist(b), normalize both histograms practically same. because of fact if scaling image factor k, , have n pixels in color c in image a, in image b have approximately k*k*n pixels in color c (depends of interpolation). every color amount "scale" proportionally, if normalize hist(a)and hist(b), results approxim

jQueryUI autocomplete not working in Twitter-Bbootstrap modal -

i have php function creates various autocomplete boxes use round pages: $partnerbox= autocomplete($array,'ps'/*form field name*/,0); i use form field name inside jquery create individual jquery functions in case have multiple boxes avoid duplicate function names. it works fine when output boxes straight in page, when try load 1 box inside twitter modal nada - ideas? the input box shows nothing happens when type - if load single working autocomplete box modal stops - any ideas? <div class="modal-body"> <div class="row"> <div class="col-md-6"> <form role="form"> <div class="form-group"> '.$partnerbox2.' <!-- <input type="text" class="form-control" placeholder="select client" required> --> </div> <button type="submit&qu

objective c - Handling Cusom Key Board Types in ios -

this question has answer here: how add custom fonts iphone app? 3 answers here in ( http://iosfonts.com/ ) site, number of fonts listed ios devices supports. indian language, tamil, there font named sangam. understanding there no localization support languages tamil, telugu or devanagiri. ios supports ttf , opentype fonts both added xcode, possible create custom keyboard lay out, typing using these fonts. these languages has no similarities of language keyboard apple supports presently, there way type, store , share text contents using these custom type fonts. yes, embed font files (.ttf or .otf files) in app add them list of dedicated uiappfonts key in info.plist file (note: key called "fonts provided application" in human-readable description) . see the doc here . you can use [uifont fontwithname:size:] name of custom font manipulate font ,

xna - C# Collision Programming - Momentum -

i'm programming 3d xna game , i'm struggling understand how implement momentum-like collision between 2 players. concept either player hit other , attempt knock opponent off level (like smash bros games) score point. //declared variables primitiveobject player1body; primitiveobject player2body; vector3 player1vel = vector3.zero; vector3 player2vel = vector3.zero; //created in loadcontent() primitivesphere player1 = new primitivesphere(tgd, 70, 32); this.player1vel = new vector3(0, 135, -120); this.player1body = new primitiveobject(player1); this.player1body.translation = player1vel; this.player1body.colour = color.blue; primitivesphere player2 = new primitivesphere(tgd, 70, 32); this.player2vel = new vector3(0, 135, 120); this.player2body = new primitiveobject(player2); this.player2body.translation = player2vel; this.player2body.colour = color.red; //update method code collision this.player1vel.x

linux - Authenticate on Wordpress with wget -

i login via wget onto wordpress website. i have found on stackoverflow related basic authentication. wget --save-cookies cookies.txt \ --post-data 'user=foo&password=bar' \ http://server.com/auth.php and tried wordpress site did not work. try this. worked me 1 of drupal projects worked on sometime ago. answered asciikewl on drupal thread https://drupal.org/node/118759 i've managed working way, using wget's own cookie handling: i'm referencing /user page, not login block (not enabled on site) #!/bin/sh site=http://your site url slash on end/ name=scriptuser pass=somethingsecure cookies=/tmp/cron-cookies.txt wget -o /dev/null --save-cookies /tmp/ba-cookies.txt --keep-session-cookies --load-cookies $cookies "${site}user" wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies -o /dev/null \ --post-data="name=$name&pass=$pass&op=log%20in&form_id=user_login" \ "${site}user?desti

multithreading - Java - threadsafe collection that sorts on remove/take -

i have situation whereby need threadsafe queue runs sort every time remove() method called , when method called. because objects can dynamically change "priority" after have been added collection due external factors. needs threadsafe. there no point extending priorityblockingqueue because run comparison function when additions made. failed find such collection/queue, tried implement own wrapping around array list: public class blockingsortontakequeue<e> implements queue<e> { private arraylist<e> m_list; public blockingsortontakearraylist() { m_list = new arraylist<>(); } @override public synchronized e remove() { m_list.sort(m_comparator); return m_list.remove(0); } .... unfortunately, having difficulty figuring out how ensure object type <e> has implement compareable interface, , use objects compareto function when trying sort list (in code have m_comparator unfinished/pl

Developing Wcf Callback service using netTcpBinding -

i stuck in problem regarding wcf callback service. i trying develop wcf callback service using nettcpbinding, created callback service using wsdualhttpbinding when try achive same thing using nettcpbinding, stuck in problem. sometimes "contract requires duplex, binding 'basichttpbinding' doesn't support or isn't configured support it." or "this protocol not support nettcpbinding" so can show me how configure web.config file , how overcome types of error.. thank you. without supplying code , config using difficult tell causing error. maybe take @ duplex messaging , technet: creating duplex service .

android - transport.connect is not doing anything javamail -

i send emails using javamail. have class able (few months ago send emails), program stops on transport.connect(emailhost, from, frompassword); sendmails activity: public class sendmails { final string smtpauth = "true"; final string starttls = "true"; final string emailhost = "smtp.gmail.com"; string fromemail; string frompassword; list<string> toemaillist; string emailsubject; string emailbody; string emailport; properties emailproperties; session mailsession; mimemessage emailmessage; private emailaccount account; private emailauthenticator authenticator; public sendmails() { } public sendmails(string fromemail, string frompassword, list<string> toemaillist, string emailsubject, string emailbody, string emailport) { this.fromemail = fromemail; this.frompassword = frompassword; this.toemaillist = toemaillist;

r - stat_summary_hex coloured by ratio -

let's have data frame following columns: x, y, num, denom , , produce hex plot colours of hexagons set sum(num)/sum(denom) . i assumed answer involve stat_summary_hex naively tried: ggplot(data, aes(x=x, y=y)) + stat_summary_hex(fun=function(d) {sum(d$num)/sum(d$denom) }) but output is: error: stat_summaryhex requires following missing aesthetics: z and understand why (i didn't give z aesthetic), i'm not sure try next: how can pass in 2 z aesthetics (i.e. num , denom )? i ended finding hack wanted, record here: ggplot(data, aes(x=x,y=y,z=complex(0,num,denom))) + stat_summary_hex(fun= function(x) { sum(re(x)) / sum(im(x)) }) essentially, did provide z parameter, column of complex numbers. complex numbers numbers, ggplot lets them through, , have 2 parts, real , imaginary part, aggregation function able compute ratio wanted.

Find Rest url to retrieve the list of Site Collections in Sharepoint 2013 -

1) go sharepoint 2013 site , click on admin 2) click on sharepoint you notice list of site collections default. i searching rest endpoint url retrieve list of site collection names. the closest https://-admin.sharepoint.com/_api/site. please help. you can use search api on root site: _api/search/query?querytext='contentclass:sts_site'&selectproperties='siteid, path, title'&trimduplicates=true parsing xml in result not simple, possible.

h.264 - IDR and non IDR difference -

what difference between idr , non idr frames? what "coded slice of non idr picture" , "coded slice data partition a", "coded slice data partition b", "coded slice data partition c", "coded slice of idr picture" ? idr, slices, partitioning - have them defined formally right there in specification : 3 definitions 3.62 instantaneous decoding refresh (idr) picture : coded picture in slices or si slices causes decoding process mark reference pictures "unused reference" after decoding idr picture. after decoding of idr picture following coded pictures in decoding order can decoded without inter prediction picture decoded prior idr picture. first picture of each coded video sequence idr picture. 3.27 coded picture : coded representation of picture. coded picture may either coded field or coded frame. coded picture collective term referring primary coded picture or redundant coded picture,

class - Selecting parent div and not every div with the same name with jQuery -

my problem is, when click on div class "trigger" every div "group" opens, parent div should open, how can this? code // global variables var nav = $('.group'), navheight = nav.height()+15, items = $('.group .item .trigger'), itemssub = items.next('.toggle_container'), itemssubopen = false, speed = 400; // global functions var navopen = function (thissubmenu) { itemssubopen = true; // height thissubmenu.css('height', 'auto'); var thisheight = thissubmenu.height(); thissubmenu .css('height', '0') .animate({height: thisheight }, speed) .addclass('open'); nav.animate({height: thisheight + navheight }, speed); }; var navclose = function () { itemssubopen = false; items.next('.open') .animate({height: 0}, speed) .removeclass('open'); nav.animate({height: