Posts

Showing posts from March, 2015

function - Why PHP include is not working? -

i'm trying make page view counter. i'm newbie php. here problem: i'm using code in "index.php": <?php include "visitcounter.php"; ?> and using following code in "visitcounter.php": <?php session_start(); if(isset($_session['visitcount']) { $_session['visitcount'] = $_session['visitcount']+1; } else { $_session['visitcount'] = 1; } echo "total page views = ".$_session['visitcount']; ?> the problem page index.php showing server error. if change code following code in index.php: <?php include "/visitcounter.php"; ?> then page not show error message display nothing. please me figure out wrong i'm doing. first of all, point mentioned of silvio silva problem. change from: session_start() to: session_start(); to avoid such problems in future, add file: ini_set("display_errors","on"); error_reporti...

php - RegEx - If Our Site URL Contains This, Then -

need regex regex newb. if our url contains searchbox. (searchbox dot on end) or searchbox-empty then, need something. example matching urls be: http://www.thesite.com/searchbox.html or http://www.thesite.com/searchbox-empty.html and non-matching url be: http://www.thesite.com/searchbox-function.html so, want matched when there not function being called. here have far: if((preg_match("@searchbox\.@",$_server['request_uri']) || preg_match("@searchbox\-empty@",$_server['request_uri'])) && !empty($_request['id']) && is_numeric($_request['id'])) { thanks help! if recall correctly, need escape backslashes: "/searchbox(?:\\.|-empty)/"

javascript - Dropdown menu, anchor doesn't work -

i have made dropdown menu , works fine, except anchor ( a href="#" ) not work. i think script has wrong, can't figure out. can can me please? <ul class="menu"> <li class="listmenu on"> <a class="depth1" href="#">aaa</a> <div class="depth2wrap"> <ul class="depth2"> <li><a href="b.html">bbb</a></li> <li><a href="c.html">ccc</a></li> </ul> </div> </li> <li class="listmenu"><a class="depth1" href="d.html">ddd</a></li> </ul> $(function($) { var li = $('.menu>.listmenu'); li.addclass('off'); $('.menu .on').find('.depth2wrap').show(); $('.menu>.listmenu>a').click(fun...

ios - Can I code in Xcode 5 and then comment out the iOS7 specific code before I submit with Xcode 4? -

there few layout issues need resolve new ios version , there new method, let’s call newmethodthatisnotinios6 can use code fix them: if ([self respondstoselector:@selector(newmethodthatisnotinios6)]) { self.newmethodthatisnotinios6 = parameter; } this code works fine in xcode 5 won’t compile in xcode 4 because method not defined. right now, comment out code when working on new apps ios6, there way compile in xcode 4? alternatively, can safely code in xcode 5 , strip out ios7 specific code before submit xcode 4? you can exclude code precompile macro's like: #ifdef __iphone_6_0 if ([self respondstoselector:@selector(newmethodthatisnotinios5)]) { self.newmethodthatisnotinios5 = parameter; } #endif this include method compiling ios 6+ sdk , not used if compiling ios 5 sdk.

casting - PHP cast to integer returns wrong value -

