Posts

Showing posts from September, 2013

linux - Bash check if all files in a folder are writable by www-data -

i have logs folder , log files owned root , need them owned www-data . i'm writing script check if owned www-data = writable user. #!/bin/bash rootfiles=$(ls -la /tmp/logs/ | grep root | sed -e 's/\s*$//') if [[ ! -z "$rootfiles" ]]; exit 1 fi exit 0 this works fine, if assume there'll no file contains word root in it's name, , that's not root www-data . how make more robust? you can use find find out: find /tmp/logs -not -user www-data but, to change owner of files, can use recursive chown : chown -r /tmp/logs/* www-data

Java program to find the IP addresses of the following websites: Facebook , google , yahoo in the same try and catch -

here code 1 website need make multiple ip's in same try , catch package javaapplication1; import java.net.inetaddress; import java.net.unknownhostexception; public class javaapplication1 { public static void main(string[] args) { try { inetaddress[] addresses = inetaddress.getallbyname("google.com"); (inetaddress address : addresses) { system.out.println(address); } } catch (unknownhostexception ex) { system.out.println("could not find"); } } } make list of facebook,google , yahoo iterate on list , use inetaddress.getallbyname(list.get(index)) arraylist<string> list = new arraylist<>(); list.add("facebook");// can add more urls (string ip : list) { try { inetaddress[] addresses = inetaddress.getallbyname(ip); (inetaddress address : addresses) {

python - Diffie-Hellman Parameters and safety -

i want create own safe connection voip app. now looking key exchange seems more tricky encrypting/decrypting. are there better approaches diffie-hellman in practice ? i understand concept of diffie-hellman think needs right values safe since natural numbers guessed. how can values using python, , safe key guessing? please me background informations / inspiring. diffie-hellman key exchange, called exponential key exchange, method of digital encryption uses numbers raised specific powers produce decryption keys on basis of components never directly transmitted, making task of would-be code breaker mathematically overwhelming. the serious limitation of diffie-hellman in basic or "pure" form lack of authentication. communications using diffie-hellman vulnerable man in middle attacks. ideally, diffie-hellman should used in conjunction recognized authentication method such digital signatures verify identities of users on public communications medium. more l

ruby on rails - No routes matches, empty action -

i've got rails application inherited previous coder. generates sortable tables , has helper function sortable sortable ends this link_to title, link, { :class => css_class, :"data-direction" => direction, :"data-sort" => column, :"data-page" => params[:page].to_i.zero? ? 1 : params[:page].to_i, :"data-title" => params[:title], :"data-search-id" => params[:search_id], :title => "sort `#{title}` #{direction}"} link conatins fields :sort , :direction when try create sortable table written controller i'm getting error (no route matches {:sort=>:company_name, :direction=>:asc, :controller=>"company"}) don't understand how code working on other controllers , fields controller , action

at - job added via PHP to queue not working -

i have small script in php set at jobs exec() . php can execute exec() , @ jobs added queue, because see them on @ queue list. echo "/usr/local/ffmpeg1.1/bin/ffmpeg -i '/data/html/admin.domain.com/httpdocs/raw/gym/gym_part_1.avi' -c:v libx264 -vsync 2 -strict -2 /data/html/domain.com/httpdocs/videos/galleries/gym_part_1.mp4" | @ +2 minutes this doesn't work. gets queued doesn't work. if i run on bash works perfectly user i'm logged in or apache user - adding sudo -u apache before at . echo "/usr/local/ffmpeg1.1/bin/ffmpeg -i '/data/html/admin.domain.com/httpdocs/raw/gym/gym_part_1.avi' -c:v libx264 -vsync 2 -strict -2 /data/html/domain.com/httpdocs/videos/galleries/gym_part_1.mp4" | sudo -u apache @ +2 minutes linux , @ version linux linux web1.com 2.6.18-400.1.1.el5 #1 smp thu dec 18 00:59:53 est 2014 x86_64 x86_64 x86_64 gnu/linux at at version 3.1.8

