Posts

Showing posts from August, 2012

sql - How to select the sum of distinct values in a table using mysql -

slno state district company 1 ab abc 2 ab ac 3 ab abc 4 ab abc 5 ab abc 6 ab ac output state district company sumzz ab abc 4 ab ac 2 what have tried select state,district,company,sum(company) sumzz company how achieve display last row based on distinct company? and what's wrong approach: select state, district, company, count(*) countzz company group state, district, company

javascript - Get selectbox expand/user focus event -

i have select box element in form. when clicked, want generate options display , insert html code. i have tried placing alerts on onclick, onfocus, onshow events, nothin happens :/ the html: <select name="select-building" id="select-building" data-native-menu="false" onfocus="populatebuildingoptions();"> </select> the javascript: function populatebuildingoptions(){ b = "{{\"buildingcode\":\"1\",\"buildingname\":\asca"\"},{\"buildingcode\":\"2\",\"buildingname\":\"vsdvs\"}}"; buildingoptions = jquery.parsejson(b); $("#select-building").empty(); for(var i=0;i<buildingoptions.length;i++){ $("#select-building").append("<option value=\""+buildingoptions.get(i).buildingcode+"\">"+buildingoptions.buildingname+"/option>" ); } } i got work on jsfiddle: http://jsfiddle.net/ut...

css - Place text within padding space -