have @ friend , tell me i'm not crazy... echo (int) (9.45 * 100); // gives 944 echo (int) 945; // gives 945 i don't understand why first instruction return 944!???? known php issue? appreciated always! according php documentation ( http://php.net/manual/en/language.types.integer.php ) when converting float integer, number rounded towards zero. that's why getting 944.

java - Converting an ANSI file with German characters to UTF8 -

i have downloaded plain text files german website not sure encoding is. there no byte markers in file. using parser assumes files encoded in utf8, not handling accented characters (those fall in byte range > 127) i convert utf8 not sure if need know encoding this. the way others have been handling these files manually open in windows notepad , re-saving in utf8. process preserves accented characters, automate conversion if possible without resorting windows notepad. how windows notepad know how convert utf8 properly? how should convert file utf8 (in java 6)? in java 7 text "windows-1252" windows latin-1. path oldpath = paths.get("c:/temp/old.txt"); path newpath = paths.get("c:/temp/new.txt"); byte[] bytes = files.readallbytes(oldpath); string content = "\ufeff" + new string(bytes, "windows-1252"); bytes = content.getbytes("utf-8"); files.write(newpath, bytes, standardoption.write); this takes bytes, ...

maven - Getting "Skipping JaCoCo execution due to missing execution data file" upon executing JaCoCo? -

i'm using maven 3.0.3, junit 4.8.1, , jacoco 0.6.3.201306030806, , trying create test coverage reports. i have project unit tests can't reports run, repeatedly getting error skipping jacoco execution due missing execution data file when run: mvn clean install -p test-coverage here how pom configured: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.14.1</version> <configuration> <reuseforks>true</reuseforks> <argline>-xmx2048m</argline> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-failsafe-plugin</artifactid> <version>2.14.1</version> <configuration> <reuseforks>true</reuseforks> <argline>-xmx4096m -xx:maxpermsize=512m ${itcoverageagent}</argline> </configurati...

jquery - interaction Django and Ajax -

i'm trying send data server , use ajax function stats(e){ jquery.ajax({ type: "post", url:"stats", data:{'csrfmiddlewaretoken': document.getelementsbyname('csrfmiddlewaretoken')[0].value, 'test':{}}, success: function(data) {alert("congratulations!"+data);}, error: function(data) { alert("please report error: "+data.responsetext);} }); } function in views.py: def stats(request): if request.is_ajax(): if request.user.is_authenticated(): if request.post: return httpresponse(request.post['test']) else: return httpresponse("post_no_exists") else: return httpresponse("no authenticate") else: raise http404 django raise multivaluedictkeyerror 'key "test" not found in querydict'. when change "test":{} -> "test":1 succeds. whats err...

osx - Preferring one function when a keybinding in two emacs packages overlap -

on os x, .emacs containing lines: (require 'dired) (add-hook 'dired-load-hook (function (lambda () (load "dired-x")))) dired-omit-mode in dired-x , ns-open-file-using-panel in ns-win fight on keybinding m-o. i understand .emacs above specifying dired-x should loaded after dired—and hence binding of m-o in dired-x should take on when emacs starts. not case. reason binding in ns-win wins. how can force dired-x keybinding @ startup? edit (following phils' suggestion) if .emacs loads 2 other packages define m-o (require 'ns-win) (require 'facemenu) (require 'dired) (add-hook 'dired-load-hook (function (lambda () (load "dired-x")))) even though dired loaded last, binding in facemenu still takes over. first, load ns-win , sets binding. this: (add-hook 'dired-mode-hook (lambda() (require 'dired-x) (define-key dired-mode-map (kbd "m-o") 'di...

css - How to center a list of icons on en amil (email html) -

i'd put in email series of 4 social icons centered (horizontally) keep being put gmail , yahoo on left side! <body bgcolor="#ffffff" style="margin: 0;padding: 0;-webkit-font-smoothing: antialiased;-webkit-text-size-adjust: none;height: 100%;width: 100%;"> <table style="margin: 0;padding: 0;width: 100%;border-collapse: collapse; background-color: #f2f2f2;"> <tr> <td style="margin: 0 auto; padding: 0;display: block;max-width: 600px;clear: both; align: center; valign: top; background-color:#ffffff ;"> <table width="100%" style="padding:0px 5px 0px 5px;" cellspacing="0" border="0" bgcolor="#ffffff" align="center"> <tbody> <tr> <td style="float:left;margin-left:6px;margin-right:6px;margin-top:10px; margin-bottom: 30px;"> ...

c++ - Opengl Texture Mapping of GL_QUADS, got strange result -

i got strange result texture mapping. i used 128*128 rgba bmp image texture mapping of gl_quads , got following strange result, test other images ok, image, got strange result. here want map leaf image gl_quads . the following code: void init (void) { glclearcolor(0.6, 0.6, 0.6, 0.0); glcleardepth(1.0); glshademodel(gl_smooth); gltexparameteri(gl_texture_2d,gl_texture_mag_filter,gl_linear); gltexparameteri(gl_texture_2d,gl_texture_min_filter,gl_linear); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_repeat); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_repeat); glenable(gl_texture_2d); glutsetcursor(glut_cursor_crosshair); } void display(){ glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glloadidentity (); glulookat(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); gluint texture[2]; unsigned int outwidth; unsigned int outheight; unsigned int outdepth; glgentextures(1, &texture[0]); glbindtexture(gl_texture_2d, texture[0]); unsigned char * data=...

php - Prevent users from accessing member pages by entering cached url -

i have website members have login noticed after logging out can enter page url in browser , go in without using login form, how prevent this. what mean believe there way me check if session valid on pages. non users can put url in browsers , enter without logging in. use session variable in php. session_start(); $_session['login'] = true; this creates session variable called 'login' can used verify whether user logged in. now, have check variable : if($_session['login'] == true){ /*goto user page*/ }else{ /*redirect somewhere else */ } to create logout button, ensure users can't copy-paste url again , enter, session_destroy(); will work fine.

ruby on rails - Debugging Rufus scheduler -

i doing in rails console: job = scheduler.at 1.minute.from_now service.log.debug 'scheduler works' end job.schedule_info => wed, 07 aug 2013 16:14:46 utc 00:00 scheduler defined in other file: require 'rubygems' require 'rufus/scheduler' def scheduler @scheduler ||= rufus::scheduler.start_new end and when run in console: service.log.debug 'scheduler works' service log file written. problem scheduler.at 1.minute.from_now service.log.debug 'scheduler works' end does not write in log after minute. missing? how debug this? actual problem i have server in ec2 seems shutdown , scheduled tasks not run. thing in development environment test task running in 1 minute , works. in server not in console. in console, mentioned failing. dev environment ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.0.0] thin 1.5.0 remote environment ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux] apache2 2.2....

css3 - pseudo elements IE10 button -

i put button using :before , :after elements , ie10/9 ignoring them completely, far can tell should working in @ least 2 versions. .buttonsml { background-position:-35px -432px; background-color: transparent; border: none; text-transform: uppercase; font-size: 2.9rem; font-weight: @font-bold; height: 55px; padding: 0 5px; position: relative; .text-shadow(0,0,4px); cursor: pointer; } .buttonsml:before, .buttonsml:after { content: " "; position: absolute; top: 0; height: 55px; width: 20px; display: inline-block; visibility: visible } .buttonsml:before { background-image: url('../images/sprite.png'); background-position: 0px -432px; background-repeat: no-repeat; background-color: transparent; left: -20px; } .buttonsml:after { background: url('../images/sprite.png'); background-position: -394px -432px; background-repeat: no-repeat; background-color:...

automation - Android uiautomator Maintainability/Stability Across Manufacturers -

i have configured , installed sl4a . going automate android using scripting platform base. many pieces of functionality seek automate may exposed through reflection. may manipulated using ui automation. have considered use of uiautomator , java reflection methods. aware reflected methods tend undocumented, uncertain , unstable across versions. however, allow degree of command line interfacing. most important endeavor code maintainability. after reading uiautomator tool documentation , exploring methods, convinced implement it, api looks clean , effective. my questions these: issues, if any, exist maintaining uiautomator tool new versions of android come online? tool api relatively stable across manufacturers, general rule, or can "finicky" behavior anticipated?

PHP TIME converting? -

i have in database shows time when users signed on recorded .. when person makes user saves script (time ();) in database under variable name "regtim". if use echo print out, example:      1375202508 how can make date if possible? or example mentioned below. for example: 08/06/2013 2:11 you can use date() function timestamp mention in second argument, date ( string $format [, int $timestamp = time() ] ) or in case: date('m/d/y h:m', 1375202508); you can read more on http://php.net/manual/en/function.date.php

Variable From PHP to Javascript -

i have code in html: <a id="<?echo $result[id]?>" onclick="displayresult()"></a> and want id number link without refresh page function: <script> function displayresult() { <? connection = mysql_connect('localhost', 'root', '...'); $db = mysql_select_db('webfaturas', $connection); $sql = mysql_query("select * `artigos` id = $id"); $resultado = mysql_fetch_array($sql); ?> </script> so can sql query id = id cames without refresh page. what you'll want grab id of link via javascript, , post php script using ajax. jquery makes easier using straight javascript - suggest reading documentation. http://api.jquery.com/jquery.post/

filesystems - What is lazy space allocation in Google File system -

i going through google file system (gfs) paper, mentions gfs uses lazy space allocation reduce internal fragmentation. can explain, how lazy space reduces internal fragmetation? source: http://research.google.com/archive/gfs-sosp2003.pdf with lazy space allocation, physical allocation of space delayed long possible, until data @ size of chunk size (in gfs's case, 64 mb according 2003 paper) accumulated. in other words, decision process precedes allocation of new chunk on disk, heavily influenced size of data written. preference of waiting instead of allocating more chunks based on other characteristic, minimizes chance of internal fragmentation (i.e. unused portions of 64 mb chunk). in google paper, says: "most chunks full because files contain many chunks, last of may partially filled." so, same approach applied file creation. it analogous this: http://duartes.org/gustavo/blog/post/how-the-kernel-manages-your-memory

java - Using media player and camera to realize live video chat in android,based sockets -

yes,i have requirement list follows(maybe can called simple ideas) 1.using camera , mediarecoder recording video (now can record , save file) refer: http://developer.android.com/guide/topics/media/camera.html 2.when recording video,i need send server transit (i plan use socket[tcp] realize) 3.server receive socket data , transit client(android/pc) 4.at same time,server send video streaming android client socket (i try using parcelfiledescriptor.fromsocket(client) ,but catch ioexception:setdatasourcefd failed.: status=0x80000000) refer: stream live video phone phone using socket fd 5.android client receive server's data , play using mediaplay , surfaceview 6.in addition,i want server can switch video streaming socket data or local file,when server transit data this idea,but don't know if feasible , don't know how achieve it wonder if can give me references or examples, thanks btw, first time ask question in stackoverflow,before view question...

Auto-close Bootstrap accordion panel when switch to mobile screen size -

using bootstrap 2.3.2 have accordion single panel open when page loaded. <div class="accordion" id="refine"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#refine" href="#refine-search"> title </a> </div> <div id="refine-search" class="accordion-body collapse in"> <div class="accordion-inner"> test text.... </div> </div> </div> the site responsive. when switching mobile screen size [ @media (max-width: 979px) ] want accordion panel close automatically, i.e. want div refine-search line change "collapse out". when in mobile mode, accordion must still work, e.g. user can...

Laravel, how to use form helper outside blade? -

for reason have write html::macro() return html tags. html::macro('mymycro', function() { $result = '<form id="xxx">...'; return = $result; } then can use html::mymacro() inside blade. {{ html::mymacro() }} is possible use form helper form::open(), form::input() generate html tags inside macro don't have manually write tags??? if so, please suggest me how because of poor background in php , laravel, tried ... $result = form::open('some_parameters'); ... but didn't work, don't know can use form helper outside blade or not, please advise me. thanks. i dont see reason why not. works charm form::macro('myform', function() { $output = form::open(['url/to/post']); $output .= form::text('firstname'); $output .= form::close(); return $output; }); // use in in regular php view... echo form::myform(); // ... or blade view {{ form::myform() }}

html - Using CSS Selectors Incorrectly -

i have code looks below. using css try , assign span tag id="tl_quantity$0" padding-right of 20px . i'm using css selectors incorrectly. know how change end of css assign span tag padding not directly calling id? here html: <td id="tdtl_payable_time$0#2" class="pslevel1gridoddrow" width="127" align="left" style=""> <td id="tdtl_payable_time$0#3" class="pslevel1gridoddrow" width="152" align="left" style=""> <td id="tdtl_payable_time$0#5" class="pslevel1gridoddrow" width="105" align="left" style=""> <td id="tdtl_payable_time$0#6" class="pslevel1gridoddrow" align="right" style=""> <div id="win10divtl_quantity$0" style="width:78px;"> <span id="tl_quantity$0" class="pseditbox_disponly"...

c# - Does Sql Server Compact Edition 3.5 query timeout? -

i realized sqlceconnection , sqlcecommand objects timeout properties readonly default value set 0. mean queries sqlce database never timeout? no timeout , can define timeout in connection string this sqlceconnection conn = new sqlceconnection(); conn.connectionstring = "persist security info=false; data source = northwind.sdf;" + "password = <password>; server=mysqlserver;connect timeout=30"; this whay msdn has say. connectiontimeout property time (in seconds) wait connection open. value 0 in sql server compact readonly.

javascript - If variable equals the number 1 -

i'm trying write simple if statement in jquery. if variable equals number 1 this, if equals number 2 this. wrote doesn't seem work , can't figure out why: $("#next-btn").click(function() { if (current_slide = 1) { first_screen(); }, else if (current_slide = 2) { second_screen(); } }); probably simple, appreciate help. you need use comparison operator == in if statement condition instead of assignment operator = remove comma after first closing curly bracket of then (true) block of if statement. can test on here . if (current_slide == 1) { first_screen(); } else if (current_slide == 2) { second_screen(); } i assume current_slide has number compare, read below how comparison operator == performs comparison. comparion equal operator if 2 operands not of same type, javascript converts operands applies strict comparison. if either operand number or boolean, operands converted numbers if ...

angularjs - Best cartridge for deploying static html/javascript files to openshift? -

i want deploy pure angular-js frontend appication openshift. application contains html/css/js files. what best cartridge can use, php5, tomcat, nodes.js? thanks the best php simple html + js app. php lightest weight cartridge have. evangelists use html apps. example - http://talks.thesteve0.com running on openshift in php cartridge , reveal.js site.

YouTube insert doesn't respect custom default settings for Privacy Settings and Category -

i using youtube api version 3 upload videos. when default upload settings specified, in our case category , privacy settings, insert function doesn't seem use them. is there way specify these settings in insert function? api call need made these default settings , pass them insert function? unfortunately, that's known internal issue. i'll see can resolved. ideally, won't have special , defaults apply videos uploaded via api.

css - When do I use class/id and when do I target the html tag directly -

Image
hello ladies , gentlemen, i have (another) question concerning html/css best practices. checked web , site came articles on when use ids , when use classes. however, that's not struggling with. i know when use class selectors on html element selectors , vice versa. example: html <div class="container"> <p class="nested-p">feefifem</p> </div> css option 1: .nested-p{...} css option 2: .container p{...} which option preferable under circumstances , why? the first option .nested-p classes ( can put class html ,body , p ,div , aside etc --- - want.) the second 1 p under .container ( yeah , that's right , p ) regarding priority - second 1 higher ( read this ) why ? becuase of : a few pasted drawing (just emphasize) so second 1 : while first 1 like:

Speeding up NPM package install -

when deploy app aws, it's copied new directory, npm install same packages, during each deploy, can take lot of time. of these packages haven't changed between builds (if @ all), having full npm-install seems waste. my app server runs bunch of different node apps, installing globally isn't option. instead i'd have app store it's node packages in location isn't wiped out during deployment, have option update packages necessary during npm install . does npm have concept of app-specific module directory isn't located in subfolder of app? way can delete app folder, , not have reinstall same packages on , on again. i achieve using symlinks, or migrating current node_module directory. if lock down dependencies versions, npm cache packages. installation wouldn't take longer. if prefer not this, can install dependencies globally , link them npm link command (which creating symlink yourself!). then, it'll update globally installed packag...

m3u8 - Is it necessary to define runtime/"run time" in m3u playlist file or is there a way around it? -

e.g. in m3u file below, running times listed 419 , 260 , 255 . #extm3u #extinf:419,alice in chains - rotten apple alice in chains_jar of flies_01_rotten apple.mp3 #extinf:260,alice in chains - nutshell alice in chains_jar of flies_02_nutshell.mp3 #extinf:255,alice in chains - stay away is possible write m3u file without these properties? or include kind of default ? are there repercussions ? i think depends lot on going read playlist. the basic m3u file contains list of files (or urls) without of '#' lines. in format player have read files if wants know duration. slow urls.

java - Android: Displaying days since received message after 24 hours pass -

i have implemented following code in android app splits the date/time value retrieved sql , displays number of minutes/hours since message received: //splits date , time string retrieved sql 2 separate strings, //and stores them array string[] dt_array = m1.gettime().split(" "); //string date = dt_array[0]; string time = dt_array[1]; //splits time 2 strings, 1 hours , 1 minutes, , stores them //into array string[] timesplit = time.split(":"); string hourstring = timesplit[0]; string minutestring = timesplit[1]; //converts new separate time strings integer variables int msghour = integer.parseint(hourstring); int msgminute =integer.parseint(minutestring); calendar currenttime = calendar.getinstance(); //retrieves current hour , minute device , stores in separate ints int currenthour = currenttime.get(calendar.hour); int currentminute = currenttime.get(calendar.minute); int hourssince; int minutessince; string timedisplay = null; if (currenthour !=...

html - How do you make an image disappear when a user clicks on it -

hello stackoverflowers, so pretty want achieve (i apologize in advance explanation not familiar language of code) a user visits page on tumblr. the user sees image of instructions hovering on blog content slight opacity. once user reads instructions, image disappear when user clicks on image. the user explores page. i'm wondering -- can done, on tumblr? any suggestions appreciated -- thanks! never used tumblr can add custom code using guide : http://www.chrisabraham.com/2011/04/06/how-to-add-custom-html-javascript-etc-code-to-your-tumblr/ and add code in body tag change "img.png" image source <img src="img.png" onclick="this.style.display='none';" style="position:absolute;opacity:0.5;left:50%;top:50%;width:100px;height:100px;margin-left:25px;margin-top:25px;z-index:100;"/> the following working example : http://jsfiddle.net/brxvx/1

How do I incorporate this Ruby file into Rails? -

i have ruby file: freshdesk.rb: require "rest_client" require 'nokogiri' class freshdesk # custom errors class alreadyexistederror < standarderror; end class connectionerror < standarderror; end attr_accessor :base_url def initialize(base_url, username, password) @base_url = base_url restclient.add_before_execution_proc | req, params | req.basic_auth username, password end end # freshdesk api client support "get" id parameter optional # returns nil if there no response def self.fd_define_get(name, *args) name = name.to_s method_name = "get_" + name define_method method_name |*args| uri = mapping(name) uri.gsub!(/.xml/, "/#{args}.xml") if args.size > 0 begin response = restclient.get uri rescue exception response = nil end end end # freshdesk api client support "delete" required id parameter def self.fd_define_delete(name, *args) name = name.to_s met...

element with negative z-index applied will not allow for hover state. how can i fix this? -

how element z-index of -1, sits behind element z-index of 2 display hover state? applied hover state element -1 z-index doesn't show through top element. that's idea of being behind - can't hover it. if want work around can create 3rd transparent div that'll placed on top of both divs , cover div1 , add hover property it.

c - Why are seek events failing with my GStreamer app? -

this seeking function: gboolean seek(customdata* data) { gint64 position; gstformat format = gst_format_time; gstevent *seek_event; /* obtain current position, needed seek event */ if (!gst_element_query_position(data->pipeline, &format, &position)) { g_printerr("unable retrieve current position.\n"); return false; } /* create seek event */ if (data->rate > 0) { seek_event = gst_event_new_seek(data->rate, gst_format_time, gst_seek_flag_flush | gst_seek_flag_accurate, gst_seek_type_set, position, gst_seek_type_none, 0); } else if (data->rate < 0) { seek_event = gst_event_new_seek(data->rate, gst_format_time, gst_seek_flag_flush | gst_seek_flag_accurate, gst_seek_type_set, 0, gst_seek_type_set, position); } else { g_printerr("rate set 0.\n"); return false; } /* check seek_event cre...

Conditional formatting using other cells in Google Spreadsheet -

i'm trying produce script changes cell colour depending on contents of other cells in row. basically, i'd change cell (col 6) red if date (col 1) of entry further 2 days prior , number cell less 1. if third column (col 5) changes y, format cell green. i'm having trouble getrange on line 5 returning null, wanted check doing correctly. thanks! function formatting() { var = new date().gettime(); var twodaysinmilliseconds = 172800000; var sheet = spreadsheetapp.getactivespreadsheet().getsheetbyname('enquiry tracking'); var columnbooked = sheet.getrange(2, 5, sheet.getlastrow()-1, 1); var bvalues = columnbooked.getvalues(); (var = 0; < bvalues.length; i++) { var columnfu = sheet.getrange(i + 2, 6, 1, 1); if (bvalues[i][0] != 'y') { var rowdate = new date(sheet.getrange(i + 2, 1, 1, 1).getvalue()).gettime(); if (now - rowdate > twodaysinmilliseconds) , (columnfu.getvalue() < 1) { columnfu.setb...

javascript - Is JQuery to be used for onclick/onchange -

i new in jquery , confused on following: supposed use jquery on onclick or onchange element via kind of: $(selector).somemethod(function(){....}); ? sure use either, it's not required. $(selector).on('click', function() { } ); $(selector).on('change', function() { } );

javascript - HTML5 Canvas smooth scroll tilemap -

i've tried build scrollable tilemap canvas object automatically calculates it's size relative screen resolution , renders tiles relative position on (bigger) map. i planned move generated tiles , draw tiles need drawn new. so means scroll map, draw new tiles @ top (for example on moving upwards) , deleting last tiles on botton out of visible canvas. my problem is: i don't think it's performance change position of every tile in canvas, think solved using getimagedata() , putimagedata() there still 1 problem left: if move these tiles , draw new tiles "hop" 30px (1 tile = 30x30), there simple / performance technically way make smooth, linear scroll effect? just fill board wither using drawimage or pattern (the latter require use translate tiles in right position). drawimage takes new destination size argument can zoom tiles too. here pattern implementation made other question, assume should able see goes on in code: function fillpa...

javascript - how to animate slide in with jQuery without showing content before it's loaded? -

in few websites developed me there slide-in/fade-in animations of content once page loaded. use jquery before animation necessary content hidden. achieve first have used css rule #content{display:none} . in page header in javascript block <script type="text/javascript"> $(function() { $('#content').css("display","block"); $('#content').stop().css("margin-top","100%").animate({margintop:'100%'} ,1300).animate({ margintop:'5'}, 700,"swing", function(){ $('#loading').fadeout(); ... if understand well, jquery code executes once page loaded , works way, there 1 problem. if user has no javascript support page remains blank because of hidden css content. google webmaster tools shows blank page preview because not execute javascript(jquery) code , safari web browser's top sites page blank page preview because of same css rule. i...

rspec - Selenium::WebDriver::Error::JavascriptError: waiting for evaluate.js load failed Firefox 23 -

today running rspec tests, following error whenever somewhere in test theres `page.execute_script' call. selenium::webdriver::error::javascripterror: waiting evaluate.js load failed # [remote server] file:///tmp/webdriver-profile20130807-3105-fpynb7/extensions/fxdriver@googlecode.com/components/driver_component.js:8360:in `r' # [remote server] file:///tmp/webdriver-profile20130807-3105-fpynb7/extensions/fxdriver@googlecode.com/components/driver_component.js:392:in `fxdriver.timer.prototype.runwhentrue/g' # [remote server] file:///tmp/webdriver-profile20130807-3105-fpynb7/extensions/fxdriver@googlecode.com/components/driver_component.js:386:in `fxdriver.timer.prototype.settimeout/<.notify' there file evaluate.js in /resources directory (instead of components) of path above, on other machines. this happened after updating firefox 23 22. haven't been able rollback yet confirm returning 22 indeed fixes problem, that's that's changed believe. ...

ibm midrange - strange CPYF issue when copy from a query output -

i have field in query database table defined : total of group qty shipped form previous query. definition in query ( idshp#01 zoned 16 2 16 ) and in pf 60 t01.idshp#01 idshp# total 16 2 i try copy pf (*map *drop) other fields copying fine idshp#01 getting .00 there data in file copied. be? i ready abandon method wanted show data manager working few weeks ago. r mdl500r text iddocd 8 00 idinv# 8 idordt 3 idprt# 15 ohviac 3 idshp#01 16 02 k idinv# 1) @ job log. there messages @ all? 2) dspffd on both files. make sure name , size same in each. it's possible source not match object 1 or both files.

actionscript 3 - AS3 change line curve -

i have end part of code, need bend in opposite directon. creates line point mouse curves up. need curve down. values change this? if ((mousex-targetpointx<0 && mousey-targetpointy>0) || (mousex-targetpointx>=0 && mousey-targetpointy<=0)) { if (mousey-targetpointy>0) { line.moveto(mousex-offset,mousey-offset); line.curveto(mousex-offset,targetpointy-offset,targetpointx-offset,targetpointy-offset); line.lineto(targetpointx+offset,targetpointy+offset); line.curveto(mousex+offset,targetpointy+offset,mousex+offset,mousey+offset); } else { line.moveto(mousex-offset,mousey-offset); line.curveto(targetpointx-offset,mousey-offset,targetpointx-offset,targetpointy-offset); line.lineto(targetpointx+offset,targetpointy+offset); line.curveto(targetpointx+offset,mousey+offset,mousex+offset,mousey+offset); } ...

groovy - Another issue when trying to POST JSON to REST URL via HttpBuilder -

i read this , several other postings on , elsewhere how send post call via httpbuilder json data content. problem none of solutions working! my problem different. i have existing json data in file. when attempt send rest interface curl: curl -x post -u "username:password" -d @/path/to/myfile.json http://localhost:8080/path/here --header "content-type:application/json" all works well. here @ (some code in there, read on): def myfile = new file('/path/to/myfile.json') if (!myfile.exists()) println "error! not have json file!" def convertedtext = myfile.text.replaceall('\\{', '[') convertedtext = convertedtext.replaceall('\\}', ']') def jsonbldr = new jsonbuilder() jsonbldr myfile.text println jsonbldr.tostring() def myclient = new groovyx.net.http.httpbuilder('http://username:password@localhost:8080/my/path') myclient.setheaders(accept: 'application/json') results = myclient.req...

PHP: count how many times a random number appears in an array using a for loop? -

i trying simulate 2000 dice rolls of 11 sided die (number 2 through 12 on sides). have store data in array. here's loop die rolled: for($counter = 0; $counter <=2000; $counter++) { $die = rand(2, 12); $int[$counter] = $die; echo " $die ,"; } ^ seems work okay have 2000 random numbers output. the next part have trouble. have output of results. make simple, let's have output number of fives rolled echo statement like: " _ _ fives rolled." i can't seem work. assignment have use loop. tried making new 1 if statement, , including if statement in loop above. no luck either. how can make work? i think 1 solve problem.. $array = array(); for($counter = 0; $counter <=2000; $counter++) { $die = rand(2, 12); $array[]= $die; } for($c=2;$c<=12;$c++){ foreach($array $r){ if($c==$r) { $arr[$c]+=1; } } } foreach($arr $key=>$value) { echo $value." [".$key....

multithreading - Android close activity after thread ends -

i have activity, , buttonclick call thread post json php file. want activity closed after thread ends. how can that? this click event: button bsave = (button) findviewbyid(r.id.button3); view.onclicklistener eventhandlerx = new view.onclicklistener() { @override public void onclick(view arg0) { sendjson( urlx, jsonarray); } ... and thread: private void sendjson(final string urlx, final jsonarray jsonarray) { thread t = new thread() { public void run() { looper.prepare(); ...} ...} } where can call finish() in order close activity? thank you you can call finish() anywhere within ui thread. can execute code within ui thread using aysnctask 's onpostexecute (replace thread it) or starting runnable using activity 's runonuithread .

system.reactive - Creating Multiple Timers with Reactive Extensions -

i've got simple class using poll directory new files. it's got location, time start monitoring location, , interval (in hours) when check again: public class thing { public string name {get; set;} public uri uri { get; set;} public datetimeoffset starttime {get; set;} public double interval {get; set;} } i new reactive extensions, think right tool job here. @ start time, , on every subsequent interval, want call web service heavy lifting - we'll use ever inventive public bool dowork(uri uri) represent that. edit: dowork call web service check new files , move them if necessary, execution should async. returns true if completed, false if not. things complicated if have whole collection of these thing s. can't wrap head around how create observable.timer() each one, , have them call same method. edit2: observable.timer(datetimeoffset, timespan) seems perfect create iobservable i'm trying here. thoughts? ...

jQuery does not fire when changing the anchor link in the URL... How can I capture this event? -

i have page accordeon-type subsections toggled open clicking on section title or clicking link dropdown in global site navigation. the intention make sections within page accessible directly anywhere. the global menu has links in format of /pagename.aspx#anchor-name /pagename.aspx#anchor-name2 to capture clicks via global navigation, use var anchor = window.location.hash; if (anchor) { toggle_element(anchor_name); } within $(document).ready unfortunately .ready fires first time page loaded. if navigate click on /pagename.aspx#anchor-name , script runs. if click on /pagename.aspx#anchor-name2 , nothing happens. how can capture activity? you need listen hash-change event jquery plugin http://benalman.com/projects/jquery-hashchange-plugin/

python - Printing items within a list within a list, etc. (Printing nested lists) -

i'm trying write function print: file1 file2 file3 file4 file5 file6 file7 when enter: c = [['file1', [['file2']], ['file3', 'file4', 'file5']], 'file6', ['file7']] it's supposed directory. here code: def tree_traverse(directory) : list1 = list(directory) in list1 : if == 'cc' : del(list1[:(list1[it]+3)]) item in directory : print(item) whenever enter input above, error saying c unexpected argument. also, when enter above input without "c = ", prints entered it. i'm quite lost @ do. this flattens list want. c = [['file1', [['file2']], ['file3', 'file4', 'file5']], 'file6', ['file7']] def getfiles(container): f in container: if isinstance(f, list): farray in getfiles(f): yield farray else: yield f print "...

intel - OpenSSL ECC gf2m modification to apply PCLMULQDQ instruction -

i'm trying modify openssl code in order use pclmulqdq instruction accelerate gf2m operations, described in intel white paper intel polynomial multiplication instruction , usage elliptic curve cryptography the paper suggests modifying following functions in crypto/bn/gf2m.c : int bn_gf2m_mod_arr() int bn_gf2m_mod_mul_arr() int bn_gf2m_mod_sqr_arr() int rshift1() with code snippets in appendix. how should it? read snippets , had no clue how modify openssl code.

How to loop through API call with requests in python -

i trying write script in python loop through list of lat/long coordinates , send each set through boundary api call. want write each individual api response. import json import requests coords = ['lat1, long1','lat2, long2','lat3, long3'] x in coords: loc={'?contains':'x','&sets':'a_parameter'} response = requests.get('http://apicall.com/', params=loc) data = response.json() print data i know not proper way syntax 'x' within api call, cannot find documentation of loop including requests api call. i think want this: for x in coords: loc={'?contains' : x , '&sets' : 'a_parameter'} ... this references x variable, not string 'x' .

asp.net mvc 4 dropdownlist does not return a value -

Image
i have 2 models - question , category - public class question { [scaffoldcolumn(false)] public int questionid { get; set; } [required] public string questiontext { get; set; } [required] public string answera { get; set; } [required] public string answerb { get; set; } [required] public string answerc { get; set; } [required] public string answerd { get; set; } [required] public int correct { get; set; } [foreignkey("category")] [display(name = "category")] [required] public int categoryid; //navigation property public virtual category category { get; set; } } public class category { [scaffoldcolumn(false)] public int categoryid { get; set; } [required] public string name { get; set; } public virtual icollection<question> question { get; set; } } in questioncontroller, have added code able access available categories dropdownlist in view - private...

d3.js - How to display top 10 pie chart slice in nvd3? -

i have pie chart generated nvd3, has many slices. by clicking legend, can control slice display or not, want top 10 (by count) of chart slices show default, , others hide (by clicking legend, can added pie chart). can in nvd3? finally, complete transforming data: [{ 'x': 10, 'y': 1, 'disabled': true, }] set disabled attribute true .

jquery - JavaScript change page effect -

hi chance know how fade in fade out change page effect in javascript? like this.. http://soulwire.co.uk/hello i have tried this.. but when fadeout not linking together..i mean not smooth above website. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('body').css('display', 'none'); $('body').fadein(1000); $('.link').click(function() { event.preventdefault(); newlocation = this.href; $('body').fadeout(2000, newpage); }); function newpage() { window.location = newlocation; } }); </script> sorry think of....does background slideshow work??? on top can add php/html code? another example... http://www.louisebradley.co.uk/portfolio/ hey try below code see working demo <!doctype html> <html> <head>...