c++ - Can we introuduce aliases for template specializations? -

can introduce alias partial specialization? mean that: template <class t, class v> class a{ }; typedef template <class t> a<t, int> mypartialspecializa<t>; int main(){ } demo but doesn't work. standard that? you need alias template this template <class t, class v> class a{ }; template <class t> using mypartialspecializa = a<t, int>; int main() { mypartialspecializa<double> a; }

android - OkHttp + Retrofit offline cache not working -

i'm requesting json data 2 servers. okhttp doesn't cache responses first server, responses second server caching properly. response first server, cache not working reason: <--- http 200 cache-control: public, max-age=2230 content-type: application/json; charset=utf-8 expires: sat, 28 mar 2015 11:34:13 gmt last-modified: sat, 28 mar 2015 10:34:13 gmt vary: * server: microsoft-iis/7.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net access-control-allow-origin: * date: sat, 28 mar 2015 10:57:01 gmt content-length: 1381 okhttp-selected-protocol: http/1.1 okhttp-sent-millis: 1427540192625 okhttp-received-millis: 1427540192940 <--- end http (1381-byte body) response first server when device offline: ---> http cache-control: public, only-if-cached, max-stale=2419200 ---> end http (no body) <--- http 504 <--- end http (0-byte body) response second server, cache works: <--- http 200 content-type: application/json; charset=utf-8 date: sat, 28 mar 20

matlab - Solve non-linear system in IntegerMod(2) -

i want solve non-linear system in domain integermod(2) matlab (mupad). tried simple example: solve({ poly(a*b, [a, b], dom::integermod(2)) }) error: can solve linear systems on field. [solvelib::domsolve] any idea how solve this? one possible solution a=0, b=0 , right?

javascript - Why I can't directly set console.log() as callback function -

why code doesn't work function callback(num, func) { for(var = 0; < num; i++) { func(); } } callback(4, console.log("hello")); i know have this: callback(4, function() { console.log("hello"); }); but still don't understand reason why have that. lets step through visualise going on. when interpreter reads code, evaluates function expressions inside-out. say: callback(4, console.log("hello")); // ^------------------^---- evaluated before "callback" called. a longer-form way of writing produces same outcome be: var result = console.log("hello"); callback(4, result); the console.log function doesn't have defined return value (or @ least not standardised one) - though incidentally functions in javascript return something - when unspecified value literally undefined . when run code calling: callback(4, undefined); this means inside callback , trying call func

php - Get URL for a date_query results in Wordpress -

i have line of code: $args = array( 'date_query' => array( array( 'after' => 'january 1st, 2015', 'before' => 'february 15th, 2015', 'inclusive' => true, ), ), ); $query = new wp_query( $args ); this code return post published between jan 1st , feb 15th. question can somehow create link results of query? for example can go localhost/wordpress?monthnum=1 and posts january, there link, or can create custom link accept parameters of date_query, can display posts match query? basically want show posts published between specific dates on separate page, , want link page, don't know if such thing possible. what try query string ?! example : localhost/wordpress?monthnum=1 will pass $_get variable current page , can value : $month=$_get['monthnum']; then can parse value specific month example: $stringdate='t

html - Bootstrap gallery: photos with different heights won't line up -

so i'm attempting make photo gallery using bootstrap, , stuck time being. first, here github link can view site. http://torgian.github.io/website-dev go gallery , change browser width. can see how images different heights, don't seem line properly. i've spent 7 hours searching , trying different things, no avail. i'm asking on here. currently i'm still learning html , css, haven't touched javascript yet. find css solution this, if possible. what achieve similar this: http://www.nasarow-fo-to.com/new-gallery click on squares on lower right , you'll see gallery pop up: can see trying achieve. nice, row of thumbnails, 3 or 4 across on desktop. i recommend setting height of of images same value, , keeping width style set auto . after this, set page overflow style break-line , , should aligning properly. an example of how follows: body{ overflow: break-line //break line on content overflow } img{ width: auto; //s

