Posts

Showing posts from February, 2014

javascript - smooth button grow and button shrink animation on hover -

i trying make simple animation; on mouse over, button animate bigger. when not hovering, return it's original size. however, whenever when try sample code, warps button odd sizes $('.btn').hover(function() { $(this).removeclass('btn-primary').addclass('btn-warning'); $(this).stop().animate({ 'height': $(this).height() * 2, 'width': $(this).width() * 1.3 }, 300); }, function() { $(this).removeclass('btn-warning').addclass('btn-primary'); $(this).stop().animate({ height: $(this).height(), width: $(this).width() }, 300); }); http://jsfiddle.net/rblqy/1/ how problem solved? i'm not entirely sure why code failing, seems have sort of calculation error when returning original size. after fiddling around bit found solution. animating padding instead of height , width don't have worry height width ratio when comes resizing link. $('.btn').hov

ios - NSString stringWithFormat cant set precision for exponential record -

i'm trying display small double value on textfield . example, docalculationforequalpressed function returns 0.00008, when display on text field shows exponential record (8e-05). don't need number shown in exponential view. how set precision when use exponential record ??? using specifier %.9g - doesn't help. double result; result = [self.brain docalculationforequalpressed:[self.brain operationarray]]; if (result == infinity || result == -infinity || isnan(result)){ nsstring *infinity = @"\u221e"; self.displayfield.text = [nsstring stringwithformat:@"%@", infinity]; } else self.displayfield.text = [nsstring stringwithformat:@"%.9g", result]; it can't done format specifier default. you need use sprintf , remove trailing zeros yourself. char str[50]; sprintf (str,"%.20g",num); // make number. morphnumericstring (str, 3); void morphnumericstring (char *s, int n) { char *p; int count;

How do I implement this array in Javascript -

array ( [254] => onjob [251] => verified [250] => verified [249] => onjob [248] => onjob [247] => onjob [244] => onjob ) i have array , want each value respective array key . how in javascript ? create object my_object={254: 'onjob',251: 'verified', 250: 'verified',249: 'onjob'}; my_object[251]; //return "verified"

svg - Dynamic fill with transition d3 -

i want dynamic fill transition using d3. http://tributary.io/inlet/11094354 how transition on load 0-60% on first load?? thanks , best regards moyeen all need add transition stop : grad.append("stop").attr("offset", "0%").style("stop-color", "red") .transition().duration(1000).attr("offset", "60%"); complete demo here .

hibernate - How to load global settings frequently used in application in Java -

1) in application have table stores settings detail used heavily every functionality.basically conditions set in table checked. now doing making db call every , fetch details , check condition.this has resulted in lot of db calls , repetitive calls same condition.there quite lot of condition records in table.we need change make perform better. 2) in previous project had same requirement have configuration table such settings configured,there implemented load configuration table @ start of application , store them in system.setproperty(name,value)..and later use system.getproperty(name) retrieve it.in case settings changed update in system property.this worked charm. however,in current case(point 1 above) don't think prev way best way because lot of records present in table having lot of columns. can suggest way how achieve such kind of behavior in java? of them can think of is 1) using system.setproperty explained. 2) using caching ehcache - standalone or hibernate(as u

sql server - SQL query to split a comma separated column into many-to-many relationships -

i given 3gb csv file need import in sql server 2012. i have 5 million rows data in staging table looks (simplified). staging table: +-------------------+------------+---------------+------------+ | name | thumbnail | tags | categories | +-------------------+------------+---------------+------------+ | history | thumb1.jpg | history,essay | history | | nutricion lecture | thumb2.jpg | food,essay | health | +-------------------+------------+---------------+------------+ the question tags , categories column in staging table. how can transfer information staging table actual table , create unique record each tag , category -- and create needed many-to-many relationships? it need check each tag against existing tags either create new record -or- fetch id of existing tag. programs : +----+-----------+------------+ | id | program | thumbnail | +----+-----------+------------+ | 1 | history | thumb1.jpg | | 2 | nutrici

Petite chez scheme confusing function with variable? (variable ___ is not bound) -

