Posts

Showing posts from March, 2014

php - Is this code safe against mysql injections? -

$stmt_update = $db->prepare("update 2_1_journal set recordday = ?, number = ? "); $stmt->execute(array($amount1, $date_day1)); is safe against mysql injections? if safe, understand because of "= ?". question how "= ?" works/helps question because here http://php.net/manual/en/pdo.prepare.php written prepared statements project sql injection if use bindparam or bindvalue option. for example if have table called users 2 fields, username , email , updates username might run update `users` set `user`='$var' where $var user submitted text. now if did <?php $a=new pdo("mysql:host=localhost;dbname=database;","root",""); $b=$a->prepare("update `users` set user='$var'"); $b->execute(); ?> and user had entered user', email='test test injection occur , email updated test user being updated user. in code (above) there no bindparams , no bi

java - What happens if I initialize an int variable to something other than an int? -

let's have following line of code: int number = b/2; where b odd int. happen? also, if b instead long, java automatically convert long int? if b char, or else ridiculous? java widen types automatically, must narrow types cast. i suggest try might learn something. can't learn program without doing @ point.

Netty: How to make sure Channel.close() was fired by the I/O thread -

i using netty 3.6.2, here pipeline factory pseudocode: private final static threadpoolexecutor executor = new orderedmemoryawarethreadpoolexecutor(8, 4194304, 4194304, 5l, timeunit.minutes); public channelpipeline getpipeline() throws exception { channelpipeline p = pipeline(); p.addlast("framedecoder", protobufframedecoder); p.addlast("protobufdecoder", protobufdecoder); p.addlast("executor", new executionhandler(executor)); p.addlast("handler", handler); p.addlast("frameencoder", protobufframeencoder); p.addlast("protobufencoder", protobufencoder); return p; } in way, handler's messagereceived() called in different thread pool instead of worker thread pool, want close channel in case exception happened in messagereceived(), according here: http://netty.io/wiki/thread-model.html , any upstream events triggered side effect of downstream event must fired i/o thread. simply

jquery - Check whether an item from a dropdown list is selected -

i have multi-select html dropdown list. want check on button click whether there item selected or not. if there no element selected, alert "item not selected" else selected items alert "selected". if ($("#ddl1 >option").length >= 1) { if ($("#ddl1 >option:selected").val() == 'undefined') { alert("not selected"); } else { alert("deleted"); } } else alert("list empty"); you can use length <= 0 here if ($("#ddl1 > option").length >= 1) { if ($("#ddl1 > option:selected").length <= 0) { alert("not selected"); } else { alert("deleted"); } } else alert("list empty");

actionscript 3 - How i can create a .ppt file from as3? -

how can create .ppt file as3? need add 1 image powerpoint , save .ppt file on button click. there as3 library available saving files ppt? immensely appreciated. thanks in advance.. i write vba code in microsoft office powerpoint you. can achieve goal code. you must create text file name "info.txt" in following order when want create powerpoint presentation (path of text file must in have placed attached "insertpicture-office 2007.pptm" , "insertpicture-office 2010 & 2013.pptm" files): line 1. distance of image left of slide line 2. distance of image top of slide line 3. image width in slide line 4. image height in slide line 5. full path , name (with extension [.pptx]) saving powerpoint presentation file line 6. full path , name (with extension) of image inserting in slide of powerpoint presentation after save text file, must run "insertpicture-office 2007.pptm" or "insertpicture-office 2010 & 2013.pptm

Reading bit by bit from a binary file with C -

