Posts

Showing posts from January, 2011

awk - add column of 1's to tab-delimited file -

can't find solution, though thousands of variations of question have been asked. i want add column of 1's tab-delimited file using awk or sed. the file have 20 million lines, efficient nice. turn this: a b c r j k t w into this: a b c 1 r j k 1 t w 1 assuming used awk -f'\t' instead of awk : { print $0 fs 1; } if didn't use -f option, replace fs 1 "\t1" .

excel - Copy data from each column based in if condition -

i have data in sheet looks like a b c d 1001 1002 1003 phone 1 1 1 tv 1 1 remote 1 ac 1 1 1 i want macro gives data in sheet like phone 1001;1002;1003 tv 1001;1003 remote 1003 ac 1001;1002;1003 in 2 columns this sample data, columns , rows vary every time large numbers 1000. need macro data first row, if corresponding cell has "1" in it. this might .. sub init() dim x, y integer dim s string dim xt worksheet set xt = sheets("sheet2")'----------> may change y = 2 6 '--------------------tv,remote,etc s = "" x = 2 4 '------------------1001,1002,1003 if cells(y, x) = 1 if len(s) > 0 s = s & "; " s = s & cells(1, x) end if next xt.cells(y, 1) = cells(y, 1) xt.cells(y, 2) = s next end sub

App Engine split application into modules -

i'm trying use new app engine modules feature , trying test drive provided sample application when i'm pushing modules with: appcfg.py update app.yaml mobile_frontend.yaml static_backend.yaml i receive error: error 400: --- begin server output --- app may not have more 2 modules. please remove 1 of existing modules deleting of versions before trying create new module. --- end server output --- ok, seems need enable billing in order push more 2 modules (i looked quotas didn't find info this), also, had billing enabled took sometime become effective if you're receiving same error wait bit.

ios - How do I change the position of this element on the ViewController programatically? -

i have code in viewcontroller.m there no strobyboard/xib file fine on screen element comes in centre automatically. how add custom position it? uiimageview *bgimageview = [[uiimageview alloc] initwithimage:_bgimage]; [self addsubview:bgimageview]; as far i'm aware should able add cgrectmake code somewhere can't figure out. any suggestions? bgimageview.frame =cgrectmake(x,y,width,height); if want maintain previous values: bgimageview.frame =cgrectmake(x,y, bgimageview.frame.sizewidth, bgimageview.frame.size.height);

C# how to find item which item is clicked in a list? -

i trying check on item have clicked, making kind of inventory, if clicked on 1w, texture change clicked texture. list have made. can't seem find code works. this.drivers = new list<driver>() { new driver(this.game, this, new vector2 (0, 62), "1w", "images/clubs/drivers/1w", this.inventory), new driver(this.game, this, new vector2 (62, 62), "2w", "images/clubs/drivers/2w", this.inventory), new driver(this.game, this, new vector2 (124, 62), "3w", "images/clubs/drivers/3w", this.inventory), new driver(this.game, this, new vector2 (186, 62), "4w", "images/clubs/drivers/4w", this.inventory), new driver(this.game, this, new vector2 (248, 62), "5w", "images/clubs/drivers/5w", this.inventory), new driver(this.game, this, new vector2 (310, 62), &q

php - How would you optimize the following mysql query -

can me in optimizing mysql query in php, takes 100 sec. select distinct a.x, a.y, a.z, tableaa inner join( tablebb b) on(a.x = b.x) or (a.x = b.m) b.n = '$input' or a.y = '$input' or a.z = '$input' tableaa has 1 million enteries tablebb has 9 million enteries is there anyother way write query? edit: tablebb has primary index on connection between n, x ,y. , indexes on x, n, m tableaa has primary index on x , indexes on y, z your query (formatted in way can better understand it) is: select distinct a.x, a.y, a.z tableaa inner join tablebb b on a.x = b.x or a.x = b.m b.n = '$input' or a.y = '$input' or a.z = '$input'; this complex optimization because of or clauses. first inclination write 2 joins instead of or : select distinct a.x, a.y, a.z tableaa left outer join tablebb b on a.x = b.x , b.n = '$input' left outer join tablebb b2 on a.x = b2.m , b2.n = '$

java - Intent filter for android downloads -

this question exact duplicate of: android download manager hook other download requests i have made download manager android, problem don't know intent use fire download manager instead of default manager of android download browser. can ? we use below intent trigger download intent intent = new intent(intent.action_view, uri.parse(httppathtofile)); here if httppathtofile http url , browser start downloading it. can listen action view here, , if url can take care of accordingly.

android - Using RelativeLayout instead of Nested Weights -

i've been working on simple soundboard app. basic design imageview title, followed 4 rows of buttons (3 in each row), makes similar old cellphone's buttons. @ bottom, there "random" , "stop" button. take less height space rows mentioned above, random button double width fill space. to achieve look, have been using nested weights , linear layouts. however, upon further research, have found bad performance because in current format, each item being measured 8 times. xml layout code below. have excluded lot of ui modifiers such margins, text, , shadows on buttons make code smaller. code may seem long, repetitive , simple understand. <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightsum="2

java - Disable parent window of popup in JSP -

i have jsp page on when 'search' button clicked popup window open, i want disable parent window on popup , using window.opener.document.body.disabled=true; but though make parent window appear disabled, dont make disabled, controls, links tabs enabled , can used/clicked. what should do? edit cannot use modal reason. you can use jquery ui dialog , , set modal form. read so answer more tips. another option iterate through input , anchor in page , and explicitly set disabled=true each of them. this blog describes how disable page elements transparent div , using css , bit of javascript .

c# - How to post only the selected value from a DropDownList? -

with following setup below, nationalities posted server, don't care entire list, selected value. how modify code selected nationality posted rest of model? model: // searchcriteria model public class searchcriteria() { public searchcriteria() { nationalities = new list<selectlistitem>(); nationalities.add(new selectlistitem { text = "any nationality", value = "any nationality", selected = true }); nationalities.add(new selectlistitem { text = "united states", value = "united states", selected = false }); nationalities.add(new selectlistitem { text = "japanese", value = "japanese", selected = false }); nationalities.add(new selectlistitem { text = "mexican", value = "mexican", selected = false }); nationalities.add(new selectlistitem { text = "canadidan", value = "canadidan", selected = false }); nation

ruby on rails - Rendering Partial with specific :category_id -

i created categories scaffold . user's can upload image , add category it. categories created in scaffold shown in dropdown users select. on image show page link category -> <%= link_to @pin.category.name, @pin.category%> it takes me (for example) localhost:3000/categories/1 on category show page want display images share same category. how do ? in models define catagory has_many :images and image belongs_to :category image should have category_id member of course then , when have category object in hand (let's @cat), iterate @cat.images you can read more models , relation in here http://guides.rubyonrails.org/association_basics.html