i've started learning scheme , i'm having trouble. using petite chez scheme (64-bit) windows. have been reading on examples using functions 'every' , 'keep' , 'accumulate' , understand built in , known petite (i.e. not have defined before use). when enter examples have read test them, error returned. example- ;; make nouns plural (define (plural noun) (if (equal? (last noun) ’y) (word (bl noun) ’ies) (word noun ’s))) > (every plural ’(beatle turtle holly kink zombie)) ;; example input (beatles turtles hollies kinks zombies) ;; expected output instead receive error "variable every not bound". if 'every' being treated variable rather known function. receive same error when try examples 'keep' , 'accumulate'. coding correct assume (since copied book i'm reading). wrong in thinking these functions built in , not need defined or there other issue? hope can shed light on this. the

c# - SqlCommand with using statement -

i saw in samples sqlcommand used this using (sqlconnection con = new sqlconnection(cnn_string)) { using (sqlcommand cmd = new sqlcommand("select id,name person", con)) { sqldataadapter da = new sqldataadapter(cmd); dataset ds = new dataset(); da.fill(ds); return ds; } } i know why using "using" statement. sqlcommand doesn't inlcude close() method, should use within using statement because implements idisposable . the purpose of using statement when control reach end of using dispose object of using block , free memory. purpose not auto connection close, dispose connection object , connection closed due it. its purpose free resources used inside using statement. according msdn: as rule, when use idisposable object, should declare , instantiate in using statement. using statement calls dispose method on object in correct way, , (when use shown earlier) causes object go out of sco

java - How to use and create a daemon thread and optimal utilization with Swing -

i creating blackjack game high school programming class , need method tracks card values , bets run in background. research on website revealed daemon threads answer. if not true, please provide me suitable alternative , include examples of how use , create alternative. my problem not understand how create daemon thread. appreciate explanation , example of how use , create daemon thread. there 1 more problem, program, created resource class contains code dealer. players subclasses of dealer , subclasses of jpanel. in subject, blackjack game uses swing display game , "optimal utilization" comes in. have application file in dealer , player objects entered so: public class panelproject extends jpanel { private playerboxclubs playerone; private playerboxhearts playertwo; private playerboxspades playerthree; private dealerboxdiamonds dealerone; public panelproject() setlayout(new borderlayout()); jpanel centersub = new jpanel(); centersub.

.htaccess - PHP: Allow file download to a authorized members only -

i have website , want registered members download particular file. have following structure: in directory having original setup file, created .htaccess file with: order deny,allow deny and, file called download.php , call file using: <?php $filename = "127.0.0.1/eye/setup/setup.msi"; if(ini_get('zlib.output_compression'))ini_set('zli b.output_compression', 'off'); header("pragma: public"); header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("cache-control: private",false); header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=\"".basename($filename)."\";" ); header("content-transfer-encoding: binary"); header("content-length: ".filesize($filename)); readfile("$filename"); exit(); ?> but, problem is: if knows exact location of file, he

java - Texture partially off screen - performance difference -

Image
on picture example of 2 situations, textured polygon being rendered. done opengl es2. a) polygon partially off viewport b) polygon inside it my question: is situation 'a)' going consume less system/gpu resources*, because texture partially off screen, or perform same if rendered inside of viewport , why? *"resources" - meaning speed, not memory. i know opengl calculate vertices first, before rendering texture , if vertices off screen/viewport, skips further calculations, same case textured object partially off screen? will omit part of texture not visible? situation should faster. vertex processing same. after that, clipping view volume applied. in situation a, part of polygon clipped, while whole polygon goes through in situation b. after that, polygon rasterized, , resulting fragments go fragment processing. since there fewer fragments in situation a, there's less work in stage. fragment shader texture sampling, visible parts of textur

c# - Add a datagridview column from another form -

i have 2 forms , datagridview in form1.im trying add new column clicking in button form2.like that: form2 private void button1_click(object sender, eventargs e) { form1 form1 = new form1(); form1.datagridview1.columns.add("test" , "test"); } how can that? form1 form1 = new form1(); this not work real form1 there, pressume. instead create reference in form2 , load in form2's constructor! here steps: the local reference form1 in form2's variables: form1 form1 when opening form2 pass reference form1 in constructor: form2 = new form2(this); store in local refence in constructor on form2: public form2(form1 form1_) { initializecomponent(); form1 = form1_; } now set use form1 , public properties , controls. use form1.datagridview1 must make public first, though. (or create public reference it..)

ios - How to calculate height of custom UITableViewCell by using UILabel's content -

how can calculate height of custom uitableviewcell using uilabel 's content in table view cell? implement heightforrowatindexpath this: - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { nsstring *text = [dataarray objectatindex:indexpath.row]; //your data string cgsize constraint = cgsizemake(yourlabel.frame.size.width, 2000.0f); cgsize size; nsstringdrawingcontext *context = [[nsstringdrawingcontext alloc] init]; cgsize boundingbox = [text boundingrectwithsize:constraint options:nsstringdrawinguseslinefragmentorigin attributes:@{nsfontattributename:yourlabel.font} context:context].size; size = cgsizemake(ceil(boundingbox.width), ceil(boundingbox.height)); return size.height; }

ios - Using timer in a tableview re creates the timer after any scroll or table reload -

Image
i'm using https://github.com/mineschan/mztimerlabel/ , in tableview cellforrowatindex using timer below: uilabel *lbltimer=(uilabel *)[cell viewwithtag:10]; mztimerlabel *upgradetimer = [[mztimerlabel alloc] initwithlabel:lbltimer andtimertype:mztimerlabeltypetimer]; [upgradetimer setcountdowntime:timestamp]; [upgradetimer startwithendingblock:^(nstimeinterval timestamp) { lbltimer.text = @"✔"; }]; but after table reloading or scrolling, timer behaves strange , seems re-generates multiple timers counting in same place. how should fix while using timer? appreciate help, elias i had @ mztimerlabel , , violates mvc badly. puts belongs model (the timer count's down time) view. problem comes from. views should able recreated without having side effects on model. i recommend ditch class, , create own. it's quite easy achieve this. create new class saves title , enddate store instances of class in model backs table create one nstimer refresh