i creating images polaroid effect using padding around image , setting background colour white img.team { background: none repeat scroll 0 0 white; box-shadow: 0 9px 25px -5px #000000; display: block; margin-left: auto; margin-right: auto; max-width: 100%; padding: 12px 12px 50px; } what write caption within space under image , between padding, kind of if had wrote on felt pen. im using bootstraps thumbnails images. i have tried negative margin on h5 h5 { color: #333333; font-size: 1.1em; margin-top: -35px; text-align: center; } html is <div class="container"> <div class="row"> <div class="span4"> <div class="thumbnail"> <img class="team" src="http://placehold.it/160x120" title="swimming" alt="swimming" ></a> <h5>swimming</h5> </div><!--end of thumbnail--> </div><!--end of span4--> however when place row of polaroids undern...

css - Wrong overflow cropping in element with border-radius on Opera -

ok, i've made fc barcelona css logo , works fine under: firefox 13 chrome 20 safari 5 ie 9 but on opera 11 (and 12 too) blaugrana stripes not cropped. have tried many configurations, , without additional wrapper, couldn't work. html: <div id="blaugrana_stripes_container" class="abs border_black fill_purple cropper layer9 rounded"> <!-- wrapper needed browsers crop overflow --> <div id="blaugrana_stripes_overflow_cropper" class="rounded"> <div class="blaugrana_stripes fill_purple border_blue"></div> <div class="blaugrana_stripes fill_purple border_blue"></div> </div> </div> related css: #blaugrana_stripes_container, #blaugrana_stripes_overflow_cropper { width: 244px; height: 244px; text-align: left; -moz-border-radius: 155px 155px 134px 134px; -webkit-border-radius: 155px 155px 134px 134px; border-radius: 155px 155px 134px 134px; } #blaugrana_stripes_con...

windows - C. Why does it equal 1? -

so i'm reading book. i'm using gcc, , when ever compile code print 1. int x = 5, y = 3; printf("%d", x > 3); the result 1. if did: int = 3, j = 4, k = 5; printf("%d", % j + < k); can explain i'm doing wrong? edit: if int = 10, j = 1; printf("%d", > j ? : j); that print out 10. because you're doing comparison, , comparisons true, 1 in decimal. (0 being false). hth

simultaneous instances of the same hudson/jenkins job -

i way individual users send repo path hudson server , have server start build of repo. don't want leave behind trail of dynamically created job configuration. i'd start multiple simultaneous instances of same job. requires workspaces different different instances. believe isn't possible using of current extensions. i'm open different approaches i'm trying accomplish. i want hudson server able receive requests builds outside sources, , start them long there free executors. want build configuration same builds except location of repo. don't want have dozens of identical jobs sitting around automatically generated names. is there out there using hudson or jenkins this? how set up? guess enough scripting dynamically create necessary job configuration through cli api script, , destroy when it's done. want keep artifacts around, destroying job when it's done running issue. don't want write , maintain own extension. this should pretty straightforward...

c# - Decimal Point in Windows phone textfield -

hello fellow c# , windows phone developers, for windows phone application, have textfield requiring user enter age. during debugging mode entered number .8. , clicked proceed , application unexpectedly closed. code need add can post message box informing user numbers more 1 decimal point unacceptable. please assuming input string, try: if (input.indexof('.') == -1 || input.lastindexof('.') == input.indexof('.')) { //good } else messagebox.show("more 1 decimal point"); a better way though use tryparse check number formatting float age; if (float.tryparse(input, out age)) { //good } else messagebox.show("invalid age.");

How to separate Hadoop MapReduce from HDFS? -

i'm curious if separate hdfs filesystem mapreduce framework. know main point of hadoop run maps , reduces on machines data in question, wondering if change *.xml files change configuration of machine jobtracker, namenode , datanodes running on. currently, configuration 2 vms setup: 1 (the master) namenode, datanode, jobtracker, tasktracker (and secondarynamenode), other (the slave) datanode, tasktraker. essentially, want change have master namenode datanode(s), jobtracker, , have slave tasktracker perform computations (and later on, have more slaves tasktrackers on them; 1 on each). bottleneck data transfer between 2 vms computations of maps , reduces, since data @ stage small i'm not concerned it. know if configuration possible, , how it. tips? thanks! you don't specify kind of options in configuration files. have take care of kind of deamons start on each machine(you call them vms think mean machines). i suppose start using start-all.sh script can find in bin dire...

interprocess C# python real time -

i'm working on project i'll have 1 application in c# , 1 in python. c# application continuously analyse stream of data , raise flag each time interesting detected. each time there event, python application have read , continues own process, while other flags continue being sent. understand c# app won't wait python 1 finish computation before sending flag. so wondering if possible create sub/pub (c# being publisher, , python subscriber), if yes how can it, , think it's idea? i'm pretty new in field, tell me if there other possibilities? thx help. simplest way pipe communication. simple way not suggested socket programming. pipes , named pipes solution communicate between different processes (over different programming languages). socket programming may need more access level , may less security. other type of ipcs seems unusable. see more info: c# - pipes python - pipes

ios - Bug using UISplitViewController in a UITabController in iPad interface -

i new ios developer working on first app. i'm quite way in it, , have managed pretty working how want, i'm chasing odd bug. here's basic app design (yes, understand may not confirm apple ui guidelines) best can describe it: it's universal app written in latest x code using storyboarding. have working iphone , ipad interface, it's in ipad interface issue exists. root controller uitabview. on 1 of tabs, have split view controller implements typical master detail pattern. in portrait mode, master table hidden , content renders. navigation bar button brings forth master table view. select item , master table view vanishes , right side updates content via segue. far good. rotate device, keeps working. split view master table stays on left, , content renders on right. works great within tab controller. here 2 use cases demonstrate bug not happening , happening, in order 1- bug not happen a) launch app in portrait. b) select nav button bring master table c) select ite...

google apps script - Delete a project in a site -

Image
does know how delete project(script) in site? i made new script , copied code project change owner of script, cannot delete project don't use more. there isn't delete in file menu. go site, go 'manage site, open script project want delete in file menu within script choose 'delete'

php - define anonymous function using values from current scope? -

i trying create anonymous function need access variables current scope in it's definition: class test { private $types = array('css' => array('folder' => 'css')); public function __construct(){ //define our asset types foreach($this->types $name => $attrs){ $this->{$name} = function($file = ''){ //this line falls over! //undefined variable $attrs! return '<link href="'.$attrs['folder'].'/'.$file.'" />'; } } } } $assets = new test(); obviously example very minimalistic gets across trying do. so, question is, how can access parent scope definition of function? (once defined don't need context when function called). edit #1 ok after using matthew's answer have added use below; issue when call function no output. if add die('called') in function produced, not if echo or return something. class test { private $types = array('css' => array('folder'...