c# - How can I have xy coordinates in a grid that can't be used? -

how can have xy coordinates can't used? don't want xy (5,5) , (7,9) ever used. how can this? x = random.next(0, 20); y = random.next(0, 20); // if xy coordinate (5,5) or (7,9), keep trying above obtain different xy value when xy coordinate created how can have coordinates not usable? just loop on creation until condition satisfied: var forbidden = new list<tuple<int, int>>(); forbidden.add(new tuple<int, int>(5, 5)); forbidden.add(new tuple<int, int>(7, 9)); while(true) { x = random.next(0, 20); y = random.next(0, 20); if(forbidden.all(t => x != t.item1 || y != t.item2)) break; } this way, loop terminate if have coordinates "allowed", i.e. reach break statement.

jquery - $(this) not working x-editable -

i'm trying set dynamic retrieve of pk , selector not working, here code: #html file <div id="{{task.id}}"> <h3> <a href="#" id="task">{{ task.task }}</a> </h3> ... </div> #js file $("#task").editable({ type: 'text', **pk: $(this).closest('div').attr('id'),** url: '/update_task/' + pk + '/', title: 'enter task', }); this 1 not working, if write: pk: $("#task").closest('div').attr('id') will work, not convenient me. thank in advance :) this refers options object, , not jquery object. if have one-off field want extract primary key send server, do: var $task = $("#task"); $task.editable({ type: 'text', pk: $task.attr("id"), url: '/update_task/' + pk + '/', title: 'enter task'

javascript - Slideshow in JS -

