Posts

Showing posts from May, 2010

DELIMITER in mysql does not work -

the below code works correctly when use command line (mysql.exe) execute, incorrect when use sql query in phpmyadmin or using scriptrunner (java) execute. the error: error syntax execute delimiter $$ how can solve problem? -- procedures -- delimiter $$ create definer=`root`@`localhost` procedure `upload_photo`( in owner_id int, in photo_name text, in photo_url text, in thumbnail text ) begin declare inserted_id int unsigned default 0; insert photo(`owner_id`, `photo_name`, `photo_url`, `thumbnail`) values(owner_id, photo_name, photo_url, thumbnail); set inserted_id = last_insert_id(); select * photo photo_id = inserted_id; end$$ -- delimiter ; phpmyadmin uses mysqli doesn't support delimiter. see if delimiter needed @ all. running script multiple rows , mysql runs of them semicolons delimiters.

windows 8 - Unable to debug Win 8 app using Mixed (Managed and Native) debugger -

in winrt app when switching debugger type mixed (from managed), application fails start.. pausing debugger shows execution at: static void main(string[] args) { global::windows.ui.xaml.application.start((p) => new app()); } the output window continually shows eetypeloadexceptions different memory locations: first-chance exception @ 0x757e4b32 in applicationname.exe: microsoft c++ exception: eetypeloadexception @ memory location 0x0bf7d134. it looks clr exception is: clr:(c:\windows\microsoft.net\assembly\gac_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll) rejecting native image because native image dependency c:\windows\microsoft.net\assembly\gac_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll had different identity expected i need use native debugger sos debugging extension (sos.dll) when creating new blank app , adding same dependencies app, don't experience problem, specific app. any ideas on issue or how troubleshoot furthe...

android - Exception "inflating class fragment" -

getting run time exception "inflating class fragment" when tried add google map in android application. go through previous comments similar have posted. couldn't solve it. log file attached here 08-07 05:30:41.587: e/androidruntime(2574): fatal exception: main 08-07 05:30:41.587: e/androidruntime(2574): java.lang.runtimeexception: unable start activity componentinfo{com.example.newapp/com.example.newapp.newapp}: android.view.inflateexception: binary xml file line #17: error inflating class fragment 08-07 05:30:41.587: e/androidruntime(2574): @ android.app.activitythread.performlaunchactivity(activitythread.java:2211) 08-07 05:30:41.587: e/androidruntime(2574): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2261) 08-07 05:30:41.587: e/androidruntime(2574): @ android.app.activitythread.access$600(activitythread.java:141) 08-07 05:30:41.587: e/androidruntime(2574): @ android.app.activitythread$h.handlemessage(activitythread.java...

Why my request get stuck when mule is secured by HTTP Basic Authentication? -

i new mule, , configured mule security http basic authentication following: <spring:beans> <!-- setup authentication --> <ss:authentication-manager alias="authenticationmanager"> <ss:authentication-provider user-service-ref="appauthservice"> </ss:authentication-provider> </ss:authentication-manager> <spring:bean id="appauthservice" class="org.jamee.demo.mule.rest.appauthservice" /> <ss:global-method-security jsr250-annotations="enabled" /> </spring:beans> <flow name="muleflow1" doc:name="muleflow1"> <http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8081" path="rest" doc:name="http"> <mule-ss:http-security-filter realm="mule-realm" /> </http:inbound-endpoint> <jersey:resources doc:name="rest"> <component...

hdfs - Hadoop dfs put fails -

i getting error (hadoop dfs -put) when process triggered shell script (run jenkins) during nigh, however, runs ok if try manually later. put: lease mismatch on /shared/file1.tsv._copying_ owned dfsclient_nonmapreduce_-2031300157_1 accessed dfsclient_nonmapreduce_-1375175076_1 13/08/07 07:11:39 error hdfs.dfsclient: failed close file /shared/epg/programs/programs/20130812/programs__20130812_20130807.tsv._copying_ any suggestion why might happen?

java - Why does my Android app stops, when I move it to the background? -

