Posts

Showing posts from April, 2011

json - GCM push different payload to different device -

i push different payload differet devices @ same time. able push same payload different devices code below. string stringregids = null; list<string> regids = new list<string>(); //add regid list stringregids = string.join("\",\"", regids.toarray());; string applicationid = "appid"; string sender_id = "senderid"; string value = "hello"; webrequest trequest; trequest = webrequest.create("https://android.googleapis.com/gcm/send"); trequest.method = "post"; trequest.contenttype = " application/json;charset=utf-8"; trequest.headers.add(string.format("authorization: key={0}", applicationid)); trequest.headers.add(string.format("sender: id={0}", sender_id)); string postdata = "{\"collapse_key\":\"score_update\"

How to know if irq is free in linux? -

how check if irq free before using free_irq() api in linux? in code, function in using free_irq() api getting called many times , irq getting free in first call, in subsequent call kernel crashing while trying free free irq. so can put condition above free_irq gets called once. : initialize #define free_irq true if(free_irq == true) { free_irq(); free_irq = false; }

c - Inserting New Node -

here function of program i'm writing more familiar nodes. it creates new node , inserts information code field , points existing first node. assigns head newly created node; unfortunately it's giving me incompatible types new_node->location = code; typedef char librarycode[4]; typedef struct node { librarycode location; struct node *next; } node; void insertfirstnode(librarycode code, node **listptr) { node *new_node; new_node=malloc(sizeof(node)); new_node->location = code; new_node->next = *listptr; *listptr = new_node; } librarycode typdef ed char [4] . can't assign 1 array another, you'll need memcpy or strcpy data 1 array other. a simpler example of what's going on: void foo() { char a[4]; char b[4]; = b; } compiling gives error: in function ‘foo’: error: incompatible types when assigning type ‘char[4]’ type ‘char *’ = b; ^ you can see you're trying assign pointer array,

c# - Returning a list of cells if the previous column is checked in a DatagridView -