i trying make simple slideshow of 3 pictures in js. i wrote following code in <head> code </head> , not working. the problem, suspect, brackets. however, far can see, brackets match up. but delete last 2 } brackets, , re add them, when type in first one, says mismatched bracket, when type second one, matches { bracket beside function line. here code. have created forward , backward buttons in body of site call function, , appear on site, when click buttons, nothing happens, due bracket problem can't figure out. above function line, included title, script tags js, , made array called pictures 3 pictures in (the pics did not end in jpg, might problem??). i set array 0. function runslideshow(forwardback){ if (document.images){ cur

rabbitmq - Where celery saves tasks? -

hy, where celery (or rabbitmq) saves scheduled, un-ack messages/tasks? restored in case of failure? understand saves parametrs along code. how if parameters few mb, can problem when there lot of tasks? thank you! broker (rabbitmq) takes care messages store , deliver, if consumer fails pending (un-acked) messages message delivered other consumer (if any) again. rabbitmq store entities in memory or on disk. i didn't mean saves parameters along code you talking message arguments or queue/exchange parameters? if meant message arguments stored message body. message size in few mb ok. best message size depends of architecture, say, in cases message size should small possible , in may care 100mb, large messages not amqp protocol designed for.

remote desktop - How to enable connection to virtualbox machine from outside the Host (i.e. from any PC connected to Internet) -

i have host virtualbox installed , guest installed (both windows xp sp3). have connection between them. , guest have internet connection. can connect via remote desktop connection host guest, want able connect guest other pc. if can, how achieve this? guest using 2 network adapters, 1 nat sharing internet connection , 1 host-only able both machines see each other on local network. assuming have internet router providing access isp... change vm networking nat bridged. check guest still has internet connectivity after rebooting or ipconfig /renew . configure router give guest fixed ip address. (typically, guest can still use dhcp router configured give guest same ip address every time.) determine ports , protocols needed connect guest. e.g, tcp on port 3389 (rpd) remote desktop. configure router's "port-forwarding" feature route external connections ip address of guest. can designate different port external connections might not through firewalls betwe

php - Select current option in select menu -

lets $cat 5, want have forum id 5 selected wont. have forum id 5. shouldn't work? <select name="category" id="category"> foreach($db->query("select name forums order disp_position asc") $row) { if ($cat == $row['id']) { echo '<option value="'.$row['id'].'" selected>'.$row['name'].'</option>'; } else { echo '<option value="'.$row['id'].'">'.$row['name'].'</option>'; } } </select> you should add id field in select. select id, name forums order disp_position asc

ruby on rails - Why does my controller render the wrong view? -

i have 2 controllers, , 1 inherits other: class firstcontroller < applicationcontroller ... def show ... end end class secondcontroller < firstcontroller ... def show ... end end the views folder first controller contains following files: views/first/show.html.erb views/first/show.js.erb the views folder second controller contains html file: views/second/show.html.erb render or redirect not being called within controller's show methods. when call secondcontroller#show js , expect views/first/show.js.erb rendered, not happening. in response: rendered second/show.html.erb . if remove file views/second/show.html.erb , there no problem, , in response rendered first/show.js.erb . why happening? what can call js view of parent controller in non-explicit way rendering first/show ? that's pretty weird. shot in dark, happens if in second controller explicitly tell file render js? class secondcontroller < firstcontroll

javascript - Trying to create Share-Wysiwyg -

i stuck how should attack problem. trying create wysiwyg editor works sharejs. demo can found here: http://173.230.158.248:10000/tiny.html i trying create light weight near realtime wysiwyg editor can incorporate site easily. problem encountering can update div area , copy html contents of div textarea. unable trigger textarea function here: https://github.com/jcostello84/sharejs-wysiwyg/blob/master/tiny_files/textarea2.js#l81 i've tried using using trigger like: $('#purpose-editor').trigger('keydown'); however returns: uncaught typeerror: object asdfads<div>asdf</div> has no method 'attachevent' does have idea how can trigger keydown event on textarea when updating div?

c# - A dictionary that can save its elements accessed less often to a disk -

in application use dictionary (supporting adding, removing, updating , lookup) both keys , values or can made serializable (values can possibly quite large object graphs). came point when dictionary became large holding in memory started trigger outofmemoryexception (sometimes in dictionary methods, , in other parts of code). after attempt replace dictionary database, performance dropped down unacceptable level. analysis of dictionary usage patterns showed smaller part of values "hot" (are accessed quite often), , rest (a larger part) "cold" (accessed or never). difficult when new value added if hot or cold, moreover, values may migrate , forth between hot , cold parts on time. i think need implementation of dictionary able flush cold values disk on low memory event, , reload of them on demand , keep them in memory until next low memory event occurs when hot/cold status re-assessed. ideally, implementation should neatly adjust sizes of hot , cold parts ,

asp.net mvc 4 - team city outputting db script -

i working team city build mvc application , used continous integration platform. within solution have mvc project , database project. team city builds both , mvc project, nuget package created. part of database project, have build event runs powershell file generates database script. is possible in team city setup output script part of output , if so, how? have @ teamcity build artifacts : find generated script in "artifacts" tab @ end of build run.

Post-install of CDH on EC2 using Cloudera Manager -- can't locate 'hadoop' executable to use hdfs -

i've installed hadoop cluster on ec2 using cloudera manager. services , running. now wish use command line client add files hdfs. i've ssh'd server , there no such executable can find. i'm assuming i've overlooking simple. help. cdh should setup alias access hadoop, if not can find hadoop ecosystem projects under /opt/cloudera/parcels/cdh/lib the binary hadoop is: /opt/cloudera/parcels/cdh/lib/hadoop/bin/hadoop

ruby on rails - How do I validate one post per day? -

i trying create validation ensure 1 post per day, 24hrs starting 00:00. how can done in rails please? i did following not sure put today method. simpler alternatives appreciated. def today where(:created_at => (time.now.beginning_of_day..time.now)) end i added validation article model: validate :time_limit, :on => :create and defined time_limit in same model so: def time_limit if user.articles.today.count >= 1 errors.add(:base, "exceeds daily limit") end but keep getting "no method" error in create action. undefined method `today' i'm not sure put method. you shoud use scopes that: class article scope :today, -> { where(:created_at => (time.now.beginning_of_day..time.now.end_of_day)) } end http://apidock.com/rails/activerecord/namedscope/classmethods/scope

php - short mysql dates array to readable -

i have array of dates contains many dates. i have placed dates on graph in php, there not enough space on graph. i want make dates short (i.e samples) placed on graph. for example array=(1,2,3,4,5,6,7,8,9,7,8,9,6,5); after short , sampling should be 1,4,8,8,5 you can loop through array , add nth values new array can use in graph. can use modulo on array keys , use ratio of values number of results whant. $new_array = array(); $array = array(1,2,3,4,5,6,7,8,9,7,8,9,6,5); $array_count = count($array); $number_of_results = 5; // number of results whant $ratio = ceil($array_count / $number_of_results); foreach ($array $key => $val) { if ( $key % $ratio == 0 ) { $new_array[] = $val; } }

php - Apache, .htaccess - Not working locally -

i have rewrite rule in .htaccess. rewriterule ^(.+?)$ /user_home.php?domain=$1 [l,qsa] which redirects mysite.com/mypage mysite.com/user_home.php?domain=mypage this works fine on shared host, when working locally, site located in www/mysite/ , instead of redirecting www/mysite/user_home.php?domain=mypage tries redirect www/user_home.php?domain=mypage doesn't exist. i following error in apache logs [error] [client ::1] script 'c:/wamp/www/user_home.php' not found or unable stat how can alter .htaccess make direct file in current directory using relative path instead of absolute path.. you need remove leading slash target url in rule this: rewritecond %{request_filename} !-f rewriterule ^(.+?)/?$ user_home.php?domain=$1 [l,qsa] rewritecond %{request_filename} !-f needed prevent infinite looping.

java - Given a class file, how to detect it uses JNI or not? -

i have java benchmarks class files. i find benchmarks have jni calls. i thought maybe can done bytecode level of javap -c , not sure. any ideas? if you're allowed load class, can use reflection: class<?> clazz = ... list<method> nativemethods = new arraylist<>(); (method m : clazz.getdelcaredmethods()) { if(modifier.isnative(m.getmodifiers())) { nativemethods.add(m); } }

ruby on rails 3 - Disabling SSL for a Heroku App -

i changed domain rails app have running on heroku. redirected original new one, , last couple of months have been running ssl on both. tried remove ssl original domain since redirect. i did thought should: turned off ssl in app config.force_ssl = false in production.rb changed dns alias , cname point "myapp.herokuapp.com" removed ssl endpoint , certs if go myapp.herokuapp.com, fine, if go myapp.com, or www.myapp.com automatically tries take me secure version of site, https://myapp.com , , standard security error warning browser. am missing something? caching issue? take time dns change kick in? i've tried on few machines/browsers, , issue consistent across of them. worst case, can add ssl endpoint on, seems overkill. config.force_ssl = true enables strict transport security header( hsts ) max-age of 1 year. see issue . such header forces browsers support contact server on https 1 year. prevent attacks in man in middle downgrades https connec

javascript - jQuery scrolltop firefox not working -

this script: function onscroll(){ document.getelementbyid("divs").style.top=""+$('body').scrolltop()+"px"; } fiddle: http://jsfiddle.net/hed2j/1/ doesn't work on latest firefox version! what doing wrong? :) help! edit: edited jsfiddle , full script :) attached onscroll event try fiddle, working in chrome, ie , latest version of mozilla : http://jsfiddle.net/hed2j/3/ i replace $('body').scrolltop() $(window).scrolltop() .

html - PHP form to send email from Website -

this html form requesting feedback. what corresponding php form place on webserver send email? new @ website design , have learnt css+ html. <table width="518" border="0"> <tr> <td width="165"><form name="form1" method="post" action=""> <label for="nameco">name/company</label> : </form></td> <td width="343"><input name="nameco" type="text" id="nameco" size="70"></td> </tr> <tr> <td><form name="form2" method="post" action=""> <label for="area">area located :</label> </form></td> <td><input name="area" type="text" id="area" size=&quo

Return an array by converting from an ArrayList in Java -

i need create method return int array casting arraylist. here code: public int[] getdestsets() { int[] array = new int[destset.size()]; destset.toarray(array); return array; } destset integer arraylist. got error "the method toarray(t[]) in type arraylist not applicable arguments (int[])". can give me hint? thanks! you can try use arrayutils class apache commons lang library. need 2 steps. first convert arraylist wrapper object array (integer[]). after can use arrayutils.toprimitive() convert array of int (int[]).

Beautifulsoup Python nested text -

i wanted obtain text "some text" nested within tags this: <tr> <td>cme globex</td> <td colspan="4"> text <a target="_blank"" href="http://...>view rollover dates</a> </td> </tr> i .findall('tr') first, some_tr.findall('td', colspan=4) second , some_td.find(text=true) . there more efficient way this? there way keep traversing through tags , find text? you can use xpath expressions using lxml : html = """<tr> <td>cme globex</td> <td colspan="4"> text <a target="_blank"" href="http://...">view rollover dates</a> </td> </tr>""" import lxml.html tree = lxml.html.fromstring(html) print tree.xpath('//tr/td[@colspan="4"]/text()') not you're after... another way maybe find anchor links "view roll

PHP stristr false positive for CDATA -

the following html/css html email sent hotmail... <style><!-- .hmmessage p { margin:0px; padding:0px } body.hmmessage { font-size: 12pt; font-family:calibri } --></style> i'm merely trying css inside style elements. may contain html comments such 1 above or cdata. strange reason php returning false-positive cdata below string above... if (stristr($b,'<style')) { $s = explode('<style',$b,2)[1]; $s = explode('>',$s,2)[1]; if (stristr($s,'<![cdata[')) { $s = explode('<![cdata[',$s,2)[1]; $s = explode(']]',$s,2)[0]; } else if (stristr($s,'<!--')) { $s = explode('<!--',$s,2)[1]; $s = explode('-->',$s,2)[0]; } else { $s = explode('</style>',$s,2)[0]; } why not take domdocument ? $html = " <style><!-- .hmmessage p { margin:0px; padding:0px } body.hmmessage { font-size: 12pt; font-family:ca

date - PHP mktime() error -

i'm of sudden getting following error on site i've done when import excel file mysql using excel_reader library. this error message mktime() produces: message: mktime() [function.mktime]: not safe rely on system's timezone settings. required use date.timezone setting or date_default_timezone_set() function. in case used of methods , still getting warning, misspelled timezone identifier. selected 'asia/krasnoyarsk' '7.0/no dst' instead the error because of following line: $string = date ($format, mktime($hours, $mins,$secs, $dateinfo["mon"], $dateinfo["mday"], $dateinfo["year"])); i'm using php version 5.3.1. script not compatible php version? how can fix error? the error says all. relying on system's timezone settings bad idea , therefore 'll need specify timezone using 1 of following options. you have 3 solutions: set default timezone in php script using date_def

coldfusion - CFLDAP to delete a group in memberOf -

can me on how delete group in memberof in ad? correct? <cffunction name="deletememberofldapgroup" access="public" output="false" returntype="void"> <cfargument name="userdn" required="true" type="string" /> <cfargument name="groupdn" required="true" type="string" /> <cfldap action="modify" modifytype="delete" attributes="member=#arguments.userdn#" dn="#arguments.groupdn#" separator="|" server = "myserver.com" port="389" username="testuser" password="abc123" /> </cffunction> thanks.

c# - Generate jQuery functions dynamically mvc 4 razor -

currently, passing list of object controller view, , generate labels object's name. what trying generate jquery function dynamically create functions (toggle form relative lable id) each label after being clicked. the jquery function not working, not output corrent jquery function in webpage...... give me soem hints? <table> @foreach (var item in model) { <tr> <td> @html.label(item.productname, new { @id = item.productid}) </td> </tr> } </table> <script type="text/javascript"> $(document).ready(function () { @foreach (var item in model) { $(@item.productid).click)(function({ //do })); } }); </script> thanks much! your js syntax wrong, starters. want give labels class name (such product_lbl ) or data attribute (if don't semantic class names) such product-lbl . way don't ha

Javascript function not firing from button click -

i have following html: <input type="text" id="theinput" /> <input id="clickme" type="button" value="search" onclick="testfunction(document.getelementbyid('theinput').value)" /><br> i trying trigger this: function testfunction(data) { alert(data); } i tried alternative, using: document.getelementbyid("clickme").onclick = testfunction(document.getelementbyid("theinput").value); sadly, neither of these methods seem function trigger. i'm sure missing simple, point out, please? i have test , found code ok, can see demo here . however, think not work in page because of way include javascript functions. have better put scripts in head tag of page. if use framework, make sure functions , bindings executed when javascript loaded.

filefield - Django python-magic identify ppt,docx,word uploaded file as 'application/zip' -

i trying identify file type of files uploaded, after searching, plan use python-magic check mime types of file. the filefield used in models, modelform used save files. after files have been uploaded, check mime type in python shell i find using magic.from_file("path_to_the_file", mime=true) woud give expected mime type image,txt,pdf files have been saved. however, docx, ppt, excel files, identify them 'application/zip' can explain why happening(the django auto save ms files zip??). , there way make magic identify docx, ppt, excel files are? thank much. i came across issue recently. python-magic uses unix command file uses database file identify documents (see man file ). default database not include instructions on how identify .docx, .pptx, , .xlsx file types. you can give additional information file command identify these types adding instructions /etc/magic (see https://serverfault.com/a/377792 ). this should work: magic.from

flex - Is there a style that will change the caret selection color in a Spark List? -

is there style or property change caret selection color in spark list? note: caret selection border color around row when using keyboard navigation. not selected row. okay, tested around bit and <?xml version="1.0" encoding="utf-8"?> <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" autodrawbackground="true" height="60"> <fx:script> <![cdata[ [bindable] public var color1:uint = 0xe54545; [bindable] public var color2:uint = 0xe5d145; [bindable] public var color3:uint = 0xa3e545; [bindable] public var color4:uint = 0x45e5c6; [bindable] public var color5:uint = 0x4564e5; [bindable] public var color6:uint = 0xe545c6; ]]> </fx:script> <s:states> <s:state name="

php - easier way to validate $_GET id's -

in url i'm passing id's this localhost/?id=1,2,3,4,5,6,7,8,9 i wondering if there better way / simpler way validate each id without using loop? if (isset($_get['id']) && !empty($_get['id'])) { $str = explode(',', $_get['id']); for($ids = 0; $ids < sizeof($str); $ids++) { if (!ctype_digit($str[$ids])) { echo 'error'; break; } } } you test string simple regular expression, eg if (preg_match('/^(\d+,)*\d+$/', $_get['id']) == 0) { throw new exeption('error'); }

jquery mobile - Phonegap Android (Not showing google ad on android HD phones) -

i have created phonegap app ios , android,in ios app google add showing perfect didn't show add in android hd device .below code have put in phonegap code google add. <script type="text/javascript">google_ad_client = "ca-pub-1334072329832035";`` google_ad_slot = "6009211105"; google_ad_width = 320; google_ad_height = 50; </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> the use of adsense mobile content in mobile application violation of adsense policies. mobile application constitutes downloadable application, if webview used display ad. adsense mobile content ad units found in mobile applications disabled. if you’re looking advertising solution mobile application, please sign admob, google’s leading mobile advertising display product.

Add commas as thousands separator and floating point dot in php -

i have this $example = "1234567" $subtotal = number_format($example, 2, '.', ''); the return of $subtotal "1234567.00" how modify definition of $subtotal, make "1,234,567.00" below output 1,234,567.00 $example = "1234567"; $subtotal = number_format($example, 2, '.', ','); echo $subtotal; syntax string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' ) but advise use money_format formats number currency string

What is the equivalent DISTINCT(sql server) in the Linq -

i have table(send) columns(id, userid,senddate) , table(receive) columns(id,sendid,username). i want show records in sendtable recieveusername. for example. (send) 1 1 2013 2 2 2013 (recieve) 1 1 jack 2 1 ema 3 2 alex 4 2 sara result 1 1 2013 jack, ema 2 2 2013 alex, sara i use query in sqlserver (the distinct keyword eliminates duplicate rows results of select statement) select distinct c2.id, (select str( username )+ ',' dbo.reciver c1 c1.sendid = c2.id xml path('')) concatenated, c2.senddate, c2.userid dbo.send c2 inner join dbo.reciver on c2.id = dbo.reciver.sendid how query in linq? it doesn't seem me need use distinct in linq query. assuming have relationships between tables set on linq datacontext, can this: var result = s in context.send select new { id = s.id, userid = s.userid, date = s.senddate,

mouseevent - jQuery - How to return a value from jQuery function (not an ajax call) -

i have following jquery function jquery(document).ready(function(){ jquery(document).mousemove(function(e){ alert(e.pagex +', '+ e.pagey); }); }); i want return these 2 values ( e.pagex , e.pagey ) in function. how can this? i tried this function getmouseposition(e) { var tt = jquery(document).ready(function(){ jquery(document).mousemove(function(e){ return (e.pagex +', '+ e.pagey); }); }); alert(tt); } getmouseposition(e) called function. can in this? any appreciated. edit: below scenario: 1. click on element on web page. 2. opens popup menu , opens jquery dialog box. 2. there image/icon in opened jquery dialog box, when click on icon, furthermore opens popup menu. when click on icon in jquery dialog return negative value first time. second time return positive value. try making handler , giving variable store results. can manipulate variable like var position = {}, // sto

java - Multiple icon comes in j2me application with multiple midlet -

Image
i developing j2me application in application have 3 midlets. 1 main midlet , 2 starting auto services. starting auto services (other 2 midlet) main midlet of pushregistry. so question have 3 midlet 3 icon comes in application. want 1 icon whole application? is possible create single icon in application multiple midlet? if not possible start autoservices without midlet? if not possible hide other 2 icon?? thanks in advance yogesh patel use attribute midlet-icon, midlet-icon principal application's icon. if use netbeans, right clic in project icon>properties>application descriptor.

jquery - show div on focus in and allow user to use option buttons -

i have html form in table allows user search or enter new details staff. show div when select input box. can using <td><input type="text" name="team" id="team" size="23" maxlength="4" onfocus="document.getelementbyid('show_teams').style.display='block';" onblur="document.getelementbyid('show_teams').style.display='none';"> </td> however user try's click option box inside div closes ( due onblur display none ) have dabled jquery , think way go can't find solution. the basic idea on selecting (focus) "team" text box div show 2 option , 3 drop down boxes. once selected correct code shift pattern placed in text box cicked, , div hide. thanks i have should example, $('.mydiv').hide(); $('#test1').focus(function(){ $('.mydiv').show(); }); $('#my_select').change(function(){ $('#test1

android - Save highscore on corona sdk? -

i want save highscore created in game , can seen in main menu when player hits highscore button, can me? you can use sqlite save highscore database way make file write score text file , save directory of system

Dojo GridX inside-column filter plugin? -

does gridx have functionality of inside-column filtering such primefaces datatable: http://www.primefaces.org/showcase/ui/datatablefiltering.jsf ? i couldn't find example it, or extension plugin doing this, i'm not sure standard name column-wide filtering placed in column header... a filtering isn't hard implement, tricky part placing component within header. couldn't find example too. somethign should possible non-hacking way well, how that?

web services - Need help to use node-soap module -

i have make server update device. asked me use node.js , device send soap request. need check parameters verify version. decided use node-soap module. (the wsdl file use local file) can't find how recover value of parameters. read node-soap spec, couldn't find how that. :/ here code (i didn't yet because i'm stuck because of this) : var myservice = { actiaproxyapi: { //myservice actiaproxyapi: { //myport getdata: function(args) { //myfunction if (args.i-uitype == "11") { var id = args.i-pcidentifiant; var reg=new regexp("[ $]+", "g"); //parse string (actually works) var tableau=id.split(reg); console.log(tableau[4] ); } return { name: args.o-podata }; } } } }; var xml = requi

java - javax.servlet.unavailablexception on jwebmail launch -

i'm having trouble on using popular jwebmail (or java webmail) jar on both tomcat 5.5 , 6. i trying make work on tomcat 6, , have put javamail jar on lib folder of tomcat found somewhere advised, still cannot make run. i got error: jul 22, 2013 10:28:54 org.apache.catalina.core.standardwrappervalve invoke severe: excepción de reserva de espacio para servlet webmail javax.servlet.unavailableexception @ net.wastl.webmail.server.webmailserver.initstorage(unknown source) @ net.wastl.webmail.server.webmailserver.doinit(unknown source) @ net.wastl.webmail.server.webmailservlet.init(unknown source) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1213) @ org.apache.catalina.core.standardwrapper.allocate(standardwrapper.java:827) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:129) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) @ org.apache.catalina.c

Nested comparator function fails TStringList.CustomSort using Delphi XE3 64-bit -

this question has answer here: why cannot take address nested local function in 64 bit delphi? 1 answer i have simple code procedure tform2.btn1click(sender: tobject); var s : tstringlist; function compare(s : tstringlist; i1, i2 : integer) : integer; begin result := comparetext(s[i1], s[i2]); end; begin s := tstringlist.create; try s.add('s1'); s.add('s2'); s.add('s3'); s.customsort(@compare); s.free; end; end; it works expected when compile 32-bit, access violation when use 64-bit. 64-bit version in function compare, s = nil. i2 = random value ; it works expected win64 target, if extract compare function outside of btn1click function. is bug of system.classes, there way fix? local nested functions should not assigned procedural variables (in particular should not passed procedural va

entity framework - EF migrations boilerplate - where is it? -

i'm speed code first migrations , project has evolved on several months stage there dozens of migrations , expect dozens more before project closes. each time use package manager add migration need make same edits generated class (specifically change out boilerplate "dbo." held global var looked config using helper, need add line of code up() , down(), add 'using' statement (move usings top of file) , replace dbo. in generated names.) i'm sure in t4 template or whatever, , migration class generated these edits made, source?

python - How to draw crosshair and plot mouse position in pyqtgraph? -

i new python , pyqtgraph. working on viewer different kinds of signals. currrently got stuck when want include crosshair , text label mouse position. working gridlayout, because later graph combined several other elements. i tried adapt pyqtgraph example crosshair / mouse interaction apart many other things in pyqtgraph not understand meaning of vb = signalgraph.vb before mousemoved() , script raises nameerror from pyqtgraph.qt import qtgui, qtcore import numpy np import pyqtgraph pg #qtgui.qapplication.setgraphicssystem('raster') app = qtgui.qapplication([]) mainwindow = qtgui.qmainwindow() mainwindow.setwindowtitle('pyqtgraph example: plotwidget') mainwindow.resize(1000,800) cw = qtgui.qwidget() mainwindow.setcentralwidget(cw) gridlayout = qtgui.qgridlayout() cw.setlayout(gridlayout) # define plot windows signalgraph = pg.plotwidget(name='signalgraph') # set position , size of plot windows gridlayout.addwidget(signalgraph,0,0) mainwindow.show()

ios - UIScrollView contained inside of UICollectionViewCell not passing touch event to the CollectionView cell -

i have uiscrollview inside uicollectionviewcell can zoom image within scrollview. when click image collectionviewcell receive event , pass uicollectionview delegate. i tried adding following uigesturerecognizerdelegate container of uiscrollview: -(bool)gesturerecognizer:shouldreceivetouch: according answer read touch event should passed on parent view - in case collectionviewcell, isn't happening. what should do? edit please note i'm not trying pinch zoom inside cell rather able receive touch events of cell. thats question having same problem. way uicollectionviewcell respond touches (intercepted uiscrollview) set userinteractionenabled = no on scrollview.

c# - Can you "Queue" webRequest to the background to speed up your program? -

the slowest part of code these lines right here: string responsestring; var webrequest = webrequest.create(url); using (var response = webrequest.getresponse()) using (var sr = new streamreader(response.getresponsestream())) { responsestring = sr.readtoend(); } return responsestring; is there way "queue up" multiple webrequest , have them download in background while code parses html between page requests? there name/method can google? links or code appreciated! thanks! *edit: full gethtml() code added you can use async methods, unblock ui , handle requests there. but posted line of code should nothing. request server occurs when calling response. with: var respone = webrequest.getresponse(); just use the, unblock ui , handle after async progresss ist done. var response = webrequest.getresponseasync(); // or beginresponse() ... endresponse(); you can read following further informa

Essential tags for building the java project using maven in pom.xml -

i building java project using maven couldn't succeed. so, can please tell me essential tags , corresponding values required in pom.xml build project? also, how add storm dependencies manually command line? my directory structure of project : root | |----com--->test----->newpackage---->*.class |--- meta-inf------>manifest.mf |----resource----->words.txt |----pom.xml |-----*.jar initially tried maven link , create pom.xml : <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>1.6</version> <executions> <execution>

.net - Unable to generate JavaScript file after saving TypeScript file -

Image
i using visual studio 2012 & have installed typescript visual studio version 0.9.0.1. have installed web essential 2012. after make changes in typescript file , save file, same changes not getting reflected in javascript file. following typescript setting. please let me know reason & steps resolve it. thank you i resolved uninstalling type script library version 0.9.0.1 , installed 0.8.1.0 version , solved problem.

android Google+ returns user birthday year as 0000 -

Image
i using google+ in application user login , posting on user wall. posting on user wall works fine. but when try user profile data returns user birthday year 0000.and happens user , other user correct birthdate. i have following code initialize google+ client mplusclient = new plusclient.builder(getapplicationcontext(), this, this) .setvisibleactivities("http://schemas.google.com/addactivity").setscopes(scopes.plus_login, scopes.plus_profile).build(); and have following code retrieve user profile data: mplusclient.loadperson(this, "me"); @override public void onpersonloaded(connectionresult arg0, person arg1) { log.i("person",""+arg1.tostring()); if (currentperson.hasbirthday()) { string birthday = currentperson.getbirthday(); mylog.i("birthdate :", "" + birthday);

namespaces - Using external libraries in TYPO3 V 6.1 for an Extension -

according http://docs.typo3.org/typo3cms/coreapireference/apioverview/autoloading/index.html typo3 v6 , using namespaces encouraged , php file should contain 1 class. quoting above link - in typo3 every class must reside in own file, i.e. there should 1 class per php file - use class naming convention , file location. my extension built using extension builder. uses twitter api library , there 1 file config.php used. file contains multiple classes in it. the question is, use config.php , following 2 conditions, should divide config.php multiple php files, each single class in ? or there neat way go ? leave external code is. coding guidelines extension , core development itself, don't need modify extenal libraries match guideline. simply include external scripts with require_once t3lib_extmgm::siterelpath('your_extension_key') . 'path/to/the/script.php'; and start using them.

javascript - loadXML does not work in chrome -

this works in ie crashes chrome in last line var ie = (window.activexobject) ? true : false; var xmldoc = (ie) ? new activexobject("msxml2.domdocument") : new window.xmlhttprequest(); xmldoc.async = false; xmldoc.resolveexternals = false; xmldoc.loadxml(xmlhttp.responsexml.text); how can solved?

dll - Add CUI references bug -

i have big problem. need develop cui tests vs 2012. need use "old" (version 10.0.0.0) cui-dll's "microsoft.visual studio.testtool.uitesting". problem is, vs always references 11.0.0.0 versions. .csprj files have right entries like: <when condition="'$(visualstudioversion)' == '10.0' , '$(iscodeduitest)' == 'true'"> <itemgroup> <reference include="microsoft.visualstudio.qualitytools.codeduitestframework, version=10.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil"> <private>false</private> </reference> <reference include="microsoft.visualstudio.testtools.uitest.common, version=10.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil"> <private>false</private> </reference> <reference include="microsoft.visualstudio.testtools.uitest.