Posts

Showing posts from May, 2011

c# - RadGrid Countdown Clock in Template Column -

i have telerik radgrid bound sqldatasource (items databound), in 1 of data bound columns there value of type datetime format h:mm:ss {0:h:mm:ss} . added template column shows "time left" so: start time - = time left i wanted ajaxified added timer , label inside updatepanel in template column - every tick (1000ms) recalculate time left . this seems work first row in radgrid here code snippets asp <telerik:gridtemplatecolumn filtercontrolalttext="filter templatecolumn column" uniquename="templatecolumn" headertext="starting in"> <itemtemplate> <contenttemplate> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <asp:label id="lbltime" runat="server" text="00:00:00"></asp:label> <asp:timer id="timer1" runat="server" interval="1000&q

pointers - Enforce NULL checking in c++ -

my method can return kind of pointer ( example boost::shared_ptr ) , pointer may null. there way enforce users of code check, if empty or not ? some example of such things - scals's option container, may boost has boost::option ? you can following: return smart pointer type throws exception if accessed , set null. throw exception instead of returning null pointer return std::optional (or boost::optional) expresses intent (i.e. "value may missing") better pointer

javascript - Update JS object based on local storeage -

i'm trying create setup object app url's in of url values dynamic , stored in local storage. question how update setup object based on latest local storage? html: <a href="javascript:slideonlyone('addon1')">addon 1</a> <a href="javascript:slideonlyone('addon2')">addon 2</a> <a href="javascript:slideonlyone('addon3')">addon 3</a> javascript: window.localstorage.setitem('tmpadd','default'); var appurl = { 'jsonurl1' : 'http://myurl.com/' + window.localstorage.getitem('tmpadd'), 'jsonurl2' : 'http://myurl.com/category/' + window.localstorage.getitem('tmpadd') }; function slideonlyone(item) { window.localstorage.setitem('tmpadd', item ); console.log(window.localstorage.getitem('tmpadd'),appurl.jsonurl1); } see working example here: http://codepen.io/anon/pen/bebve/ u

mysql - Constructor queries on a non-persistent entity unexpectedly fail to supply a Boolean parameter as a constructor argument -

there 2 tables in mysql database user_table feedback the relationship between them intuitive - 1 many user_table feedback . i need fetch list of selected columns these tables are from feedback feedbackid (java.lang.long) feedbacktitle (java.lang.string) feedbackdescription (string, decorated @lob ) feedbackdate (org.joda.time.datetime) testimonial (java.lang.boolean) from user_table userid (java.lang.long) firstname (java.lang.string) these many fields out of many others required executing query. the criteria query follows. criteriabuilder criteriabuilder=entitymanager.getcriteriabuilder(); criteriaquery<feedbackutils>criteriaquery = criteriabuilder.createquery(feedbackutils.class); metamodel metamodel = entitymanager.getmetamodel(); entitytype<feedback> entitytype = metamodel.entity(feedback.class); root<feedback> root = criteriaquery.from(entitytype); list<selection<?>>selections=new arraylist<selection<?

shift - Allign the words to the specified column in vim using commands -