Subtract Two Numbers In HTML/JavaScript -

i trying subtract 2 numbers html input form , populate result input field using javascript. unfortunately new javascript please kind point me in right direction. here's html code. <div class="form-group col-lg-6"> <label for="exampleinputtext">total price</label> <input type="text" name="totalval" class="form-control" id="totalval"> </div> <div class="form-group col-lg-6"> <label for="exampleinputtext">initial deposit</label> <input type="text" name="inideposit" class="form-control" id="inideposit"> </div> <div class="form-group col-lg-6"> <label for="exampleinputtext">outstanding dues</label> <input type="text" name="remainingval" class="form-control" id="remainingval" > </div>

spacing - Batch to duplicate text lines including spaces -

i'm using windows 7. need batch file copy lines of 1 text file individual files. batch file i've written far works perfectly: @echo off setlocal enabledelayedexpansion set counter=1 /f %%x in (originallist.txt) ( set "line_!counter!=%%x" set /a counter+=1 ) set /a numlines=counter - 1 echo %line_1% >a1.txt echo %line_2% >a2.txt echo %line_3% >a3.txt echo %line_4% >a4.txt echo %line_5% >a5.txt the problem have lines of text contain space ie c:\users\my account\documents\line saving saves as c:\users\my how store entire line?? your problem: space 1 of standard delimiters of for . if don't define token, defaults one. string first space or comma or semicolon, ... solution: set delimters none (no delimiter): for /f "delims=" %%x in (originallist.txt) (

Replacing symbols or line break in windows batch -

i found batch script changes string string. below batch script changes every 'bath' 'hello' in test.txt @echo off setlocal enabledelayedexpansion set intextfile=test.txt set outtextfile=test_out.txt set searchtext=bath set replacetext=hello set outputline= /f "tokens=1,* delims=¶" %%a in ( '"type %intextfile%"') ( set string=%%a set modified=!string:%searchtext%=%replacetext%! echo !modified! >> %outtextfile% ) del %intextfile% rename %outtextfile% %intextfile% (copied how replace substrings in windows batch file ) but want changing every '△▽' 'newline , xy' in test.txt example, if test.txt is abc△▽def then result should be abc xydef before attacking problem, tried easier-looking problem : changing every '△▽' 'xy'. easier-looking problem looks difficult me. changed bath △▽, , hello xy in above script. script didn't work. reason guess - since △,▽ symbols. could teach me how

symfony - Symfony2 with entity type in form -

here situation, have form in need entity field type. inside benefitgroup entity have benefitgroupcategory selection. my buildform is: public function buildform(formbuilderinterface $builder, array $options) { $builder->add('benefitgroupcategories', 'entity', array( 'class' => 'appbundle:benefitgroupcategory', 'property' => 'name', 'label' => false, 'query_builder' => function(entityrepository $er) { return $er->createquerybuilder('c') ->orderby('c.name', 'asc'); },)) ->add('benefitsubitems', 'collection', array('type' => new benefitsubitemformtype(), 'allow_add' => true, 'label' => false,)); } it's typical product-category relationship. benefitgroup can have 1 category , categ

utf 8 - Parsing data from file with PHP -

i've strange issue parsing data file file_get_contents. file contents: 0,0,0 (there 3 random numbers in range 0 255 separated comma) $s = file_get_contents($this->filepath); var_dump(trim($s)); $rgb = explode(',', trim($s)); var_dump($rgb); output: string(8) "0,0,0" array(3) { [0]=> string(4) "0" [1]=> string(1) "0" [2]=> string(1) "0" } and if try converting integer: string(14) "255,128,255" array(3) { [0]=> string(6) "255" [1]=> string(3) "128" [2]=> string(3) "255" } echo((int)$rgb[0]); // -> 0 echo((int)$rgb[1]); // -> 128 echo((int)$rgb[2]); // -> 255 the file in encoding utf-8 , think there whitespace char in parsed string, don't know should it, cause simple trim not work. thanks ideas! your file begins byte order mark (bom). length of both strings giveaway, both 3 bytes long. ideally, should atte