i'm developing android application , have following code lines: @override public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_back || keycode == keyevent.keycode_home) { movetasktoback(true); return true; } [... more code ...] } when test on emulator, works , closes app , opens @ point before. when load apk on real device, stops application , starts new, when open again. loading screen. where problem? have tried saving state of activity ? solution here

javascript - Firebase transaction does not update actual value in the Firebase DB -

i using angularjs , firebase in app. when user press button want increase price of auctioning item $0.01 , after has been committed firebase db - deduct $1.00 user's balance. use firebase transaction() that, value of item not updated in firebase db: $scope.auctionpriceref = travelbidsfirebaseref.child('auction/' + $scope.auction.id + '/price'); $scope.auctionpriceref.transaction(function(currentvalue) { console.log("current val + 0.01: " + (currentvalue + 0.01)); return currentvalue + 0.01; }, function(error, committed, snapshot) { if (error) { console.error("error increasing auction price: " + error); } if (committed) { console.log("successfully increased auction price to: " + snapshot.val()); $rootscope.authuser.balance -= 1.0; } }); this code executes without errors , can see following output @ console (the initial price of item 1.00): current val + 0.01: 1.01 increased auction price to: 1 the collback execute...

java - Non-generic object of generic type -

for following codes: arraylist<string> ar = new arraylist<string>(); ar.add(45); and arraylist<string> ar = new arraylist(); ar.add(45); i getting compile time error @ line ar.add(45) as: cannot find symbol symbol : method add(int) location: class java.util.arraylist<java.lang.string> al.add(45); ^ both piece of code failing invalid input . why compiler raising warning of unchecked or unsafe operation second piece of code? then why compiler raising warning of unchecked or unsafe operation second piece of code? because you're assigning arraylist variable type arraylist<string> . means while compiler enforce expectation array list contain strings when reference list through ar , can't sure don't have other references non-parameterized arraylist you'll use add non-strings it, this: arraylist anythinggoes = new arraylist(); arraylist<string> onlystrings = anythinggoes...

Gnuplot C++ plotting in real time from txt files -

hi plotting data file through pipe in c++. have written function reads in text file, processes information, plots data in text file , plots labels , arrows needed. now need way plot smoothly in loop, different text file read , plotted every iteration without gnuplot window flickering. for example: for (unsigned int = 0; i< 10; i++){ processing_plotting(i, gp); } this code have in main program plot text file indicated 'i'. eg: laserdata1, laserdata2 etc.. currently plot flickers , unreadable due speed called. have looked way plot data in real time gnuplot haven't had luck, appreciated. thanks a picture of sort of thing plotting: http://imgur.com/3etpmab there example of animation comes gnuplot-iostream library. doesn't flicker, @ least not on machine (linux). disclaimer: i'm author of library, shameless plug. your code snippet doesn't show how interface gnuplot, there 3 things must sure do: 1) don't close , reopen pipe af...

simple numeric validation in jquery for input -

can me simple jquery numeric validation? <input type="text" name="yourphone" id="yourphone" required style="border-radius:6px; border:1px solid #ccc; width:300px; height:25px;" /> <input type="submit" value="send inquiry" class="button" id="mysubmitbutton" /> you can change input type number <input type="number"... (although not browsers support html5 input types). or can use this: $('#myform').on('submit', function(){ var value = $('#yourphone').val() return $.isnumeric(value); }); but phone numbers can complex, not numbers. in case user uses + ( ) - . , can use this: ( demo ) $('#myform').on('submit', function(){ var value = $('#yourphone').val() var regex = new regexp(/^\+?[0-9(),.-]+$/); if(value.match(regex)) {return true;} return false; });

python - logging with uwsgi (multiprocess) + flask -

i plan run uwsgi (4 processes) following command command = uwsgi --master --processes 4 --die-on-term --socket /tmp/uwsgi.sock --file run.py --callable app --stats /tmp/stats.socket --memory-report --post-buffering 32768 --virtualenv <virtualenv> --logto2 <log_path> i want use streamlogger log stdout , stderr. question is: uwsgi multiplex log 4 worker processes log file? i know syslog better option , there many other options: http://uwsgi-docs.readthedocs.org/en/latest/logging.html but want start off stream logger if can handle concurrent log messages workers. just add --log-master , every logline serialized master write line synchronously file.