java - Is string Object Created in Heap if we use new String("abcd") -

this question has answer here: how compare strings in java? 23 answers string s1 = new string("anil"); string s2 = s1.touppercase(); string s3 = s1.tolowercase(); system.out.println(s1 == s2); system.out.println(s1 == s3); if string object created in heap both false.but gives false,true. string s1 = new string("anil"); this statement creates new object and , string s3 = s1.tolowercase(); points location of 1st object s1 and thats reason getting true second condition also see how java handles strings clear understanding hope helps!!

java - SWT Window doesn't close on context menu click -

i using shell shell = new shell(display,swt.none); this removes listener or disables close event. when try right click application in taskbar , "close window" doesn't anything. if use shell style such swt.min then performs close operation. using windows 7. i need have borderless window , @ same time able close application context menu, if possible. swt.no_trim does want. window without border still closes using taskbar context menu.

javascript - Creating a Search Box -

what trying allow user artists based on artist's name in search box below (in html) , presenting user artist's name , link different html page if user's search matches artist in array. the trouble is, when click "search" page goes original page. not sure disconnect is. not sure if calling id correctly; if id in right place; if action correct on in u.addevent function; or if search function written correctly. any ideas? rd <body> <div class="imgs"> <a target="_blank" href=""><img src="img/04.png" alt="img" /></a></div> </div> <div class="form"> <form method="post" action="handler.php"> <input name="textfield" id="searchbox" type="text" class="colortext"/> </form> </div> </div> <script> var fakedatabase = []; var foxyshazam = {

python - Writing to a memory file instead of file path -

is possible supply path buffer write data instead of supplying file path e.g. instead of object.save("d:\filename.jpg") supply path memory buffer. want avoid writing image object data file .jpg , save directly memory can have in memory rather loading again disk. i believe looking stringio library.

php - Laravel: accessing a resultset -

i'm new laravel , trying access object database. book object , when print screen line: {{{ $book or 'default' }}} i object printed so: [{"id":"1","title":"dress crabmeister","isbn":"18274827","publication_date":"14\/03\/1978","author_id":"1","genre_id":"4","available":"1","created_at":"1397346572","updated_at":"1397346572"}] although fine , proves successful, when try access 1 attribute such title , gives me undefined exception. try access line: $book->title i'm sure obvious answer appreciated, thanks. it depends on how return object. there multiple ways laravel. returned object seems json-object. try following in view <script> var book = '{{ $book }}'; //... window.console.log(book.title); </script> or don

ruby on rails - You have 1 pending migrations: 20140415221104 CreateBoxesAndBoxesSuppliers -

when execute rake comand get: have 1 pending migrations: 20140415221104 createboxesandboxessuppliers run `rake db:migrate` update database try again. as error suggests, need run rake db:migrate . as per error, mysql2::error: table 'boxes' exists , created boxes table migration , 20140415221104 createboxesandboxessuppliers migration trying create boxes again. you should not creating boxes table again in 20140415221104 createboxesandboxessuppliers migration.

javascript - Rspec, Capybara: Ambiguous match, found 2 elements matching field 'brief' -

i have implemented inline form show/hide function jquery , few of specs failing. post comments answers , questions, , comments can posted in reply other comments. when form shown, 'add comment' link changes 'cancel' , upon clicking 'cancel', form hidden. my spec: scenario 'on answer', js:true submit_answer @answer.brief submit_comment @comment_brief, '.answers' expect(page).to have_content(@idea_brief) expect(page).to have_content(@question_brief) expect(page).to have_content(@answer.brief) expect(page).to have_content(@comment_brief) end scenario 'on comment', js: true @commentreply = factorygirl.create(:comment) submit_comment @comment_brief, ".question" submit_comment @commentreply.brief, '.question-comments', 'reply comment' expect(page).to have_content(@question_brief) expect(page).to have_content(@comment_reply) end i assume 2 errors identical, having js

c# - Package.appxmanifest not present in solution -

i'm using visual studio 2013 ultimate. i've started windows phone 8 app in blend, , finished in visual studio. according this article , need to: in visual studio, close manifest file if it’s open in xml code view. in solution explorer, expand project node of app. double-click package.appxmanifest file. the problem - don't have package.appxmanifest file in solution. how create it? maybe need convert solution windows store project? if yes, how that? that's poorly worded documentation. windows phone 8 projects not contain package.appxmanifest--they contain wmappmanifest.xml can edit in "designer". i've tried upgrading wp 8 project 8.1 , in fact adds package.appxmanifest--which editable in "designer". i'm surmising if added windows store app solution, converting universal app, same thing.

c - Updating/Refreshing text displayed on the terminal -

i'm attempting create game of life program in c, i'm not familiar process update output displayed on terminal. so, example, have 2d char array, each element contain either '#' or '-'. print array onto screen, rather printing new 2d array every time there state change, want overwrite old array in terminal new state. i have looked ways this, haven't had luck. closest have found carriage return in printf function (\r), can tell me best way this. specifically, how print out 2d array on screen, change elements of array, , print out new array on top of old one, ie, overwrite it. (some of these links, code snippets linux, , others windows) given specific questions , (and assuming know how write array console) : 1) write first array. 2) clear console (or over write console) this: #include <stdlib.h> void main() { system("cls"); } or write following stdout: (linux) write(1,"\e[h\e[2j",7); which

