Posts

Showing posts from March, 2011

html - Browser cache- not understanding the cache related headers -

cache-control: public, max-age=31536000 age: 422816 expires: fri, 25 jul 2014 20:52:54 gmt date: thu, 25 jul 2013 20:52:54 gmt last-modified: thu, 29 mar 2012 18:19:50 gmt what purpose of max-age, age, date, , last modified headers if browser can use expires: date determine if should cached or refreshed? its legacy, though headers subtly different things. different browsers work differently (certainly in past), , there wasn't standard way of doing things. eg. ie 6 won't respond modern caching headers. make sure site works correctly, have consider older browsers (at least now). have at page information.

database - Executing queries from sqlite file in iOS -

is possible read .sqlite script row insertions , updates in ios? or if want read sql statements file, can read file line line if regular text file? need make large amount of row insertions in existing sqlite table have, , have insert statements in .sql file. i've looking way this, not able find ios. thanks! your .sqlite script text file can load it. can read in line line can read whole script (depending on size) nsstring ( stringwithcontentsoffile:encoding:error: ) , use contents want.

binary data - How to pack integers of arbitrary size to byte buffer in Python -

the other way simple int(byte_buffer.encode('hex'), 16 ) but how convert integer byte_buffer . the length stored prepending struct.pack('>i', len(byte_buffer)) value. in 2.7 there int.bit_length() start, unfortunately must able run on 2.6. this came with. def int2str(i): _bytes = list() while > 0: n = % 256 _bytes.insert(0, n) = >> 8 return ''.join(struct.pack('b', x) x in _bytes)

java - How to convert string array to object using GSON/ JSON? -

i have json this: [ [ "passport number", "nationality", "reasons" ], [ "shais100", "india", "" ], [ "", "", "agent id not matched." ], [ "", "", "" ] ] i want populate arraylist<string[]> ,please tell me how do? and empty strings should not convert null. that's simple, need following: 1.- first create gson object: gson gson = new gson(); 2.- correspondent type list<string[]> (note can't list<string[]>.class due java's type erasure ): type type = new typetoken<list<string[]>>() {}.gettype(); 3.- parse json structure of type type : list<string[]> yourlist = gson.fromjson(yourjsonstring, type);

jsf 2 - Making AT-LEAST any one of Input Fields as Required in JSF Form -

this question has answer here: jsf multiple input text (one of them required) how validate if @ least 1 of multiple input fields entered? 2 answers i want make at-least 1 of filed required in form. for example: <h:form id="searchform"> <h:outputlabel value="user name:"/> <h:inputtext value="#{searchbean.username}" id="user_name"/> <h:outputlabel value="location:"/> <h:inputtext value="#{searchbean.location}" id="location"/> <h:outputlabel value="date of birth"/> <p:calendar value="#{searchbean.dob}" id="dob"/> <p:commandbutton value="search"/> </h:form> in above form has there 3 input fields: user_name location dob and s

listview - getting java.lang.ArrayIndexOutOfBoundsException in android -

i using pinned-section-listview here , getting following error after scrolling, 07-31 17:52:46.640: e/inputeventreceiver(25288): exception dispatching input event. 07-31 17:52:46.657: e/androidruntime(25288): fatal exception: main 07-31 17:52:46.657: e/androidruntime(25288): java.lang.arrayindexoutofboundsexception: length=2; index=2 07-31 17:52:46.657: e/androidruntime(25288): @ android.widget.abslistview$recyclebin.addscrapview(abslistview.java:6916) 07-31 17:52:46.657: e/androidruntime(25288): @ android.widget.abslistview.trackmotionscroll(abslistview.java:5442) 07-31 17:52:46.657: e/androidruntime(25288): @ android.widget.abslistview.scrollifneeded(abslistview.java:3310) 07-31 17:52:46.657: e/androidruntime(25288): @ android.widget.abslistview.ontouchevent(abslistview.java:3654) 07-31 17:52:46.657: e/androidruntime(25288): @ android.view.view.dispatchtouchevent(view.java:7143) 07-31 17:52:46.657: e/androidruntime(25288): @ android.view.viewgroup.dispatchtra

node.js - javascript promise not passing all arguments (using Q) -