Using Webgrid to create <th> tag -

i tried render table using webgrid, structure using webgrid render doesn't contain <th> tag, , renders <td> inside <tr> tag inside ''. can me how render <th> tag without using <table> ? such : ` <tbody> <tr> <th> </th> <td></td> </tr> </tbody> </table> ` thx lot the webgrid render th elements default unless set displayheader parameter false. render them in tr within thead element. additionally, render opening <table> tag. if don't want opening <table> tag, have manually construct whatever html want render.

javascript - mocha run tests twice -

i have several tests node js express application written in coffeescript run under mocha control. unfortunately mocha runs tests twice, becouse in same directory jave .coffee , .js files. .js files generated editor automatically .map files. that's quite handy if need debug something. how can filter .coffee or .js executed directory not both of them? in package.json, create entries following: "scripts": { "test": "npm run test-coffee", "test-js": "mocha -r spec test/*.js", "test-coffee": "mocha -r spec test/*.coffee" } now can run npm test , npm run test-js , or npm run test-coffee . if have tests in subdirectories, want use find command run subtests you're interested in.

How to define route name for nested resource in Ember.js? -

i've got nested resources in ember routes. lets suppose according this example , router.js looks like: app.router.map(function() { this.resource('post', { path: '/post/:post_id' }, function() { this.resource('comment', { path ':comment_id' }); }); }); the documentation says should generate routes like: /post/:post_id post.index /post/:post_id/:comment_id comment.index however these post.show , comment.show , how rename these routes? i have working following setup. routers dynamic segment: app.router.map(function() { this.resource('post.show', { path: '/post/:post_id' }); this.resource('comment.show', { path: '/post/:post_id/:comment_id' }); }); overriding serialize hook of app.commentshowroute reflect url expected: app.commentshowroute = ember.route.extend({ serialize: function(model) { return { post_id : model.get(...

iphone - How to change iOS Notification Center pulling direction? -

i have set root viewer's direction upside down. when enter app, can pull out notification center top (near home button). after pressed home button, went app, notification center pulled out bottom, view's direction not changed. i'm wondering how change ios notification center pulling direction? i'm using xcode 4.6 , testing on iphone 5 6.02 -(nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmaskportraitupsidedown; } - (bool)shouldautorotate { return yes; } the ui notifications stupid, agree. should two-finger swipe top (or right) edge (like in mountain lion track-pad). however, it's system-owned gesture can't rid of it, , if find workaround there's no guarantee keep working on different os releases. i'm not sure, apple may reject app if try alter system behaviour.

How does the this c++ code work -

