Posts

Showing posts from September, 2011

php - Multiple while <option> update with query -

i'm trying achieve update query multiple <options> while loop. using feature assign position id's images can place them on various positions in website. have working single image, means have update each image manually. in current situation running form inside while loop. submit button posts data process file , saves. works. each image individually. i want able update image positions single submit button. in current code think problem run form inside while loop. using data multiple forms in single query not possible if right. i'm writing request noticing more of business logic error- trying wrap head around work. lets situation/code: it works this: option > button option > button each update button directs file 'photopositions.php' article id , executes insert query. i want situation: option option update button resulting in: update images single click. image the insertquery on photopositions.php looks this: $inse

plone - CopyError - OFS.CopySupport.manage_pasteObjects limited to ~ <160 objects? -

i'm using view archive old content moving folder. (catalog search enddate more n months ago, pass id's following command: target.manage_pasteobjects( source.manage_cutobjects(idstoarchive) ) one or 2 years ago moving 800 or more objects no problem. today need limit catalog search around 80 items. otherwhise module ofs.copysupport, line 193, in manage_pasteobjects copyerror: data in clipboard not read, possibly due cookie data being truncated web browser. try copying fewer objects. running plone 4.1.6 / zope2-2.13.15 tried deactivate beaker-session-datamanager (still same problems) any pointers appreciated you installed latest plone hotfix, 20130618 . includes ddos-prevention measure limiting size of __cp cookie data 8kb (decompressed). future zope versions include fix. to work around temporarily option increase maximum size default. doing will allow other threads use larger cookies until restore default: from ofs.copysupport import _cb_de

python - Having trouble installing pyyaml and nltk with 64bit winpython -

i've searched around awhile, , tried http://nltk.org/install.html#source-installation-for-32-bit-or-64-bit-windows , registry changes other sites (ex. http://www.comoke.com/index.php/2010/11/pyyaml-on-windows-7-64-bit-python-nltk-pyyaml-python-required-not-found-in-registry/ --although modified use winpython folder). (it seem indicate have nltk installed, winpython doesn't seem come nltk, , "import nltk" doesn't work) my output running command "pip install pyyaml nltk" below: c:\winpython-64bit-2.7.5.1\python-2.7.5.amd64\scripts>pip install pyyaml nltk downloading/unpacking pyyaml running setup.py egg_info package pyyaml skipping 'ext\_yaml.c' cython extension (up-to-date) requirement satisfied (use --upgrade upgrade): nltk in c:\winpython-6 4bit-2.7.5.1\python-2.7.5.amd64\lib\site-packages installing collected packages: pyyaml running setup.py install pyyaml checking if libyaml compilable traceback (most recent call l

bash - Automatic screenshots for shell tutorial -

Image
i'm working on small bash tutorial programming course. alternate between explanations commands , images below lorem ipsum dolor sit amet.. lorem ipsum dolor sit amet... i automatically generate these images given list of commands doing manually tedious. going screenshot cropped image easy part, i'm looking solutions "commands => screenshots" part. for example, these 2 images generated following "instructions" : clear ls saveas "img1.png" clear mkdir example ls saveas "img2.png" i've looked @ http://ascii.io/docs/about , thinking of using similar technique : python script reading "instructions" , feed them subprocessed shell , calling screenshot utility when needed. am trying reinvent wheel ? there tool used generate these kind of images ? or simplest way achieve goal ? imagemagick's import can used capture window images using -window . hide menu, toolbar, tabbar, , scrollbar in terminal

SQL Server 2005 using identifier from previous join statment -

i have table 2 columns, first pkey, second identifier; ban & iid respectively. i looking pull out top 2 iid's every distinct ban. used sub-query in max(iid) works fine. when try join table 1st statement next highest max(iid) get: "msg 4104, level 16, state 1, line 1 multi-part identifier "ii.iid" not bound." this referring statement in 2nd join "where iid < ii.iid" select distinct ii.ban, ii.iid, ii2.iid (select distinct ban, iid = max(iid) bill_timeliness..invoices with(nolock) group ban) ii join (select distinct ban, iid = max(iid) bill_timeliness..invoices with(nolock) iid < ii.iid group ban) ii2 on ii.ban = ii2.ban i have tried re-creating first part second subquery of statement. i tried iid < max(ii.iid) neither of these worked....i appreciate if can me out here. -ben this should work you: select o.ban, x.maxid topid, max(case when o.iid != x.maxid o.iid else null end) se