php - How to set 2 different color for different texy in FPDF -

Image
how set 2 different colors in fpdf?? i have tried code below $pdf=new fpdf(); $pdf->addpage('p', 'a5'); $pdf-> setmargins(25, 50); $pdf->settextcolor(91,137,42); $pdf->setfont('times','',10); $pdf -> text (60, 37, 'title' ); $pdf->settextcolor(0,0,0); $pdf->setfont('times','',15); $pdf -> text (60, 37, 'invoice' ); but tests displaying single color. any solution this? i made minimal working example code: <?php require('fpdf/fpdf.php'); $pdf=new fpdf(); $pdf->addpage('p', 'a5'); $pdf->setmargins(25, 50); $pdf->settextcolor(91,137,42); $pdf->setfont('times','',10); $pdf->text (60, 27, 'title' ); $pdf->settextcolor(99,0,0); $pdf->setfont('times','',15); $pdf->text (60, 57, 'invoice' ); $pdf->output('test.pdf'); when holding

python - how to get index of a dictionary within a list -

test = [{"first" : "xyz", 'score': [1,2,3,4]},{"first" : "tests", 'score': [22,33,4]}] i trying find xyz in test , list scores of xyz . the index of dictionary not unique dictionaries hashed. need use keys access values in dictionary. small work-around can be: >>> test = [{"first" : "xyz", 'score': [1,2,3,4]},{"first" : "tests", 'score': [22,33,4]}] >>> in test: # iterate through loop ... if i["first"] == 'xyz': # check if dict's value @ "first" ... print("the score {}".format(i["score"])) ... # print score ... [1, 2, 3, 4]

confusion between clang and llvm -

i think know difference between clang , llvm @ same time confused. understand clang front-end take program , hexing-parsing-ast creation , creating ir(llvm ir). and llvm, backend, takes ir, optimizes , creates assembly target architecture. correct ? read llvm not have linker. how handled on os x ? how @ assembly generated llvm ?x and llvm, backend, takes ir, optimizes , creates assembly target architecture. correct ? what you've described there sounds pretty correct, except several target architectures, llvm generates binaries directly, without having go through intermediate assembly-printing stage. i read llvm not have linker. how handled on os x ? you use system linker, ld . also how @ assembly generated llvm ? either disassemble output binary (with otool , example) or use clang -s generate assembly rather binary output.

php - Accessing Laravel Rest API with curl - JSON -

i'm trying client work api i'm having trouble, i'm new curl maybe can me. my api controller (laravel.project/api/v1/users/{id} public function show($user) { if ($user == null) return $this->setstatuscode(404)->respondnotfound('user not found'); return $this->respond($user); } this answer making simple request postman { "data": { "id": 4, "name": "helena", "email": "hh@gmail.com", "created_at": "2015-03-26 21:13:16", "updated_at": "2015-03-26 21:13:16" } } response headers: cache-control → no-cache connection → keep-alive content-type → application/json date → sat, 28 mar 2015 15:44:45 gmt server → nginx/1.6.2 transfer-encoding → chunked everything fine till now, then, when use curl in client way: public function delete($url

How can I make this Java leap year program loop? -

i have make program tells if year leap year or not, class. have basic function of program done, want able ask user if want whole thing again (if enter yes, repeat program. if enter no, program terminate). preferably use while loops can't quite figure out how it. appreciated. system.out.println("this program let enter year , tell you" + " if lear year"); int lyear; scanner scan = new scanner(system.in); system.out.println("enter valid gregorian year(greater 1581): "); lyear = scan.nextint(); boolean leapyear = ((lyear % 4 == 0) && (lyear % 100 != 0) || (lyear % 400 == 0)); if (lyear < 1582) { system.out.println("that not gregorian year"); } else if (leapyear) { system.out.println("that leap year"); } else { system.out.println("that not leap year"); } } you may try proceed following code snippet - while(scan.hasnext()){

python - how to configure the base report to printer in openerp? -