javascript - Uncaught TypeError: Cannot read property 'submit' of undefined -

this html when inspect element in chrome <html> <head> <title>please wait</title> <link rel="shortcut icon" href="images/ajax-loader1.gif" type="image/x-icon"> <style type="text/css"> </style> </head> <body onload="autosubmit();" cz-shortcut-listen="true"> <div> <p class="header">please wait... payment request being processed......</p> <p class="image_style"> <img src="images/ajax-loader.gif"> </p> <ul> <li>this secure payment gateway using 256 bit ssl encryption</li> <li>when submit transaction, server take 1 5 seconds process, may take longer @ times </li> <li>please not press "

Using JQuery I am not able to remove class and add class to my SVG -

i trying use jquery click event remove class , add different class svg object not changing fill expected. $(".seat").click(function (event) { var result = $(this).data("seat"); var state = $(this).data("state"); $(this).removeclass( "seat" ).addclass( "taken" ); result = result +" - "+ state; $("#statusbox").html(result); }); my js fiddle here unfortunately, class not work same svg tags standard html, @ least in respect jquery. rather treat class, need treat attribute. $(".seat").on('click',function(e){ var $this = $(this), $data = $this.data(); $this.attr('class','taken'); $("#statusbox").html($data.seat +" - "+ $data.state); }); since removing class present , giving new class, assigned attribute of class new value of taken . if actual code more complex multiple classnames, may

How to print time ellapsed (seconds)java -

in run method of game loop tried print time program has been running in java. tried system.out.println(system.nanotime() / 1000000); because that's how many milliseconds in second.(if didn't know) prints seconds near end wanted exact seconds testing purposes. searched online , suggested using same formula thought of. can give exact one? store previous time in private member. private long previoustime; initialize in constructor. previoustime = system.currenttimemillis(); compare current time in run method (each iteration of game loop) long currenttime = system.currenttimemillis(); double elapsedtime = (currenttime - previoustime) / 1000.0; system.out.println("time in seconds : " + elapsedtime); previoustime = currenttime;

multithreading - Lightweight parallel Clojure for loop on Incanter matrix? -

i have function uses for loop modify elements of matrix. element-wise function not huge, unsure best way deal this. want have 1 thread each core of machine (automatically detected) execute these. ideally, balance execution based on core workload. have looked creating custom thread pools receiving workers, not sure if work. pmap seems might useful, saw in thread coordination overhead signficant if every single operation future. thoughts how approach this? code below, links afterwards. (defn alter-matrix! [matrix] (let [row-count (nrow matrix) col-count (ncol matrix)] ; iterate through each element coordinates. (for [x (range row-count) y (range col-count)] ; calculate whether element altered. (let [event (rand)] ; 50% chance of alteration. (if (< event 0.50) ; unsafely set new element altered version. (.setquick matrix x y ; return altered form of element. (alter-element (.getquick matrix x y))))))))

android - OverlayItem looses focus when FragmentActivity Dismiss -

i have mapview overlay items in it. these overlay can tapped show fragmentactivity within mapview. problem when fragmentactivity has been dismissed, mapview returns focus current location. want return focus on tapped overlay item. how can done? answers highly appreciated. thanks this code have isn't working. final defaultitemizedoverlay overlay = new defaultitemizedoverlay(trafficprofilemarkeroverlay); final overlayitem overlayitem = new overlayitem(geopoint, "", ""); overlay.additem(overlayitem); overlay.settaplistener(new itemizedoverlay.overlaytaplistener() { @override public void ontap(geopoint pt, mapview mapview) { intent trafficprofileintent = new intent(getapplicationcontext(), trafficprofilepopupactivity.class); startactivity(trafficprofileintent);overlay.setfocus(overlayitem); } }); mapview.getoverlays().add(overlay);

javascript: fetch day of the week based on a specific date -

i searched stackoverflow did not find solution problem. i have specific date 2014-05-20 , want day of week mentioned date. i tried following var date = new date(); console.log(date.getday()); but return current day. require day based on given date! i tried var givendate = '2014-05-20'; new date(givendate) but above not generate anything. your question both code combine , check answer on without answer still show code, check demo jsfiddle javascript var givendate = '2014-05-20'; var date = new date(givendate); console.log(date.getday()); console log 2

php - All my links showing just home page, htaccess issue -