how can move or shift words in entire file specified column? example below: before : 123 abc 112 xyzs 15925 asdf 1111 25asd 1 qwer after : 123 abc 112 xyzs 15925 asdf 1111 25asd 1 qwer how can done using command mode? here thing need shift 2nd word specified column here specified column 8 approach built-in commands first :substitute whitespace tab character, , :retab tab stop column 8, expanding spaces (for given example): :.,.+4substitute/\s\+/\t/ | set tabstop=7 expandtab | '[,']retab (i'm omitting resetting of modified options, should matter you.) approach plugin my alignfromcursor plugin has commands align text right of cursor column. combine :global command invokes lines in range, , w motion go second word in each, , you'll get: .,.+4global/^/exe 'normal! w' | leftalignfromcursor 8

c++ - "launching 'project' has encountered .." , project file does not exist -

Image
i wanted write 'hello world' in eclipse c++, not work i go run configurations, config options c++ programs should give? i know don't care 'debug' - 'release', how that? here did: file->new->c++ project pop window. type name of project want. then, below says executable , inside folder, have (by default guess) empty project. click next , finish. now project appears in left column of eclipse. right click , select new->file , name main.cpp the main window of eclipse opens file main.cpp , write inside: #include <iostream> int main() { std::cout << "hello erjan\n" << std::endl; return 0; } then click on build , it's hammer icon in middle of toolbar. code compiles , ready launch it! so, click on run icon (3 positions right of build icon) , should see output in console.

logic - how to generate list of records using list of lists data in erlang -

i have list of lists itemlistdata = [[1,"abc","def",30],[2,"axn","foo",23],[3,"bde","fo1",21],..] , form list of records using record item{itemno, name, description, quantity} . items list length varying. best way create new list of records using itemlistdata . @graymalkin's answer involves lot of copying through use of ++ binary operator. 1 should prefer list comprehensions here: make_records(records) -> [#item{'#'=no, name=name, descr=descr, qty=qty} || [no,name,descr,qty] <- records]. edit: use function thusly: (in shell) 1> rd(item, {'#', name, descr, qty}). 2> itemlistdata = [[1,"abc","def",30],[2,"axn","foo",23],[3,"bde","fo1",21]]. 3> some_module:make_records(itemlistdata).

node.js - How do I access the instagram API with Express JS and Jade? -

i having trouble getting information instagram's api , sending jade rendered on front end. app.route("/api") .get(function(req, res){ var url = "https://api.instagram.com/v1/users/1234/media/recent/?client_id=xxxx"; request(url, function(err, res, data){ console.log(json.parse(data)); // go here res.render('show', {media : data}); }); // or here? res.render('show', {media : data}); }); i trying collect 10 images api path , send them jade. getting parsed response in terminal of several entries. having hard time figuring out how send multiple responses jade file, having jade file loop through them. i know user id , client id in url variable not correct. if have alternate method using request() , open well. so answering own question on one. rendering has inside of request() function. issue in callbacks. issue had "res" response .get , request() callback. when changed &

google apps script - Restrict notifications sent for changes referenced in columns -

i referenced this post make launch calendar dates , names: the 2 columns have 1 date (a) , other launch name/description (b). in ideal state, wanted send notifications when: there new launch entry name (b); not date entered yet (a) separately, sending update date changes (a) , referencing launch name (b); there won't case have date no launch name (unless i'm in process of entering 1 after other), there should not notifications sent if there's date entered , no corresponding b cell yet. i'm seeing false positives code in following ways: 1.) if don't enter date (a) put text in column (b), i'm getting date email empty referencing (b); i'd restrict not send notification if corresponding cell in column empty 2.) i'm getting duplicate date (a) emails; has adding date when second 'if' condition present check column b (launch name); it's when add new date, receive 2 emails adding date. 3.) if enter launch name (b) no date (a), i&#

Why doesn't Python use ^ to denote squaring a number but uses ** instead? -

a few languages i've seen utilise ^ symbol, , doesn't seem reserved in python. sort of confuses me since ^ symbol (very) known , python supposed easy use, not case in using ** . is there logical explanation this? mean it's not huge difference, curious choice? as guido says "python’s first , foremost influence abc, language designed in 1980s lambert meertens, leo geurts , others @ cwi.". x raised power y implemented x**y in abc . abc influenced setl & algol 68.

Android Eclipse Emulator trouble -

for past couple of days have not been able android emulator in eclipse launch successfully. i've gotten several different errors including: process system isn't responding, app has unfortunately closed, , emulator squatting @ splash screen hours. have tried several things listed on forum, no luck. thought if posted logcat output, may have idea going on. ?:??: w/?(?): --------- beginning of /dev/log/system 04-22 19:16:05.610: i/vold(45): vold 2.1 (the revenge) firing 04-22 19:16:06.310: d/vold(45): volume sdcard state changing -1 (initializing) -> 0 (no-media) 04-22 19:22:06.040: i/systemserver(382): entered android system server! 04-22 19:22:08.100: i/systemserver(382): waiting installd ready. 04-22 19:22:08.110: i/systemserver(382): enabled strictmode logging wm looper 04-22 19:22:08.110: i/installer(382): connecting... 04-22 19:22:08.590: i/systemserver(382): power manager 04-22 19:22:09.110: i/systemserver(382): activity manager 04-22 19:22:11.540: i/activitymanage

reshape2 - Convert from long wide data fromat to long data format in R with multiple depth headers -