i need read 256 bit each step until binary file ends.is there operation in c read bit bit? use fread function , read 32 chars. chars shift bit bit 8 times. after reading ı write 256 bits file. ı have same thing write? mean ı write 32 chars => 32*8 = 256 bit. no, minimum item can read or write char (and keep in mind that's not necessarily 8 bits, depends on implementation). if want manipulate parts of char once have in memory, you'll need use bitwise operators sich & , | << , >> ( and , or , left/right shift ). and yes, can fwrite write arbitrary number of characters (in same manner use fread read them).

jquery - JWPlayer Error Loading player -

i use jw player in wordpress. , error error loading player. no playable source found. i on mobile. in firefox , safari works, nut customer told in pc in firefox , safari doesn't work. jwplayer("myelement").setup({ sources: [{ file: "http://www.mydomain.com/v/v.flv", width: "480", height: "270" }] });

Managing CakePHP Plugins with Composer -

over time i've developed number of cakephp plugins reuse across projects. i'd start managing them dependencies. my initial thoughts should make each plugin private composer library. however, composer manages dependencies single vendors folder, wise , / or feasible link symlink cakephp plugin directory vendors folder? or there better solution trying achieve? for cakephp plugins should @ composer/installers project helps put them in right folder: https://github.com/composer/installers

javascript - CSS styled radio buttons don't respond to keyboard -

i using css style radio buttons ios segmented buttons. not respond keyboard input. missing? here html of example: <nav class="segmented-button"> <input type="radio" name="seg-1" value="organisation" id="seg-organisation" checked> <label for="seg-organisation" class="first">organisation</label> <input type="radio" name="seg-1" value="users" id="seg-users"> <label for="seg-users">users</label> <input type="radio" name="seg-1" value="units" id="seg-units" disabled> <label for="seg-units">units</label> <input type="radio" name="seg-1" value="tags" id="seg-tags"> <label for="seg-tags" class="last">tags</label> </nav> he

c - Can bit-fields only be fields of a structure/union, never "normal", "stand-alone" variables? -

the field part of bit-fields seems suggest can fields inside structure or union. can bit-field typical "stand-alone" variable, outside aggregate data-type union or structure follows: int sum:6; //can work declaration statement? sum=4; if not, why so? if bit-fields intended use less memory, why can't declare variable bit-field if know won't exceed size? bit-fields part of structs or unions because that's c standard allows. have been possible decide differently. why committee decided write standard way is, have ask them. to find information in c99 standard: from table of contents: 6.7 declarations 6.7.2 type specifiers (okay, 1 little bit obscure) 6.7.2.1 structure , union specifiers. one bit-field declarator_opt : constant-expression part of syntax. syntax allowed here, , consequence 1 cannot declare bit-fields elsewhere. the syntax tells name of bit-field can optionally omitted, if curious sort of information. clause 6.7.

php - Execute a script at certain times on external web server without cron -

i've got website hosted on external web hosting service amongst other things, allows users subscribe events , added registration list. i'd able remind these users via email 1 day before event occurs, remind them updated information location, etc.. currently, hosting service doesn't support cron jobs, thought provide means achieve this. i've had idea of executing function when user visits front page nearest time when send emails, seems bad option , left me thinking there must better way. i know of companies execute scripts @ specific time fee, more flexibility being able configure directly on website. i'm wondering if there api in php allow me this, or if idea best way of achieving goal, or missing obvious.. any appreciated. take @ mcrypt_encrypt , mcrypt_decrypt functions. can set php script on external page get parameter input. input used authentication noone unauthorized runs script. use above functions encrypt , decrypt authorization

jquery - Ajax How to get Multiple Response while response is generating -

i want know if it's possible print while ajax processing request.if yes please let me know, because facing 1 problem , want print in between ajax call request , it's response comes actually want read csv of 3000+ rows , in between process want display no of rows read , copied in csv. so want show process bar out of 3000 there 50 rows copies , continue process until reach 3000 rows. it there way let me know! you can use xhr progress events (if browser supports them): https://developer.mozilla.org/en-us/docs/dom/xmlhttprequest/using_xmlhttprequest#monitoring_progress https://dvcs.w3.org/hg/progress/raw-file/tip/overview.html#interface-progressevent how check in javascript if xmlhttprequest object supports w3c progress events? but question more i have 1000 bytes out of possible 9999 . want know how many rows have read point. i think can read xhr.responsetext on each progress event, if request parseable when incomplete (such plain text), , when not usi

sql - Can I use aggregate functions and get individual results in one query with MySQL? -

i have apartment table many columns. apartments share price , idlayout column values. however, still have different values area (shoddy workmanship). i need to: 1) group apartments same idlayout , price , min , max area , count number of apartments in each group. 2) list individual apartments each group. can done one query , should trying so? what tried: i got query first part, can't come way list apartments in result set. select count( * ), price, rooms, max( area ) areamax, min( area ) areamin apartment group price, layout_idlayout order rooms asc, price asc you need use join: select apartment.*, areamax, areamin, cnt apartment inner join ( select idlayout, price, max(area) areamax, min(area) areamin, count(*) cnt apartment group price, layout_idlayout) ap_grp on apartment.idlayout=ap_grp.idlayout , apartment.price=ap_grp.price this show apartment data, along max, min , count other apartments have same price