i have installed in base_report_to_printer module print direct printers , installed dependences pycups things'. have configure printing action , default printer in user profile. want print direct printer when hit print button? i have followed below procedure: after installing enable "printing / print operator" option under access rights give users ability view print menu. to show available printers server, use settings/configuration/printing/update printers cups wizard. then go user profile , set users printing action , default printer. i want print direct printers. you need install pycups library server. step install pycups sudo apt-get install libcups2-dev sudo pip install pycups then need configure cloud printers google accounts. in google cloud printers see ipp of printers. you need add new printer server using ipp . when user request print printer server identifies request , forward request appropriate location. to show available pri

angularjs - AppGyver rootview can't open URL -

according tutorial : all location properties can either supersonic routes or urls. when use in structure.coffee, nothing loaded, initial splash screen shown: rootview: location: "http://example.com/page1" what else should set? it looks current issue on github . from post: a workaround run local clone of steroids , change https://github.com/appgyver/steroids/blob/master/src/steroids/features.coffee#l6 false, after can write splashscreen: autohide: true in config/app.coffee .

ui style for selected item in angularjs material -

on ui, have several buttons. want highlight user have tapped few seconds. there directive or style can use? or have write own? yes, asking available in angular-material. make sure making buttons below: <md-button class="md-raised md-primary">zero</md-button> here md-button directive , class specify change , feel... md-primary , md-fab ... angular materials documentation here md-select there in angular-material. can group buttons if want, place them in md-list , behave want. and, yes, md-menu & md-dropdown coming in next few releases.

javascript - Writing a simple sniffer in web -

we have simple client-server sniffer (wireshark ui). server listening messages, parsing them , send parsed messages client. want move web platform (web ui instead client) proper way this? i thought sending ajax requests server every x seconds, , update html, new packets. don't know if idea, when have big amount of messages. , how many time packet filtering take, implemented in jquery (scanning whole html , hide not relevant rows) i see many problems such solution. maybe there better way implement this? maybe there way asynchronous messages?

javascript - Keyout and keyup -

i've found need js function suits needs , wants. however, there 1 minor downside it. the function waits x milliseconds (ikeydelay) before executes function, bind key event (keyup or keydown). works. however, when user exits input input loses focus, function executed again. execution should prevented occur, because unnecessary. my js skills not good, maybe 1 of can me? $.fn.delayedkey = function(fn, ikeydelay, skeyevent) { var itimeoutid, oeventdata; if (!$.isfunction(fn)) { oeventdata = arguments[0]; fn = arguments[1]; ikeydelay = arguments[2]; skeyevent = arguments[3]; } if (!ikeydelay || 0 > ikeydelay) { ikeydelay = 500; } if (!skeyevent || !this[skeyevent]) { skeyevent = 'keydown'; } function fnexeccallback() { cleartimeout(itimeoutid); fn.apply(this, arguments); } function fndelaycallback() { var = this, args = arguments; cleartimeout(itimeoutid);

I need your help about read_fwf in python pandas -

Image
the example of text file picture according file, direction of data changed after word 'chapter' in other word, direction of reading changed horizontal vertical. in order solve big problem, find read_fwf in pandas module , apply failed. linefwf = pandas.read_fwf('file.txt', widths=[33,33,33], header=none, nwors = 3) the gap between categories(chapter, title, assignment) 33. but command(linefwf) prints of pages line includes horizontal categories such title, date, reservation blank lines. please, want know 'how export vertical data only' let me take stab in dark: wish turn table column (aka "vertical category"), ignoring other columns? i didn't have precise text, guesstimated it. column widths different yours ( [11,21,31] ) , omitted nwors argument (you meant use nrows , it's superfluous in case). while column spec isn't precise, few seconds of fiddling left me workable dataframe : this pretty typical of read-i

preprocessor - R preprocessing (adding ;) -

i need @ end of each line in csv file, , add ; if there not one. the thing is, when read file line line ( data <- read.table(path, sep="\n") ) , save it, output goes from: "a";"b";"c" to: "a;b;c" thank time , help.