Use Array Data in CodeIgniter Model as SQL? -

in controller, passing data model using following code: $data = array( 'gid' => $this->input->post('gid'), 'name' => $this->input->post('name'), 'pic' => $this->input->post('pic'), 'link' => $this->input->post('link') ); var_dump($data); $this->login_model->insert_entry($data); in model, want use gid value part of sql statement, so: $get_gid = $this->db->query('select * users gid = $gid'); obviously doesn't work, i'm wondering how gid $data , use in sql statement? tested using $get_gid = $this->db->where('gid', $data['gid'])->get('users'); print_r($get_gid); however output is: ci_db_mysql_result object ( [conn_id] => resource id #30 [result_id] => resource id #33 [result_array] => array ( ) [result_object] => array ( ) [custom_result_object] => array ( ) [curre

html - Can websites using CSS be correctly shown in feature phones? -

i wondering if html tag: <link rel="stylesheet" href="template/style.css"> can stylesheet loaded correctly on feature phones? like quentin says, depends on what's in stylesheet. feature / dumb phones have varying css support, you'd need bit of research. started: http://www.developer.nokia.com/resources/library/web/#!nokia-browsers/symbian-browsers/css-3-support.html a list of css3 properties nokia's symbian browser can support. sure there's lot more stuff floating around. if didn't know, symbian's os used on phones such n95 (last non-smartphone owned) unfortunately stuff media queries you'd use modern responsive design pretty shaky on these platforms experience. hope helps!

jquery - Filter out select options based on radios data -

there a related question great response, approach , actual implementation requires different strategy. please view demo sample have done homework: http://jsfiddle.net/k8fnb/ i have 2 home works: make select options hidden , visible based on data-filter: todo make select option selected based on radio value: done when click radio, select value should same radio value (#2), , done, should filter visibility of select options based on radios' data-filter. data filter ["a","b","c"] on #filters should make options values a, b, c visible, , hide rest. issue how #1. html: <div id="filters"> <input type="radio" name="filter" value="a" data-filter="["a","b","c"]"/><label>a </label> <input type="radio" name="filter" value="b" data-filter="["a","b","c"]"/><la

remote access - Failed to remotely execute R script which loads library "rhdfs" -

i'm working on project using r-hadoop, , got problem. i'm using jsch in java ssh remote hadoop pseudo-cluster, , here part of java code create connection. /* create connection instance */ connection conn = new connection(hostname); /* connect */ conn.connect(); /* authenticate */ boolean isauthenticated = conn.authenticatewithpassword(username, password); if (isauthenticated == false) throw new ioexception("authentication failed."); /* create session */ session sess = conn.opensession(); //sess.execcommand("uname -a && date && uptime && who"); sess.execcommand("rscript -e 'args1 <- \"dell\"; args2 <- 1; source(\"/usr/local/r/mytest.r\")'"); //sess.execcommand("ls"); sess.waitforcondition(channelcondition.timeout, 50); i tried several simple r scripts, , codes worked fine. when comes r-hadoop, r script stop running. if run rscript -e 'args1 <- "dell"; args

ios - I get the error Property '...' not found on object of type '...' -

appdelegate.h #import <uikit/uikit.h> @interface appdelegate : uiresponder <uiapplicationdelegate> @property (strong, nonatomic) uiwindow *window; @end appdelegate.m #import "appdelegate.h" #import "firstviewcontroller.h" #import "secondviewcontroller.h" @implementation appdelegate - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions: goes on normal app.......... @end firstviewcontroller.h #import <uikit/uikit.h> @interface firstviewcontroller : uiviewcontroller @property (strong, nonatomic) iboutlet uiimageview *bground; - (ibaction)settingspressed:(id)sender; - (ibaction)startpressed:(id)sender; @end @class secondviewcontroller; @interface secondviewcontroller : uiviewcontroller @property(strong,nonatomic)secondviewcontroller *secondviewcontroller; @end firstviewcontroller.m #import "firstviewcontroller.h" @interface firstviewcontroller () @end @implement

php - Return value from ajax form -

i have login form in php. have used ajaxform page not reloaded when username or password wrong. have page checklogin.php checks whether username , pw there in database , returns count of number of rows. want compare count in login.php , display error message if count=1 , redirect page if count=2. tried display count in errordiv using target: 'errordiv' , checking innerhtml failed so. my login.php <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script type="text/javascript" src="scripts/jquery.form.js"></script> <!--slider-in icons--> <script type="text/javascript"> function checklogin() { var request=$("#login-form").ajaxform( { target:'#errordiv' }).abort(); request.submit(); var divmsg=document.getelementb

git - What's the difference between 'closing' and 'deleting' a branch? -

what's difference between 'closing' , 'deleting' branch? i see these 2 terms bandied i'm not sure mean precisely in context of git. both referring same thing ( git branch -d ) or there subtle difference of should aware? i may wrong far understanding that, unless tag branch prior deletion, once branch deleted there's no evidence left behind ever existed. correct? there no explicit command in git referred close possible convention, programmers refer branch "closed" when merged project , no longer being maintained. branch kept around, other times deleted, idea is not being used anymore. to answer second question, there few ways can keep track of branch after delete it. common way via remote host. running git -d branch_name destroy local copy. remote host still have version in case need later. can stash branch delete , come later. how stash git stash save "i'm saving branch before delete because yolo" here link on

module - Search an id in python with BeautifulSoup -

i need problem... doing code know content of tag but... can take content if have got id? from bs4 import beautifulsoup import urllib2 code = '<span class="vi-is1-prcp" id="v4-27"> 15,00 eur </span>' soup = beautifulsoup(code) price = soup.find('a', id='v4-27') # <-- problem print price if html code should replace 'a' tag 'span' tag. should this... ... price = soup.find('span',id="v4-27") print price #optional price.string give 15,00 eur #instead of entire html line

Why are my @components not detected by spring? -

this 1 tricky - me @ least.component scan not seem work here web.xml <!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>geomajas gwt face example application</display-name> <context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath:org/geomajas/spring/geomajascontext.xml classpath:org/geomajas/plugin/rasterizing/defaultrasterizedpipelines.xml web-inf/applicationcontext.xml <!-- web-inf/applicationcontext2.xml --> <!-- web-inf/layer*.xml --> <!-- web-inf/map*.xml --> web-inf/layerosm.xml web-inf/maposm.xml <!-- web-inf/applicationcontext2.xml --> </param-value> </context-param> <filter> <f

double - 1 divided by very large number return 0, C -

i decided post question because i'm not sure why i'm getting result. researched in site , others finding no solution. sorry if i'm violating websites rules remember, i'm new. code of function written in c returning unexpected result: double gauss (double average, double variance, int data) { double model,power; power = ((((data-average)*(data-average))/(2*variance))*(1)); model = (pow(e,(int)power)); return 1.0/model; } i don't know if should post rest of code if want to, wanted keep post short. issue occuring 1.0/model because model big number. c doubles have limited precision, if divide 1.0 large double, precision error net 0 (effectively, actual answer close 0 precision error round zero). you try use long double more precision, think better off using arbitrary precision library gmp .

d3.js - jasmine testing on external library -

i attempting basic testing using jasmine. use external library & intend spy/mock method calls on library object (d3) , make sure appropriate methods called on d3. var d3spy = jasmine.createspyobj('d3', ['select']); spyon(window, 'd3').andreturn(d3spy); expect(d3spy.select).tohavebeencalled(); when 'select' being called on object, error. typeerror: object function () { spyobj.wascalled = true; spyobj.callcount++; var args = jasmine.util.argstoarray(arguments); spyobj.mostrecentcall.object = this; spyobj.mostrecentcall.args = args; spyobj.argsforcall.push(args); spyobj.calls.push({object: this, args: args}); return spyobj.plan.apply(this, arguments); } has no method 'select' what doing wrong? the failure in code following spyon(window, 'd3').andreturn(d3spy); this line wil return spy when call d3() . replace d3 object function when called returns {select: jasmine.createspy()} . using d3

c - Starting a thread from inside an interrupt handler -

i'm trying start thread interrupt occurs. however, have realized can't start thread within interrupt handler (or function directly or indirectly being called interrupt handler). so, have decided have handler assert flag. then, separate thread continously monitors flag , if it's asserted in turn create (and start) thread. here's pseudocode: int interrupt_flag = 0; interrupt_handler(void) { interrupt_flag = 1 } monitoring_thread(void) //this thread started @ start of program { while(1) { if(interrupt_flag) { interrupt_flag = 0; //start thread here sleep(/*some amount of time*/); } } } i'm not happy having dedicated while loop monitoring flag. problem reduces speed of other threads in program. reason, i'm calling sleep function increase speed of other threads in program. question: there way can start thread upon interrupt, without having dedicated while loop? there workaround starting thread within interrupt handler

jquery - Use blur.js on a Google map (v3 API) -

currently attempting do, use blur.js on div named map_canvas contains google map. i've tried create div on , use: $(document).ready(function() { $('#blurredcoverdiv').blurjs({ source: '#map_canvas', radius: 30, overlay: 'rgba(0, 0, 0, .2)' }); }); however, resulting in error in console: get http://[site]/none 404 (not found) blur.js:279 i've seen 1 stackoverflow question involving this question , however, solution there didn't seem solve problem. any ideas why may happening, or way fix it? you 404 error because blur.js looking background-image in source 's div. since map_canvas set none , blur.js push 404 error console ( 'none' not found ). i haven't tested it, solution comes mind right set google map static image map_canvas 's background-image . if works, can go on , write function takes current view on map_canvas 's canvas , apply static image background-image .

php - how to get the connection object of a specific user? -

i working in real time symfony app using ratchet library, in app need send data specific user logic solution use sessionprovider attach symfony2 session object each incoming connection object. documentation states have setup non-native session handler store sessions i.e. in database via pdo. , work fine moment need connection object of specific user send him data in other way need find connection object reference user , can't find way ? her's server code : $app=new aggregateapplication(); $loop = \react\eventloop\factory::create(); $context = new \react\zmq\context($loop); $pull = $context->getsocket(\zmq::socket_pull); $pull->bind('tcp://127.0.0.1:5555'); $pull->on('message', array($app, 'onnotification')); $websock = new \react\socket\server($loop); $websock->listen(8080, '127.0.0.1'); $handler = $this->getcontainer()->get('session.handler'); $server=new \ratchet\wamp\

html - $index, in Table, not sequential... angularjs -

i have table in html. the rows counted (via use of $index ), , certain rows shown (via use of ng-show ). problem : $index not return right count. table's count should go "1,2,3...", not. <tbody> <tr ng-repeat="fruit in basket" ng-show="fruit.isjuicy == type"> <td>{{$index + 1}}</td> <td>{{fruit.name}}</td> </tr> </tbody> here's jsfiddle ; don't forget click on buttons see issue: http://jsfiddle.net/f6hcx/2/ what causing counting problem? how can solved? (could please comment/rate question's description clarity, (was understood?) cheers!) edit: question has been answered. more info using filters: how use parameters within filter in angularjs? the problem using ng-show show or hide individual items. in reality, $index correctly counting number of items — it's hidden, can't see values. if closely @ example,

Button disappears but the other column members of the row remains visible in datagridview c# -

Image
i writing code make sure if translate button pressed new row appears row members except string text visible..now have written code makes button disappear , members still visible. this view after button pressed.. now button invisible other members still visible.this code have tried.. private void datagridview1_cellcontentclick(object sender, datagridviewcelleventargs e) { bool ce = false; bool check = true; column_handling(); datagridviewtextboxcell c = new datagridviewtextboxcell(); if(!(datagridview1.rows[e.rowindex].selected)) { datagridview1.rows[e.rowindex].selected = false; if (e.columnindex == 10) { if((convert.toint16(this.datagridview1.rows[e.rowindex].cells[0].value) == convert.toint16(this.datagridview1.rows[e.rowindex + 1].cells[0].value)) && (convert.toint16(this.datagridview1.rows[e.rowindex].cells[1].value) == convert.toint16(this.datagridview1.rows[e.rowindex + 1].cells[1].value)))

clojure - `lein deploy clojars` hangs -

i've installed gpg4win, generated keys , pasted public key clojars per leiningen gpg readme . however, when lein deploy clojars , after asking me clojars username , password , printing has created jar, hangs. typing nothing. any ideas how fix this? ok, turns out having version of pgp packaged git, generated keys default setting other "rsa , rsa". removing , regenerating keys solved problem.

image - Overidding imshow -

when use following, imshow(imread('image1.jpg')); imshow(imread('image2.jpg')); imshow(imread('image3.jpg')); imshow(imread('image4.jpg')); imshow(imread('image5.jpg')); imshow(imread('image6.jpg')); i got image named image6.jpg in output figure. there option figure,imshow(...); view images each in new window. but writing figure in each line need view image repeated , tedious process. there other solution same output figure,imshow(..); without using figure function. i put on question because while programming lot somewhere forget use figure function , image need view wont visible. have been overwritten other image. provide me solution. i ask simplicity in writing code. if there solution, please mention. thanks in advance. i'm not sure, don't think there's workaround that. matlab changes current figure handle of new image when use imshow . 1 thing can make copy of imshow in local

ios - How to make UIImage on setImage UIButton more higher -

Image
what want make uibutton adhere uiview menu when uibutton isselected. black square on uinavigation uiimage after uibutton selected. question how make uiimage (black square) more higher uibutton after selected? this code on uibutton class .m: - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { //...our red stretchy uiimage *redimage = [uiimage imagenamed:@"button_red.png"]; uiimage *redstretchy = [redimage stretchableimagewithleftcapwidth:redimage.size.width / 2 topcapheight:redimage.size.height / 2]; //...initialization code [self setframe:frame]; [self settitle:title forstate:uicontrolstatenormal]; [self setbackgroundimage:redstretchy forstate:uicontrolstatenormal]; [[self titlelabel] setfont:[uifont boldsystemfontofsize:font_size]]; [[self titlelabel] setshadowoffset:cgsizemake(font_shadow_offset, font_shadow_

javascript - What's const property on IE -

i have got error in ie10. script5039: redeclaration of const property i deleted const property window , document set var . but error still occurred. so want know if there other const property on ie . or if have other answers error, please tell me. i delete below code var window var document judging answer "script5039: redeclaration of const property" in ie9 seems ie not correctly identify line error happens. think thing can check more variable names might conflicting. script5039: redeclaration of const property using ie9 suggests might e.g. using history var name. if not case, try checking properties of window , document elements , see conflict variables in global scope. it might possible error message faulty , caused ie trying render page in quirks mode (see js error 'redeclaration' of var when it's first line in program? ). fix should fix script standards compatible.

ios - google mobAd is conflict with Parse framework in (-ObjC) how to solve this issue? -

i have google mobile ad in project , make work should add -objc other linker flag have added parse framework project ,and 1 need remove -objc can compile after run project crashes on exception : terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[gadobjectprivate changestate:]: unrecognized selector sent instance 0x1dde57b0' so please can conflict ?? or should use ad engine if there no solution ? you can use -objc parse. when use flag, though, need include facebook sdk , dependencies well. that's because -objc flag tells linker load all frameworks , classes referenced code, turns optional facebook sdk library required library. instead of using -objc , consider using -force_load cherry pick frameworks loaded .

junit - maven release:prepare skips test-jar -

i`m using maven ver. 3 following plugin generate separated *.jar file tests. <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>2.4</version> <executions> <execution> <id>core-tests</id> <phase>package</phase> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> and release plugin configuration looks following: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-release-plugin</artifactid> <version>2.0-beta-8</version> <configuration> <releaseprofiles>release</releaseprofiles> <preparationgoals>clean install</preparationgoals> <generatereleasepoms>fal

actionscript 3 - Loading Javascript in Flash (picture reference) -

i need help! want load picture url in flash as3 have following code in javascript shows picture. want load same reference in flash.. fb.api('/me?fields=username', function(response) { function detect(url) { var image = new image(); image.src = url; image.onload = function() { var result = 'result'; // example result } document.body.appendchild(image) } detect("https://graph.facebook.com/" + response.username + "/picture?width=200&height=200"); you cannot call api as3 directly because facebook's library written in javascript. you'll have use js intermediary. however, gio's response above correct. use externalinterface api pass message js as. i'm pasting modifications need make in js below builds upon has written. his answer correct , complete , should mark such. fb.api('/me?fields=username', function(response) { function detect(url) { var image = new image();

I want to select record based on the current date in codeigniter , but this query fails. -

i have select records based on current system date . if hard code date value , query works fine if modify to $date1=date('y-m-d h:i:s'); $res=$this->db_model->sql("select * vbl_assignment inner join vbl_student_course on vbl_student_course.course_id = vbl_assignment.course_id inner join vbl_course on vbl_assignment.course_id = vbl_course.course_id vbl_student_course.student_id =".$this->session->userdata('loggedinstudent')->student_id." , vbl_assignment.accept_until_date > ".$date1); query fails. idea worng here. try: $res=$this->db->query("select * vbl_assignment inner join vbl_student_course on vbl_student_course.course_id = vbl_assignment.course_id inner join vbl_course on vbl_assignment.course_id = vbl_course.course_id vbl_student_course.student_id =".$this->session->userdata('loggedinstudent')->student_id." , vbl_assignment.accept_until_date > '".$date1.&quo

internet explorer - Why isn't my CSS working in IE 8 and IE 7? -

what in css doesn't work in ie8 & ie7? nav { position: fixed; top:60px; left:30px; color:black; float:left; } nav div#button { width:205px; height:50px; text-align: center; padding-top: 5px; margin-bottom:10px; font-size: 23px; } nav { color: #000000; text-decoration: none; } nav div#button:active { width:250px; height:65px; } nav div#button.home { background-color: #79b22c; } nav div#button.links { background-color: #3b50cc; } nav div#button.aanbod { background-color: #ba3bcc; } nav div#button.forum { background-color: #1caeb2; } nav div#button.contact { background-color: #daa520; } it works fine in ie9 & ie10. ie8 & ie7 displays no-styled text. have tested browserstack. can me please? <nav> , other html5 elements defined after ie 7 , ie 8 released, browsers aren't aware of how handle them. they can, however, instructed handle them. and, html5shiv can this: include htm

Passing AJAX arguments to JQuery -

function myfunction(action, arguments){ $.get(action, arguments) } myfunction("link/to/mypage", { "idcustomer": "123", "junk": $.now }) expected connection: link/to/mypage?idcustomer=123&junk=random actual result: link/to/mypage why this? how can solve it? thanks! arguments reserved word in javascript. change else , try again!

How to add listener to a sprite in cocos2d in android -

i working on cocos2d,and in need of adding listener sprite.my code here public class gameoverscreen extends cclayer implements keyhandler { public static ccscene scene(difficulty difficulty, long totalscore) { ccscene result = ccscene.node(); ccsprite redeem = ccsprite.sprite("redeem.png");// listener sprite cgsize s = ccdirector.shareddirector().winsize(); redeem.setscale(block.scale*main.scale); redeem.setposition(-1, -1); redeem.setanchorpoint(cgpoint.ccp(-0.7f, -1)); result.addchild(new gameoverscreen(newhighscore, totalscore)); result.addchild(redeem); return result; } @override public boolean cctouchesbegan(motionevent event) { location = ccdirector.shareddirector().converttogl(cgpoint.ccp(event.getx(), event.gety())); if(cgrect.containspoint((redeem.getboundingbox()), location)){ //action } return true; } short , simple trick resolve

Perl Script: Search for string from a folder with multiple files -

i have folder multiple .txt files in it. want check few strings in text files , give output out.txt 5 lines above , 5 lines below of located string. if insist on perl oneliner; perl -n -e 'if (/searchstringhere/) {print "\n\n\n\n\n$_\n\n\n\n\n"}' *.txt if grep solution works you, consider more elegant... update it struck me might windows user, don't have grep... this code not tested, don't have perl installed on machine, should work: !#yourperl/perl $flag, $l1, $l2, $l3, $l4, $l5, $l6; $cnt = 5; $file = shift; open("$file") || die "can't open $file\n"; while (<>) { $l1 = $l2; # starting reserving lines print $l2 = $l3; $l4 = $l5; $l5 = $l6; $l6 = $_; if (/your string here/) { $cnt = 5; print ($l1$l2$l3$l4$l5$l6);# print line + 5 prev lines next } if ($cnt >0) { # print next 5 lines print $l6; $cnt--; } }

api - delphi, windows impersonation as user to copy a file -

i need copy file located on directory on newtwork local machine. did research , found function called windows api, when tried call copy file received access denied message. here project. procedure tform1.btnloginlogonclick(sender: tobject); var phtoken: thandle; begin writelog(''); writelog('current user: ' + getcurrentuser()); // check correct login phtoken := 0; try phtoken := checklogin(edit1.text, edit2.text, edit3.text); //user,password,domain writelog('handle: ' + inttostr(phtoken)); if (phtoken > 0) begin writelog('user login ok'); // login ok, switch acl new login context (demo purpose only) impersonateloggedonuser(phtoken); writelog('impersonated user: ' + getcurrentuser()); if( copyfile(pwidechar(edit4.text),('c:\cp2101.zip'),false)=false) then//copyfile('c:\a.jpg','c:\warn.jpg',true))=false showmessage(syserrormessage(getlasterror));

how to convert a number in binary to it's decimal value using c# -

!!!!answered!!!! i need little finishing simple bit manipulation program. asks user number print number's binary representation ask user bit position , bit value apply changes displays changes made user in binary ?????? convert changes number again. ?????????? i need little step 5 , see code i'm complete noob , please not laugh :) appreciated. console.writeline("enter integer number"); int number = convert.toint32(console.readline()); string binarystring = convert.tostring(number, 2); console.writeline("the binary representation of {0} is", number); console.writeline(binarystring.padleft(16, '0')); bitarray b = new bitarray(new int[] { number }); console.writeline("enter bit's position (0 15)"); int position = convert.toint32(console.readline()); console.writeline("enter bit's value (true or false)"); bool value = conve

ruby - click method not supported for safari 6 -

i want write automation script in selenium ruby safari(version 6).but click method of selenium not supported safari version 6 there other way click selenium element. thanks. you can use javascript instead same. following java equivalent produce click. should able convert ruby. javascriptexecutor js = (javascriptexecutor) driver; string script = "var elem = document.getelementbyid('element_id');"+ "if( document.createevent) {"+ "var evobj = document.createevent('mouseevents');"+ "evobj.initevent( 'click', true, false );"+ "elem.dispatchevent(evobj);"+ "} else if( document.createeventobject ) {"+ "elem.fireevent('onclick');"+ "}"; js.executescript(script); reference ruby equivalent script = "var elem = document.getelementbyid('element_id');"+ "i

css - Stretching a div across the width of the screen in bootstrap -

i wish stretch div blue across width of screen used inside container class in bootstrap. here's code <div class='container'> <img src="http://lorempixel.com/175/80/sports/1" width="230" height="70" class="pull-left" /> <div class='clearfix'></div> <div class= 'padding-top'></div> <div class="blue"></div> <div class="padding-bottom"></div> here's css blue div .blue{ border-top:3px solid #8dbf43; width:100% !important; } but directive doesn't seem working, still contained inside container. in order stretch : james answer usefull : https://stackoverflow.com/a/22556241/2454790 bootply : http://www.bootply.com/123651 css : .blue{ border-top:3px solid #8dbf43; width:100% !important; height:200px; // <-- height of div background:blue; position: absolute

android - NewRelic conflict with parse object -

i have integrated newrelic android app, add jar file of new relic parse object gives me fatal error. 03-21 15:17:34.739: e/androidruntime(3573): fatal exception: main 03-21 15:17:34.739: e/androidruntime(3573): java.lang.verifyerror: com/parse/parseacl 03-21 15:17:34.739: e/androidruntime(3573): @ com.parse.parseobject.setdefaultvalues(parseobject.java:2764) 03-21 15:17:34.739: e/androidruntime(3573): @ com.parse.parseobject.<init>(parseobject.java:160) 03-21 15:17:34.739: e/androidruntime(3573): @ com.codenterprise.cashbackkorting.tab.oncreate(tab.java:111) 03-21 15:17:34.739: e/androidruntime(3573): @ android.app.activity.performcreate(activity.java:5066) 03-21 15:17:34.739: e/androidruntime(3573): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1101) 03-21 15:17:34.739: e/androidruntime(3573): @ android.app.activitythread.performlaunchactivity(activitythread.java:2307) 03-21 15:17:34.739: e/androidruntime(3573): @ andro

asp.net mvc 4 - Getting invalid ID and Name in mvc razor when model has navigation property? -

Image
this razor code in view. int pmtcount = 0; if (item.projectmaterialtypes != null) { @foreach (var x in item.projectmaterialtypes) { pmtcount = pmtcount + 1; @html.hiddenfor(model =>model.projecttypes[ptcount - 1].projectmaterialtypes.tolist()[pmtcount - 1].projectmaterialtypeid, new { value = x.projectmaterialtypeid}) @html.hiddenfor(model => model.projecttypes[ptcount - 1].projectmaterialtypes.tolist()[pmtcount - 1].materialtypes.name, new { value = x.materialtypes.name }) <label>@html.checkboxfor(model => model.projecttypes[ptcount - 1].projectmaterialtypes.tolist()[pmtcount - 1].status, new { @onclick = "togglesingle('smt-" + x.materialtypeid + "')" }) @x.materialtypes.name</label> } } populating id , name on browser. but getting null object in controller submitting form, please let me know there way solve problem? simply changed icollection list in

ios - How to prevent top bar from impeding view -

Image
i'm writing first ios app , have noticed top bar appears on application: my main window created this: _window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; i noticed this similar question , not have navigation controller. root controller tab controller. how can fix this? you should use applicationframe instead of bounds . bounds return size including status bar while applicationframe return frame of content app. _window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] applicationframe]]; in ios7 status bar can translucent. means applicationframe , bounds return same frame because content can drawn bellow status bar. fix can offset window bellow status bar ( 20px ) _window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] applicationframe]]; _window.clipstobounds = yes; _window.frame = cgrectmake(0, 20, _window.frame.size.width, _window.frame.size.height - 20); _window.bounds = cgrectmake(0, 20, _window.frame.siz

javascript - Why is CKEDITOR not finding the icons for the editor in my rails production site? -

i using ckeditor , not showing icons in toolbar. here setup: application.rb config.assets.precompile += ckeditor.assets config.autoload_paths += %w(#{config.root}/app/models/ckeditor) application.js //= require ckeditor/override //= require ckeditor/init i using capistrano deploy code server. here getting when inspect missing icon: element.style { background-image: url(/assets/ckeditor/plugins/icons-03589ffff0ab72dc57d667560eff4018.png); background-position: 0 -1440px; background-size: auto; } .cke_ltr .cke_button__newpage_icon { background: url(icons.png) no-repeat 0 -1440px !important; } it looks compiling css correctly, when untick background: url(icons.png) no-repeat 0 -1440px !important; in inspector icon works. any ideas great, struggling see doing wrong here standard issue - it's rails not picking icons.png when you're deploying production server. got icons working using preceding tutorial: #/lib/tasks/ckeditor.rake require 'fil

Unable to post to Restful API through Ajax using android phone -

i developing android application using phonegap. trying execute simple login module, works fine in web browser. when comes apk, not working. not able post request restful api. var usr = $('#email_address').val(); var pass = $('#password').val(); if(usr != '' && pass != ''){ alert("before calling method"); $.ajax({ url:apiurl +"api/sample/sample123", type: "post", crossdomain : true, data: {username:usr,password:pass}, datatype: "json", success: function(data){ /*here posting dummy code, can't show original code*/ var response = eval(data); alert(response.response); } }); when executing on android phone, getting first alert above i.e "before calling method" not showing alert. have configured res/xml/cordova.xml <access uri="*" subdomains="true"/> also hav

android.os.NetworkOnMainThreadException -

i have used asynctask in code. showing error have given in logcat.i have created google api emulator of api 18.in not working.but working in api8. whether work in real device of version? btnlogin.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { new logintask_1().execute(); } }); asynctask class logintask_1 extends asynctask<string, string, string> { /** * before starting background thread show progress dialog * */ @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(registeractivity.this); pdialog.setmessage("loging in..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } /** * deleting product * */ protected string doinbackground(string... args) {