maybe can't done because have data in bad format, i'm trying "kind of" wide format long format. if modify data in excel first, know how melt, have lot of data, , i'm hoping not have modify hand first. basically have headers have depth have multiple descriptors each column of sales. account, brand, variety , tier (and maybe others depending on how goes) account brand variety tier dates 1/1/2011 sales xxx 2/1/2011 sales xxx and format need in be date account brand variety tier sales i don't understand how convert using reshape or melt though. suggestions, or have hand? edit actual data looks (names changed protect innocent) account account account account account account b brand brand brand brand b brand b brand c variety cab chard merlot pinot grigio pinot noir tier tier 2 tier 3 tier 2

java - Sorting a integer list without a sort command -

so have code: public class sortedintlist extends intlist { private int[] newlist; public sortedintlist(int size) { super(size); newlist = new int[size]; } public void add(int value) { for(int = 0; < list.length; i++) { int count = 0, current = list[i]; if(current < value) { newlist[count] = current; count++; } else { newlist[count] = value; count++; } } } } yet, when run test, nothing prints out. have system.out.print in class in same source. where going wrong? edit: print code comment: public class listtest { public static void main(string[] args) { sortedintlist mylist = new sortedintlist(10); mylist.add(100); mylist.add(50); mylist.add(200); mylist.add(

wso2 - Is it possible to define a stream with a payload field that accepts an array of values? -

my scenario follows: wso2bam 2.4.0 used present kpis data captured wso2esb proxies one of operations of given proxy takes array of items, each 1 fields one of kpis requires aggregate calculations on items of messages a possible solution send multiple events bam using iterator, seems bit inefficient me. cleaner approach way specify given payload field can accept array of values. i've read library examples, cover simple streams. it not possible define payload(or other) field accepts array of values stream.

android - Is "Upstream Google Cloud Messaging and User Notifications Sign-up" compulsory? -

is signup " upstream google cloud messaging , user notifications sign-up " @ link " https://services.google.com/fb/forms/gcm/ " compulsory notification server app device? i have created sample app , sending sample notification server. m getting "ok" response along message_id, assume means message has been accepted gcm bit message not getting delivered registered device? read somewhere gcm, registration link above required. tried didnt response google. missing anything? harshil. yes, compulsory. when sending message through gcm , need specify sender_id given when create project inside, , this, have sign up. if got ok response, doubt specified correct sender_id message got discarded. maybe might help: how send location of device on server when needed

Loading images through url in android -

iam loading images in listview url image decoding in background getting following errors. package com.abc; import java.io.inputstream; import java.net.url; import java.sql.array; import java.util.arraylist; import java.util.hashmap; import java.util.list; import org.apache.http.namevaluepair; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import android.r.integer; import android.app.listactivity; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.drawable.drawable; import android.media.image; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.view; impo

ImageButton coming out small. Java-Android Devleopment -

having problem! have made image buttons in xml using relative layout. ok when i've made them when run on phone comes out small! want expand width of device (or width of device goes to) here's xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <imagebutton android:id="@+id/prewedbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/weddingbutton" android:layout_alignparenttop="true" android:layout_margintop="90dp" android:contentdescription="@drawable/prewedbutton" android:src="@drawable/prewedbutton" /> <imagebutton android:id="@+id/weddingbutton" android:layout_width="wrap_content"

intersection - Returning indexes of intersected lists with Python -

i have 2 lists: 1. ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'f'] 2. ['c', 'd'] and i'd indexes of intersection a, b: 3. [[2, 3], [5, 6]] how python? also these inputs: 1. ['263', '9', '470', '370', '576', '770', '800', '203', '62', '370', '576', '370', '25', '770', '484', '61', '914', '301', '550', '770', '484', '1276', '108'] 2. ['62', '370', '576'] should give: 3. [[8, 9, 10]] one way be: >>> l1 = ['a', 'b', 'c', 'd', 'e', 'c', 'd', 'f'] >>> l2 = ['c', 'd'] >>> [range(i,i+len(l2)) in xrange(len(l1)-len(l2)+1) if l2 == l1[i:i+len(l2)]] [[2, 3], [5, 6]] >>>

meteor - Redirecting page with Iron-Router -

currently using accounts packages supplied meteor allow people sign site working on. want allow users have bio page, whenever logged particular person side bar navigation appears lot of links 1 of says "bio". want bio redirect me home page bio page i.e: localhost:3000/ -> localhost:3000/bio/userid23453423434 currently write using iron-router this: ... <li><a href="{{pathfor 'bio'}}">bio</a></li> ... and in router have: router.map(function() { ... this.route('bio', {path: '/bio/:_id', data: function () { return {_id: meteor.userid()} } }); ... but when click on link not redirected anywhere. ideas doing wrong? you don't need parameter _id in path since using meteor.userid(). iron-router won't render if can't find _id parameter in template. removing fix issue: router.map(function() { ... this.route('bio',

Ruby on Rails 4 select multiple -

i have form creates new users. trying add drop down option select permission levels. want able select multiple permission levels per user. this view, added {:multiple => true} : <%= f.label :permission, "permission level" %> <%= f.select :permission, [ ["read only", "read"], ["ip voice telephony", "ip_voice"], ["ip video telephony", "ip_video_telephony"], ["enterprise gateways", "enterprise_gateways"], ["consumer atas", "consumer_atas"], ["ip pbx", "ip_pbx"], ["master of all", "all"] ], {prompt: "select permission level"}, {:multiple => true}, class: "input-lg" %> my controller, added :permission => [] : def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation, :admin, :permission => []) end the error view, f.select: wrong number of argume

java - shared data stored in memory in a cluster on tomcat based app -

i'm writing tomcat 7 java application uses websockets. this java application on amazon ec2 cluster behind load balancer app on around 2-5 servers. i have classes holds online users , know if it's possible share information around cluster. is memcached solution? can data there shared between cluster? never used memcached. guess or should change code store in database data shared among servers? what's efficient solution overcome problem? any information regarding issue appreciated. thanks welp memcached answer. simple that. amazon ec2 provides memcached based cluster can used memcached api (spymemcached) or own implementation (that uses spymemcached) called elasticache-java-cluster-client can audio detects memcached nodes.

html - two overlaying divs with a transparent color, how to make upper one mask the lower one? -

i have 2 divs overlap. 1 square rounded corners such it's circle , other long rectangle. they're @ top of page make nice header. circle overlaps rectangle. want put buttons in there, etc. both divs use background color. note transparency. background-color:rgba(256,256,256,0.2); when circle overlaps rectangle, naturally colors blended color stronger (it's more white). there way "ignore" bottom color since it's underneath , have top color dominant one? css blending options me out here or have pull rectangle our , somehow plug crack between circle , rectangle? .rectangle { width:100%; height:100px; background-color:rgba(256,256,256,0.2); margin-bottom:5px; } .circle { width:400px; height:400px; top:-200px; left:-200px; position:absolute; background-color:rgba(256,256,256,0.2); border-radius:200px; }

wordpress - activate plugins on custom theme -

i'm new wordpress , created first template. in functions.php have put following code, function understand should call plugins plugins directory: if (function_exists('register_sidebar')) { register_sidebar(array( 'name' => 'widgetized area', 'id' => 'widgetized-area', 'description' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '' )); } i see plugins, , in widget screen see 'widgets' screen , allows me drag widgets working area. the website displays plugin's html neither js nor css working. what missing? above code have added in functions.php register sidebar not call plugin. not have connection plugin. you can call sidebar added in template follow: if ( is_active_sidebar( 'widgetized-

Javascript: How do I change every word visible on screen? -

i want joke code changes every word on screen specific other word, example: "i trains" --> "hello hello hello" well, that's easy. problem select every text on screen. can me? recursively walk nodes , regex replace. quick , dirty example: function replaceallwords(newword) { (var = 0; < document.childnodes.length; i++) { checknode(document.childnodes[i]); } function checknode(node) { var nodename = node.nodename.tolowercase(); if(nodename === 'script' || nodename === 'style') {return;} if (node.nodetype === 3) { var text = node.nodevalue; var newtext = text.replace(/\b\w+/g, newword); node.nodevalue = newtext; } if (node.childnodes.length > 0) { (var j = 0; j < node.childnodes.length; j++) { checknode(node.childnodes[j]); } } } } //use replaceallwords("hello"); do

java - How to "save" my program? -

hi guys i'm working on kind of "dungeon crawler" game , need saving program. jframe save(all of entered text)so when close program , open desktop have entered text , have changed still in program. i'm confused how save , hoping help. ahead of time of time, anwsers, links, examples, , advice. clear new , have been coding 5 days , still use netbeans jframe "design" feature generate of code me. below i've posted code second jframe. feel free copy , paste code in netbeans ide. :). note: in case needing names other jframes. "character" second jframe "mainclass" java app "maingamepanel" third jframe note:some buttons may not work because not of jframes package ddsheet; //this code jframe named character import java.nio.file.files; import javax.swing.jfilechooser; public class character extends javax.swing.jframe { public character() { initcomponents(); } /** * method called within constructo