html - jquery slideUp and slidedown callback repeating -

im creating jquery accordion , triggering effect onclick, im having problem because there excess action of slideup , slidedown in last level of ul, error occurred when following actions - click "button" -choose , click or any(a,b or c) -then select , click a.1 or any.. -then click again parent a -then click open again -click of childs as notice, click once slideup , slidedown trigger. here jquery $(document).ready(function() { $("#ins-type").appendto("li.prd"); $("li.prd>a").click(function(event){ event.preventdefault(); $("#ins-type").slidetoggle(); }); $("#ins-type>li>a").stop().click(function(event){ event.preventdefault(); if($(this).parent().hasclass("act")){ $(this).parent().find('ul').find(".act").find('.the-ins-desc').slideup().parent().removeclass("act"); $(this).parent().find("ul.the-ins").slideup();

How to get int from float in picat? -

i try to read line string console (stdin) in picat , half: main => l = read_line(), b = l.length/2, s = l.slice(1,b), println(s). crashes error(integer_expected(2.0),slice) when int used instead of b - no crash. how turn b integer? try either using integer(..) function convert l.length/2 integer or use to_integer() function....should you.

user interface - Java Increase Rectangle Thickness -

how increase thickness of rectangle when using g.drawrect ? want blue rectangle have thick line. this code - if(selectedapartment == 0) { g.setcolor(color.red); g.fillrect (150, 120,aptwidth, aptheight); **g.setcolor(color.blue); g.drawrect(150, 120, aptwidth, aptheight);** g.setcolor(color.black); g.setfont(new font("boldfont",font.bold,14)); g.drawstring("1", 150+15, 120+25); } else if (selectedapartment != 0) { g.setcolor(color.red); g.fillrect (150, 120,aptwidth, aptheight); g.setcolor(color.black); g.drawrect(150, 120, aptwidth, aptheight); g.setcolor(color.black); g.setfont(new font("boldfont",font.bold,14)); g.drawstring("1", 150+15, 120+25); } you should use setstroke set stroke of graphics2d object. here's example of code segment in program: import java.awt.*; import java.awt.geom.line2d; import javax.swing.*; public

python opencv videowrite doesn't write video -

i started programming python opencv. used following page opencv 3.0.0 tutorial tutorial @ read docs when tried use example saves videos, doesn't work. displays content webcam, , creates file called output.avi, when checked size of ouput.avi, 0 bytes. tried using different codecs, yuy2 i use python 2.7.8 , opencv 3.0.0 , windows 8.1 replacing: fourcc = cv2.videowriter_fourcc(*'xvid') with: fourcc = cv2.videowriter_fourcc('m','j','p','g') worked me... more generally: look fourcc code of video compression format you're after here , , whatever code - instance 'fmp4' ffmpeg - plug in in following manner: cv2.videowriter_fourcc('f','m','p','4')

php - Slim Framework - 404 Page Not -

i came across slim framework , have been playing it. i'm running 404 issue. code below: know has url i'm not quite sure how fix problem. have define url "profiles" somewhere? also directories this: include dbhandler.php config.php dbconnect.php lib slim v1 .htaccess index.php problem in code: mysite.com//parentfolder/v1/profiles throws 404 error $app->post('/profiles', 'authenticate', function() use ($app) { // check required params verifyrequiredparams(array('gender')); $response = array(); $gender = $app->request->post('gender'); global $user_id; $db = new dbhandler(); // creating new task $profile_id = $db->createuserprofile($user_id, $gender); if ($profile_id != null) { $response["error"] = false; $response["message"] = "pro

javascript - Use password input with MaskedInput.js -

so have searched around , far have not found answer this. maskedinput.js plugin digitalbush used lot of places lot of masked input plugins. of them seem focus on masking input format , not allowing formatted mask use secure password field. obviously, not true security fix standard business requirement. trying accomplish use html5 password input maskedinput.js plugin. works except dashes represented bullets mask becomes useless. if has solution not hack please let me know. have setup fiddle testing has jqueryvalidate on input these 2 plugins typically found peas , carrots throughout web. the sample fiddle here sample: <input type="password" class="form-text" name="ssn" id="ssn" required="true" minlength="9" maxlength="9" aria-describedby="ssn-errors" placeholder="social security number" > javascript additional logic force validation on blur: $("#ssn", "body&q

python - django limit the number of requests per minute -

i'm trying limit number of requests ip in case many requests it. for example: if more 50 requests per minute want block ip 5 minutes. when use request.meta['remote_addr'] ip of local host , not 1 sent request. how can ip of computer sent request? how can limit ip not send more requests x time? django-ratelimite limit number of requests receive on given amount of time. install: pip install django-ratelimit in view: from ratelimit.decorators import ratelimit @ratelimit(key='ip', rate='10/m') def myview(request): ...

objective c - UIView AnimateKeyFrames All At Once -

why of nslogs being run @ once? my understanding each 1 should separated 1 second. incorrect? [uiview animatekeyframeswithduration:5.0 delay:0.0 options:0 animations:^{ [uiview addkeyframewithrelativestarttime:0.0 relativeduration:1 animations:^{ nslog(@"1"); }]; [uiview addkeyframewithrelativestarttime:1 relativeduration:1 animations:^{ nslog(@"2"); }]; [uiview addkeyframewithrelativestarttime:2 relativeduration:1 animations:^{ nslog(@"3"); }]; [uiview addkeyframewithrelativestarttime:3 relativeduration:1 animations:^{ nslog(@"4"); }]; [uiview addkeyframewithrelativestarttime:4 relativeduration:1 animations:^{ nslog(@"5"); }]; [uiview addkeyframewithrelativestarttime:5 relativeduration:1 animations:^{ nslog(@"6"); }]; } completion:nil]; here log:

Create XML Schema for Java with inheritance and Java Interfaces use -

Image
i have collection of classes manipulating domain vehicles here's question : need save (through parse) data xml files. have create xml schema (xsd), finding difficulties regard inheritance , interfaces. first, seems necessary explain quickly classes: the vehicle class abstract class , contains base attributes: public abstract class vehicle implements serializable { public enum stato { disponibile, non_disponibile } private string plate; // targa private string mark; // marca, casa produttrice private string model; // modello private string trim; // trim private float capacity; // capacità di carico // ... other... private stato stato; // stato del veicolo private string allestimento; public vehicle(){} public vehicle(string plate) { this.plate=plate; } // get&set methods // ... } and now, example, car : public class car extends vehicle implements drivingpart

haskell - Is there a package on hackage with common utils/idioms from other functional(ish) languages? -

f# has great util function (|>) b = b a can readability long chains of function applications. redefine easily, it's part of class of convenience functions (another tupleapply f (a, b) = f b don't belong anywhere file called "utils.hs". there package "sugar" i'm looking for, or best practice avoid using idioms that?

android - how render canvas on imageView to show circle moving faster (not jumping) -

i have balls class extends imageview , on have circle ball going left side right side , in time speed of moving increased < private void render() { while (true) { thread.sleep(30); if(x > getwidth()){ step++ && x = 0; } x += step } } private void update() { while (true) { thread.sleep(60); postinvalidate(); } } any thing when step equals 20 , more < ball not movie rightly , see jumping < i testing step = 5 , thread.sleep(value--) < did not work rightly how can move ball faster , render of ondraw rightly tnx < @};-

mysql - Count number of times, a number appears and update it to a different column -

i not sure how in mysql, have searched can't seem find solution. , have table so. id pid occurrence 1 23 blank 2 23 blank 3 44 blank basically, occurrence should have value of 2, id 1,2 , value of 1 id 3. appreciated. can call count , group by, , number of times each 1 occurance, update column occurrence in right place each pid. to correct occurrence value can do select pid, count(*) occurrence your_table group pid to update table do update your_table t1 join ( select pid, count(*) occurrence your_table group pid ) t2 on t1.pid = t2.pid set t1.occurrence = t2.occurrence

Sorting user defined structure in C++ -

i have data structure of following form: struct e{ unsigned k; unsigned c; unsigned v[100]; }; main() { vector<e*> vece; e e1; e1.k=10; e1.c=20; e1.v[0]=30; e1.v[1]=31; vece.push_back(&e1); e e2; e2.k=101; e2.c=28; e2.v[0]=82; e2.v[1]=32; vece.push_back(&e2); //sort vece e.k of structure } i have large vece containing thousands of objects of type e. need sort vece again , again. fastest way can sort vece in-memory -- here vece sorted on e.k. 1 of ways 1 can same building priority queue. priority rather expensive due insertions. there other fast way can sort vece on "k". also after sorting , outputting results user want delete vece entirely..but can not consists of pointers e. how can destroy vece completely, values pointed e deleted. the gcc version using is: gcc (ubuntu/linaro 4.6.4-6ubuntu2) 4.6.4 given e quite big structure, should have vector<e*> , swapping elements fast swapping single integer. can use either sort or

java - How I do fix with IlegalStateException? -

when run app , run option 10 (newboatlistactivity), app crashes. according log, caused java.lang.illegalstateexception. have feeling caused somewhere in if else statement. if know how fix this, please through code below: public void createlist(view view) { //declare references boatlist boat_list; boat newboat; boat newboat2; boat newboat3; textview tv; edittext et; edittext et2; string infilename; string urlfile; boolean file_problem = false; scanner fsc = null; //set references et = (edittext) findviewbyid(r.id.edit_infile); et2 = (edittext) findviewbyid(r.id.edit_urlfile); tv = (textview) findviewbyid(r.id.text_main); //get user input. allows user choose way file infilename = et.gettext().tostring(); urlfile = et2.gettext().tostring(); //create new boat object newboat = new boat(); newboat2 = new boat(); newboat3 = new boat(); //try access , open file in app's assets direct

Is there a way to handle heap memory fragmentation in AVR/Arduino microcontrollers? -

i've been searching few days without luck. heap memory fragmentation result of using malloc() , free() heavily in microcontrollers/arduino. if using them unavoidable, how can defragment heap every , make sure next malloc() call find contiguous memory allocate? create pool of fixed-size memory chunks. when need amount of memory, allocate 1 of chunks pool , use portion need. when you're done it, return chunk pool. pool never fragment because chunks same size. , if chunks available they're right size. you'll need couple bytes , second you'll think you're being wasteful tying entire chunck. you'll remember you're avoiding memory fragmentation , you'll feel better it. if size of allocations vary 1 fixed-size memory pool might wasteful. can make 2 or 3 fixed-size memory pools small, medium, , large chunks. make sure return chunks same pool obtained them from. use queue or linked list organize chunks in pool. chunks removed que

maven - Error building Hadoop 2.6 on Windows 8 -

i'm following tutorial build , install hadoop. http://www.srccodes.com/p/article/38/build-install-configure-run-apache-hadoop-2.2.0-microsoft-windows-os however, when give below command vs2010 command prompt: mvn package -pdist,native-win -dskiptests -dtar i below error: main: [mkdir] skipping c:\hdfs\hadoop-hdfs-project\hadoop-hdfs\target\native because exists. [exec] current os windows 8.1 [exec] executing 'cmake' arguments: [exec] 'c:\hdfs\hadoop-hdfs-project\hadoop-hdfs/src/' [exec] '-dgenerated_javah=c:\hdfs\hadoop-hdfs-project\hadoop-hdfs\target/native/javah' [exec] '-djvm_arch_data_model=64' [exec] '-drequire_libwebhdfs=false' [exec] '-drequire_fuse=false' [exec] '-g' [exec] 'visual studio 10 win64' [exec] [exec] ' characters around executable , arguments [exec] not part of command. execute:java13commandlauncher: executing 'cmake' arguments: 'c:\hdfs\hadoop-hdfs-project