i unable visit page, menu link redirect me same home page. here htacess file, didn't understand after lot of googling even. kind regards options +followsymlinks rewriteengine on rewritebase / #redirect 301 /?action=main.cancel_newsletter http://www.mysite.us/cancel rewritecond %{query_string} ^action=main.cancel\_newsletter$ rewriterule ^/*$ http://www.mysite.us/cancel? [l,r=301] rewritecond %{query_string} ^action=main.market\_news$ rewriterule ^/*$ http://www.mysite.us/news? [l,r=301] rewritecond %{query_string} ^action=main.profiled\_companies$ rewriterule ^/*$ http://www.mysite.us/profiledcompanies? [l,r=301] rewritecond %{query_string} ^action=main.adregister$ rewriterule ^/*$ http://www.mysite.us/register? [l,r=301] rewritecond %{query_string} ^action=main.register$ rewriterule ^/*$ http://www.mysite.us/register? [l,r=301] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule .* /index.php [l] <ifmodule mod_security

json - wpf databinding to downloaded data -

i having bit of trouble understanding correct way following: the data binding exists on internet json file. on timer tick, download , using javascriptserializer, deserialize class. now, want bind data when deserialize, creates new class, binding breaks (meaning have set itemssource or datacontext again). does know way around this? thanks! what control trying bind data to? if can bind observable collection data source, need clear observable collection before fetching data, , add fetched record collection post deserialization. if not use observablecollection, can add public properties viewmodel , refresh when data back. ensure refresh happens becuase view bound public properties of view model , not aware of object returned call.

How to insert JSON values into MySQL using PHP for an API creation? -

i have following json values: [newcomposemail={"msg":"test mail","senderuserid":"1006","subject":"test","to":"10002"}, composemail] my query is: insert `push_msg_table`(`pid`, `subject`, `msg`, `sentuserid`, `sent_time`, `upload_path`, `status`) values() i need insert these values mysql table. new json. try use in php json_decode(newcomposeemail,true); adding true proper array else return object in php if there multiple entries in json , have loop through json array, in order insert multiple entries in db

c# - Using Double datatype for if Statement -

double similarity = matcher.match(features1, features2); if (similarity== ?? ) // sould write here { application.exit(); } if feature1 , feature2 matches application should exit please me since double floating point type compare double using tolerance , e.g. double tolerance = 0.001; // instead of features1 == features2 if (math.abs(features1 - features2) <= tolerance) { application.exit(); }

javascript - Validation Twitter Bootstrap with Django -