javascript - How can I use npm for front-end dependencies? -

i want ask if possible (and idea) use npm handle front-end dependencies (backbone, jquery). i have found backbone, jquery , on available through npm have set extraction point (the default node_modules ) or symlink or else... has done before? is possible? what have change in package.json ? short answer: sort of . it largely module author support this, isn't common. socket.io example of such supporting module, demonstrated on landing page. there other solutions however. these 2 know about: http://ender.no.de/ - ender js, self-described npm analogue client modules. bit involved tastes. https://github.com/substack/node-browserify - browserify, utility walk dependencies , allow output single script emulating node.js module pattern. can use jake|cake|rake|make build script spit out application.js, , automate if want fancy. used briefly, decided bit clunky, , became annoying debug. also, not dual-environment npm modules run through browserify. personally, opting using r...

xna 4.0 - XNA game components -

i confused how pass values of variables 1 gamecomponent another. using xna 4.0. i created 2 gamecomponents, drawstring , inputmanager. want read keyboard input of user , pass onto drawstring update position. i cant add components on drawstring(drawablegamecomponent). can on class not on gamecomponent. can guys post examples here. beginners. use gamecomponent want have update called on every frame, , use drawablegamecomponent want have draw called on every frame , loadcontent called when appropriate (at start of program, whenever device lost, when user pressed ctrl-alt-del on windows). for inputmanager might want update method, can keep user input updated, inputmanager gamecomponent . drawstring doesn't sound needs be. both classes sound services. in constructor or initialize method of game class, following: components.add(minputmanager = new inputmanager(this)); services.addservice(typeof(inputmanager), minputmanager); services.addservice(typeof(drawstring), mdr...

Passing Parameters By Reference In JavaScript? -

i have technical challenge i'm trying figure out best way solve. here's scenario. i have 1 html page launches html page...let's call main.html has button calls test.html inside test.html user can answer series of questions , submit results learning management system. each time test have javascript variable inside test.html page gets incremented b c, etc. example, if take test first time 0001a , second time 0001b. this works great, if close test.html page, since javascript variable inside it, counter start off @ 0001a again if user tries take test. next test user submits 0001c. not sure how this... i thought of passing variable test.html page via like: test.html&id=c means main.html calls test.html need know user has done 2 tests , i'm not sure can pass value html page html page called it? anyway, i'm wondering best way solve problem? thanks i think best way solve problem setting cookie in browser via javascript: document.cookie = 'mycookie=testcoo...

mysql - Storing Payment Details and Subscription Details -