i having trouble passing arguments. promise callback receives 1 instead of three: var asyncfunction= function(resolve) { settimeout(function() { resolve("some string passed", "and another", "third"); }, 1000); }; var promisefunction = function () { var deferred = q.defer(); asyncfunction(deferred.resolve); return deferred.promise; }; promisefunction().then(function() { // 1 argument passed here instead of 3 // { '0': 'some string passed' } console.log(arguments); }); any idea doing wrong? q promises can resolve d 1 argument - promise stands 1 single value, not collection of them. put them in array explicitly if need multiple values. multiple-parameter-callbacks, can use .spread() .

delphi - How to read key input? -

i trying have key control camera. there no onkeypress tform how can read input keyboard? procedure tform2.formkeypress(sender: tobject; var key: char); var ok: boolean; begin ok := true; case key of 'a': camera1.position.y:=camera1.position.y+1; 'a': camera1.position.y:=camera1.position.y+1; 'd': camera1.position.y:=camera1.position.y-1; 'd': camera1.position.y:=camera1.position.y-1; 'w': camera1.position.x:=camera1.position.x-1; 'w': camera1.position.x:=camera1.position.x-1; 'x': camera1.position.x:=camera1.position.x+1; 'x': camera1.position.x:=camera1.position.x+1; 'q': camera1.rotationangle.z := camera1.rotationangle.z-1; 'q': camera1.rotationangle.z := camera1.rotationangle.z-1; 'e': camera1.rotationangle.z := camera1.rotationangle.z+1; 'e': camera1.rotationangle.z := camera1.rotationangle.z+1; 'z': camera1.position

java - Using new Date() as unique identifier -

imagine have proccess creates 1000 entities each second. each of these entities call setter : newentity.setdate(new date()); 1) possible 2 entities recieve same date? or safe assume unique identifier effect date field? 2) if answer question #1 :"yes" - let's make minor tweak: lets create function: public static synchronized date getdate() { return new date(); } will work now? newentity.setdate(getdate()); 3) system.nanotime()? edit 4) : public static synchronized date getdate() { thread.sleep(1000); return new date(); } thanks. a simple test shows 2 consecutive calls new date() can return same date. making method synchronized won't make difference. if need unique id, use atomicinteger counter , return counter.getandincrement(); new ids. ps: using system.nanotime() won't either resolution os , processor dependent , low enough 2 consecutive calls can return same result too. edit your 4th proposal slee

android - Cannot compile, Unable to execute dex, cannot merge, non-jumbo instruction -