i using django , twitter bootstrap. using following code validation. add more validations. example if variable django false return 'owner not exist'. tried following not working. <script type="text/javascript"> var test = {msg_owner|safe} $(document).ready(function() { $('#frm').bootstrapvalidator({ message: 'this value not valid', feedbackicons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { 'owner': { validators: { notempty: { message: 'please enter owner' } test==false: { message: 'owner not exist' } } } }); }); </script> in server side

node.js - req param returns an empty array -

i using node.js , mongodb geolocation app , req param returns empty array exports.findpressure = function(req, res) { var queryobject = req.param('q'); console.log(queryobject); db.collection('pressure', function(err, collection) { collection.find( { loc: { $near :[ req.param('q') ] , $maxdistance : 5 }},{"value" : 1, _id : 0}) .sort({_id : -1}).limit(1).toarray(function(err, items) { res.send(items); }); }); }; the longitude , latitude values displayed in console listening on port 3000... connected 'weather' database 8.9068256,52.019347499999995 /pressure?q=8.9068256,52.019347499999995 200 27ms - 2b the url follows http://localhost:3000/pressure?q=8.9068256,52.019347499999995 if use values 8.9068256,52.019347499999995 getting value database if use req.param('q') returning empty array you seem passing values part of query string. req.query.q should contain comma-s

c# - Parsing Tab delimited text files -

i have tab delimited file columns , rows example: rows might not have value columns. know "order" doesn't change third tab delimited thing column3 , on. column1 column2 column3 .... column12 .... column34 ... column50 123 34 abc 234 def as@ddd.com true 45 nyc wwe@dsds.com false now need read file not of columns important program. example need stuff values in column2, column12,column45 what approach suggest? try following approach static void main(string[] args) { datatable datatable = new datatable(); streamreader streamreader = new streamreader(@"c:\temp\txt.txt"); char[] delimiter = new char[] { '\t' }; string[] columnheaders = streamreader.readline().split(delimiter); foreach (string columnheader in columnheaders) { datatable.columns.add(columnheader); // i've added column headers here. } while (

javascript - Js RegExp split every other line -

i'm new @ using regex , can't figure out how this. i have grouped data separated every other line, so: liste #1 val 1; val2; val3 liste #2 ... and output should : array( "liste #1 val 1; val2; val3", "liste #2 val 1; val2; val3" ) how acheive this? i split result again, forming structure : array(0 => ['title' =>, 'values' => array()]) assumed require 3 splits. why use regex, read 2 lines @ time? var lines = data.split('\n'); (var = 0; < lines.length ; = + 2) { var myarray = []; myarray.push(lines[i]); //this doesn't strip '\n' myarray.push(lines[i+1]); //this doesn't strip '\n' }

HTML/CSS Menu Active Link Background Not Aligned -

i have html menu uses class show page active within website. <div id="menu"> <ul> <li class="activelink"><a href="index.html">home</a></li> <li><a href="early.html">growing , school</a></li> <li><a href="career.html">films</a></li> <li><a href="jamesbond.html">james bond</a></li> <li><a href="gallery.html">pictures</a></li> </ul> </div> when i've been designing menu, have used firefox preview local files , looked fine. however, when viewed menu in chrome , ie, background shows menu item active out of line vertically within menu. please see http://jsfiddle.net/c9mzg/ in fact, when i've copied code jsfiddle , viewed in firefox, same problem chrome , ie shows reason, menu on local file still looks absolutely fin

php - Laravel update controller with many inputs -

i have resource , i'm trying set update controller. in case edit form has many inputs , need update database them there might columns in database not changed edit form. have controller this: public function update($id) { $hostess = hostess::find($id); $inputs=input::all(); foreach ($inputs $key => $value) { $hostess->$key= $value; } if ($hostess->save()) { return redirect::route('hostesses.show', $hostess->id); } return redirect::back()->withinput()->witherrors($hostess->geterrors()); } this gives me error because using put in view , column not found: 1054 unknown column '_method' in 'field list' because input::all() getting hidden inputs put method. can use input::except() that, proper way of updating laravel? you can this: $hostess = hostess::find($id) $post_data = input::all(); // or $post_data = input::except('_method'); // warning untested if bl

html - MySQL database to .TXT using PHP -

i have form in html5 , on submit runs php script connects mysql database, insert table , write down lines in table .txt file. for reason gives following warnings: 1 record added warning: fopen(c:/xampp2/htdocs/bap000/opdr002_config.txt): failed open stream: no error in c:\xampp2\htdocs\bap000\opdr002_input.php on line 25 warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp2\htdocs\bap000\opdr002_input.php on line 28 warning: fclose() expects parameter 1 resource, boolean given in c:\xampp2\htdocs\bap000\opdr002_input.php on line 33 the form: <html> <head> <title>bap les</title> </head> <body> <form name="formone" method="post" action="opdr002_input.php"> color: <select name="color"> <option value="blue">blue</option> <option value="red">red</option> </select> <br /> x: <input type="nu

python 3.x - redis-py and hgetall behavior -

i played around flask microframework, , wanted cache stats in redis. let's have dict: mydict = {} mydict["test"] = "test11" i saved redis with redis.hmset("test:key", mydict) however after restore stored = redis.hgetall("test:key") print(str(stored)) i see weird {b'test': b'test11'} stored.get("test") gives me none mydict str method result looks fine {'test': 'test11'} . so, why binary marker added restored data? checked in redis-cli , don't see explicit b markers there. wrong hgetall? this intended behavior. default, strings coming out of redis don't decoded. have couple options: decode data yourself. create client instance decode_responses argument, e.g., strictredis(decode_responses=true) . decode strings come redis based on charset argument (which defaults utf-8). you're sure every response redis has string data want decoded utf-8.

android - Corona SDK - Create Health Bar with different HP value -

i have rectangle image use health bar fill. health goes down, width of bar decreases until 0. part of code works fine, bar's width goes down , stays in same x position width being changed. my problem when create monster different hp value, different width of health bar. how can create same size rectangle different hp value? thank much. -- create health bar monsterbar = display.newrect( 20, 160, 26, 10 ) monsterbar:setreferencepoint(display.bottomleftreferencepoint) monsterbar:setfillcolor( 80,150, 0 ) -- monster hit monsterbar.width = monsterbar.width - scorehud.text monsterbar:setreferencepoint(display.bottomleftreferencepoint) you need use percentile intermediate value, can use in progress bar. for example, compute monster health percent that, making sure hp current <= hp max: local nmonsterhppercentile = (nmonsterhpcurrent / nmonsterhpmax) * 100 once have percentile value, adapt rectangle created max size of "100" example (or 200, 300 etc

c - char * to ASN1_INTEGER -

for pki certificate generation , , setting serial number , used rand_bytes 20 bytes of random serial number, wanted char * set serial number of certificate , seems of type asn1_integer * tried asn1_type_set_octetstring(asn1_type *, unsigned char *, len) since takes asn1_type * , not asn1_integer* gave crash how convert between unsigned char * asn1_integer ? thanks, i'm sure you're looking for, wrong. if want have 20-byte asn1_integer 1 way sending through bignum library first : unsigned char data[20] = {0}; rand_bytes(data, sizeof(data)); data[0] &= 0x7f; // build big number our bytes bignum* bn = bn_new(); bn_bin2bn(data, sizeof(data), bn); // build asn1_integer our bignum asn1_integer* asnint = asn1_integer_new(); bn_to_asn1_integer(bn, asnint); // todo: use asn1_integer // cleanup asn1_integer_free(asnint); bn_free(bn);

php - Looping through the arrays -

this original code [width] => array ( [0] => 400px [1] => 323a ) [height] => array ( [0] => 244px [1] => 244px ) [captions] => array ( [0] => [{ "captionid": 1,"caption": "learning clock face fun - learn importance of time.","xycordinates": "40px-250px","dimension": "70%-20%"},{"captionid": 2,"caption": "12 or 12 pm","xycordinates": "40px-250px","dimension": "70%-20%"}] [1] => [{ "captionid": 1,"caption": "learning clock face fun - learn importance of time.","xycordinates": "40px-250px","dimension": "70%-20%"},{"captionid": 2,"caption": "12 or 12 pm","xycordinates": "40px-250px&q

java - -accountId cannot be resolved or is not a field -

i can't figure out what's problem method, have arraylist named accounts i'm trying implement other class' method. i'm getting errormessage: "multiple markers @ line -accountid cannot resolved or not field -accountid cannot resolved or not field" why doesn't work? public boolean deposit(long pnr, int accountid, double amount){ for(int = 0; < customerlist.size(); i++) { if(this.pnr == pnr) { for(int j = 0; j < accounts.size(); j++) { if(accountid == accounts.accountid)//problem seem here { balance = balance + amount; } } } else return false; } return true; } accounts seems list, should try access field of item of list instead of accessing item of list itself. if(accountid == accounts.get(j).accountid

sql - MySQL Query help - Grouping and count problems -

i have mysql database trying specific count of data catch. best way explain showing you. i have table has username , id_no, id not going unique there circumstances show duplication of (which expected), table might this username id_no user1 1111111 user1 1111111 user1 1111111 user1 1111111 user1 2222222 user1 3333333 user1 3333333 user1 444444 user1 444444 user1 444444 user1 555555 user1 666666 i need unique count of piece of cake select username, count(distinct id_no) cases group username that gives me count of 6. gets interesting need join table add category table might username cat id_no user1 category1 1111111 user1 category2 1111111 user1 category2 1111111 user1 category2 1111111 user1 category5 2222222 user1 category6 3333333 user1 category7 3333333 user1 category8 444444 user1 category8 444444 user1 category8 444444 user1 category11 555555 user1 category12 666666 with need unqu

php - How to add a class to Composer for autoloading? -

i have class called class.feed.php , how include composer such when 'vendor/autoload.php' included or required in example index.php , class included? note, still php newbie. here's example of using composer. { "autoload": { "psr-0": {"appname": "src/"} } } set structure follows: src/ - appname/ vendor/ composer.json index.php place classes inside appname folder, use namespace class relative src folder. classes should have same filename class name starting capital, example class called demo in appname: <?php namespace appname; class demo { public function __construct(){ echo 'hi'; } } then in root create index.php include autoload vendor once composer has been installed. to use class call namespace followed class name <?php require('vendor/autoload.php'); $demo = new \appname\demo();

javascript - Destroying object -

there nice rich text editor scribe . in app have multiple editable divs on page, , on every focus event on particular div want turn div editable mode scribe. on blur event destroy instance of scribe, due fact having seperate instance every div high memory consuming. this amd module attaches scribe instance given dom element: define(['scribe'], function (scribe) { 'use strict'; function init(element) { var scribe = new scribe(element, { allowblockelements: true }); //... } return { attacheditor: init }; }); this piece of code makes use of module above: $('.editable').focus(function(e) { editormodule.attacheditor(e.target); }); and can't figure out how detach or destroy existing scribe instance. tried code: define(['scribe'], function (scribe) { 'use strict'; var scribe; function init(element) { scribe = new scribe(element, { allowblockelements: true });

java - Short filename causing issues with two otherwise identical Paths -

i used files.createtempfile("hello", "txt"); to create temporary file , stored returned path . i have eclipse ifile resource linked temporary file created: linkedfile.createlink(tempfile.touri(), iresource.none, null); if want path resource, call linkedfile.getlocation().tofile().topath() on local machine, works 100% fine. on remote test machine, 2 different paths: from files.createtempfile: c:\users\userna~1\appdata\local\temp\hello3606197456871226795txt from getlocation().tofile().topath() c:\users\username_testing\appdata\local\temp\hello3606197456871226795txt the folder username_testing , folder gets turned short filename, , direct creation of temporary. these 2 paths not considered equal path.equals(...) , causing failing of tests on remote machine. in general, makes me bit nervous using path.equals(...) though in actual real operation of application haven't had issues yet. there way can force system always use long filena

enthought - quit() function not working in Canopy, but works using terminal -

i'm learning python online @ moment , using (macos) canopy install of python. lesson how use quit() function try except. error in canopy: ---> 11 quit() 13 print 'your number is:', number nameerror: name 'quit' not defined ----------------- here code: try: inpt = raw_input('enter number: ') number = float(inpt) except: print 'error, please enter numeric number' quit() print 'your number is:', number all code print out number if put in that's not number, says 'error, please enter numeric number', instead of throwing error. same code works fine using terminal. i'm wondering, should using canopy or missing something? thanks canopy's python shell ipython's qtconsole. ipython has taken scientific python world storm in recent years power , convenience, , in respects proper superset of standard python, few of small convenience changes can confusing beginners. quit 1 of sma

powershell - Confirming an IP before starting an executable in winxp32 -

windows question y'all. have powershell v1.0 , that's making more difficult, first foray powershell. i'm linux/osx guy. to make matters worse on managed system, if didn't come winxp base install can't install it. i need basic while loop pings server1, , once has successful ping start task.exe all can find on technet , othe ms sites , web @ large powershell v3 or v4. sorry noob :( i don't remember v1 , wouldn't support anymore, , don't have system can test on think should work: do { $result = ping server1 } until ( $result -match 'received = [1-4]' ) & task.exe

javascript - Ajax call of php function does not send json array -

this javascript calls php function through ajax json datatype. data returned php should json array 3 items: html, todays_events, debug_text. on linux json returned isn't array. last item, debug_text returned, response['html'] null. this ajax call. $.ajax({ url: "get_events.php", type: "post", data: { user_id: user_id, todays_only: todays_only }, datatype: 'json', cache: false, async: false, success: function (response) { if (response != '') { if ( trim(response["html"]) != "" ) { var scroll_5_html = response["html"]; $("#scroll_5").html(scroll_5_html); } else { var filter_select = document.getelementbyid("filter_today").checked; if ( filter_select == true ) { noevents_text += "<br/>for today"; }

weblogic - SSL debug tracing may be required to determine the exact reason the certificate was rejected -

found below error in logs after starting weblogic. how solve issue? nothing have deployed here, new environment have installed recently. error message: apr 23, 2014 10:40:37 pm utc warning security bea-090482 bad_certificate alert received mt-dcs2-admin.com - 60.5.100.20. check peer determine why rejected certificate chain (trusted ca configuration, hostname verification). ssl debug tracing may required determine exact reason certificate rejected. enter code here < as error says, try enable debug mode see cause of problem. try this: http://docs.oracle.com/cd/e23943_01/web.1111/e13707/ssl.htm#autoid12 -dssl.debug=true -dweblogic.stdoutdebugenabled=true edit (first comment): you must add these arguments start of weblogic. depending on how run server, you'll have edit run script file. the standard startup script named startweblogic.cmd if you're running windows , startweblogic.sh if you're running unix (weblogic8). contents of windows , unix s

php - Get Last row value and N row value before last row -

how read , echo n rows before last row in text file using php? example in file.txt test1 test2 test3 test4 test5 test6 test7 i want last row value , 3 row before last row. result : test4 test7 here code far (just show last row) $line = ''; $f = fopen('\\\\192.168.183.28\\wk$\\sbin\\file.txt', 'r'); $cursor = -1; fseek($f, $cursor, seek_end); $char = fgetc($f); while ($char === "\n" || $char === "\r") { fseek($f, $cursor--, seek_end); $char = fgetc($f); } while ($char !== false && $char !== "\n" && $char !== "\r") { $line = $char . $line; fseek($f, $cursor--, seek_end); $char = fgetc($f); } $future_sn = substr($line, 28, 36); any advice? try $array = explode("\n", file_get_contents

php - array to string conversion return error of stdClass -

if($stmt->execute()){ $user = $stmt->get_result(); while ($obj = $user->fetch_object()) { $result[] = $obj; } } $result1encoded = json_encode($result); echo $result1encoded; // [{"uid":"1","firstname":"john"}] i used implode : echo $result1encoded = implode(' ',$result1); // expecting '[{"uid":"1","firstname":"john"}]' but says object of class stdclass not converted string you can use array_map("json_encode", $your_array) first convert each element of array string, , use implode glue together. see https://eval.in/141541 <?php $a = array(); $a[0] = new stdclass(); $a[0]->uid = "1"; $a[0]->firstname = "john"; $a[1] = new stdclass(); $a[1]->uid = "2"; $a[1]->firstname = "albert"; $b = array_map("json_encode", $a); echo implode(&#

java - What is JBPM? Why use it? -

i java developer. develop new application framework. in application going integrate jbpm, spring , hibernate also. so please, answer below questions, what jbpm? why use it? what workflow engine? please give example. thanks answer. quoting wikipedia : jbpm open-source workflow engine written in java can execute business processes described in bpmn 2.0 (or own process definition language jpdl in earlier versions). released under asl (or lgpl in earlier versions) jboss community. for complete information can check this out. quoting wikipedia : a workflow engine software application defines process, rules governing process decisions, , routes information. key component in workflow technology , typically makes use of database server. the relationship: jbpm flexible, extensible workflow management system. business processes , expressed in simple , powerfull language , packaged in process archives, serve input jbpm runtime server. jbpm bridges gap

cocoa - How to prevent logout from app running as agent -

the sample menu bar app agent lsuielement true. want prevent logout on conditions. i tried - (nsapplicationterminatereply)applicationshouldterminate:(nsapplication *)sender. never receive message when user logs out. but without , able prevent logout well. need alternative solution prevent logout. do not use lsuielement in plist. instead on launch use: [nsapp setactivationpolicy:nsapplicationactivationpolicyaccessory]; i verified applicationshouldterminate: in fact called when done way.

gwt - Multiple Click handlers -

i have different 3 different buttons different onclick events : add.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { add(); } }); set.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { set(); } }); get.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { get(); } }); so if extend 10 buttons script far long, there way pass methode or seperate handlers? suppose have view: customview.ui.xml <g:verticalpanel> <style:button ui:field="addbutton" text="add"/> <style:button ui:field="setbutton" text="set"/> <style:button ui:field="getbutton" tex