javascript - chrome.storage.local.get results in "Undefined" when called -

i'm building chrome extension, , needed save data locally; used storage api . got run simple example , save data, when integrated application, couldn't find data , giving me "undefined" result. here code: function saveresults(newsid, resultsarray) { //save result for(var = 0; < resultsarray.length; i++) { id = newsid.tostring() + '-' + i.tostring(); chrome.storage.local.set({ id : resultsarray[i] }); } //read , delete saved results for(var = 0; < resultsarray.length; i++) { id = newsid.tostring() + '-' + i.tostring(); chrome.storage.local.get(id, function(value){ alert(value.id); }); chrome.storage.local.remove(id); } } i not type of data saving or how much, seems me there may more 1 newsid , resultsarray of varying length each one. instead of creating keys each element of resultsararry have consider

java - oAuth 2.0 for google apps audit api -

i using following method oauth credentials google apps audit api string consumer_key = "consumer_key"; string consumer_secret = "consumer_secret"; googleoauthparameters oauthparameters = new googleoauthparameters(); oauthparameters.setoauthconsumerkey(consumer_key); oauthparameters.setoauthconsumersecret(consumer_secret); oauthparameters .setscope("https://apps-apis.google.com/a/feeds/compliance/audit/ https://www.googleapis.com/auth/userinfo.email"); oauthparameters .setoauthcallback("url_where_i_handle_callback_from_google"); googleoauthhelper oauthhelper = new googleoauthhelper( new oauthhmacsha1signer()); oauthhelper.getunauthorizedrequesttoken(oauthparameters); req.getsession().setattribute("tokensecret", oauthparameters.getoauthtokensecret()); string approvalpageurl = oauthhelper .createuserau

MongoDB cloning (db.copyDatabase), clone only half of database -

i have database have 4 gb data , when try dump mongodump dump 1,93 gb. , when try clone db.copydatabase() copy same amount of data mongodump. is there limit in mongodb? thanks , sorry bad english (i hope understand me). edit { "ns" : "some-db.persons", "firstextent" : "0:31000 ns:some-db.persons", "lastextent" : "4:b50d000 ns:some-db.persons", "extentcount" : 13, "extents" : [ { "loc" : "0:31000", "xnext" : "0:42000", "xprev" : "null", "nsdiag" : "some-db.persons", "size" : 32768, "firstrecord" : "0:310b0", "lastrecord" : "0:38e3c"

optimization - WPF Application in POS terminals -

im working on application pos terminals specification one: cpu support intel pineview d525 duo core, 1.8g, l2 1m fsb667/800mhz chipset cpu integrated graphic + ich8m system memory 1 x ddr3 so-dimm socket 2gb graphic memory intel gma 3150 share system memory 256mb they dont have active cooling, , when works on 5-7 hours (with wpf app still running), hot , work slow - example relogginng user in system (with ado connection, , select user name = entered string) sometime takes 2 minutes. here question - possible somehow optimize wpf application (for example turn function off)? checked cpu usage ~25%, application doesnt take of ram memory. maybe there problem graphic card? bad thing that, pos after 5-7 hours shows on sensor 100*c (+ -), , becouse of work slow (even opening computer etc.). it possible tune application low power there no magic switch it. you need remove effects make simple possible. i'd guess these in order, might have compare cpu usage on se

regex - How to get to a file by passing relative path in java? -

i trying understand "how file passing relative path of file or folder?" . here example: code: public class somex { public static void main { string filename = system.getproperty("user.dir"); <---this gives me path current working directory. file file = new file(filename + "../../xml_tutorial/sample.xlsx" ); system.out.println(file.getcanonicalpath()); <---this gives me path file residing in folder called "xml_tutorial". } } >>>> here, know file location able pass correct relative path. and, managed print file path. have deleted "sample.xlsx" , executed above code; no failing gives me path name , same path when file exists (i.e. before deleting). how possible ? expecting exception here. why not throwing exception ? two, want use regular expression file n

windows - How can my java app detect if its being blocked by firewall -

i have created application desktop using java works server , accepts incoming connections using serversocket . software works on lan , needs allowed firewall. how can check within app if being blocked pc's firewall ? you can try connect reliable site eg stackoverflow.com try { new socket("stackoverflow.com", 80); } catch (ioexception e) { // wrong, not firewall problem ... } // no firewall

java - Implementing Factory Method Pattern using Spring -

i want understand how following factory method pattern can implemented using spring. here code without using spring interface fileparser { void parse() } class xmlfileparser implements fileparser { void parse() { } } class pipefileparser implements fileparser { void parse() { } } class fileparserfactory { fileparser getparserinstance(string filetype) { if("xml".equals(filetype) return new xmlfileparer(); else return new pipefileparser(); } } class activityhandler() { void handle(string filetype) { fileparser fileparer = fileparserfactory.getparerinstance(filetype); fileparser.parse(); } } thanks in advance. i create bean fileparserfactory repsonsible returning new parsers. additionally factory bean have map (filetype => parser) , default parser public class fileparserfactory { private map<string, fileparser> fileparsers; private fileparser

java - Generate all combinations of 10 digits without any repetition -

this question has answer here: generating variations without repetitions / permutations in java 9 answers i having assignment creating password through java: suppose work in safe selling company , manager asked create list of ten digit numbers between 0000000000 , 9999999999 without repeating digit in same number. method algorithm in java? here's i've done far: public static long generatenumber() { string s1 = "33333"; double d = math.random(); d=d*100000.0; int = (int) d; string s2 = string.valueof(i); string s3=s1+s2; long m = long.parselong(s3); return m; } if you're looking ten digit numbers without duplicate digits, you're looking generate permutations of digits, i.e. string "0123456789" . there other threads on this, example these generating permutation

facebook - How can I detect new opened window with JavaScript? -

i have page facebook button pops new window confirm like. how can detect when window opens/closes? the reason i'm asking because facebook provides way subscribe event when confirmed, there doesn't seem way detect user canceled confirmation(either closing window or clicking "cancel" instead of "confirm"). any ideas appreciated :)

ios - Do "Supported Interface Orientations" have precedent? -

i'm developing app , 1 screen auto-rotate landscape. this rotating screen in app. i'm trying find easiest way of doing this. if set supported orientations in build summary page (i.e. toggle buttons) portrait. can override in code screen want auto-rotate? or have other way round? i.e. support orientations , disable screens don't want rotate? thanks or have other way round? i.e. support orientations , disable screens don't want rotate? yes. must list info.plist all orientations support. limit particular view controller orientations supportedinterfaceorientations . 1 landscape view controller must presented, i.e. use "modal" segue or call presentviewcontroller:animated: . my answer here may useful: https://stackoverflow.com/a/13755923/341994 and answer here: https://stackoverflow.com/a/15301322/341994

imageview - How to fill the screen with an image on Android -

i'm working on mdpi, , when add imageview activity doesnt fill screen, tried setting scaletype fitxy image didnt fill screen, i'm using relativelayout you must set width , height parameters match_parent in xml layout (instead of wrap_content)

php - How to hide the next button when no pages to dispaly -

can me please? sure easy guys. battling find solution on how hide next link when there no pages display code follows: if (!isset($_get['page']) or !is_numeric($_get['page'])) { $page = 0; } else { $page = (int)$_get['page']; } $pages_query=mysql_query ("select count * hardware"); $result = mysql_query("select * hardware limit $page, 3"); echo '<a href="'.$_server['php_self'].'?page='.($page+3).'">next</a><p>'; $prev = $page - 3; //only print "previous" link if "next" clicked if ($prev >= 0) { echo '<a href="'.$_server['php_self'].'?page='.$prev.'">previous</a>'; } you can use mysql_num_rows($result) number of records in hardware: $result = mysql_query("select * hardware limit $page, 3"); $record_count = mysql_num_rows($result); if ($record_count > 1) echo &

css - Whitespace at the end of the HTML -

i trying dynamic grid layout links other pages, consisting of picture , text. problem don't seem find way of introducing whitespace (padding/margin) after grid layout. in other words, page ends main div ends. here code. appreciated, have tried lot of methods, , neither 1 of them worked. lot. <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" media="screen" href="resources/index.css" /> </head> <body> <div class="header"></div> <div class="body"> <!-- standard link each category, inserted n times .. problem visible after inserting min of 12 times--> <a href="" class="categorie"> <img src="imgs/asd.png" class="imagine"/> <div class="nume&

change desktop wallpaper c# -

this question has answer here: change desktop wallpaper using code in .net 3 answers i want create program saves bmp image file on driver , sets image wallpaper. code managed write saves image in correct place image doesn't appear wallpaper. please help... class program { [dllimport("user32.dll", charset = charset.auto)] private static extern int32 systemparametersinfo(uint32 uiaction, uint32 uiparam,string pvparam, uint32 fwinini); private static uint32 spi_setdeskwallpaper = 20; private static uint32 spif_updateinifile = 0x1; private string imagefilename = "d:\\wall.bmp"; static void main(string[] args) { bitmap bmp = new bitmap(properties.resources.wall); bmp.save("d:\\wall.bmp"); systemparametersinfo(spi_setdeskwallpaper, 0, "d:\\wall.bmp", spif_updateinifile);

Applying Dynamic LINQ on Azure table storage is thowing exception Value cannot be null -

im trying query azure table storage's table using dynamic linq queries subset of columns along dynamic constructed predicate. able generate predicate, implement select i.e. projection operation required properties/ columns entities of azure table i'm facing difficulties. sub set of columns i'm trying use dynamic linq library. here columns not predefined, columns can anything, user may select. these columns nothing properties of customer class.. months.asparallel().forall(x => rowkeys.asparallel().withdegreeofparallelism(5).forall(y => { string startrowkey = y.getrowkeystartfilter(); string endrowkey = y.getrowkeyendfilter(); datacontextexcisecustven rptcontextparallel = new datacontextexcisecustven(); var strpredicate = getpredicate(x.tostring(), startrowkey, endrowkey); iqueryable<dynamic> query = (rptcontextparallel.createquery<domaindata.entities.excise.i

r - How to change na.action for zero-inflated regression model? -

i running zero-inflated negative binomial regression model using function zeroinfl pscl package. i need exclude na's model in order able plot residuals against dependent variable later in analysis. therefore, want set na.action="na.exclude" . can without problem non-zero-inflated negative binomial regression model (using glm.nb glm package), eg. fm_nbin <- glm.nb(dv ~ factor(idv) + contr1 +contr2 + contr3, data=df, subset=(df$var<500), na.action="na.exclude") fm_nbin.res = resid(fm_nbin) plot(fm_nbin.res~df$var) works fine. however, when same zero-inflated model, not work: zinfl <- zeroinfl(dv ~ factor(idv) + contr1 +contr2 + contr3 | factor(idv) + contr1 +contr2 + contr3, data=df, subset=(df$var<500), na.action="na.exclude") zinfl.res = resid(zinfl) plot(zinfl.res~df$var) gives error error in function (formula, data = null, subset = null,

Enable image upload for CKEditor at asp.net -

i use ckeditor asp.net c# project. how can enable image upload tab editor. read find articles none of them useful. of them php. want asp.net. thank helping. i http://www.codedigest.com/articles/aspnet/423_upload_images_and_integrate_with_ckeditor_in_aspnet.aspx letutorial using filebrowserimageuploadurl property our own implementation of file uploader. botton of upload didn't appear , nothing happened. code here: <head runat="server"> <script src="scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script src="ckeditor/ckeditor.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { ckeditor.replace('<%=ckeditor1.clientid %>', { filebrowserimageuploadurl: '/upload.ashx' }); }); </script> </head> <body> <form id="form1" runat="serve

javascript - doesn't work .buttonset() on jQuery -

i have number of :checkbox elements initialized wordpress. set .buttonset() function #format not work... sample: http://jqueryui.com/button/#checkbox html: <div id="format"> <?php $categories = get_categories(); foreach ($categories $category) { ?> <input type="checkbox" name="check" value="<?php echo $category->cat_id; ?>"> <label><?php echo $category->cat_name;?></label><?php } ?> </div> js: $('#format').buttonset(); $('input[type=checkbox]').removeclass('ui-helper-hidden-accessible'); $(':checkbox[name=check]').each(function( ){ var nameid = 'check'+ (i+1); this.id = nameid; $(this).next('label').prop('for', nameid); }); all checkboxes has same name "check". try this: <div id="format"> <?php $i = 0; $categories = get_categories

php - Codeigniter Multiple File Upload Encryption Issue -

i've got big form allows users upload multiple files/filetypes offer/bid creating. working fine except 1 piece: name encryption of files before saving database. i haven't found rhyme or reason it, it's hit or miss. image works fine every time. other documents (which allow [*] types, consist of various business docs such pdf, doc, xls, etc.) ones spotty. i found threads on , elsewhere general issues name encryption have yet come across 1 deals specificity of issue. here's upload function: //for multi uploads function do_uploads($name, $file) { $status =""; $msg = ""; $file_element_name = $name; //go through , figure out goes if($name == "quotedoc") { $folder = "quotedocs"; $allowed = '*'; } else if($name == "productofferphoto") { $folder = "product_p

css - Different image align ment for mobile -

i have 2 column content theme 1 column text , other image have coded in such way (coded in html) looks like text - img , img - text , text - img , img - text , text - img , img - text , but mobile need in text - img, text - img, text - img, text - img, text - img column code .one-half, .three-sixths, .two-fourths { width: 48.4375%; line-height: 1.2875; } html code <div class="one-half first"></div> <div class="one-half"></div> is possibility changing in mobile in html or css (if yes, how?) my site url <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <style> .one-half-first { float:left; width:3

c# - Splitting a string seems not to work -

i have problems reading file (textasset) line line , getting results! here file trying read: author comment info 1 x arg 0001 0.581 2.180 1.470 info 2 x arg 0001 1.400 0.974 1.724 info 3 x arg 0001 2.553 0.934 0.751 info 4 x arg 0001 3.650 0.494 1.053 info 5 x arg 0001 1.188 3.073 1.532 info 6 x arg 0001 2.312 1.415 -0.466 info 7 x arg 0001 -0.232 2.249 2.180 end here code using: //read file string[] line = file.text.split("\n"[0]); for(int = 0 ; < line.length ; i++) { if(line[i].contains("info")) { //to replace spaces single underscore "_" (it works fine) string l = regex.replace(line[i]," {2,}","_"); //in debug.log correct results //for example "info_1_x_arg_0001_0.581_2.180_1.470" debug.log(l); string[] subline = regex.split(

Does anybody get these weird repeated ()()()()()() in Vim? -

Image
couple of times day this, when typing in browser() statement while debugging. it repeats whole bunch of brackets, when typed pair. type "browser() esc :w enter " (without quotes) can save , go r environment, , pauses second, , sticks these brackets in. it's not problem, quick undo takes out, wondering why this. moving fast vim (touch typist). i'm using vim 7.3 on windows 7. on more 1 machine. in cases i'm mapping caps lock escape using sharpkeys, don't know if might factor. seeing this? remedy? thanks. for completeness, here vimrc file: colorscheme clarity syntax enable set guifont=consolas:h10:cansi set number set tabstop=4 set shiftwidth=4 set softtabstop=4 set expandtab set autoindent set smarttab set backspace=indent,eol,start set nocompatible set expandtab filetype plugin on filetype indent on set ruler set cursorline set noerrorbells set visualbell "set guioptions-=m set guioptions-=t i guessing on line 32 had: browser

Implementing javascript menu into website -

i following tutorial on creating javascript menu , have got working in blank html file. however, i've tried working in index page , isn't working. i've linked working nav nav2.html , 1 i'm trying working index.htm js files in folder on root called js , css files in folder on root called css. i suspect need edit html code bit work in index file i've tried can , still isn't working. would appreciate help calebk ok several things: your header's overflow set hidden hiding menu you'll have change that, can try setting overflow:visible removes problem header overflows right you'll have fix that. remove position:absolute submenu it's positioning wrong. slider hiding submenu, fix you'll have increase z-index of #topnav div let's z-index:10 after making changes result: http://prntscr.com/13f2lu

mysql - Search a many to many relationship with a wild card, performance issues -

i building database app , testing performance issues on larger data set. generated 250,000 location records. each location can assigned many categories , category can assigned many locations. data-set has 2-4 categories assigned each location. i want allow user search locations filtering categories should allowed using wild card search. maybe want match categories word "red" in it. if type red, shows locations have category title has "red" in it. in addition, wildcard search location title same string. i wrote query works performance awful in large data-sets. using inner queries fine if limit set , find results quick (around .05ms). if don't find results right away, looks goes through whole database , query takes around 9-10 seconds. here simplified layout of database: locations: id | title | address categories: id | title locations_categories: id | location_id | category_id here query using: select `id`,`title`,`address` (`locations`) t

python - Find all links within a div using lxml -

i'm writing tool needs collect urls within div on web page no urls outside div. simplified page looks this: <div id="bar"> <a link dont want> <div id="foo"> <lots of html> <h1 class="baz"> <a href=”link want”> </h1> <h1 class="caz"> <a href=“link want”> </h1> </div> </div> when selecting div firebug , selecting xpath get: //*[@id="foo"]. far good. i'm stuck @ trying find urls inside div foo. please me find way extract url defined href in elements. example code similar i'm working on using w3schools: import mechanize import lxml.html import cookielib br = mechanize.browser() cj = cookielib.lwpcookiejar() br.set_cookiejar(cj) br.set_handle_equiv(true) br.set_handle_gzip(true) br.set_handle_redirect(true) br.set_handle_referer(true) br.set_handle_robots(false) br.set_handle_refresh(mech

c++ - Data position in file -

at first loaded variables memory @ application start. on time, number of variables became huge don't want anymore. instead retrieving them when needed (using mapped file, story). at first write variables file. (this repeated many times...) vector<udtaudioinfo>::iterator = naudioinfos.content().begin(); (;it != naudioinfos.content().end(); ++it) //i think here should store position data begin in file //i still need add code that... //now write variables fwrite(&it->unitid,sizeof(int),1,outfile); fwrite(&it->floatval,sizeof(double),1,outfile); //i think here should store length of data written //i still need add code that... } but need load variables dynamically, need keep track of stored. my question be: how can find out current write position? think , hope use keep track on data resides in file. you can use function ftell() reading or writing variables. for example, in example code above, find position @ s

Python one-liner (converting perl to pyp) -

i wondering if possible make one-liner pyp has same functionality this. perl -l -a -f',' -p -e'if ($. > 1) { $f[6] %= 12; $f[7] %= 12;$_ = join(q{,}, @f[6,7]) }' this takes in comma separated list of numbers 8 numbers per line , outputs in same format except last 2 numbers in each line reduced modulo 12. outputs first line (the header line) verbatim first. i have quite lot of these obscure perl one-liners , in first instance translate them python. for record, i'm not sure approve. writing code horizontally doesn't seem me better writing vertically, , -- in friendly way -- i'm little sceptical offers many advantages in practice might seem. 1 of joys of python no longer have worry writing golfscript. that said, how about: pyp "mm | p if n==0 else (p[:-2] + [(int(x)%12) x in p[-2:]]) | mm" which produces: localhost-2:coding $ cat exam.pyp a,b,c,d,e,f,g,h 11,22,33,44,55,66,77,88 12,23,34,45,56,67,78,89 13,24,35,46,57,

solr - dataimport handler is indexing 0 documents -

hello i'm tring create dataimport url i have url http://domain.loc/path under url have dynamicly generated xml now have dataimport this <dataconfig> <datasource type="httpdatasource" /> <document> <entity name="pages" pk="uid" url="http://domain.loc/?no_cache=1&amp;type=9999" processor="xpathentityprocessor" foreach="/items" transformer="dateformattransformer"> <field column="uid" xpath="/items/item/uid" indexed="true" stored="true" /> <field column="name" xpath="/items/item/title" indexed="true" stored="true" /> </entity> </document> xml under url looks this <?xml version="1.0" encoding="utf-8"?> <i

jquery live filter based on content and tags -

i'm using jquery live filter plugin: (function($){ $.fn.livefilter = function(inputel, filterel, options){ var defaults = { filterchildselector: null, filter: function(el, val){ return $(el).text().touppercase().indexof(val.touppercase()) >= 0; }, before: function(){}, after: function(){} }; var options = $.extend(defaults, options); var el = $(this).find(filterel); if (options.filterchildselector) el = el.find(options.filterchildselector); var filter = options.filter; $(inputel).keyup(function(){ var val = $(this).val(); var contains = el.filter(function(){ return filter(this, val); }); var containsnot = el.not(contains); if (options.filterchildselector){ contains = contains.parents(filterel); containsnot = containsnot.parents(fil

android - Crash while starting the third activity -

i'm new in android. i'm having problem right now. app crashes when starting 3rd activity here code package com.example.anagramgame; import android.app.activity; import android.os.bundle; import android.database.cursor; import android.widget.toast; public class level_list extends activity{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.level_list); dbadapter db = new dbadapter(this); db.open(); cursor c = db.getallquestions(); if(c.movetofirst()) { { displaytitle(c); }while (c.movetonext()); } db.close(); } public void displaytitle(cursor c) { toast.maketext(this, "id: " + c.getstring(0) + "\n" + "answer: " + c.getstring(1) + "\n" +

mongoid - Sorting on GeoWithin MongoDB -

so made query: db.zips.find( { loc : { $geowithin : { $box :[ [ -90 , 30 ] , [ -80 , 40 ] ] } } } ) and here 1 (out of many) outputs: { "city" : "apison", "loc" : [ -85.016404, 35.014926 ], "pop" : 1614, "state" : "tn", "_id" : "37302" } my question how able sort population , limit 10? when try {$sort{pop:1}} errors doesn't know pop, when add {$limit:10} @ end or query doesn't limit 10 entries shows me last column. any appreciated! db.zips.find({loc:{$geowithin:{$box:[[-90,30],[-80,40]]}}}).sort({pop:1}).limit(10)

Java - Using Generics or Inheritance -

i have interface, resource , supposed wrap something , expose few operations on wrapped object. first approach write following, strategy pattern in mind. interface resource<t> { resourcestate read(); void write(resourcestate); } abstract class abstractresource<t> implements resource<t> { // strategy comes in. protected abstractresource(resourcestrategy<t> strat) { // ... } // both read , write implementations delegate strategy. } class exclusiveresource<t> extends abstractresource<t> { ... } class shareableresource<t> extends abstractresource<t> { ... } the 2 implementations above differ in locking scheme used (regular locks, or read-write locks). there resourcemanager , entity responsible managing these things. idea of usage client, be: resourcemanager rm = ... mycustomobject o = ... mycustomreadwritestrategy strat = ... rm.newresourcefor(o, "id", strat); this way, client know