i've checked different codes i'm not able make effective use. i'm trying check value in 1st column boolean, if column checked need data in second column displayed in text/list box (if multiple boxes checked). this how looks datatable dt = new datatable(); dt.columns.add("methods",system.type.gettype("system.string")); dt.columns.add("select", system.type.gettype("system.boolean")); datarow dr = null; foreach (datagridviewrow row in datagridview1.rows) { //get appropriate cell using index, name or whatever , cast datagridviewcheckboxcell datagridviewcheckboxcell cell = row.cells["select"] datagridviewcheckboxcell; //compare true value because value isn't boolean if (cell.value == cell.truevalue) { listboxtemp.datasource = cell.

orm - Laravel Eloquent last inserted object wrong properties -

i've got problem while using laravel eloquent orm: when inserting new eloquent model in database, data corrupted. concrete: $newitem = new notificationnewitem; $newitem->item_id = $item->id; // item_id primary key (returned getkeyname()) $newitem->save(); return notificationnewitem::find($item->id); this code not return same $newitem = new notificationnewitem; $newitem->item_id = $item->id; $newitem->save(); return $newitem; whereas 2 items should same, shouldn't ? weird part returned json object (i show directly in browser) in first case inserted in database, , in second case json object's primary key (here item_id) equal 0 if in database corresponding entry has primary key equal 3 (or different values). here's laravel code if want see error again : http://pastebin.com/9wcsnvsq there 2 "returns" in model function insertandgetelement() , return items different primary keys (the first 1 in pastebin returning primary key equa

overlay - Imagemagick tiling with annotation -

i splitting big image with: convert input.jpg -crop 2256x3043 +repage +adjoin output-%02d.jpg how can annotate tile number @ center of each image? thanks. ok, found solution: convert input.jpg \ -crop 2256x3043 +repage +adjoin \ -pointsize 300 -gravity center -annotate 0 "%[p]" \ output-%02d.jpg this split images in tiles 2256x3043 big , write @ center number of tile (starting 0) big sized font. got using imagemagick escape property %p , defined as: index of image in current image list

sql - Can I do a INSERT using select from another DB with the same table name -

i have person table (sqlserver 2008r2) , using .vbs , .bat files sync data table called person in database a database b . note - db names different table names same. because peson table has 137 fields looking way write both insert , update statement. how can thsi without listing 137 fields? at moment connect database a , populate recordset called rs people table records. then loop through rs , query people table in database b if found update people table in database b people table record database a if not found insert people record database a people table on database b now nice , easy since has 137 fields not want write massive update , insert statements. have option such as: the table structures identical between people on database a , people on database b recordset obtained in step 1 above using 1 one db connection , query in step 2 using separate db connection different db instance on different server. help. you can using qualified

html - Font not rendering? -

i have following css (generated byn sass): @font-face { font-family: "locust"; src: url(/assets/locust.ttf) format("truetype"); src: url(/assets/locust.svg) format("svg"); } the path seems accessible - i'm on localhost:3000 , if can download/see fonts typing localhost:3000/assets/locust.ttf , instance. yet firefox don't render font: <h1 style="font-family: locust;">test</h1> i'm using rails, don't think problem related, since html , css generated seems correct me, , fonts accessible. if knew need generate, know how fix. asset url here code use: #app/assets/stylesheets/fonts.css.scss @font-face { font-family: 'lato'; src: asset_url('layout/fonts/lato/lato-hairline-webfont.eot'); src: asset_url('layout/fonts/lato/lato-hairline-webfont.eot?#iefix') format('embedded-opentype'), asset_url('layout/fonts/lato/lato-hairline-webfont.woff&

python - Access Javascript variable in Django Template -

is there way access javascript variable in django template tags ? can , <!doctype html> <html> <body> <script> var javascriptvar=0; </script> {% if javascriptvar==0 %} {% else %} {% endif %} </body> </html> no, django template compiled server side. sent client browser executes javascript. nothing changed javascript executing on client browser can have affect on template. it's late @ point. however javascript make request server more information. or pre-compute value on server before send client. if more explicit trying should able help. you can of course use django templates set javascript variables. <script> var myvar = '{{ py_var }}'; </script>

iOS drawing circle Path for percent state -

i try draw circle given percent value (like if have 25% draw quarter of circle). @ moment im able draw full circle within view. ideas problem? code atm: - (uibezierpath *)makecircleatlocation:(cgpoint)location radius:(cgfloat)radius { self.circlecenter = location; self.circleradius = radius; uibezierpath *path = [uibezierpath bezierpath]; [path addarcwithcenter:self.circlecenter radius:self.circleradius startangle:0.0 endangle:m_pi * 2.0 clockwise:yes]; return path; } - (void)drawcircleforlocation{ cgpoint location = cgpointzero; location.x = self.frame.size.width/2; location.y = self.frame.size.height/2; cashapelayer *shapelayer = [cashapelayer layer]; shapelayer.path = [[self makecircleatlocation:location radius:9] cgpath]; shapelayer.strokecolor = [[uicolor whitecolor] cgcolor]; shapelayer.fillcolor = nil; shapelayer.linewidth = 1.5; [self.laye

java - Where is the NullPointerException coming from? -

i'm trying write method converts 2 digit number 2000 + number, returns other numbers , returns null when null passed argument. this implementation works intended private integer convertto4digits(integer modelyear) { boolean istwodigit = modelyear != null && modelyear < 100; if (istwodigit) { return 2000 + modelyear; } else { return modelyear; } } but 1 fails npe in return statement when called null. private integer convertto4digits(integer modelyear) { return (modelyear != null && modelyear < 100) ? (2000 + modelyear) : modelyear; } or bug? i'm using eclipse keple jdk 1.7.0_04 i think answer can found in chapter 15.25 of jls if 1 of second , third operands of primitive type t, , type of other result of applying boxing conversion (§5.1.7) t, type of conditional expression t. so when either second or third operand primitive type expression's type primitive. if pass null reference branch

css - bootstrap icon for username and password -

i designing login page. here adding icons username , password, when add icons along icons someother icons adding how resolve . here code. <div class="left-inner-addon "> <i class="icon-user"></i> <input type="text" placeholder="user name" name='j_username' > </div></div> and css follow, <style type="text/css"> .left-inner-addon { position: relative; } .left-inner-addon input { padding-left: 30px; } .left-inner-addon { position: absolute; padding: 10px 12px; pointer-events: none; } </style> and dont have reputation post pic of login form . i got idea of facing, according current standards of twitter bootstrap, have use following code achieve want. had tested on live server , working fine. replace html code following code : <div class="input-group"> <span class="input-group-addon glyphic

node.js - NodeJS - Having trouble reloading external js? -

i trying build sort of plugin manager can reload external source files on fly without shutting down node app. quick proof of concept eval'd plugin files functions being prototyped class. seemed work great, except cant seem scoping right. functions evaluated , prototyped, im not sure why functions cant grab global vars. have advice on this? rather manually loading file, rely on require . now, problem require has internal cache , load modules once. however, can force unload quick workaround: delete require.cache[require.resolve(myplugin)]; require(myplugin);

c# - How to assign 0 to whole array -

i have array. int[] array = new int[10]; . want assign '0' whole array without using loop means 0 stored in of indexes. how it. after creation items of array have default values, 0 int. so, don't need here. from arrays (c# programming guide) : the default values of numeric array elements set zero, , reference elements set null. also c# specification 12.2 array creation elements of arrays created array-creation-expressions initialized default value. 5.2 default values for variable of value-type, default value same value computed value-type's default constructor 4.1.2 default constructors for sbyte, byte, short, ushort, int, uint, long, , ulong, default value 0. but after assigning other values want indexes 0 again how it? update: can use array.clear : sets range of elements in array zero, false, or null, depending on element type. in case: array.clear(array, 0, array.length); consider use l

java - MultipleOutputs in hadoop -

i using multipleoutputs in reduce program of reduce phase. data set working on around 270 mb , running on pseudo distributed single node. have used custom writable map output values. keys countries present in datasets. public class reduce_class extends reducer<text, name, nullwritable, text> { public void reduce(text key,iterable<name> values,context context) throws ioexception, interruptedexception{ multipleoutputs<nullwritable,text> m = new multipleoutputs<nullwritable,text>(context); long pat; string n; nullwritable out = nullwritable.get(); treemap<long,arraylist<string>> map = new treemap<long,arraylist<string>>(); for(name nn : values){ pat = nn.patent_no.get(); if(map.containskey(pat)) map.get(pat).add(nn.getname().tostring()); else{ map.put(pat,(new arraylist<string>())); map.get(pat).

mysql - InnoDB performance -

i know there plenty of information on topic, think i've tried can, , don't know new ideas (if any?) increasing mysql database performance. situation: use etesting platform (taotesting if knows it). uses mysql database, 8 tables. @ moment 1 of tables has ~500k rows. others either empty or has ~10-15 rows. @ first mysql performance terrible using platform, decided convert myisam tables innodb , make my.cnf changes. seemed have improved performance, not as wanted. server has 1 cpu / 4 cores. 6 gb ram. it's not dedicated mysql, hosts php/apache/nginx. what's more, there 80% more selects database inserts/updates/deletes. any ideas how further (if possible) improve mysql configuration welcome . here's my.cnf: # # mysql database server configuration file. # # can copy 1 of: # - "/etc/mysql/my.cnf" set global options, # - "~/.my.cnf" set user-specific options. # # 1 can use long options program supports. # run program --help list of avai

php - SLIM returns 404 page not found -

im aware problem has been mentioned before, answers follow. none of these answers have helped me far. im still getting 404 page not when testing slim (webservice) using chrome advanced rest client figured might post solution here. this first time using slim framwork, figured starting example found on web nice startup. created described here , tested on local wamp server .. worked expected. thought confirm on 1 of web sites uploaded whole thing sub-directory on site (/task_manager/) .. before created database on site , configured config.php correct mysql settings. when testing here, 404 page not found methods. implemented method should return "hello world" .. still 404 .. is 404 occure because need change somethings in .htaccess im bit confused. works localy on wamp not when uploaded web-site. have checked mod_rewrite loaded on apachee 1 ruled out ... all code can seen here based on tutorial: any appriciated .. :)

php print email id with some part hidden -

i have variable contains email id axceasddfe.gdfs@cif.in , csderid.asldfj@xiz.com i want show them first 4 characters , ** continue replacing characters , @ , continue ** , com or in example : $email_id = "axceasddfe.gdfs@cif.in"; $email_text = convertemailformat($email_id); echo $email_text; // ouput axce**********@****in i want convertemailformat function fo it. try this: function obscure_email($email){ $email_array=explode('@', $email); $email_word=$email_array[0]; $email_domain=$email_array[1]; $obscured_email=substr($email_word, 0, 3); for($i=3; $i<strlen($email_word); $i++){ $obscured_email.='*'; } $obscured_email.='@'; for($i=0; $i<strlen($email_domain)-2; $i++){ $obscured_email.='*'; } return $obscured_email.substr($email, -2, strlen($email)); } echo obscure_email('test@testing.

templates - c++ map finding value and associated key -

i develop 1 program in c++ in have find key in stl map using values. values assigned key 5 tuples (srcip,port,destip,port,srcno) now want check in map whether there key assosiated values. trying this. but showing error wrong number of template argument. note(in program in pair key->value) value consist of tuple of 5 variable. template<class t> struct map_data_compare : public std::binary_function<typename t::value_type,typename t::mapped_type,bool> { public: bool operator() (typename t::value_type &pair,typename t::mapped_type i) { return pair.second == i; } } class values { private: std::string c_addr; int c_port; std::string s_addr; int s_port; int c_id; public: values(std::string,int,std::string,int,int); void printvalues(); }; values :: values(std::string caddr,int cport,std::string saddr,int sport,int cid) { c_addr=caddr; c_port=cport; s_addr=saddr; s_port=sport; c_id=cid; } void values::printvalues() { cout << c_addr<<":"

ios - When i use UITapGestureRecognizer for tab UITextfield only in section 0, but section 1 some row cannot tab when select tableviewcell -

Image
my tableview have 2 sections , in section 0 have 1 row make uitextfield in this, want edit in uitextfield (section0,row0) but don't want tab select row (section0,row0) i use uitapgesturerecognizer problem can fixed - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { ... if(indexpath.section == 0) { uitapgesturerecognizer *taprecognizer = [[uitapgesturerecognizer alloc]initwithtarget:self action:@selector(didtapanywhere:)]; [cell.contentview addgesturerecognizer:taprecognizer]; } ... } but when scroll table , click in section 1 in row 3,row6,row9,… cannot tab call didselectrowatindexpath function. when comment out //uitapgesturerecognizer section 1 in row 3,row6,row9,… can select section 0 row 0 can select (i don’t want). i think problem draw cellforrowatindexpath when scroll, don’t know way solve problem. thank you

c# - Is it possible to make a method inside an interface that takes list of method from that interface as parameter? -

edit: i decided to: add savechanges() method repository, , make saving changes optional. use transactionscope , savechanges in controller methods the above should work , simple implement - may not best approach, , not direct answer question have do. original question: i use following repository pattern interface in project: public interface irepository<t> { keyvaluepair<bool, exception> create(t entitytoadd); keyvaluepair<bool, exception> create(list<t> entitylisttoadd); keyvaluepair<bool, exception> createorupdate(t entity); keyvaluepair<t, exception> get(int entityid); keyvaluepair<bool, exception> update(t entitytoupdate); keyvaluepair<bool, exception> update(list<t> entitylisttoupdate); keyvaluepair<bool, exception> delete(int entityid); keyvaluepair<bool, exception> delete(list<int> entityids); keyvaluepair<list<t>, exception> getfilter

javascript - "rails-backbone" gem: how to implement the simple js code using backbone js -

i having code how use using backbone.js. planning implement javascript code in rails. code below gives dropdown menu default , 1 "write own question" facility, 1 can write there own question clicking on option. one can write own question on textbox appears below dropdown menu when clicked on "write own question" otherwise text box hidden. store string written user database or rails model.please suggest me way using backbone.js <select onchange="checkother(this);"> <option value="select 1 question....">select 1 question...</option> <option value="on street did grow up?">on street did grow up?</option> <option value="what first phone number?">what first phone number?</option> <option value="what make of first car?">what make of first car?</option> <option value="write own question..."&g

How to include Ruby string in JavaScript -

i have ruby code: <%= "hello #{@namevar}" if condition %> i can include ruby snippet in js in following way- <script> var v1="<%= @user.name %>" </script> but can't embed previous code in javascript. i have tried following: var v2="<%= \"hello #{@namevar}\" if condition %>"; but didn't work. thanx. your attempt correct, don't need escape double quotes inside ruby code though: var v2="<%= "our funding ask #{@startup.funding_ask_text}." if @startup.try(:funding_ask_text) %>";

java - how to change getWritableDatabase() pointing path? -

i have code: // 2. reference writable db sqlitedatabase db = this.getwritabledatabase(); cursor cursor = db.rawquery(query, null); and see db is sqlitedatabase: /data/data/com.myapp/databases/user.db however part of app writes here: adb pull data/data/com.myapp/user.db ( verified pulling adb pull ) how can change path of sqlitedatabase: /data/data/com.myapp/databases/user.db ) ? /data/data/com.myapp/databases/user.db correct location databases. consider fixing part of code expects data/data/com.myapp/user.db . to change path, can supply full path sqlitedatabasehelper constructor instead of database name user.db .

c - libipq not supported in Ubuntu 12.04 -

i have requirement of altering packets part of university's research project , came across 2 libraries. libnetfilter_queue , libipq deprecated version. libnetfilter_queu e documentation next 0 on packet alteration , documentation came across done via libipq . thus, when run code error passer: unable create netlink socket: protocol not supported found out due fact libipq not supported in new linux kernels. my query is, there work around make libipq work ubuntu 12.04 lts or reference documentation or tutorials implement packet alteration via libnetfilter_queue . i @ days , not find solution. appreciated. :) thank :) p.s: question posted on here ( https://askubuntu.com/questions/430234/libipq-not-supported-in-ubuntu-12-04-lts ) once ip_queue module gone, can't use libipq , leverages module directly; no, there's no workaround unless install older kernel still has ip_queue module. that said, you've mentioned absolutely nothing you've tri

android - AsyncTask status in Activity's onStop() state -

i have started asynctask decode contents in file on button click. asynctask running fine, pressed home button. activity entered onstop() state. happens asynctask , run or stop in onstop() state? activity stop not make async task stop. async task continue , if have reference of view in post execute cause exception. you can use asynctaskloader instead. read it: http://mobile.dzone.com/articles/loaders-versus-asynctask

emacs - How to provide a "double prefix argument" programmatically? -

in code, want set mark. the documentation set-mark-command says, with c-u c-u prefix argument, unconditionally set mark point is. so how call set-mark-command in way? edit: see should using push-mark instead, in particular case. general question of how provide double-prefix argument programmatically remains. like this: (set-mark-command '(16)) small explanation find info: f1 f set-mark-command jump definition in simple.el *help* window. c-u c-m-x call eval-defun prefix argument, instruments code debugging when function called. c-u c-u m-x set-mark-command . you should in debugger. e arg give (16) .

django-allauth: How can I add a Site for my domain? -

i'm new django , i've installed django-allauth. i followed docs, i'm stuck on post-installation steps: add site domain, matching settings.site_id (django.contrib.sites app). for each oauth based provider, add social app (socialaccount app). fill in site , oauth app credentials obtained provider. i don't understand part @ all. i tried register site & socialaccount nothing changes. also, saw had define site id put in settings: site_id = '1' please, me this? appreciated. update i found tutorial let me go on this. registered app in facebook , obtained app id & secret , established /admin/socialaccount/socialapp/ when ready page not found (404) request method: request url: myip/accounts/profile/ using urlconf defined in gameproject.urls, django tried these url patterns, in order: ^admin/ ^accounts/ ^ ^signup/$ [name='account_signup'] ^accounts/ ^ ^login/$ [name='account_login'] ^accounts/ ^ ^logou

javascript - Current date selected by default in twitter bootstrap datepicker -

i trying have current date selected default in twitter bootstrap datepicker. after googling while found way this. have this: $('#date').datepicker('setdate', new date()); $('#date').datepicker('update') $('#date').datepicker({ autoclose: true, startdate: '-2m', enddate: '+1d' }); this works nicely, code ugly (why need touch datepicker 3 times). looking documentation have not found way in 1 function. after last attempt: $('#date').datepicker({ autoclose: true, startdate: '-2m', enddate: '+1d', setdate: new date() }); i gave up. there way write same thing in 1 function? what understand post, first 2 invocations call setdate , update functions. not properties, cannot set them tried. the third invocation though sets various attributes in object literal notation.

c# - List Grouping on multiple fields -

this question has answer here: grouping in linq ( on multiple fields) 1 answer i have list of type contains 5 fields. list wish retrieve values groups issuetype & id together. in table below issuetype abc & id = 2 appears once in new list. how do this? i should point out issuetype enumeration. not sure if makes difference issuetype id abc 1 abc 2 abc 2 abc 3 xzy 4 xyz 1 i have tried using groupby in linq. list<issuelog> uniqueerrorlog = errorlog.groupby(err => err.issuetype, err => err.id).select(err => err).tolist(); update ok have since tried line below. var uniqueerrorlog = errorlog.groupby(iss => new { iss.issuetype, iss.id }); i check output , grouping seems have made no difference. going table example can still see 2 abc's id = 2 being output when want one.

multithreading - Implementing reload method in C++ Thrift Server -

i'm using apache thrift framework, i'm writing application, has c++ server , python client. application has big resource object, used during life. application needs have reload method. should delete resources, , load new instances disk. wrote cleaning method, , calling before load method. that's work, if use tsimpleserver(one-threaded). when i'm starting use threadedserver or tnonblocking server(multi-threaded), cleannig method doesn't work, can see, it's calling doesn't clean. server starting use twice amount of memory. tried use mutex during cleaning method, didn't help. me,it's seems matter in multithreading, remote methods starts in child thread, can't release resources allocated in main thread. template<typename t> void deleteprocessors(t &processor) { (typename t::iterator iter = processor.begin(); iter != processor.end(); ++iter) { delete iter->second; } processor.clear(); } class taggerhandler : vi

Rails options_for_select with selected model value -

there following code: f.select :engine_value, options_for_select(engine_values_select_items) as can see, it's select list options. problem if form object has got float value in engine_value value not selected in select tag. how can fix this? code engine_values_select_items: def engine_values_select_items (1..6).step(0.1).to_a.map{|s| [s.round(2), s.round(2)]} end i thought rails did default, perhaps wrong? i can remember myself dealing issues. imho in cases approach followed meet expectations similar "generators" , combinations of them. there another post might you. also not forget check out proper syntax (i talking order). then, try using "selected: " see how go. hope helps,

php - Update one field multiple times in MySql -

good day all. i've done script copy csv in database, starts import data in system. done passing multtiple times on whole "import" table, first import categories, take products...and on. each time script passes, update flag field called importato , when copy csv 0, import categories, put @ 1, 2, , on. in way can keep track of going on. if encounter error during import, set importato field 10, @ end have items has got errors. keep track of past imports, every time write csv update importato 11, 12 13 , delete 13. done series of update : if(mysql_query("delete `importazione` importato = 13")){ if(mysql_query("delete `importazione` (importato = 4) or (importato = 5) or (importato = 6)")){ if(mysql_query("update importazione set importato = 13 importato = 12")){ if(mysql_query("update importazione set importato = 12 importato = 11")){ mysql_query("update impo

apache - Porting application which uses Oracle mod_plsql to PostgreSQL -

i need port application uses oracle mod_plsql postgresql. database procedures called on http use of apache + mod_plsql. procedures ported postgresql, can not find replacement apache + mod_plsql part. have experience on ho , use? update (to make stuff more clear): see: http://docs.oracle.com/cd/b14099_19/web.1012/b14010/concept.htm how mod_plsql work. what need way call function on postgrsql as: protocol://hostname[:port]/dad_location/[[!][schema.][package.]proc_name[?query_string]] ei: http://www.acme.com:9000/pls/mydad/mypackage.myproc?a=v&b=1 you fork nodejs based implementation of mod_plsql nodeplsql starting point , "simply" replace oracle access postgreesql. should able use pretty of logic in nodejs , need change way how code interacts database in oracle.js module. please keep me posted, if go way.

Why this PHP line not printing the the Error message? -

in 1 of file wrote these statements. instead of printing error message generates page normal errors. try { $var = 90 / 0; // error dvide 0 } catch (exception $e) { die( 'something gone wrong'); } a php error not same php exception. in script, no exceptions thrown - error occurs. you same result if install custom error handler: <?php // install temporary error handler set_error_handler(function($error) { die("something wrong"); }); // invalid $var = 90 / 0; // error dvide 0 // restore previous error handler restore_error_handler(); ?> if you're real fan of exceptions, install error handler automatically turns errors php exceptions: <?php // install error handler turns error exceptions set_error_handler(function($error) { throw new exception($error); }); // open try-catch block catch exceptions try { // invalid $var = 90 / 0; // error dvide 0 } catch (exception $exception) { // oo

git - Working on Linux-How to add a system call from the basics? -

i new linux. want add system call linux. don't know begin.can please guide me through whole process? installing linux getting kernel source code. don't know run or test or write modified source code. please me also. searched online linux kernel source code giving me lot of options of git files. they? how install them? thank you. here tutorials adding system calls kernel http://arvindsraj.wordpress.com/2012/10/05/adding-hello-world-system-call-to-linux/ http://blog.techveda.org/adding-system-calls-linux-kernel-3-5-x/ http://www.cs.rochester.edu/~sandhya/csc256/assignments/adding-a-system-call.html http://seshagiriprabhu.wordpress.com/2012/11/15/adding-a-simple-system-call-to-the-linux-3-2-0-kernel-from-scratch/ http://appusajeev.wordpress.com/2010/11/13/implementing-a-system-call-in-linux-kernel-2-6-35/

javascript - Jquery bind 'copied' event -

i'm using bootstrap's popover component display bit of text copied user. need make popover disappear after user has copied text. so far had tried: $('.popover-content input').select().bind('copy', function () { $('#link').popover('hide'); }); the problem copy event seems run bound function before clipboard contents updated. means when copy triggered popover dom element has been destroyed along text field. i had thought set popover css display: none; doesn't feel tidy or elegant way of performing action. does know if there 'copied' event or other way of doing cross browser. use unbind() method: $('.popover-content input').select().bind('copy', function () { $('#link').popover('hide'); $(this).unbind('copy'); });

MongoDB How to use $not, $and/$or with $type? -

i have different data types same field name f with this reference, i want find records not double , not null i'm able find records not double by db.foo.find({ f:{$not:{$type:1}} }) but can not combine query not null tried with db.foo.find({f:{$not:{$and:[{$type:1},{$type:10}]}}})' db.foo.find({$and:[{f:{$not:{$type:1}}}, {f:{$not:{$type:10}}}] }) but fails any ? what want $nor condition db.foo.find({ $nor:[ { f: {$type:1} }, { f: null }] }) which means none of included arguments true. not simplified usage of finding null value.

jquery - Load javascript file every time a new page is loaded -

i'm using http://instantclick.io on website (a pjax jquery plugin) , i'm experiencing problems regarding javascripts. it's temperamental - page load scripting working fine, other times parts of scripts not run. also, scripts running more once. example, if set console log in .click() function, i'll see console log multiple times when there should one. in instantclick.io documentation, explains how load script on each page load: if have snippet of javascript need execute on every page change, use following: instantclick.on('change', yourcallback); but need run whole js file rather function. have tried wrapping instantclick.on('change', function(){ around whole js file, scripts still not running again after new page opened. in console, i'm seeing lots of errors relating functions being undefined, indicate files not being loaded each time. how solve this? thanks! write in callback code adding js file dynamically

xml - How to add an attribute in a Zorba XQuery? -

i have xml documents root node called entity . each document, want count how many nodes has name tender , add attribute entity . import module namespace file = "http://expath.org/ns/file"; $file in file:list("../api/entity/p/", true(), "??????.xml") let $doc := doc(concat("../api/entity/p/", $file)) return update insert attribute number_of_tenders {count($doc//tender)} $doc/entity i following http://exist-db.org/exist/apps/doc/update_ext.xml , not zorba, guessed standard xquery. i error 6,69: static error [err:xpst0003]: invalid expression: syntax error, unexpected expression (missing comma "," between expressions?) what doing wrong? i suspect update statement not correct zorba. exist implements draft of xquery update 1.0. believe instead zorba correctly implemenets xquery update 1.0 specification, update should conform instead: http://www.w3.org/tr/xquery-update-10/ perhaps like: for $file in file:list(

symfony - Symfony2: doctrine:mapping:import throws Doctrine\ORM\Mapping\MappingException - Table [...] has no primary key. -

i want import doctrine mapping table called stores. do: ./app/console doctrine:mapping:import mybundle annotation --filter="stores" i error: [doctrine\orm\mapping\mappingexception] table cat_map has no primary key. doctrine not support reverse engineering tables don't have prima ry key. am using filter incorrectly? dont want doctrine try , map table other 'stores' requested create syntax: create table `stores` ( `id` int(11) unsigned not null auto_increment, `storeid` int(11) not null, `store` text not null, primary key (`id`) ) engine=myisam auto_increment=96 default charset=utf8; despite --filter attribute doctrine analyse tables. if ok go through filter creating specified entity. so, should try fix cat_map table adding primary key. if you're not figuring out way or if got particular needs, please update question including cat_map part.

javascript - How to link section tabs -

hi need sections i'm using section-container auto deep_linking;true have data-slug each tabs, i have 3 tabs images on them want have direct link access each individual tabs have link on homepage. tried adding location.hash script, tried .on click , .trigger, , none of them works. thanks lot. <body> <div class="section-container auto" data-section="" data-option="deep_linking;true;"> <section class="active"> <p class="title" data-section-title=""><a href="#tab1"></a><span>tab1</span></p> <div class="content" data-slug="loans" data-section-content=""> <h1>tab1</h1></div> <p class="title" data-section-title=""><a href="#tab2"><span>tab2</span></a></p> <div class="content" data-slug="tab2" data-section-content=&q

mysql - adding two subqueries to produce third column -

i need add 2 values 2 subqueries , add third column. can write whole subqueries twice produce sum, there better way it? select d.id, concat(d.disease, '( ', d.disease_nepali, ' ) ') disease, ifnull((select patients.d_o_m + patients.d_o_f patients clinic = 22 , patients.disease = p.disease), 0) 'district1', ifnull((select patients.d_o_m + patients.d_o_f patients clinic = 21 , disease = p.disease), 0) 'district2' diseases d left join patients p on (d.id = p.disease , p.district = 9 , p.status = 1 , p.report_date '2014-03%') group disease you can use sub select select t.*,t.district1 + t.district2 `new_col` ( select d.id, concat(d.disease, '( ' ,

python 3.x - sqlalchemy reflecting table and inserting a row -

im building wrapper db_connector using sqlalchemy... since im trying stay generic presume wont know tables il have , cant use orm line of development.... trying use reflection system, reflect table database , trying create new object table in order insert new info got user. at moment func gets table_name table insert new row , row_arguments, list arguments new row... im struggling creating new object of table, more precise object of row table, think if id manage doing swell , using session manage add new row. question how can create kind of object things pass? got engine,session,metadata in class defined.... def insertrow(self,table_name,row_arguments): self.table = self.gettablesindb(table_name) self.session = self.session() class test(object): pass mapper(test,self.table) string ="" in row_arguments: string += insert = test() self.session.add(insert) self.session.commit() in middle of code have lots of thin

c# - Hide/Display 'Clear' Button when Filter has been used -

i have problem in hiding clear button until filter options have been selected. i have 4 asp:dropdownlist's , 'apply filter' button. when option selected user has click 'apply filter' button. beside 'apply' button, have 'clear/reset' button when click it, reset asp:dropdownlist's defaults. what want display 'clear/reset' button when of asp:dropdownlist's not equal default. please bar in mind user use filter 2 & 3 , leave filter's 1 & 4 default's code have take in mind. i want best way have been on google , cant find answer need. my default.aspx: <dl class="filterlist" style="margin-top: -5px"> <dt> <asp:label id="environment" runat="server" text="environment" associatedcontrolid="environmentdd" /> </dt> <dd> <asp:dropdownlist id="environmentdd" runat="server

how to share via Google+ from mobile app in android? -

how share via google plus in android, kindly send code , details. intent gplus = sharecompat.intentbuilder.from(mainactivity.this) .settext("this site has lots of great information android!http://www.android.com") .settype("text/plain") .getintent() .setpackage("com.google.android.apps.plus"); startactivity(gplus); i tried perform share via google plus in android using above code..but application gets crashed when run this...kindly me execute.. try run in mobile device. if run app in emulator, there no google-play services library. run app in real device.

java - Automatically creation of test databases using Maven -

i integrated postgresql first jax-rs project , wondering how can setup databases test application using maven. managed create database , tables need before test phase starts, not able fill tables test data. missing guide tells me how setup spozz_db_testdata.xml file. know how add rows use primitive types string or integer, binary data? any solution or tips help. current spozz_db_testdata.xml <?xml version='1.0' encoding='utf-8'?> <dataset> <avatars /> <users /> <spots /> <spot_revisions /> <spot_images /> <comments /> </dataset> 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"> <modelversion>4.0.0</modelversion> <groupid>net.avedo

Android chrisbanes Action bar pull to refresh not working in nested layouts -

action bar pull refresh not working in following case <?xml version="1.0" encoding="utf-8"?> <uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.pulltorefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ptr_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:id="@+id/top_btns_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:orientation="horizontal" >

php output buffering - prevent part of code from being parsed? -

i generating static html pages using output buffering using include. is there way prevent parts of php code being parsed? rather having output, php still intact? according php documentation: when file included, code contains inherits variable scope of line on include occurs. variables available @ line in calling file available within called file, point forward. however, functions , classes defined in included file have global scope. with said, don't think can use include here. if don't want php code parsed php interpreter, use file_get_contents() or similar. allow fetch file without of php code being parsed.

html - Center aligning of the text in dropdown? -

i have searched answer question .. found 1 solution in .. 1 user had suggested use padding-left or qustion. <select> <option>one</option> <option>one-two</option> </select> when add padding-left works fine browser .. when check dropdown in devices , not aligned @ center expected .. have given values padding-left in percentage , pixels .. there other way works fine in browsers , devices??

ios7 - iAd is working on test app, but not when its on appstore -

i've made app containing iad in ios 7. it's working fine on development state, testing on phone. but after it's been released @ appstore, no ad's being showed. i have checked code, , iad enabled anyone know why ? it takes 3 days ads displayed in new app.

ios - UITableViewCell subclass: Delete and reorder button not showing -

i using uitableviewcell subclass in highly customized uitableview. want implement edit button. implemented button, action, setting uitableview editing:yes , on. problem cells not show delete or move buttons or handlers. need implement in subclass this? bests, philip do complete implementation of edit , delete buttons in tableview, customize according requirement - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *simpletableidentifier = @"referrral remaindercc"; referrralremaindercc *cell = (referrralremaindercc *)[tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { uiviewcontroller *c = [[uiviewcontroller alloc] initwithnibname:@"referrralremaindercc" bundle:nil]; cell = (referrralremaindercc *) c.view; } if (dataarray.count==0) { return 0; } else { referraldc *referral =[dataar