here code int& fun(){ static int x = 10; return x; } int main() { fun() = 30; cout<< fun(); getch(); } the output 30. how work? let's read line line: int& fun() declares function named fun returns reference integer variable { static int x = 10; the x variable static inside function. special place in memory reserved , initialized 10 . every time function called x value stored in special location. return x; } we return x , leave function. let's go main one: int main() { fun() = 30; remember fun returns reference int. here modify integer 30 . since integer has static allocation every time fun called on x start 30 , unless other changes made. cout<< fun(); since x 30 that's get. getch(); } suggestion: use gdb , trace program's execution step-by step: $ gdb ./a.out (gdb) b main breakpoint 1 @ 0x40077b: file 1.cpp, line 11. (gdb) r starting program: /tmp/a.o...

php - How should I create route on with google maps API? -

Image
problem hi, new google maps api. want achieve results showed in below image. reading docs in google maps api v3 couldn't figure out library should use draw route, show km (distance) ran user or start , end point marker. any leading docs or demo/tutorial provided google or developer related topic great. in advance. map image read https://developers.google.com/maps/documentation/javascript/directions and search distance.value to display km

perl - prompting multiple questions to user (yes/no & file name input) -

i want ask user multiple questions. have 2 types of questions: y/n or filename input. i'm not sure how place nice if structure. , i'm not sure if should use 'else' statements too. this? have far: print "do want import list (y/n)?"; # first question yes/no $input = <stdin>; chomp $input; if ($input =~ m/^[y]$/i){ #match y or y print "give name of first list file:\n"; $list1 = <stdin>; chomp $list1; print "do want import gene list file (y/n)?"; if ($input =~ m/^[y]$/i){ print "give name of second list file:\n" # can use $input or need define variable?; $list2 = <stdin>; chomp $list2; print "do want import gene list file (y/n)?"; } } one word: abstraction. the solution chose not scale well, , contains repeated code. write subroutine prompt hides of complexi...

wordpress - Parse error: syntax error, unexpected end of file in___ -

my site's theme has been working fine few days when suddendly without coding changes getting error: parse error: syntax error, unexpected end of file in /home/henrysst/public_html/wp-content/themes/bettycommerce/includes/pro_framework/admin.php on line 812 i have made no changes theme, , working fine before (apart revolution slider not working) here line pulling error: } add_action('upfw_admin_header_links','upfw_default_header_links'); here link site, if of help: http://henrysstuff.co.uk/ thank in advance can provide. full code: <?php /****** ** pro bones framework version *************************************/ define('upthemes_ver', '1.0.0'); /****** ** theme init hook *************************************/ function upfw_theme_init(){ do_action('upfw_theme_init'); } /****** ** admin init hook *************************************/ function upfw_admin_init(){ do_action('upfw_admin_init'); } /**...

python - POST request with Multipart/form-data. Content-type not correct -

we're trying write script python (using python-requests a.t.m.) post request site content has multipartformdata. when post request manually (by filling in form on site , post), using wireshark, came (short version): content-type: multipart/form-data; content-disposition: form-data; name="name" data (8 bytes) john doe when try use python-requests library achieving same result, sent: content-type: application/x-pandoplugin content-disposition: form-data; name="name"; filename="name"\r\n media type: application/x-pandoplugin (12 bytes) //and in piece posted:// john doe the weird thing 'general type' of packet indeed multipart/form-data, individual item sent (key = 'name', value= 'john doe') has type application/x-pandoplugin (a random application on pc guess). this code used: response = s.post('http://url.com', files={'name': 'john doe'}) is there way specify content-type of in...

php - Do I need mysqli->real_escape_string after filter url? -

i'm asking question because i'm still not quite sure if filter $_get variable enough prevent mysql injection, @ first have filter function function filter_url($url) { if (is_array($url)) { foreach ($url $key => $value) { // recurssion $url[$key] = filter_url($value); } return $url; } else { // remove except a-za-z0-9_.-&= $url = preg_replace('/[^a-za-z0-9_\.\-&=]/', '', $url); return $url; } } i have $_get=filter_url($_get); everytime before call $filter_case =isset($_get['product_id'])?"and product_id={$_get['product_id']}":""; do need $mysqli->real_escape_string($_get['product_id']) ? if still have imply it, kind of sql injection overpass query method? besides, important $mysqli->real_escape_string($_session['member_id']) i'm thinking of possible manipulate $_session variable? this wrong question ask. you ne...

jquery - Isotope shiftColumnOfItem combined with hashHistory - how to? -

i'm using isotope filter set of items , jquery bbq handle hashhistory stuff. it's working fine, except following: items collapsed - when clicked, expand , display more text. when 1 of items expanded, filtering info gets lost (which obvious, i'm not sending them on click yet) , see items again on screen. on click expanding item, i'm using just $container.isotope('shiftcolumnofitem', this.parentnode); i have been searching still couldn't find way of combining method (or relayout) current filtering/hash parameters. tips welcome! thank you. after more time tweaking code, it's working. it more general javascript issue regarding jquery bbq / isotope. i changed markup expanding/collapsing item <a href="#" data-toggle="collapse" data-target="#item10-collapse"> to <a href="javascript: void();" data-toggle="collapse" data-target="#item10-collapse"> this way, ...

javascript - Element move by Jquery scroll -

i have problem element position moving scroll event. problem: i'm scrolling page , append 1px css top value (every scroll). after i'm scrolling page down, , remove 1px css top value. think it's return original position, not. here code: var lastscroll = $(window).scrolltop(); $(window).scroll(function(env) { var scroll = $(this).scrolltop(); if (scroll > lastscroll){ console.log('scroll down'); $('#home>article').css({ top: "+="+1+"px" }); } else { console.log('scroll up'); $('#home>article').css({ top: "-="+1+"px" }); lastscroll = scroll; }); thanks idea! hope might help, used while ago. have been using: <script type="text/javascript">// <![cdata[ $(window).scroll(function () { var ttop = $('.container').position().top; var hcltb = $(...

java - JNA pointer to unsigned char* -

i have array of bytes , want pass c function using jna. found examples allocated pointer using new memory , used write function copy array data me not acceptable because have big block of data. is there possibility pass java array directly c library ? i want : mylib lib = native.loadlibrary("test"); pointer p = mybytearray; //i want make possible lib.somefunction(p); passing primitive array or pointer memory equivalent operations, i.e. can map this: public interface mylibrary extends library { void somefunction(byte[] input); void somefunction(pointer input); }

ruby on rails - ActiveRecord Relation size strange behavior -

i have encountered strange behavior of activerecord relation recently. suppose, have stat model following properies: clicks views created_at and others further suppose have following scope: scope :aggregated, select('sum(clicks) clicks, sum(views) views).group('date(created_at)') as result expect array of stat object info aggregated day, , is. consider this: # in 1 place = stat.aggregated #in other place if a.size > 0 'do stuff' else 'do other stuff' end and it works fine if a relation is loaded , when a not loaded fails method undefined error. turns out when relation not loaded size calls count on relation, changes query, returns hash, , brakes code. is implied behavior? for me kind of counter-intuitive change method semantics depending on whether relation loaded or not. that's how activerecord relation works. can convert array , size on it. a = stat.aggregated.to_a #in other place if a.size > ...

java - ImageIcon exception -

im new java, , while running on eclipse linux mint java-7-openjdk (i think , although dont know if eclipse has own sun jdt), public class gui extends jframe{ private jcombobox box; private jlabel picture; private static string[] filename = {"b.png","x.png"}; private icon[] pics = {new imageicon(getclass().getresource(filename[0])), new imageicon(getclass().getresource(filename[1]))}; exception in thread "main" java.lang.nullpointerexception @ javax.swing.imageicon.<init>(imageicon.java:205) @ bucky.gui.<init>(gui.java:10) @ bucky.apples.main(apples.java:12) i cant see problem (linux mint 15 cinnamon) this exception thrown in imageicon constructor , states getclass().getresource(filename[0]) or getclass().getresource(filename[1]) null the path specified isn't correct. make sure folder these images in classpath an easy check can made: file f = new file("b.png"); system.out.println(f.exists()); sh...

c# - Get Repeater Label in the current "row" being accessed -

i have following repeater: <asp:repeater id="rptleaverequests" runat="server" onitemdatabound="rptleaverequests_itemdatabound"> <itemtemplate> <table id="tableitem" runat="server"> <tr> <td style="width: 100px;"> <asp:label id="lbldate" runat="server" text='<%#eval("date", "{0:dd/m/yyyy}") %>'></asp:label> </td> <td style="width: 100px;"> <asp:label id="lblhours" runat="server" text='<%#eval("hours") %>'></asp:label> </td> <td style="width: 200px;"> <asp:label id="lblperiod" runat="server" text='<%#eval("amorpm") %>'></asp:label> </td> ...

php - Globally disable all MySQL writes -

i using php's pdo mysql create web application. wish put web application in "demo" mode. means writes (updates, inserts, deletes) disabled, , applicable continues out errors. arguments sake, application in demo mode if $_session['demo_mode']=1. without putting conditionals around each write statement, how can done. $dbh->exec("insert t1(c1, c2) values ('v1', 'v2')"); $dbh->lastinsertid(); $q=$dbh->query("select c1 t2 c2=123"); $v=$q->fetchcolumn(); you can modify rights of user application connects as, gets select and similar rights. here comprehensive list of individual rights can grant user. example (to adapted need, of course): revoke privileges on yourdatabase.* 'application_user'@'host'; grant select on yourdatabase.* 'application_user'@'host'; obviously, produce errors when application tries write anything. app should prepared fail graciously if planni...

SQL Server filtered index - can anyone explain this error I am seeing? -

okay, have table filtered index. here script create table, add data , add index: create table supplier ( supplierid int not null, supplierlinkid int null, suppliername varchar(50)); insert supplier values (1, 2, 'test supplier 1'); insert supplier values (2, null, 'test supplier 2'); insert supplier values (3, null, 'test supplier 3'); create unique nonclustered index uq$supplier$supplierlinkid on supplier (supplierlinkid) supplierlinkid not null; then decide want add new column, supplier code, table , maintainability reasons don't want @ end of table. can't use: alter table supplier add suppliercode varchar(50); instead go table designer, highligh supplierlinkid column , right-click, insert column , enter details: column name = suppliercode; data type = varchar(50); allow nulls = when click save error: 'supplier' table - unable create index 'uq$supplier$supplierlinkid'. create unique index stateme...

iphone - Identifying an UIImageView without tag -

i have generic generated imageviews in scrollview each of these images have 2 gesturerecognizer single/double tapping on imageview. problem how identify whether imageview tapped first or second time. in scenarios it's easy use tag of imageview, have 2 different gesturerecognizer on each imageview , every gesturerecognizer uses different identification method based on tag number, identify image. here generate imageviews dynamically: -(void) initlevels{ _level = [level alloc]; _unit = [unit alloc]; self->_units = [[nsmutablearray alloc] init]; _keys = [[nsmutablearray alloc] init] ; int x = 0; int y = 0; int = 0; (nsobject *object in self->_levels) { if ([object iskindofclass:_level.class] && != 0) { x = x + margin_right + object_width; y = 0; } else if ([object iskindofclass:_unit.class]){ _unit = (unit *) object; [self->_units addobject:_unit.description]; uiimageview *imageview = [[uiimageview alloc]...

Git push new local branch to remote, without having to specify name -

when working on patch fixes specific, tracked issue, our workflow looks like: 1. git checkout patch; git pull upstream patch; # make sure we're up-to-date 2. git checkout -b issue-435-db-integrity-exception 3. # code awesome 4. git commit -am "fixes issue #435" 5. git push -u origin issue-435-db-integrity-exception then open pull request origin/435 upstream/patch , code review can take place on github/bitbucket. start on step #1. but , though may sound bit whiny, great if didn't have explicitly name remote branch want create: git push -u origin issue-435-db-integrity-exception it's not lot of fun type branch name on again, , disagree changing 435 or more compact. is there way (1) force git push current branch named branch, creating if necessary without explicitly naming it? not globally , on-the-spot kind of flag. or, possible (2) access current branch in git alias, , write like: [alias] pnew = push -u origin $(git symbolic-ref --short ...

java - Regular expression for lines starts with capital letter word -

i have below lines of text in text file, james working in london program developed in java program working i want lines have starting word capital letter james working in london program working thanks for english language, can use this ^[a-z].* the ^ start of line. , [a-z] means capital letter.

Dotcover report (nunit) not covering all classes in assembly. -

dotcover report (nunit) not covering classes in assembly. when see report generated dotcover using nunit-console.exe (2.4.1), find couple of classes assembly not all. i don’t use nunit dotcover, there common things. did check dotcover config file? probably, there filters there. more info here: http://www.jetbrains.com/dotcover/webhelp/dotcover__introducing_console_runner.html

ssh keys - ssh still asking for password -

i have 2 servers called: "eps" , "dev". on server dev have added public key of eps authorized_keys file. have restarted ssh service on dev server ensure picks new public key added authorized_keys file. however when try , ssh "dev" "eps", i'm prompted passphrase key. exact prompt is: enter passphrase key '/home/webmaster/.ssh/id_rsa': why happening? thought should log me dev server right away. when creating ssh key using ssh-keygen prompted password secure private key. therefore ssh use key password has entered unlock private key locally, why seeing "enter passphrase key". not same password authenticate user on ssh server. in order have password-less login need create keyfile ssh-keygen has empty password.

How to get Windows 8 Surface (Tablet) Unique ID -

how windows surface unique device id?. i tried below api device id changing based on bluetooth settings: hardwareidentification.getpackagespecifictoken(nonce) as answered here, windows.system.profile.hardwareidentification.getpackagespecifictoken(null).id converted string work id. not sure if best practice, works nonetheless.