i'm needing because can't solution own, had read lot of post , investigating lot without solution. i've proyect have subprojects ( actionbar,sliding,facebook,etc.. ) , when try compile receive following error times. [2013-07-31 14:44:06 - dex loader] unable execute dex: cannot merge new index 67109 non-jumbo instruction! [2013-07-31 14:44:06 - ojiva] conversion dalvik format failed: unable execute dex: cannot merge new index 67109 non-jumbo instruction! i'm using eclipse latest adt , latest tools ( r22 ) latest sdk ( 18 ). i've set dex.force.jumbo=true on project.properties , i've tried set dex.force.jumbo=true but without lucky :(, ideas ? try adding dex.force.jumbo=true project.properties file

email - Attach Two Files PHP -

i have gotten script send 1 file through email have been asked make can accept two. my script far looks like. // obtain file upload vars $fileatt = $_files['file1']['tmp_name']; $fileatt_type = $_files['file1']['type']; $fileatt_name = $_files['file1']['name']; if (is_uploaded_file($fileatt)) { $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==multipart_boundary_x{$semi_rand}x"; $headers .= "\nmime-version: 1.0\n" . "content-type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "this multi-part message in mime format.\n\n" . "--{$mime_boundary}\n" . "content-type: text/html; charset=\"iso-8859-1\"\n" . "content-transfer-encoding: 7bit\n\n&

android - Returning to home screen from Activity instead of parent -

i have music player activity doesn't behave want. activity can opened inside app, notifications bar , when switching/resuming app background. when launched app -> backpress on activity -> returns previous app activity. ok when launched notification -> backpress on activity -> returns home screen (it ok) when resumed homescreen/recent apps -> backpress on activity -> returns home screen (not ok) - user assume app since activity leaf , tab activity root activity. i want parent activity when pressing back, not going on home screen(when resumed notifications, ok if returns home screen, both variants ok me in scenario) <activity android:name=".player.playeractivity" android:configchanges="keyboardhidden|orientation" android:label="@string/audio_player_activity_title" android:launchmode="singleinstance"/> and starting activity: //this intent start

python - Replace all lines [fromString ,toString] in file -

i replace section of text in text file given string. example, given following file content: 1 ---from here--- 2 ---to here--- 3 i write python function upon initiation in format of fashion : replacesection('pathtofile','---from here---\n','---to here---\n','woo hoo!\n') this should change original file to: 1 woo hoo! 3 i have come straightforward implementation (below) believe has disadvantages, , i'm wondering if there simpler implementation : the code long, makes understanding little cumbersome i iterate on code twice (instead of inplace replacements) - seems inefficient this same implementation use c++ code, , guess python has hidden beauties make implementation more elegant def replacesection(pathtofile,sectionopener,sectioncloser,replacewith = ''): ''' delete lines in section of given file , put instead customized text. return: none if replacement performed , -1 otherwise. '

asp.net - Problems with input type password in html -

Image
i have section in asp website (after logging in), user accounts can added. problem user inputs of type password , email user's email address , password fields. reason, auto populates these fields based on values memorized login page. following image presents scenario. suggestions? <tr> <td>email </td> <td><asp:textbox id="txtemailtoadd" runat="server" width="200px" autocomplete="off"></asp:textbox></td> <td></td> </tr> <tr> <td>department </td> <td> <asp:dropdownlist id="cbodepttoadd" runat="server" width="200px"> </asp:dropdownlist> </td> <td></td> </tr> <tr> <td>position </td> <td> <asp:dropdownlist id="cbopostoadd" runat="server" width="200px"> </asp:dro

Installing themes in wordpress -

i trying install themes in wordpress , error occured - fatal error: maximum execution time of 30 seconds exceeded in c:\wamp\www\wordpress-3.5.2\wordpress\wp-includes\class-http.php on line 953. this? not able it. find php.ini file, , edit line.. max_execution_time = 30 raise 60 or whatever need. not sure of location of php.ini on wamp, remember can create phpinfo file view php configuration find source of php.ini.

asp.net - Try Catch, AddHandler to log exceptions -

i want create sub handles try-catch exception thrown event. i need add each exception message single log file, without having add logex(ex) (my sub adding string in log file) in every single try-catch block, that's need event handler came up. i've searched lot, found ways create event handlers triggered unhandled exceptions. thanks in advance. as far know, .net not raise application level events handled exceptions, control-flow. considering this, have edit of error handling 1 way or other, either adding method suggest, or bubbling errors using throw(); , considering errors @ global level using application_error event. recommend approach because more maintainable should want change logging method or add additional logic here.

git - Removing files from index and gitignore -

this combination of number of questions i've seen on stackoverlow, have number of files wish on .gitignore list, i've added files manually. the problem appears these files indexed before adding them gitignore list, appeared in "changes not staged commit". wish remove them git can't see them did 'git rm --cached ' of them. however after doing when doing git status know see them 'deleted' under 'changes committed' i.e. staged, if 'git reset head ' moves them 'modified' under 'changes not staged commit' all want ignore them completely, how do this? git rm them, commit. until commit, they'll show deleted.

multithreading - Does Java have an indexable multi-queue thread pool? -

is there java class such that: executable tasks can added via id, tasks same id guaranteed never run concurrently the number of threads can limited fixed amount a naive solution of map solve (1), difficult manage (2). similarly, thread pooling classes know of pull single queue, meaning (1) not guaranteed. solutions involving external libraries welcome. if don't find out of box, shouldn't hard roll own. 1 thing wrap each task in simple class reads on queue unique per id, e.g.: public static class serialcaller<t> implements callable<t> { private final blockingqueue<caller<t>> delegates; public serialcaller(blockingqueue<caller<t>> delegates) { this.delegates = delegates; } public t call() throws exception { return delegates.take().call(); } } it should easy maintain map of ids queues submitting tasks. satisfies condition (1), , can simple solutions condition (2), such executors. ne

java - is there a faster way to extract unique values from object collection? -

i have method extract values object collection employee information: public class employee { public string area; public string employee_id; public string employee_name; } i'd distinct areas did thought easier, check if arraylist contains value, if not add it, takes 187ms complete, : long starttime = system.currenttimemillis(); arraylist<string> distinct_areas = new arraylist<string>(); (int = 0; < this.employeetress.length; i++) { if (!distinct_areas.contains(this.employeetress[i].area)) distinct_areas.add(this.employeetress[i].area); } string[] unique = new string[distinct_areas.size()]; distinct_areas.toarray(unique); long endtime = system.currenttimemillis(); system.out.println("total execution time: " + (endtime - starttime) + "ms"); then thought differently see if gets faster, sorting array check last item if different add it, , little bit faster, takes 121ms comp

forms - Echo after dropdown seletion in php -

i'm new in php, need help. have xml file containing information's song name, author name , id. use xml file import song names drop down menu. after visitor selects song name drop down menu, should author name, don't know how create this. here xml file: <songs> <song> <name>i left heart on europa</name> <author>author name 1</author> <id>1</id> </song> <song> <name>oh ganymede</name> <author>author name 2</author> <id>2</id> </song> <song> <name>kallichore</name> <author>author name 3</author> <id>3</id> </song> and php file: <?php $songs = simplexml_load_file('rss.xml'); echo "<select id='selsongs'>"; foreach($songs $song) { echo "<option value='".$song->id."'>".$song->name."</option>"; } echo &quo

c++ - Check function Compare Issue -

im writing function compares 32bit crc extracted buffer ( uint32_t lbuffer[10] ) first ten entries contain randomly generated data, calculated crc computed within checkcrc function. can see why doesn't want give true result? appreciated! here function code: bool crc32::checkcrc(const uint32_t* pldata , uint32_t llength, uint32_t previouscrc32) { bool flagpass; uint32_t lcalccrc,lmsgcrc; //msg crc needs extracted first lmsgcrc = pldata[llength-1]; //newly calculated crc //lcalccrc = calculate_crc32(pldata,llength-1,linitcrc); lcalccrc = ~previouscrc32; unsigned char* current = (unsigned char*) pldata; while (llength--) { lcalccrc = (lcalccrc >> 8) ^ crc_table[(lcalccrc & 0xff) ^ *current++]; } lcalccrc = ~lcalccrc; if (lcalccrc == lmsgcrc) { flagpass = true; } else { flagpass = false; } return flagpass; } the problem in how hare handling length of data b

How to compare two Strings in java without considering spaces? -

i have 1 example. public class test { public static void main(string[] args) { string a="vijay kakade"; string b="vijay kakade"; if(a.equalsignorecase(b)){ system.out.println("yes"); }else{ system.out.println("no"); } } } i need check these strings without considering spaces. how achieve this? how ignore spaces in strings when compare them? you can try create new string replacing empty spaces. if(a.replaceall("\\s+","").equalsignorecase(b.replaceall("\\s+",""))) { // take care of spaces tabs etc. } then compare.

android - PhoneGap 3 plugin: exec() call to unknown plugin "..." -

i've been trying upgrade plugin v3, , i've managed past plugin loading issues, , i've managed expose plugin client environment (making changes way exec works, etc). but when watch adb logcat with adb logcat | grep -v nativegetenabledtags | grep -i web i error: d/pluginmanager(11189): exec() call unknown plugin: websocket i can't work out what's gone wrong, , i'm not sure why android build can't see plugin. i've pushed code github repo, if able replicate , i'd welcome! i'm trying write experience of conversion , logging gotchas hit them (there's in readme, though it's incomplete): here's repo: https://github.com/remy/phonegap_test – remy define plugin in "res/xml/config.xml" find these lines in file <feature name="app"> <param name="android-package" value="org.apache.cordova.app" /> </feature> and append these right after: <featu

c++ - Weird control boundaries detection on QGraphicsProxyWidget -

hello in application i'm making qgraphicsview , set scene on it: qgraphicsproxywidget *rotateitemicon; hoverfilter *hv = new hoverfilter(); // hover filter class connect(hv,signal(signalhover(qobject*)),this,slot(objecthover(qobject*))); connect(hv,signal(signalhoverleave(qobject*)),this,slot(objecthoverleave(qobject*))); ui->testicon->installeventfilter(hv); ... scene = new qgraphicsscene(this); scene->setscenerect(0, 0, 661, 255); ui->testicon->setparent(null); rotateitemicon = scene->addwidget(ui->testicon); // here add control scene , receive qgraphicsproxywidget object rotateitemicon->settransformoriginpoint(ui->testicon->width()/2, ui->testicon->height()/2); ui->graphicsviewfive->setscene(scene); //qgraphicsview on form ui->graphicsviewfive->show(); my hoverfilter.cpp #include "hoverfilter.h" #include "qdebug" hoverfilter::hoverfilter() { } bo

Using windows scheduler to run python script with inputs -

i have difficult problem. want setup windows scheduler run python script every day. make program simple, want to: start input 10 today, add 5, return 15 start yesterday's return, add 5, return value (start 15, add 5, return 20) ...... etc does know if possible? you write return text file next day program reads text file , starts number reads text file re-writes new value text file this way can save data while program isnt running , retreive later hope :)

html - Putting footer on the bottom of the page -

i put footer on bottom of page (or bottom of screen, if page shorter screen). using code: <div id="wrapper"> <div id="header-wrapper"> ... </div> <!--header-wrapper--> <div class="clear"></div> <div id="body-wrapper"> <div class="row960"> <div class="menu">...</div> <div class="content">...</div> </div> <!--row960--> </div> <!--body-wrapper--> <div class="clear"></div> <div id="footer-wrapper" class="gray"> </div> <!--footer-wrapper--> </div> <!--wrapper--> and css: .clear{ clear:both; display:block; overflow:hidden; visibility:hidden; width:0; height:24px; margin:0px } html, body{ margin: 0; padding: 0; height: 100%;

xml - Tricky xpath query -

i'm new xpath , xml parsing in general. read documentations couldn't find solution problem. .xml looks (fyi: it's playlist part of "itunes music library.xml"): <dict> <array> <dict> <key>name</key><string>playlist 1</string> <key>playlist id</key><integer>187826</integer> <key>playlist persistent id</key><string>04250e0617138909</string> <key>all items</key><true/> <key>playlist items</key> <array> <dict> <key>track id</key><integer>11111</integer> </dict> <dict> <key>track id</key><integer>22222</integer> </dict> </array </dict> <dict> <key>name</key>

JAVASCRIPT / JQuery How execute onmouveover 1 time -

im trying show popup when mouse on li element. my popup got animation (get visible fading, comes up, comes down) the problem popup's animation seems in endless loops while mouse on li. i got alot's of li element , made process give them automatics id, passing them in 'for' loop. my code important edit sorry echo"<li id='".$li_id_name.$li_id."' onmouseover='showpopup(this)'>"; echo"<div id='".$li_id_name.$li_id."detail'>some text</div>"; echo"</li>"; javascript / jquery function showpopup(obj) { d3.select('#'+$(obj).attr('id')+"detail").transition().duration(100).style('opacity','1').each('end', function() { d3.select('#'+$(obj).attr('id')+"detail").transition().duration(100).style('margin-top','-300px').each('end', function() { d3

Data mining library for hadoop -

i using mahout dataminng algorithms in hadoop. has bug in cases.is there other data mining library works hadoop? thanks. why not use spark ? it's efficient open source cluster computing system, both fast run , fast write. distributed data mining, spark tool. hope helpes!

bitmap - Load BMP pixel data into array C -

Image
i'm trying read pixel data bitmap array of structured (which contains r, g , b ints, colours). i'm using 12x12px image testing (because believe bmp specification says pixel data padded zeros @ end of each line make word-aligned. 12px width automatically word aligned. here code i'm using. infoheader , fileheader parsed perfectly, , 12x12 2d array of image s im created. printing rgb data each pixel prints rubbish. typedef struct __attribute__((__packed__)) { unsigned char b; unsigned char g; unsigned char r; } image; int main(void) { fileheader fh; infoheader ih; file *img = fopen("pic.bmp", "rb"); fread(&fh, sizeof(unsigned char), sizeof(fileheader), img); fread(&ih, sizeof(unsigned char), sizeof(infoheader), img); image im[ih.width][ih.height]; fseek(img, fh.imagedataoffset, 0); int i, j; (i = ih.height-1; >= 0; i--) { (j = 0; j < ih.width; j++) { fread(&

javascript - Using itemprop attributes with AngularJS -

i making changes cart built using angularjs, 1 of tasks add itemprop attributes existing markup eg. <span itemprop="color">{{colouroption.colour.code}}</span> the problem value gets interpolated later after ajax call returns, webcrawler or whatever wants access itemprop doesn't interpolated value, gets angular expression instead. is there way around this? you can use ng-bind directive mask templating in event of web-crawlers. <div ng-bind='colouroption.colour.code'>this search-engine friendly text.</div>

css - jQuery select if no predecessor matches class -

in sharepoint portal trying fix problem lists wider page borders (custom master page) , funny when display on far right. writing jquery function reset width. my function works fine, fine works in sharepoint dialogues, - don't want work in dialogues! here method of selecting elements, works. var elements = $(".s4-wpcell-plain > div > *, #pagebody.s4-ca > div > *"); however, want exclude matching if page run in dialogue. now, there .ms-dlgcontent style, way above (like, parent of parent of parent, etc...) of elements i'm using in selector match. how can match element if there no predecessor matches class? [update] well, thank you, faithful jquery gurus such quick responses. tried of techniques , doesn't quite trick, let me explain bit more (sorry didn't think of before). here css path #pagebody div in dialogue. can see class specifying dialog @ start. html.ms-dialog body form#aspnetform div#s4-workspace.s4-nosetwidth

Connect vertices of the graph in Haskell -

graph stored list of tuples. first element of tuple - vertex, second element tuple - vertices connected. headname-vertex want connect [:t=srting]** elements-vertises want connect [:t=list]** a can connect vertices [(1,[2]),(2,[])], want connect [(1,[2]),(2,[1])]. kind of did, not work. wrong? help, please. connect_command graph headname []=(graph,"you didnt enter elements connect!\n") connect_command graph headname elements= if (has_element graph headname) ((update_connect graph graph headname elements []),"element "++headname++" connected "++listtostring (checked_elements graph headname elements []) []++"\n") else (graph,"element "++headname++" name not found!") update_connect _ [] _ _ result=result update_connect maingraph (item:graph) headname (i:elements) result= if ((fst item)==headname) (update_connect maingraph graph headname elements (result++[((fst item),(checked_elements maingraph headname

Sqlite insert not working with python -

i'm working sqlite3 on python 2.7 , facing problem many-to-many relationship. have table fetching primary key this current.execute("select extensionid tblextensionlookup extensionname = ?",[ext]) and fetching primary key table current.execute("select hostid tblhostlookup hostname = ?",[host]) now doing have third table these 2 keys foreign keys , inserted them this current.execute("insert tblextensionhistory values(?,?)",[hid,eid]) the problem don't know why last insertion not working keeps giving errors. have tried is: first thought because have autoincrement primary id last mapping table didn't provide, isn't supposed consider it's auto incremented? went ahead , tried adding null,none,0 nothing works. secondly thought maybe because i'm not getting values tables above tried printing out , shows works. any suggestions doing wrong here? edit : when don't provide primary key error as the table has 3 colu

Perl not of a string equals to? -

my $pass = !$message; i came across perl code $message string , $pass suppose boolean value. checked as ok ($pass, $test) i confused not (!) of $message? how tranlate boolean value? empty string false , nonempty string true? the ! unary logical negation operator. false strings "" , "0" . if such string negated logically, evaluates 1 . other strings true-ish. negation of these "" (the empty string) or numerically 0 . other false values undef , number 0 . therefore, ok ($pass, $test) pass if $message undefined, empty string, or zero.

vim - How to merge menu entries for normal and visual mode? -

i have many menu entries these: nnoremenu <silent> 94.015.10 &mymenu.test\ :call test("%","keyw2",keyw3")<cr> vnoremenu <silent> 94.015.10 &mymenu.test\ :<c-u>call test("'<,'>","keyw2",keyw3")<cr> one normal mode ' nnoremenu ' and 1 visual mode ' vnoremenu ' with same keywords except first 1 ("%","'<,'>") is there no way merge them together? p.e. possible this: an <silent> 94.015.10 &mymenu.test\ :call test("","keyw2",keyw3")<cr> and check within function if normal mode or visual mode active? when use :an , visual mode automatically aborted via <c-c> . means there no way retrieve mode more (and <c-u> prefix not necessary); if need mode information, have keep 2 different menu definitions. if reduce code duplication, have utilize other means, e.g.

wordpress - Redirect all https to http, except 3 pages [htaccess / php] -

running wordpress site, therefore has own rule remove index.php links. furthermore, every time in url there "cache_img", specific rule applies. what need: for current rules keep working in case url in https, rewrite http (301), except 3 pages (bookingstep1, bookingstep2, bookingsep3) i suck @ htaccess, makes little no sense me, hope can me this. i'm open either htaccess or php solutions. this have @ moment (and may have mistakes in it...) rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/(cache_img) [nc] rewriterule . /index.php [l] rewriterule ^cache_img/(.*)x(.*)-(.*)/r/(.*) cache_img/tt.php?src=http://mydomain.com/$4&w=$1&h=$2&zc=$3&q=100 i tried adding @ top of htaccess: rewritecond %{https} on rewritecond %{request_uri} !^bookingstep(1|2|3)\/?$ [nc] rewriterule ^(.*) http://mydomain.com/$1 [r=301,l] which works pages... removes https , rewrites th

WebDav PROPPATCH method status HTTP/1.1 424 Failed Dependency -

i trying access , modify properties 'creationdate' , 'lastmodified' of file have uploaded webdav url. getting response 'http/1.1 424 failed dependency' interpret 'the request failed due failure of previous request' according https://tools.ietf.org/html/rfc4918 . i lost previous request failing here, when run code don't error on it. here code: fileinfo^ myfi=gcnew fileinfo(myfilepath); string^ mytime=myfi->lastwritetimeutc.tofiletimeutc().tostring(); string^ strbody = "<?xml version=\"1.0\"?>" + "<d:propertyupdate xmlns:d=\"dav:\">" + "<d:set>" + "<d:prop>" + "<creationdate>" + myfi->creationtimeutc.tofiletimeutc().tostring() + "</creationdate>" + "</d:prop>" + "<d:prop>" + "<lastmodified>" + m

mysql - SQL: how to find people that have attended only one event -

given schema , data: create table contacts (id int, name varchar(255)); create table events (id int, name varchar(255)); create table tickets (contact_id int, event_id int); insert contacts (id, name) values (1, 'alice'), (2, 'bob'), (3, 'charlie'); insert events (id, name) values (1, 'event 1'), (2, 'event 2'); insert tickets (contact_id, event_id) values (1,1), (1,2); insert tickets (contact_id, event_id) values (2,2); how find people have attended 1 event? expect find bob, has attended 1 event, not alice has been 2 events , not charlie has attended zero. potentially there hundreds of contacts , events, , want find contacts particular event have not attended events before. i'm drawing blank on one. edit: let me clarify, how find people have attended 1 specific event? event 2, expect find bob, has attended 1 event, not alice has been 2 events , not charlie has attended zero. @yang's answer work users have att

PHP PDO - doesnt insert all statements in the loop -

lets imagine situation should insert lot of rows in loop using pdo. $sql = "insert products (name, price) values (:name, :price)"; $stmt = $db->prepare($sql); ($i = 0; $i < 100; $i++) { $name = md5(rand(0, 1000)); $price = rand(0, 1000); $stmt->bindparam(':name', $name); $stmt->bindparam(':price', $price); try { $result = $stmt->execute(); if (!$result) { print_r($db->errorinfo()); } echo $db->lastinsertid(); } catch (exception $e) { echo $e->getmessage(); } } in way 100 rows not inserted database. , echo @ 23th line output like: 1 2 3 4 5 ... 59 60 61 61 61 61 61 61 and print_r @ 20th line output array ( [0] => 00000 [1] => [2] => ) pdo error code 00000 means works fine. , no rows affected. , if try manually insert row on $result false - ok. and 61 rows inserted table. , each time

How to return Time using a 2-D array (Java)? -

Image
edit: unfortunately dont know how implement return statement. problem (mpfp book 2005) this program designed add time onto time. e.g. add 1 hour , 40 minutes 2:20 ~ gives 4:00 using conventional 2-d array stores new time . my issue not know how append integers 'newminutes' , 'newhours' onto 2-d array return in standard time form. public class addingtime { private static int [] [] nativeclockadd (int oldhours,int oldminutes,int addhours,int addminutes) { int newminutes = 0, newhours = 0; int[][] time = new int [newminutes] [newhours]; // return time. newminutes = oldminutes + addminutes; while (newminutes > 60) // subtract 60 minutes, add hour { newminutes -= 60; addhours += 1; } newhours = oldhours + addhours; while (newhours > 12) { newhours -= 12; } return time; } public static void main(string[] args) { system.out.println (nativeclockadd(4,5,7,8))

PHP: Does base64_encode protect from mysql injections? -

i'm trying set php page safely accept file upload (a resume), store mysql blob, , provide download later. when download pdfs later viewing, seem corrupted , won't open properly. thanks question jgoettsch ( php: reversing mysql_real_escape_string's effects on binary ), realized feeding file data through mysql_real_escape_string (to prevent injection) might corrupt file contents, , got idea pass binary through base64_encode() instead, , use base64_decode() before download. here's mockup code demonstrating i'm doing (which not working): the upload: <? // file contents $cv_pointer = fopen($_files['cv']['tmp_name'], 'r'); $cv_content = fread($cv_pointer, filesize($_files['cv']['tmp_name'])); fclose($cv_pointer); // insert sql $sql = sprintf("insert documents (name, file, size, date_uploaded) values ('%s', '%s', '%s', now())", mysql_real_escape_string($_files['cv'][

xml - XSLT following-sibling output not as expected -

i want elements between first sale , next sale. initial xml <parent> <sale seqno="1"/> <discount seqno="2"/> <coupon seqno="4"/> <coupondetail seqno="5"/> <sale seqno="6"/> <sale seqno="7"/> <sale seqno="8"/> <payment seqno="9"/> </parent> desired xml: <discount seqno="2"/> <coupon seqno="4"/> <coupondetail seqno="5"/> i have following applying template following-sibling::*[(number(@seqno) &lt; number(following::sale[1]/@seqno))] output getting: <discount seqno="2"/> <coupon seqno="4"/> <coupondetail seqno="5"/> <sale seqno="6"/> <sale seqno="7"/> <sale seqno="8"/> <payment seqno="9"/> if hardcode in sequence number of next sale item co

html - How to make entire group change color on hover? -

if go http://cascade2.hostei.com/collection.html and hover on picture of chandelier, notice entire group turns grey blue. if hover on caption below it, notice caption turns blue. how can change when hover on caption, turn border of picture blue? preferably in html or css. ignore shadow , of other errors. html: <center> <figure class=cheese> <a class=cheese href="images/cascadelucecatalog.pdf"> <center><img src="images/cataloguefront.jpg" width="400" height="398" alt=""/> </center><figcaption> <h2><p>2013 cascade luce catalog</p></h2></figcaption></a> </figure></center> css: .cheese { background-color: #4d4d4d; -webkit-box-shadow: 1px 1px 15px #999999; box-shadow: 1px 1px 15px #999999; color: #fff; } .cheese p{ color: #fff; } .cheese:hover, .cheese:active, .cheese:focus, .cheese :hover, .cheese :active,

Row width changes using button in twitter bootstrap table -

i made stupid typo when typed put width instead of height! i using buttons in each row of twitter bootstrap table. using table class table-condensed , button class btn-mini. problem when insert button height of row doubles. cannot find causing there appears no margin, padding or line-width attached button. <table class="table table-condensed"> <tbody> <tr class="span3"> <td class="span1"> <button class="btn btn-mini">button</button></td> <td class="span1"> <button class="btn btn-mini">button</button></td> <td class="span1"> <button class="btn btn-mini">button</button></td> </tr> </tbody> </table> you can ignore class each cell divide total span of row according number of cells