Posts

Showing posts from February, 2010

javascript - What should be the timeout for window resize dragging? -

i have code fires when user has stopped resizing window (by dragging). uses 100ms timeout not fire @ every single window resize event. i'd find balance between swiftness , unnecessary runs of code heavy. user experience standpoint, how many ms should set to? var resizeto = false; $(window).resize(function(){ if(resizeto !== false){ cleartimeout(resizeto); } resizeto = settimeout(function(){ // code }, 100); });

utf 8 - How to convert windows-1256 to utf-8 in lua? -

i need convert arabic text windows-1256 utf-8 how can that? help? thanks try lua-iconv , binds iconv lua.

iOS6 XCode4.6.2 Passing Row Number via a Segue -

if pass data via seque view controller, e.g. - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([segue.identifier isequaltostring:@"mysequeidentifier"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; recipientviewcontroller *destviewcontroller = segue.destinationviewcontroller; destviewcontroller.intpassedrow = indexpath.row; } } this passes correct row number but... i error saying "incompatible integer pointer conversion assigning 'int' 'int'." if both ints have done wrong?

xml - Data at the root level is invalid. Line 2, position 12 -

i trying create .xml file in isolatedstorage , updating when try read file getting xmlexception. here code using (isolatedstoragefile isostore = isolatedstoragefile.getuserstoreforapplication()) { xmlwritersettings settings = new xmlwritersettings(); settings.indent = true; try { isolatedstoragefilestream isofilestream = isostore.openfile("favourites.xml", filemode.open, fileaccess.readwrite); using (xmlwriter writer = xmlwriter.create(isofilestream, settings)) { xdocument doc = xdocument.load(isofilestream); doc.root.add( new xelement("recipe", new xattribute("id", thisrecipe.recipeid), new xattribute("title", thisrecipe.title), new xattribute("youtubeid", thisrecipe.youtubei

Get xml attribute in PHP -

i want know temperature city using yahoo wheater (xml), xpath , php. code use doesn't work. can element (description) not attribute (temperature) want. $xml = new domdocument(); $xml->load("http://weather.yahooapis.com/forecastrss?w=12818432&u=c"); $xpath = new domxpath($xml); $result = $xpath->query("//channel"); foreach ($result $value) { //$weather = $value->getelementsbytagname("description"); $weather = $value->getelementsbytagname("yweather:wind"); $temp = $weather->getattribute("chill"); print $temp->item(0)->textcontent; } you should use getelementsbytagnamens() elements within namespace. $ns_yweather = "http://xml.weather.yahoo.com/ns/rss/1.0"; $weer = $value->getelementsbytagnamens($ns_yweather, "wind")->item(0); print $weer->getattribute("chill");

Draw faster circles with Python turtle -

i have exercise wherein have draw lot of circles python turtle. have set speed(0) , using: from turtle import* speed(0) i=0 while < 360: forward(1) left(1) i+=1 to draw circles. takes long. there faster way? you draw fewer segments, rather 360 go 120: while < 360: forward(3) left(3) i+=3 that make circle less smooth, 3 times faster draw.

HTTP Status 500 - java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl -

this question has answer here: how import javax.servlet api in eclipse project? 12 answers when try browse "localhost:8080" on myeclipse, following error: type exception report message java.lang.noclassdeffounderror: not initialize class org.apache.jasper.el.elcontextimpl description server encountered internal error prevented fulfilling request. exception javax.servlet.servletexception: java.lang.noclassdeffounderror: not initialize class org.apache.jasper.el.elcontextimpl org.apache.jasper.servlet.jspservlet.service(jspservlet.java:343) javax.servlet.http.httpservlet.service(httpservlet.java:728) root cause java.lang.noclassdeffounderror: not initialize class org.apache.jasper.el.elcontextimpl org.apache.jasper.compiler.validator$validatevisitor.prepareexpression(validator.java:1568) org.apache.jasper.compiler.validator$validate

javascript - How to display an image when pressing a button in html? -

i thought doing have worked, i'm confused why isn't when style hiding image begin with, not showing when button pressed. here's code: function showimg() { x=document.getelementbyid("map_img") x.style.visibility="visible"; } <body> <img id="map_img" src="map.jpg" style="visibility:hidden" width="400" height="400"/> <form id="form1" name="form1" align="center"> <input type="submit" id="map" value="map" onclick="showimg()"/> </form> i've tried in both situations: <input type=button id="map" value="map" onclick="showimg()"/> and: <style> .hidden{display:none;} .show{display:block;} </style> function showimg() { x=document.getelementbyid("map_img") x.class="show"; } <body>

coffeescript - jQuery cycle.all.js first slide timeout -

i'm using cycle.all.js jquery plugin ( http://jquery.malsup.com/cycle/ ). right it's working fine, need first image have shorter timeout rest. when user first hovers mouse on slideshow-div cycle begins immediately, after first slide changes timeout 650. how code looks right now: $('div#slideshow').mouseenter(-> $(this).cycle fx: "fade", speed: 1 timeout: 650 ).mouseleave -> $(this).cycle 'stop' you can delay option , give negative value: $(this).cycle fx: "fade", speed: 1 timeout: 650 delay: -650 ) note causes go immediately second slide, think want, since first image of slideshow visible before user hovers on it. as benjamin pointed out, in coffeescript can use @ shortcut this : $('div#slideshow').mouseenter(-> $(@).cycle fx: "fade", speed: 1, timeout: 650, delay: -650 //go next slide ).mouseleave -> $(@).cycle 'stop'

php - how do i prevent mySql injection -

this question has answer here: how can prevent sql injection in php? 28 answers i need know how prevent our database sql injection, read many blog , answer on internet not justify way should prefer or best. mysql: mysqli: mysql_real_escape_string. or using using pdo: i know if user inserting in database becomes vulnerable sql injection, , use code insertion: <?php $con=mysql_connect("localhost","root",""); $db=mysql_select_db("test",$con); $foo=$_post['foo']; $boo=$_post['boo']; $insert="insert table set foo='$foo',boo='$boo'"; so should prevent database injection..... idea appreciated highly.. thanx in advance if know below code, well, translating pdo like: from sql code: <?php $con=mysql_connect("localhost","root",""); $db

windows runtime - How to await a method in a Linq query -

trying use await keyword in linq query , this: the 'await' operator may used in query expression within first collection expression of initial 'from' clause or within collection expression of 'join' clause sample code: var data = (from id in ids let d = await loaddataasync(id) select d); is not possible await in linq query, or need structured different way? linq has limited support async / await . linq-to-objects, useful operation know of select async delegate (which results in sequence of tasks). list<t> data = new list<t>(); foreach (var id in ids) data.add(await loaddataasync(id)); if can loaddataasync in parallel safely, example rewritten as: t[] data = await task.whenall(ids.select(id => loaddataasync(id)));

c# - Filtering a string array when elements represented (partially) in an other array of strings -

i'm reconstructing following statement. ienumerable<string> input = ..., filter = ..., output = input.where(filter.contains(element)); for now, works supposed words matched way need exact. in language of customer there lot of conjugations , requirement posted use joker characters ("dog" should match "dog", "doggy" , "dogmatic"). i've suggested following change. sure, though, if can regarded smooth eyes. can suggest improvement or gets? ienumerable<string> input = ..., filter = ..., output = input.where(word => filter.any(head => word.startswith(head))) i considering iequalitycomparer implementation that's objects of same type, while condition on string contra ienumerable . generally, have linq statement fine , don't see big issue being "smooth on eyes" (linq calls can more out of hand this). if want, move filter.any(head => word.startswith(head)) separate fun

c++ - Compare two strings (but different types of) -

in c++ program, need compare if 2 strings equals or not : taglib::string artist1 = f.tag()->artist(); (see http://taglib.github.io/api/classtaglib_1_1string.html ) and argv[2] (which comes int main(int argc, char *argv[]) ). i tried lots of ways it, don't succeed : artist1 != argv[2] doesn't work, strcmp(artist1,argv[2]) doesn't work well, etc. thanks in advance. you try this: artist1.to8bit() != argv[2] according documentation, function to8bit() should return object of type std::string() , overload of operator != accepting const char* available. just make sure include appropriate header before: #include <string> // <== need work std::string

jquery - Twitter Bootstrap carousel and navigation -

i use twitter bootstrap carousel on website in full screen: web site link in bottom menu, click on "architecture & habitat" arrows appear navigate through slides. my links in form: <a id="projet-citizen" class="" data-interval="5000" data-slide-to="25" href="#mycarousel"> ... </ a> access each slide works against fade effect stops often, if want go previous slide. have ever had problem? did miss something? twitter bootstrap carousel have no built-in javascript/jquery effects transitions; done using css transitions. to handle transition have set in css: .carousel .active.right {left: 0, opacity: 0, z-index: 2;} other relevant question: can twitter bootstrap carousel plugin fade in , out on slide transition

jquery - "hasClass" synonym in rails -

in app need check if span id="transaction_sign" has class negative , if - add "minus" number, user has entered in field , save in negative form database. in fact, if using jquery , rails need this: def add_sign_to_transaction if $('#transaction_sign').hasclass('negative') { @transaction.amount *= -1 }; end but, of course can't in in transaction_controller.rb file, need put def before_filter . is there way check css on page in rails? or maybe need gems it? your form should send either: transformed data in first place, or enough additional data transformations on server side. view-layer representations brittle substitutes appropriate models. the technical answer question no, unless view layer altered server-side code , not js. if client alters style(s) should either send right data or flag. flag could, of course, hidden field set style of form element, or boolean triggered presence of given style

javascript - Are WinJS/Metro Apps single threaded? -

i read in windows 8 development tutorial metro apps written using html/javascript runs on single thread. if so, how executes asynchronous functions in winrt? yes, javascript engine indeed single-threaded. calls api native code though , such can - , - open separate threads. see this msdn article thorough explanation of underlying mechanics recommendations on how deal in code. winjs promise internally uses setimmediate allow rendering , message loop take on between multiple javascript functions , - important side-effect - shorten callstack.

how to properly escape data with javascript for query string for decoding in PHP -

this question has answer here: get php stop replacing '.' characters in $_get or $_post arrays? 14 answers i'm trying create query string, passes form elements , entered data via request php file. i'm using encodeuricomponent in javascript encode input field names field values. what i'm encountering field values seem passed receive them in $ get correctly, field names have dot (.) replaced underscore ( ). example: <input type="text" name="form.0.text.0" value="" /> this field.name arrive @ php script form_0_text_0 instead of form.0.text.0 , while entered text (e.g. this contains lot of .... ) arrive fine. i'm using following code part of query string generation: + encodeuricomponent(field.name) + "=" + (field.type == "checkbox" ? (field.checked) : encodeuricomponent(field.

javascript - AJAX list update, get new elements and count -

i have html list <ul id='usernamelist'> <li class='username'>john</li> <li class='username'>mark</li> </ul> and form add new names via ajax, multiple add separated commas. response list names [{name:david, newuser:yes}, {name:sara, newuser:yes}, {name:mark, newuser:no}] i'm trying insert names sorted alphabetically in list, example http://jsfiddle.net/vqu3s/7/ this ajax submit var form = $('#formusername'); form.submit(function () { $.ajax({ type: form.attr('method'), url: form.attr('action'), data: form.serialize(), datatype: "json", beforesend: function () { // }, success: function (data) { var listusernames = $('#usernamelist'); var numusernames = listusernames.children().length; $.each(data, function(i, user) { if(user.newuser == "yes"){ var htmluser = &q

powershell - winform displaying in classic view outside of ISE -

not sure causing issue have powershell script uses windows forms ui. when developing inside of powershell ise looked nice modern style buttons. when run powershell displays in windows classic style view , crashes when make call new-object system.windows.forms.savefiledialog . there fix can add code script not looks better functions outside of ise? edit: function call savefiledialog . works inside of ise when run script powershell crashes when call this. function exporttocsv([system.object[]] $exparray) { $save = new-object system.windows.forms.savefiledialog $save.createprompt = $false $save.supportmultidottedextensions = $true $save.defaultext = "csv" $save.filter = "csv (*.csv) | *.csv*" $save.title = "export csv" if ($save.showdialog() -eq "ok") { $exparray | export-csv $save.filename } } include following command in script before showing form modern style appearance. [system.windo

perl - Reading multi-line records -

given code data file content of each data records, i'm unable print first line of each record. however, print first line of first record in: 1aaaaaaaaaaaaa special note: i'm sure there many ways this, in case, need solution follows code question.... data file content of records 1aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa __data__ 1bbbbbbbbbb bbbbbbbbbbb bbbbbbbbbbb __data__ 1cccccccccc ccccccccccc ccccccccccc __data__ { local $/="__data__\n"; open $fh,"<","loga.txt" or die "unable open file"; while(<$fh>) { # remove input record separator value of __data__\n chomp; # display line of each record if(/([^\n]*)\n(.*)/sm) { print "$1\n"; } } close ($fh); } i undesirable output of: [root@yeti]# perl test2.pl 1aaaaaaaaaaaaa [root@yeti]# i need output of first

css - Expanding nested container to page width -

i have div fixed width of 960px , nested containers no specific width stretches parent container. possible, without removing outer container, stretch inner container full page width, in same time, content should wide outer container. a little example: +------------------------------------------------+ | browser window (100%) | | | | +-----------------------------------+ | | | (a) inner container (960px) | | | | | | |*****|***********************************|******| | | (b) | | | | | | | | should stretch 100% of | | | | body , have inner width of | | | | of 960px (or same | | | | closest parent) | | | | | | |*****|***********************

sorting - Change default position of product in categories from 1 to product ID in Magento 1.7.0.2 -

in magento 1.7.0.2, adding lot of products backend positions of these new items in corresponding categories 0 or 1. when sorting on frontend, arbitrary sorting postion. i set position of these items in categories equal product_id directly on database (table catalog_category_product), , sorting works correctly. solution set position of product in category equal product_id in code, don't know , how that. any help? many thanks ok function _savecategories in class mage_catalog_model_resource_product appears looking for. have around call insertmultiple. take in $data array containing category_id, product_id , position (which oddly set 1) i think @ point can make edit. though suggest rewrite class rather editing core code.

JFrame Picture in NetBeans as Background -

i'm done coding program i'm having difficult time adding picture jframe (i've done in code without using graphic interface jpanel. at moment i'm trying this, keeps giving me errors , wont display picture. (javaoskartid package, hourglassone.jpeg intended picture) thank response! url urltoimage = this.getclass().getresource("javaoskartid/hourglassone.jpeg"); imageicon icon = new imageicon(urltoimage);

javascript - TinyMCE limit characters typed by users -

i googled lot limiting characters in tinymce nothing working! how create message box if users type more 500 characters? got it! new version uses ed.on("keydown", function(ed,evt) { instead of ed.onkeydown.add(function(ed, evt) { so function becomes: setup : function(ed) { var max_tekens = <?php echo $max_aantal_tekens_excl_opmaak; ?>; var beschikbaar_voor_opmaak = <?php echo ($max_aantal_tekens_incl_opmaak - $max_aantal_tekens_excl_opmaak); ?>; ed.on("keydown", function(ed,evt) { aantal_tekens_zonder_opmaak = tinymce.activeeditor.getcontent().replace(/(< ([^>]+)>)/ig,"").length; aantal_tekens_met_opmaak = tinymce.activeeditor.getcontent().length; var key = ed.keycode; $('#omschrijving_wijzigen_tekens').html(max_tekens - aantal_tekens_zonder_opmaa

c# 4.0 - Self Hosted Web API Authentication -

i have self hosted web api running, using dotnetopenauth issue authorization tokens. basically, project consists of 2 apicontroller endpoints (authorize , token). force client have log in form, prior being able call either endpoint. (forms authentication guess). however, doesn't seem works self hosted web api projects, so, trying implement myself. as of now, when user calls authorize web method, render login page , force them login. however, have mechanism in place once user logs in, can send cookie response. understand if write cookie in response, browser automatically send relevant cookies upon subsequent requests. however, test client uses httpwebrequest call web api. have build mechanism save response cookie file on hard disk, , then, read back, , associate httpwebrequest on subsequent requests? or , there built framework can leverage (just how browser automatically take care of me). i figured once figure part out, extend authorizationfilterattribute, , use c

cron - Where in Wordpress DB are stored wp_cron tasks? -

i looking in wp_options table there nothing eventhough have set cron tasks like: add_action('init', function() { if ( !wp_next_scheduled('my_awesome_cron_hook') ) { wp_schedule_event(time(), 'hourly', 'my_awesome_cron_hook'); } }); or stored in txt file in wordpress? it's stored in database inside wp_options under option_name cron . you can array with: _get_cron_array() or get_option('cron') . see: http://core.trac.wordpress.org/browser/trunk/wp-includes/cron.php

pcap - Traceroute and packet capture -

the following code required capture route taken packet moves local router destination router. should print intermediate routers , ip addresses. code given below. output doesn't list ip addresses. shows 1 router's ip. how can modify code shows intermediate ip addresses? please me out. thank you! input format : ./a.out (destination ip) (port no) (max_ttl) (max_probe) the output got this: ./a.out 68.71.216.176 80 10 2 tracing 68.71.216.176 max_ttl 10 on port 80 2 probes 1>192.168.1.1:80.....192.168.1.3:35410------------------->time-to-live exceeded: time-to-live exceeded on transit 1>192.168.1.1:80.....192.168.1.3:35410------------------->time-to-live exceeded: time-to-live exceeded on transit 2>192.168.1.1:80.....192.168.1.3:35410------------------->time-to-live exceeded: time-to-live exceeded on transit 2>192.168.1.1:80.....192.168.1.3:35410------------------->time-to-live exceeded: time-to-live exceeded on transit 3>192.168.1.1:80.

javascript - How can I get this HTML5 Canvas paint application to work for both touch and mouse events? -

here source code of i'm trying do: http://jsfiddle.net/3ngtm/ javascript: window.addeventlistener('load', function () { // canvas element , context var canvas = document.getelementbyid('sketchpad'); var context = canvas.getcontext('2d'); // create drawer tracks touch movements var drawer = { isdrawing: false, touchstart: function (coors) { context.beginpath(); context.moveto(coors.x, coors.y); this.isdrawing = true; }, touchmove: function (coors) { if (this.isdrawing) { context.lineto(coors.x, coors.y); context.stroke(); } }, touchend: function (coors) { if (this.isdrawing) { this.touchmove(coors); this.isdrawing = false; } } }; // create function pass touch events , coordinates drawer function draw(event) {

ruby on rails - Failing to push to heroku -

i attempting push rails 3.2.12 app heroku, configured postgres database. first time ran git push heroku master received below error. running: rake assets:precompile rake aborted! not connect server: connection refused server running on host "127.0.0.1" , accepting tcp/ip connections on port 5432? after troubleshooting came across this post , put following line in config/application.rb file: config.assets.initialize_on_precompile = false i ran heroku run rake db:migrate begin populating heroku database , received following error: running rake db:create attached terminal... up, run.4115 rake aborted! undefined local variable or method `config' main:object /app/config/application.rb:5:in `<top (required)>' /app/rakefile:5:in `require' /app/rakefile:5:in `<top (required)>' funny enough, line 5 of application.rb previous line added: config.assets.initialize_on_precompile = false lastly, noticed can't start database locally ab

rake db:seed error for Rails app using MongoDB, sunspot_solr -

i working on ruby on rails application uses mongodb, , have implemented basic sunspot functionality. here information environment rails 3.2.11 mongo 2.4.3 sunspot 2.0.0 gem mongo_mapper gem sunspot_rails gem sunspot_solr gem sunspot_mongo_mapper i had working, having problems. can run bundle exec rake sunspot:solr:start when try bundle exec rake db:seed i following error: rake aborted! rsolr::error::invalidrubyresponse - 200 ok error: <result status="1">java.lang.nullpointerexception @ org.apache.solr.handler.xmlupdaterequesthandler.dolegacyupdate(xmlupdaterequesthandler.java:129) @ org.apache.solr.servlet.solrupdateservlet.dopost(solrupdateservlet.java:87) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ javax.servlet.http.httpservlet.service(httpservlet.java:820) @ org.mortbay.jetty.servlet.servletholder.handle(servletholder.java:511) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(se

How can I see cucumber table differences with the progress formatter? -

in cucumber, when table steps fail, see following error plus stack trace, there no actual information given table differences. tables not identical (cucumber::ast::table::different) how can cucumber show me table differences? i found following monkey patch worked on cucumber 1.1.9 create support file eg features/support/progress_formatter_extensions.rb require 'cucumber/formatter/progress' module cucumber module formatter class progress def exception(exception, status) @exception_raised = true if exception.kind_of?(cucumber::ast::table::different) @io.puts(exception.table) @io.flush end end end end end

stream - C++: how do I create istream with desired content? -

i given function following signature. can't change it, have work it. void parse(std::istream & in); i'm supposed test function, call predefined content , check if values parsed. therefore need call function... parse("abcdedf....") ... wasn't able to find way how it. i'm new c++ may dumb question. far understand streams, istream when reading source, file example. need turn regular string source don't know how. use string stream : std::istringstream iss("abcdef...."); parse(iss); like std::ifstream , used reading in files, std::istringstream derives std::istream , can upcast std::istringstream & std::istream & pass in.

css - Creating custom scrollbar in IE -

i trying create custom scrollbar, managed work on chrome, opera, , firefox. however, struggling make work on ie. below code use ::-webkit-scrollbar { width: 0.50em; height: 2em ::-webkit-scrollbar-button { background: green; } ::-webkit-scrollbar-track-piece { background: blue; } ::-webkit-scrollbar-thumb { background: red; }​ you'd better off using 3rd party library (or @ least taking inspiration one), here examples http://learnboost.github.io/antiscroll/ http://charuru.github.io/lionbars/ http://jscrollpane.kelvinluck.com/

ios - How can I add a delay before it continues -

is there way in normal obj-c or cocos2d make delay inside if-else block? if ([self isvalidtilecoord:ctilecoord] && ![self iswallattilecoord:ctilecoord]) { [self addchild:circle0]; //wait 2 seconds //perform task } just simple lag wait between 2 tasks, or stalling action. there simple way this? you can use performselector: withobject: afterdelay: method delay tasks: if ([self isvalidtilecoord:ctilecoord] && ![self iswallattilecoord:ctilecoord]) { [self addchild:circle0]; //wait 2 seconds [self performselector:@selector(continuetask) withobject:nil afterdelay:2.0]; } and in selector method: -(void)continuetask { //perform task }

c# - Simple way to check how many rows I have in my database -

i'm connected database through sqlconnection class. there simple why check how many rows in database or have create sqldatareader , increment till last row in ? i assume "rows in database" means "rows in table" . you should use count , sqlcommand.executescalar : int rowcount = 0; using(var con = new sqlconnection(connectionsstring)) using (var cmd = new sqlcommand("select count(*) dbo.tablename", con)) { try { con.open(); rowcount = (int) cmd.executescalar(); } catch (exception ex) { // log exception or else useful, otherwise it's better to... throw; } }

javascript - Fitting element into table cell -

i trying fit canvas element table cell no padding @ all, i.e. want no margins between canvas , top/bottom of cell. therefore, define row height 20px , canvas height 20px. use padding:0px styling. however, no padding top , left , still padding @ bottom. in fact, looks table cell gets taller in order accommodate undesired margin. how can resolve it? also, difference between defining canvas width , height in html , css? 1 override other? below html code. thanks. <!doctype html> <html lang="en"> <html> <head> <meta charset="utf-8"> <title>experiment</title> <body> <script> $(function() { var canvas = document.getelementbyid('my_canvas'); var ctx = canvas.getcontext('2d'); ctx.fillrect(0,0,20,20); $("#my_table > tbody > tr:eq(0) > td:eq(0)").append($("#my_canvas")); }) </script> </head> <style media="screen&

How do I convert this piece of XML into a javascript collection? -

i'd convert xml looks this: <products> <product> <name>bill</name> <id>1</id> <age>19</age> </product> <product> <name>jim</name> <id>2</id> <age>23</age> </product> <product> <name>kathy</name> <id>3</id> <age>53</age> </product> </products> into format: name, id, age in collection like following: collection = [ 'bill-1-19', 'jim-2-23', 'kathy-3-53', ]; i think best way xslt stylesheet outputs right? use help, i've been trying figure out hours now. here have far: <!doctype html> <html> <body> <script> if (window.xmlhttprequest) { xhttp=new xmlhttprequest(); } else // ie 5/6 { xhttp=new activexobject("microsoft.xmlhttp"); } xhttp.open("get","after.xml",fal

jquery - unknown reason for broken javascript button -

i have been building portfolio site quite while now, , have made use of few simple scripts. recently, of these scripts have stopped working. for reference, here site: http://www.jcstudios.org the meta link on bottom left hand side of page supposed bring login form in place of navigation menu , toggle , forth clicked. however, javascript button has broken. noticed happened not long after installing prettyphoto plugin site. if case messing scripts, find fix plugin 1 of plugins able achieve looking for. ideas why script stopped working? here script, assure worked fine while before spontaneously breaking. $('.togglemeta').toggle(function(){ $('.togglemeta').text('site nav') $('#meta').css('display', 'block'); $('#sitenav').css('display', 'none'); },function(){ $('.togglemeta').text('meta') $('#meta').css('display', 'none'); $('#sitenav'

android - Make background cover all screen sizes -

i have code makes background picture cover whole screen, not content. works fine computer , iphone android picture doesn't stretch length wise cover whole screen vertically. code follows. css: body { background-image:url(background.png); border:none; background-size:100%; -webkit-background-size:100%; -moz-background-size:100%; -o-background-size:100%; background-attachment:fixed; background-repeat:repeat-x; } the image 5x500 pixels. if have better solution cover page background image let me know. background size can ggive problems sometimes. try adding min-height html try adding min-height: 100%; to body

Convert arithmetic string into double in Java -

i have program user inputs 6 doubles, , program outputs every combination of operators can go in-between doubles 1024 separate strings. here first 2 results if user inputed 14,17,200,1,5, , 118: "14.0+17.0+200.0+1.0+5.0+118.0" "14.0+17.0+200.0+1.0+5.0-118.0" what want perform arithmetic according order of operations. each double stored variable through f , each operator in-between these variables stored char a_b through e_f. so: double a, b, c, d, e, f; char a_b, b_c, c_d, d_e, e_f; my first thought write code this: public double operategroup() { value = 0; switch (a_b) { case '+': value += + b; break; case '-': value += - b; break; case '*': value += * b; break; case '/': value += / b; break; default: break; } switch (b_c) { case '+': value += c; break; case '-&

Haskell SDL-mixer compilation error -

i trying install sdl-mixer haskell package using "cabal install sdl-mixer". when so, gives error resolving dependencies... [1 of 1] compiling main ( /tmp/sdl-mixer-0.6.1-10381/sdl-mixer-0.6.1/setup.lhs, /tmp/sdl-mixer-0.6.1-10381/sdl-mixer-0.6.1/dist/setup/main.o ) linking /tmp/sdl-mixer-0.6.1-10381/sdl-mixer-0.6.1/dist/setup/setup ... configuring sdl-mixer-0.6.1... configure: warning: unrecognized options: --with-compiler, --with-gcc checking sdl-config... /usr/bin/sdl-config checking gcc... gcc checking whether c compiler works... no configure: error: in `/tmp/sdl-mixer-0.6.1-10381/sdl-mixer-0.6.1': configure: error: c compiler cannot create executables see `config.log' more details. failed install sdl-mixer-0.6.1 cabal: error: packages failed install: sdl-mixer-0.6.1 failed during configure step. exception was: exitfailure 77 if makes difference, on arch linux. how install package? make sure have installed libsdl-mixer prerequisite.

jquery - Knockout bindings not updating in IE 8 -

i have page displays list of items in db , text box add new new item. when page first rendered list displayed in ie, when add new item list not updated in ie 8. works correctly in chrome. here code: self.listofdepartments.getlistofalldepartments = function () { $.getjson('/department/listalldepartments', function (data) { var mapped = ko.mapping.fromjs(data); self.listofdepartments(mapped); }); }; self.adddepartmentmodel.adddepartment = function () { self.errors = ko.validation.group(this, { deep: true, observable: false }); if (self.adddepartmentmodel.errors().length == 0) { $.ajax({ url: "/department/add/", type: 'post', data: ko.tojson(self.adddepartmentmodel), contenttype: 'application/json', success: function (result) { $('#success').html('department added successfully.'); $("#success&qu

migrate code using C99 dynamically allocated multidimensional arrays into C++ -

i'm in process of trying learn how things in c++, , 1 of aspects i'm grappling how efficiently implement dynamically allocated multidimensional arrays. for example, have existing function: void myfunc(int *lambda, int *d, int *tau, int r[*tau][*d]) { int i, j, k, newj, leftovers; r[0][0] = *lambda; j = 0; // j indexes columns; start 0 for(i = 1; < *tau; i++){ // indexes rows leftovers = *lambda; for(k = 0; k < j; k++){ r[i][k] = r[i - 1][k]; // copy prior j leftovers = leftovers - r[i][k]; } r[i][j] = r[i - 1][j] - 1; // decrement r[i][j+1] = leftovers - r[i][j]; // initialize right of j if(j == *d - 2){ // second last column for(k = 0; k <= j; k++){ if(r[i][k] != 0){ newj = k; } } j = newj; // can't think of better way }else{ j++; // increment j } } // next row please } from i've read, seems common recommendation use std::vector purpose. care offer advice or code snippet on ho

php - How to access an ZF2 application without “public” in URL -

i completed project on zf2, uploaded on shared hosting. folder zend app files inside, , in document root files public folder visible, because want uris www.example.com (not www.example.com/public/ ). what have done in cases zf1 app throw app directory in document root , server's .htaccess equivalent made not serve files there ( deny all ). stick gateway script document root , update paths found in there including application_root , path autoloader. hope helps.

ajax - Javascript onload two functions not returning the data -

i trying display 2 javascript function when page load. seems 1 overwriting one. here javascript code: function welcome(){ if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("welcome").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","php/display_welcome.php", true); xmlhttp.send(); } function testimonial(){ if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=functio

r - Back Test ARIMA model with Exogenous Regressors -

is there way create holdout/back test sample in following arima model exogenous regressors. lets want estimate following model using first 50 observations , evaluate model performance on remaining 20 observations x-variables pre-populated 70 observations. want @ end graph plots actual , fitted values in development period , validation/hold out period (also known testing in time series) library(tsa) xreg <- cbind(gnp, time_scaled_co) # 2 time series objects fit_a <- arima(charge_off,order=c(1,1,0),xreg) # charge_off ts object plot(charge_off,col="red") lines(predict(fit_a, data),col="green") #data contains charge_off, gnp, time_scaled_co you don't seem using tsa package @ all, , don't need problem. here code should want. library(forecast) xreg <- cbind(gnp, time_scaled_co) training <- window(charge_off, end=50) test <- window(charge_off, start=51) fit_a <- arima(training,order=c(1,1,0),xreg=xreg[1:50,]) fc <- fo

recursion - Create and traverse a binary tree recursively in C -

i want create binary tree , traverse preorder traversal, , use recursive method. these code can compiled can not run correctly, , found maybe can not finish createbitree() function, don't know problem is. #include <stdio.h> #include <malloc.h> typedef struct binode{ int data; struct binode *lchild; struct binode *rchild; //left , right child pointer }binode; int createbitree(binode *t); int traversebitree(binode *t); int main() { binode *t; createbitree(t); traversebitree(t); return 0; } int createbitree(binode *t) { //create binary tree preorder traversal char tmp; scanf("%c", &tmp); if(tmp == ' ') t = null; else { t = (binode *)malloc(sizeof(binode)); t -> data = tmp; createbitree(t -> lchild); createbitree(t -> rchild); } return 1; } int traversebitree(binode *t) { //traverse binary tree preorder traversal if(t != n

swing - Java Layer JPanels -

i need layer jpanels don't know how. have 3 panels, first background, second character/sprite move around , layers first panel(background, , third bar off side (used buttons , has nothing layers). how layer panel 1 , panel 2? edit: background made of grid of 25x25 labels icon in each. some options: use jlayeredpane can layer components using z-order integer constant. remember when doing this, using null layout, , responsible setting size , position of components added jlayeredpane. if background doing painting image, use single jpanel, , paint image bufferedimage displayed in jpanel's paintcomponent method. sprite painted location vary.

sdl - Clang with C code: enumeration values not explicitly handled in switch -

i'm trying compile code clang 3.1 , option -weverything : #include <stdio.h> #include <stdlib.h> #include <sdl/sdl.h> sdl_surface* init(sdl_surface* screen); int main() { sdl_event event; sdl_surface* screen = null; int quit = 0; screen = init(screen); if (screen == null) { return exit_failure; } while(quit == 0) { while(sdl_pollevent(&event)) { if( event.type == sdl_quit ) { quit = 1; } else if( event.type == sdl_keydown ) { switch( event.key.keysym.sym ) { case sdlk_up: printf("up\n"); break; case sdlk_down: printf("down\n"); break; case sdlk_left: printf("left\n"); break; case sdlk_right: printf("right\n"); break; default: break; } } } } sdl_freesurface(screen); sd

jquery - Removing a particular Javascript action from a responsive theme -

i have responsive theme. when viewing website on small screen, shows "menu" , have tap see menu items. want show menu items straight without user having tap "menu" before seeing them. tried using firebug see triggers , tried removing that. messes whole site in desktop view well. here the link . if point me in right direction telling me code remove that'd great. appreciated. i believe hidden via css. show menu when browser mobile go bootstrap-responsive.css file on line :1424 , change 'display:none' 'display:block'. clear code looking for. nav#main_menu.smooth_menu ul { display: none; background:#fff; } it in @media (max-width: 767px) media query. that should show menu when user on mobile browser while keeping toggle functionality.

Chrome developer tools workspace mappings -

Image
can tell me how chrome developer tools workspace mappings work. believe available in canary @ moment. i thought supposed allow me make changes css rules in elements view , have them automatically saved local files demonstrated paul irish @ google io 2013. can't functionality work. https://developers.google.com/events/io/sessions/325206725 it works in canary @ moment. edit: in chrome (since ver 30+) 1) need open devtools settings panel. has 'workspace' section. 2) in section need click on 'add folder' item. show folder selection dialog. 3) after selecting folder see info bar access rights folder. 4) result see 2 top level elements in source panel file selector pane. in case localhost:9080 site , devtools local file system folder. @ moment need create mapping between site files , local files. can via context menu on file. it doesn't matter file map, local or site file. 5) @ moment devtools ask restart. after restart devtools

xslt - xsl : Incrementing a global variable -

i know fact variables in xsl immutable. in scenario, want increment global variable , use value later. there other way can done? have added enough comments in code make question more clear. please note using xslt 1.0 <xsl:variable name="counter">0</xsl:variable> <xsl:template match="/"> <xsl:for-each select="condition_abc"> <xsl:variable name="returnvalue"> <!--returnvalue return value named template getvalue --> <xsl:call-template name="getvalue"/> </xsl:variable> <xsl:if test="not($returnvalue= '')"> <!-- if returned value not null here want add increment logic, $counter = $counter+ 1 --> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template match="some_pattern"> <attribute> <!-- final 'counter' value above xsl block

Send packet python -

how in python? this. packetbuffer[0] := $00; packetbuffer[1] := $12; packetbuffer[2] := $12; 'sendpacket(processid, @packetbuffer, true, false);' use socket module: import socket s = socket.socket(socket.af_inet, socket.sock_stream) s.connect((your_host, your_port)) msg_to_send = 'whatever' num_sent = 0 while num_sent < len(msg_to_send): sent = s.send(msg_to_send[num_sent:]) if sent == 0: raise runtimeerror("socket connection broken") num_sent += sent

c# - Removing the sort arrow from DataGrid programmatically in WPF -

in wpf application, have datagrid columns displays sortable data. user can sort , subsort whichever column wants. i added button should clear sorting , return datagrid unsorted state using mvvm pattern (meaning button bound relaycommand in viewmodel, clears datagrid's datasource's sortdescriptions .) this how code looks now: viewmodellocator.myviewmodel.groupeditems.sortdescriptions.clear(); the datagrid's datasource groupeditems object (of type listcollectionview ). when click button, see datagrid returns original, non-sorted state, however, sorting arrows in column headers remain if datagrid still sorted. how can programmatically remove these arrows? to remove arrows in datagrid try: foreach (var column in dt.columns) { column.sortdirection = null; } where dt datagrid .