i trying create subscription based payment module project. there 3 plans will cost 49$ right free till acquire users. 499$ have 15 days trial 799$ have 15 days trial. we using stripe payment integration. i have users table follows users(name, email, password, ....) now want store following define , maintain plans which plan user subscribed to when user subscribed plan - details regarding payments - upgrade - downgrade etc. can 1 share how can via mysql tables , if missing key information need store ? here little sketch of in scenario : tables users id, nameemail, password, ... maintainplans id, user_id, name, ... payments id, name, user_id, ... operations id, type, user_id, name, ... notes the user_id field reference of course id primary key of user table each tables can,of course, contains more columns containing more information or relations(i have inserted essentials. the operations type field should contain enumeration possible value (u...

date - Calculate time period list between 2 time in php? -

i want generate 3 time-period-list column between 2 times. if $start_time = '08:00 am'; $end_time = '10:00: pm'; time period list as: morning ----- noon ----- eve 8:00 1:00 pm 6:00 pm 8:30 1:30 pm 6:30 pm 9:00 2:.0 pm 7:00 pm to ... ... ... 12:00 pm 5:00 pm 10:00 pm i have calculated times between $start_time , $end_time as: $time = time(); $rounded_time = $time % 900 > 450 ? $time += (900 - $time % 900): $time -= $time % 900; $start = strtotime('08:00 am'); $end = strtotime('10:00 pm'); for( $i = $start; $i <= $end; $i += 1800) { echo "<input name='start_time' type='radio' value='".date('g:i a', $i)."' />"." ".date('g:i a', $i)."<br>"; } remaining work divide these times in 3 column mention above thanks in advance mates. you can use strtotime method add , substract time period given time. example: $time = strtotime('10:00'); $halfanhourbe...

how to ignore "," while rounding off decimals using javascript? -

this question has answer here: remove commas string using javascript 1 answer <html> <head></head> <body> <label class="xyz"> <span class="aaaa">rs. </span> 1,399.00 </label> <label class="xyz"> <span class="aaaa">rs. </span> 199.00 </label> <script> function deciremove(){ var = document.getelementsbyclassname('xyz'); for(var i=0; i< all.length; i++) { var x = all[i].childnodes[2].nodevalue; x= math.round(x); all[i].childnodes[2].nodevalue = x; } } deciremove(); </script> </body> </html> in above code want rounding off decimals 2 values, when value 199.00 works n gives 199 when 1,399.00 gives nan. , because of ",". how ignore or delete ",". replace commas. x= math.round(x.replace(/,/g, ''));

android - ActivityNotFoundException: No Activity found to handle Intent { act=splashscreen.app.test.CLEARSCREEN }? -

i m getng problem..basically simple creating splash screen aftr loading splash screen want load main form here m getng problem............i hav added activity manifest well.... here java code public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash); thread logotimer=new thread(){ public void run() { try { int timer=0; while(timer<5000) { sleep(100); timer=timer+100; } startactivity(new intent("splashscreen.app.test.clearscreen")); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } { finish(); } } }; logotimer.start(); } } and here manifest activty hav included <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".splashscreenactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> ...

php - Alternatives to face.com API -

sadly, face.com api being shut down due acquisition facebook. are there decent alternatives out there? i'm looking check given image if there face in + demographics content it. sad news indeed. if have reason , have account, may extend until october, 2012: http://developers.face.com/extension-request/ for else, here's list of potential alternatives i've compiled: opencv: http://opencv.willowgarage.com/ (c/c++ @ least opensource, standalone , downloadable) viewdle (objective-c)... bought/axed google, instead see: face recognition on iphone betaface api: http://www.betafaceapi.com/ (c#/.net or api) rekognition: http://rekognition.com/ (api) lambda labs: http://lambdal.com/ (api; still in private beta) biometrycloud: http://www.biometrycloud.com/ (api; mentioned private beta) sky biometry: http://www.skybiometry.com/ the following similar more on augmented reality (ar) library side detecting objects or movement webcam only, extending trained detect fac...

Android Light Sensor Returns null -

Image
i developing project light sensor, problem light sensor return null , testing device samsung galaxy y . doubt: light sensor code wrong or galaxy y not contains light sensor? i have tried below code: package com.example.lightsensor; import android.app.activity; import android.content.context; import android.hardware.sensor; import android.hardware.sensorevent; import android.hardware.sensoreventlistener; import android.hardware.sensormanager; import android.os.bundle; import android.widget.progressbar; import android.widget.textview; import android.widget.toast; public class lightsensoractivity extends activity { progressbar lightmeter; textview textmax, textreading; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.light_sensor_layout); lightmeter = (progressbar)findviewbyid(r.id.lightmeter); textmax = (textview)findviewbyid(r.id.max); textreading = (textview)findviewbyi...

java ee - how to overcome this NullPointerException? -

Image
import java.sql.*; import java.io.*; import java.util.*; public class { public static void main(string args[]){ try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); connection con= drivermanager.getconnection("jdbc:odbc:debjeet", "system", "tiger"); preparedstatement st=con.preparestatement("insert emp values('?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?')"); //there 17 fields in database bufferedreader dis= new bufferedreader(new inputstreamreader(system.in)); system.out.println("enter desired username"); string us=dis.readline(); st.setstring(1,(string)us); //this attempt made me remove exception ,otherwise below index 4.also exception occurs here. system.out.println("enter desired password"); string pw=dis.readline(); st.setstring(2,pw); system.out.println(...