Posts

Showing posts from March, 2013

sql construct condition with if statement mysql -

i want construct such sql condition. have table car, has such fields id_status , id_category , storage_address . need select cars id_status in (2,4) , if id_category = 4 need check field storage_address not null or empty. how make it? should use sql if statement? need like: select * car id_status in (2,4) , if(id_category = 4,storage_address not null,'1=1') try this: select * car id_status in (2,4) , if( id_category = 4, storage_address not null, 1 ) simply put, not need string '1=1' , plain 1 truthy value. or can select * car id_status in (2, 4) , ( id_category != 4 or storage_address not null )

roundtrip - How to calculate maximum, minimum and average RTT of ping in python? -

it's 1 question of our assignment. have calculated rtt using time.clock()-initialtime in python, got stuck when comes max, min, avr rtts. should do? i'm thinking has packet size? send bunch of pings , run trivial statistics on rtts get. can't deduce max, min, or average sample size of 1.

.net - Entity Framework Includes -

is there recommended maximum amount of .include statements use in entity framework query. i think read somewhere microsoft recommends no more 3 cant find source. thanks in advance. see performance considerations entity framework http://msdn.microsoft.com/en-us/data/hh949853.aspx (p 8.2.2) : it takes relatively long time query multiple include statements in go through our internal plan compiler produce store command. majority of time spent trying optimize resulting query. generated store command contain outer join or union each include, depending on mapping. queries bring in large connected graphs database in single payload, acerbate bandwidth issues, when there lot of redundancy in payload (i.e. multiple levels of include traverse associations in one-to-many direction). i suggest use sql profiler or ef profiler (f.e. efprof) can performance issues

javascript - Jasmine: how to spy on inner object method call? -

i have 2 prototypes want test: var person = function() {}; person.prototype.pingchild = function(){ var boy = new child(); boy.getage(); } var child = function() {}; child.prototype.getage = function() { return 42; }; what want test: to check getage() method called inside of pingchild() method that jasmine specs try use purpose: describe("person", function() { it("calls getage() function", function() { var fakeperson = new person(); var chi = new child(); spyon(fakeperson, "getage"); fakeperson.pingchild(); expect(chi.getage).tohavebeencalled(); }); }); describe("person", function() { it("calls getage() function", function() { var fakeperson = new person(); spyon(fakeperson, "getage"); fakeperson.pingchild(); expect(fakeperson.getage).tohavebeencalled(); }); }); describe("person", function() { it(...

java - Save image to iOS Gallery from libGDX -

i need export image libgdx game, , make appear in default photos app on ipad. currently, this: pixmap image = getscreenshot(); filehandle file; string filename = "diplom_" + game.player.getid() + ".png"; if(gdx.files.isexternalstorageavailable()) file = gdx.files.external(filename); else file = gdx.files.local(filename); pixmapio.writepng(file, image); pixmap.dispose(); but screenshot doesn't appear anywhere. how can make appear in photos app? at first try adding logger see add put file. if put in local: local files stored relative application's root or working directory on desktops , relative internal (private) storage of application on android. note local , internal same on desktop. if external external files paths relative sd card root on android , home directory of current user on desktop systems . refare filehandling libgdx wiki so guess save in local thats why wont find in ios. else need create right pa...

asp.net - How to add blank row in grid view? -

i new asp.net binding 1 list of data object grid view. want display blank row after each record in grid view have done below in code behind list<databasedto> lstdatabase= new list<databasedto>(); foreach(int jobnumber in jobnumberlist) { databasedto dataobject = new databasedto(); dataobject = getdatabasedata(jobnumber);//method retrieve data , return data object lstdatabase.add(dataobject); lstdatabase.add(new databasedto()); } gridview.datasource = lstdatabase; gridview.databind(); it's working correct getting desired blank row in grid view know not right way because adding object list can add blank row in place of adjust blank row aspx page. know there way using datatable not because adds unnecessary records datatable . other work around or way solve great. thank you. try <div> <asp:datalist id="datalist1" runat="server"> <itemstyle forecolor="#4a3c8c" backcolor="#e7e7ff...

php - Check if user exists in database -

i've made user class validates data passed through form , subsequently updates database table users. want add functionality such checking if username , email exists in table, i've added little script doesn't seem working. i inserted duplicated email address , did not error message "email exists" instead success message "1 row inserted": am doing wrong below? there perhaps better way approach this? public function insert() { if (isset($_post['submit'])) { $email = isset($_post['email']) ? $this->mysqli->real_escape_string($_post['email']) : ''; $result = $this->mysqli->prepare("select * users email='".$email."'"); if ($result->num_rows) { echo "email exisits!"; } else { $stmt = $this->mysqli->prepare("insert users (username, password, name, email) values (?, ?, ?, ?)"); $stmt->bind_param('ssss', $username, $password,...

c# - How to get a random number from a range, excluding some values -

in c#, how random number range of values - 1..100, number should not in specific list of values, 5, 7, 17, 23? since no-one has posted example code: private int givemeanumber() { var exclude = new hashset<int>() { 5, 7, 17, 23 }; var range = enumerable.range(1, 100).where(i => !exclude.contains(i)); var rand = new system.random(); int index = rand.next(0, 100 - exclude.count); return range.elementat(index); } here's thinking: build hashset of numbers want exclude create collection of numbers 0-100 aren't in list of numbers exclude bit of linq. create random object. use random object give number between 0 , number of elements in range of numbers (inclusive). return number @ index.

android - One of many prebuilt libraries is not included on ndk-build -

i'm developing android application native code. have native prebuilt libs should included in project. first put prebuilt libs in libs/armeabi folder of project. problem these files got deleted on build. so googled little bit , found have include these prebuilt libraries in android.mk file copied libs/armeabi folder. here part of android.mk: [...] include $(clear_vars) local_module := libavcodec local_src_files := $(target_arch_abi)/libavcodec.so include $(prebuilt_shared_library) include $(clear_vars) local_module := libavdevice local_src_files := $(target_arch_abi)/libavdevice.so include $(prebuilt_shared_library) include $(clear_vars) local_module := libavfilter local_src_files := $(target_arch_abi)/libavfilter.so include $(prebuilt_shared_library) include $(clear_vars) local_module := libavformat local_src_files := $(target_arch_abi)/libavformat.so include $(prebuilt_shared_library) include $(clear_vars) local_module := libavutil local_src_files := $(targe...

encoding email address using c# and decoding using javascript in a gridview -

i new user .net forgive me if problem basic. i have gridview displaying users information including emails. want encode these emails server side , decode them client side. <script type="text/javascript"> function uncryptedmailto(s) { var n = 0; var r = ""; (var = 0; < s.length; i++) { n = s.charcodeat(i); if (n >= 8364) { n = 128; } r += string.fromcharcode(n - (1)); } return r; } function showemail(s) { location.href = uncryptedmailto(s); } </script> <asp:gridview id="gridview_users" runat="server" onrowdatabound="gridview_users_rowdatabound" > <columns> <asp:templatefield headertext="email" sortexpression="email"> <itemtemplate> <a href="javascript:showemails(<%# eval("email", "mailto:{0}...

android - App started with a custom url scheme does not appear in recent apps list -

when app started custom url scheme not appear in "recent apps" list (appears on holding home button). example: i start app link in sms. app launches. ok . then press home button , go home screen. still ok . then hold home button , list of recent apps appears. app not on list. in not ok - expect app on list. if select messaging app list app comes up. not ok . expect see messaging app instead. androidmanifest.xml : <activity android:name=".mainactivity" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.view"/> <category android:name="android.intent.category.default"/> <category android:name="android.intent.categor...

android - Displaying Custom Fragment in DailogFragment -

i have fragmentactivity has button, on clicking button showing dailog public class fragmainactivity extends fragmentactivity implements android.view.view.onclicklistener { button shobut; public string dailogtag="dialog"; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); shobut= (button) findviewbyid(r.id.button1); shobut.setonclicklistener(this); } @override public void onclick(view v) { mydialogfragment newfragment = mydialogfragment.newinstance(); fragmentmanager fm ; fm=getsupportfragmentmanager(); newfragment.show(fm, dailogtag); } } my dialog class public class mydialogfragment extends dialogfragment { static mydialogfragment newinstance() { return new mydialogfragment(); } @override public view oncre...

android - Gridview with edittext and imge but with one button -

i need grid view imageview, edittext , textview in each field, , 1 button below try many codes, main problem button copies in each field of gridview too. unless dont mention in code! here code of getview: public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub view v; if(convertview==null){ layoutinflater inflater = ((activity)context).getlayoutinflater(); v= inflater.inflate(r.layout.gridview,parent, false); tv = (textview)v.findviewbyid(r.id.textview1); tx = (edittext)v.findviewbyid(r.id.edittext1); tv.settext(""+r.drawable.download); imageview iv = (imageview)v.findviewbyid(r.id.imageview1); iv.setimageresource(mthumbids[position]); } else { v = convertview; } return v; xml file: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_...

c# - Deserialization with Newtonsoft.Json -

i have controller, can send json object , recieve same object again. problem ajaxsavefoo creates foo object empty object back. how create deserialization ? /// <summary> /// returns foo /// </summary> /// <returns></returns> public jsonnetresult ajaxloadfoo() { return new jsonnetresult { data = new foo() }; } /// <summary> /// saves foo /// </summary> /// <returns></returns> public jsonnetresult ajaxsavefoo(foo foo) //who tries deserialize this!!, empty { return new jsonnetresult { data = foo }; } my client side.. $.ajax({ type: "post", url: "ajaxsavefoo", data: json.stringify(this._fooobj), success: this.savesucces, datatype: "json", contenttype: "application/json; charset=utf-8", error: this.savefailure }); foo when sent down.. { "customernumber": 2, "customerstatus": "1" } foo ...

same origin policy - How to put multi JavaScript function in a page? -

here again full code use without css, want run these 2 javascripts, can send me full code edited? here demo page http://iscree.orgfree.com here have jquery-1.4.2.js works both codes when in specify pages, not same page! <script type="text/javascript" src="http://www.iscreen.orgfree.com/js/jquery-1.4.2.js"></script> <style type="text/css">a {text-decoration: none}</style> <!here js1----------> <script type="text/javascript">//<![cdata[ $(window).load(function(){ jquery(document).ready(function(){ jquery('#hideshow').live('click', function(event) { jquery('#content').toggle('show'); }); }); });//]]> </script> <!here js1----------> <!here js2----------> <script type='text/javascript'>//<![cdata[ $(windows).load(function(){ // optional code hide divs $("div").hide();...

sdk - Android systrace errno 8 -

i have win7 pc, latest android sdk , python 2.7 , trying start systrace. start script "\android-sdks\platform-tools\systrace\" after commsnd "python systrace.py" recieve error: oserror: [errno 8] exec format error what can be? adb , python correctly installed , working good. windows doesn't support running systrace command line. please check following questions error running systrace tool in adb using jelly bean 4.1 emulator on windows 7 systrace windows

osx - Printing PDF/Doc/Docx from Mac OS X application? -

is there way print .doc, .docx, .pdf files without opening native application in cocoa, is there way invoke nsprintpanel application invoke print dialog given file. i new cocoa programming, highly appreciated. printing requires view. if remember correctly, default behavior print content view of main window. so, easiest way make main window's view (within content view) either pdfview or nstextview, you've loaded contents of pdf or word file. if want have other views, need customize printing, in case direct the printing programming guide .

javascript - Backbone.js events not firing when clicking on Icon-Font-Icon (sometimes text) on button -

my backbone click events won't fire when clicking on buttons icon fonts (like icon). one view e.g. looks this: var networkstatusview = backbone.view.extend({ template: _.template(helper.view('network/status')), events: { 'click a': 'navigate' }, navigate: function (el) { backbone.history.navigate($(el.target).attr('href'), true); return false; }, render: function () { this.$el.html(this.template(userlocation.tojson())); return this; } }); in template a"button" looks (yeah, it's bootstrap ;)): <a href="/link" class="btn"><i class="icon-info-sign"></i> Über</a> have got idea why these events fire when clicking on borders, paddings , freespace of button won't fire when clicking on icon (and on text)? thanks! the solution (thanks @nekaab !) worked me: change el.target el.currenttarget, navigate function this: navigate: function (el...

c - How do I build OpenSSL statically linked against Windows runtime? -

i'm working on c++ application windows uses openssl 1.0.1e library. i'm on visual studio 2008. for portability reasons application statically linked against runtime libraries ( /mt , /mtd options). , don't ship runtime libs application. per openssl faq , library default linked against multithreaded dll runtime ( /mdd ) incompatible scenario. make program work i've added applink.c project. on dev machine , on test computers program works fine. but unfortunately i've located computers app doesn't start. windows displays error: the application failed initialize (0xc0150002). click on ok terminate application. i've opened libeay32.dll in dependency walker , see msvcr90.dll not found. trick applink.c doesn't work me. how build openssl /mt or /mtd option? use nt.mak makefile rather ntdll.mak makefile. as aside, have written scripts around standard openssl build scripts make 'easier' (for me @ least) use openssl on ...

android - "This version of the application is not configured for billing through Google Play" error with signed apk (billing v3) -

this question describe relatively same problem. problem seems unique in these points, my apk signed. app upload week ago. purchase items created week ago. i'm using listed account testing. in app version 3. the confusing point keystore generated different device using eclipse, i'm using android studio here. the problem leaves no clue except above point. idea helpful.

How to get System Login and logoff time in ASP.net MVC4 -

am new asp.net mvc4 want program can record system login time , system logoff time along ip address. thanks in advance.... to record client ip address use httpcontext.request.userhostaddress //in controller or httpcontext.current.request.userhostaddress// in classes to record login , logout time. create custom action filter class , record datetime given below. [customfilter(currentaction="login")] public actionresult login() { ... } [customfilter(currentaction="logout")] public actionresult logout() { ... } public class customfilter : actionfilterattribute { string currentaction {get; set;} void iactionfilter.onactionexecuting(actionexecutingcontext filtercontext) { // todo: add action filter's tasks here mydbentities storedb = new mydbentities (); if(currentaction.equals("login")) { logindetail log = new logindetail () { logintime= da...

Embedded YouTube videos without hidden controls until clicking on the video -

i'd display embedded youtube videos controls hidden default, , when user clicks on video, controls appear. videos on this page . in google documentation pages found how hide controls altogether, not in way. , using firebug while visiting page can't see options used in iframe code relates controls. so how that? for reason embed code isn't allowing hide player controls anymore (it working yesterday). way used make work again use old embed code parameters hide controls when click video show if roll out hide again here's code: <object width="560" height="310"> <param name="movie" value="https://www.youtube.com/v/_-7k-z5zzos?version=3&rel=0&autohide=1&iv_load_policy=3&modestbranding=1&showinfo=0"></param> <param name="allowscriptaccess" value="always"></param> <embed src="https://www.youtube.com/v/_-7k-z5zzos?version=3&rel=0&...

java - How Does Eclipse find the JRE or JDK locaton? -

according eclipse faq. read eclipse not consult java_home environment variable. my doubt how eclipse initializes virtual machine . not know location of java . eclipse.ini file not have -vm configuration. still able run eclipse. the source update according eclipse installation guide . eclipse not write entries windows registry . as far know, invoke jvm, eclipse executes java command, so, if it's @ system execution path, eclipse won't need find instalation directory. to check, can start os shell , execute next command (from location): > java -version edit: (partially) wrong. faq ( http://wiki.eclipse.org/faq_how_do_i_run_eclipse%3f#find_the_jvm ) if jvm installed in eclipse/jre directory, eclipse use it; otherwise launcher consult eclipse.ini file , system path variable so, eclipse first looks inside eclipse/jre dir installed vms, if empty, consults eclipse.ini file, , @ last, looks @ system path.

What is the difference between locals and globals when using Python's eval()? -

why make difference if variables passed globals or locals python's function eval() ? as described in documenation , python copy __builtins__ globals, if not given explicitly. there must other difference cannot see. consider following example function. takes string code , returns function object. builtins not allowed (e.g. abs() ), functions math package. def make_fn(code): import math allowed_locals = {v:getattr(math, v) v in filter(lambda x: not x.startswith('_'), dir(math)) } return eval('lambda x: %s' % code, {'__builtins__': none}, allowed_locals) it works expected not using local or global objects: fn = make_fn('x + 3') fn(5) # outputs 8 but not work using math functions: fn = make_fn('cos(x)') fn(5) this outputs following exception: <string> in <lambda>(x) nameerror: global name 'cos' not defined but when passing same mapping globals works: def m...

android - Docx conversion -

i doing simple docx conversion app in android. file file = new file(path + "sample1.docx"); fileinputstream fis = new fileinputstream(file); xwpfdocument document = new xwpfdocument( fis); xwpfwordextractor extractor = new xwpfwordextractor(document); string doctext = extractor.gettext(); added above line in oncreate method. included dom4j,poi3.8,poi-ooxml3.8,poi-xml-schema3.8 & xmlbeans jars in libs folder. when run got error unable execute dex: method id not in [0, 0xffff]: 65536 googled , got info converting jar dex. with out dex possible docx reading? dont want xlsx & pptx packages of poi. i want covert doc , docx file. there separate code doc&docx conversion. thanks i able make jword working under android. had many issues apache poi have (conversion dalvik format failed).

php - Codigniter linking queries. -

i sorry if n00b question cant seem head around problem. i using mahana message library , trying create basic views , basic controller send message , retrieve messages. have sending message nailed (just about) , can view sent message on recipients profile. this problem. want able show details of user sent message along side sent message on recipients view message page. these details stored in users table. the question is, how run model query username, avatar location etc view_my_messages function in messages controller, based on result of get_all_threads($user_id) model in messaging model? i have included code controller, view , model below. controller: function view_my_messages(){ $this->load->library('mahana_messaging'); $user_id = $this->session->userdata('id'); $data['message'] = $this->mahana_model->get_all_threads($user_id); $this->load->view('messages/my_messages',$data); ...

Detect Google Chrome Aura with JavaScript, possible? -

navigator.useragent does not report it: "mozilla/5.0 (windows nt 5.1) applewebkit/537.36 (khtml, gecko) chrome/31.0.1613.1 safari/537.36" i see (aura) literally in chrome://version/strings.js, gets reported in chrome://version/

css - Margin of header is added to body (how to solve it ?) -

i try solve problem hours ... tried few tricks, small hack, tried add positions "relative, absolute...etc", "top", top add invisible not fixed div behind fixed , others, want cleanest solution possible , know why have got problem. : have menu "fixed" top, , header. header behind menu (normal), the problem when add margin header, adds margin body, while want add margin header inside body, place header under menu without position:relative+top:xpx. , use "box-sizing: border-box" doesn't change anything http://jsfiddle.net/wdnz4/ <div id="menu"> </div> <div id="header"> test1(success)<br>test2<br>test3(lose)<br>test4<br>test5 </div> (can't post css, little bug, go jsfiddle) thanx in advance ! add top:0; property #menu : #menu { height: 40px; width: 100%; position: fixed; background-color: red; top:0; } jsfiddle: http://jsf...

node.js - NodeJS Memcached - Use multiple servers -

how can add multiple memcache server in nodejs? like in php: $memcache = new memcache; $memcache->addserver('memcache_host', 11211); $memcache->addserver('memcache_host2', 11211); thanks radu the library installed when npm install memcached seems node-memcached . adding multiple memcached servers explained in documentation, here .

google visualization - Set Fixed axis values -

i had code set v axis scale 0 - 4. deleted , cannot remember how got working again. see below chart code, , code think used before. this think used before... vaxis: { viewwindowmode:'explicit', viewwindow: { max:100, min:99.8 } } below chart // create line chart, passing options var linechart = new google.visualization.chartwrapper({ 'charttype': 'linechart', 'containerid': 'chart_div', 'options': { //'width': 300, 'height': 300, 'legend': 'top', 'backgroundcolor': '#eeeeee', 'colors': [ '#8ea23f'], 'pointsize': 5, 'title': 'selected site , species abundance on time' }, 'view':{'columns':[0,2]}, }); there go: 'vaxis': {'title': 'something here', 'minvalue': 0,...

ruby on rails - Devise with multiple models -

how setup devise more 1 model? i've tried using rolify , cancan setup separate roles in database, each role has different way authenticate login. example, student have student_number, , lecturer have username no student_number. there bunch of other attributes lecturer won't have student , vice versa. i'm new rails 4. it looks classes , inheritance can come handy in case. defining user mode , let student , lecturer inherit class? class student < user # student's peculiar attributes end class lecturer < user # lecturer's peculiar attributes end then can have 2 separate controllers , corresponding views. the login page might have 2 links proper login pages.

php - Override PDF tax settings -

we override mage_tax_model_config have different tax settings specific customer groups. went except pdf documents. we checked current customer group id $customer->getgroupid() $customer mage::helper('customer')->getcustomer(); why don't work on pdf documents? please see override class in detail: public function displaysalespricesincltax($store = null) { $customer = mage::helper('customer')->getcustomer(); if ($customer->getgroupid() > 1) { return false; } else { return true; } } public function displaysalespricesexcltax($store = null) { $customer = mage::helper('customer')->getcustomer(); if ($customer->getgroupid() > 1) { return true; } else { return false; } }

Verilog questions on 2's complement and left roate -

i trying write 16 bits alu verilog. inputs 16 bits ain,bin , 16 bits output out. i required 2's complement addition , subtraction of both inputs. such wondering if can use '+' , '-' operator. ain+bin , ain-bin also, required left rotate of bits in value n. came out following replicate form 32 bits , shift left n bits. problem required reduce 16 bits again how can that? out <=({a,a}<<n); yes, can use +- operators if want add or subtract 2 numbers. if want truncate result 16 bits, assign result 16 bit wire/register, , automatically drop upper bits , assign lower 16 bits out . in cases may create lint warning, may want assign result intermediate variable first, , explicit part select. wire [15:0] out; wire [15:0] a; wire [31:0] a_rotate; a_rotate = {a,a} << n; out = a_rotate[15:0];

yui3 - Loading a URL when dropdown option Changes in YUI -

i trying load url when drop down menu changes via yui change event. want navigate url. i made long search. didn't got way. thanks :) <select id="dropdown"> <option value="http://example.com/home">home</option> <option value="http://example.com/about">abount</option> </select> y.one("#dropdown").on("change", function() { //'this' points dropdown node //so it's value value of selected option. assume keep new url there document.location.href = this.get('value'); });

php - Convert SQL to active record in CodeIgniter -

select *, sum(`relaxation_rating` + `food_rating`) ratings group code order ratings desc destinations how convert sql code cctiverecord in codeigniter? i tried following methods, did show results. $this->db->select("'(select *, sum(relaxation_rating + food_rating) database group code') ratings", false); $this->db->get("database"); try: $data = $this->db->select('*, sum(`relaxation_rating` + `food_rating`) ratings', false)->group_by('code')->order_by('ratings', 'desc')->get('destinations')->result_array(); or, $this->db->select('*, sum(`relaxation_rating` + `food_rating`) ratings', false)->group_by('code')->order_by('ratings', 'desc')->get('destinations')->result();

c# - Get total row count in Entity Framework -

i'm using entity framework total row count table. want row count, no clause or that. following query works, slow. took 7 seconds return count of 4475. my guess here it's iterating through entire table, how ienumerable.count() extension method works. is there way can total row count "quickly"? there better way? public int getlogcount() { using (var context = new my_db_entities(connection_string)) { return context.logs.count(); } } that way row count using entity framework. see faster performance on second+ queries there initialization cost first time run it. (and should generating select count() query here, not iterating through each row). if interested in faster way raw row count in table, might want try using mini orm dapper or ormlite . you should make sure table defined (at least, has primary key), failure can affect time count rows in table.

sql - android SQLiteDatabase.Update() is returning 2, why? -

i have database , query items. the list of items are: type- coffee: name- cafe latte type- coffee: name- flavoured latte type- coffee: name- mocha type- coffee: name- americano type- coffee: name- short black type- coffee: name- flat white type- coffee: name- espresso type- coffee: name- espresso con panna type- coffee: name- espresso machiato type- coffee: name- espresso affogato type- coffee: name- pot of coffee and when call function: public int edititem(menuitem menuitem){ contentvalues itemnewvalues = new contentvalues(); //itemnewvalues.put(item_type,menuitem.gettype()); itemnewvalues.put(item_name,menuitem.getname()); itemnewvalues.put(item_regprice,menuitem.getregprice()); itemnewvalues.put(item_largeprice,menuitem.getlargeprice()); string[] args = new string[1]; args[0]= menuitem.getname(); return db.update(database_table, itemnewvalues,item_name+"=?", args); } log.i("tag","updating (no of e...

javacard - Authentication fail error while loading an applet to a test sim card -

while loading applet sim card, authentication failure error. because of limited try of sim card key, wonder error means card blocked, or nor? before loading applet, must authentication card manager on smartcard. in order authentication, have know card issuer keys. there limit number of attempt authenticate. number 10. if exceed limit, card block. once authentication limit reset.

java - ActiveMQ embedded broker accessible via Weblogic servlet -

i'd following , i'm not quite sure if i'm not wasting time: i'm trying run activemq embedded broker inside weblogic servlet. idea is, clients able connect jms via http , embedded broker serve requests. know crazy idea, it's legacy application , lot of client code depends on jms. idea switch connection string , add libraries clients. works fine when create tcp connection, have no idea how map servlet internal broker the restrictions these: no changes in weblogic configuration(like datasources, bridges, jms etc) no spring http only this servlet definition web.xml: <servlet> <servlet-name>activemqservlet</servlet-name> <servlet-class>com.mycompany.activemqservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>activemq</servlet-name> <url-pattern>/servlet/activemqservlet</url-pattern> </servlet-mapping> important parts of servlet: public class activem...

Excel Counting non blank cells -

i having no luck trying count non blank cells in excel. have tried multiple formulas , keep getting inaccurate data. here situation: i creating preventative care list physicians (i have 4) created list of patients have received letter re: prev. care , inputting needs second letter , has results. results negative, positive. have list set in alphabetical order on patients last name , have physician initials in other column. want check see percentage of each doctors patients have done prev. care. want calculate separately. unfortunately, cells no in order. have tried knowledge. help! this give how many blank cells have. can deduct total number of cells in column, or use directly compute percentage (1 - x) x percentage of blank cells. =countblank(<your column>) e.g: =countblank(a1:a10)

How exactly does one integrate a cache in his project (spring + hibernate) -

i have project supports 10's of concurrent users. my project spring + hibernate project mysql db. i keep cache of entities (i.e. player) i have couple of questions: 1) how work cache (when have one) ? if have persist player change cache , persist hibernate? 2) spring support cache mechanism ? if how 1 work it? hibernate hibernate has second level cache . start work need to: choose cache provider (ehcache, infinispan, ...). configure cache region (and choose corresponding strategy depending on situation) enable cache entity it declarative, of time not need change application code. spring spring has cache abstraction . there common steps (choose chache provider, configure cache regions). more general pourpose cache, not related hibernate entities , transactions. must more work (annotate necessary methods annotations). in general if player class hibernate entity better go hibernate cache. may not true if have special demands. hope helps.

Subtracting days from a date in javascript -

i have 2 <input type="text"> tags , enter dates in them 22-05-2013 i want subtract 22-06-2012 date how do this? i've tried code didn't work: function returndate(ndays){ var = new date(); var dayoftheweek = now.getday(); now.settime(now.gettime() - ndays * 24 * 60 * 60 * 1000); alert(now); // returns current date alert(now.getfullyear() + "/"+(now.getmonth()+1)+"/"+now.getdate()) // returns new calculated date } so need difference between 22-05-2013 , 22-06-2012 the best way use moment.js . has fantastic support dates.

ibm mobilefirst - IBM Worklight - $("#pagePort").load() not working in Windows Phone 8 -

i'm using $("#pageport").load() navigating between pages in app, , it's working in android (both emulator & device) perfectly. however, app can't change page when tried run windows phone 8's emulator. i have done following in order make changepage functionality work in windows phone 8. suspect change make many things "suddenly" work well. this change supposed part of next jquery mobile release @ point in time... please try it: open jquery.mobile-1.x.x.js , refactor code follows: - var uri = url ? this.parseurl( url ) : location, - hash = this.parseurl( url || location.href ).hash; + var uri = this.parseurl( url || location.href ), + hash = uri.hash; and: - return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash; + return uri.protocol + uri.doubleslash + uri.host + uri.pathname + uri.search + hash;

Are text files a long string or an array of shorter strings? -

i have thought text files (.txt) merely long strings , different lines created through inclusion of (an invisible) \n. however, although not said explicitly, have seen references text files string arrays. are text files collection of string arrays each line being separate string? so, instead of text file being: string = "i went supermarket\ni bought loaf of bread\ni ate bread later day" are text files really: string[1] = "i went supermarket" string[2] = "i bought loaf of bread" string[3] = "i ate bread later day" ? text files, , files in general, logically contiguous sequence of bytes, or otherwise known array. operating system provides abstractions , tools can load parts of array memory on demand. however, application free load interpret data sees fit, using operating system abstractions of reading random sections of array. if wished treat text file line @ time, making line (delimitated newline character) individual ...

Asp.Net (not MVC) and Visual Studio Unit Testing -

i prepared spend time getting strikes 1 minute question in know. work on n tier application in different projects in same solution. when visual studio starts running both business logic , web start @ same time. i want use unit tests in weird way, want call web method, call business logic , hence database, i.e. want use unit test drive software. really i'd run test, have breakpoints working on test code , middle tier started when tests start. at moment breakpoints don't appear work , i'm not sure how start mt, have go effort of exec'ing process in code or built in? really @ beginning stage here, i'm used nunit not visual studio unit tests. any suggestions? thanks

Use git commit history to find project hot-spots? -

this question has answer here: finding changed files in git 8 answers i'm joining new project long , storied commit history, , i'd use history show me hot-spots in project: files have been commonly (and recently) edited. ideally, i'd avoid writing more few lines of script (ruby, python, javascript; doesn't matter which). anybody know of one-liner can rank git project files according activity in commit history? you can use one-liner print top 100 changed files: git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -100

eclipse - Android adb install unsuccessful (facebook integration, Ubuntu) -

i have installed android-sdk (not adt bundle - don't know purpose), eclipse, added adt plugin eclipse , added several virtual devices. according manual on fb dev. site, trying install facebook command: ./adb install ~/facebook-android-sdk-3.5/bin/fbandroid-3.5.apk but turned error: error: device not found i managed import android library facebook-sdk , attempted launch example file. result: failed install hellofacebooksample.apk on device 'emulator-5554': device not found [2013-08-28 17:46:37 - hellofacebooksample] com.android.ddmlib.installexception: device not found [2013-08-28 17:46:37 - hellofacebooksample] launch canceled! any idea have missed? must 1 problem of following: phone usb drivers not installed. you not connected. usb debugging not enabled in phone. pc or phone usb port problem.

c# - How can i download an image from html documents with wildcards -

i'm writing c# program pull .jpg image html document, name of target image changes every often. me being new programmer, can not figure out how achieve desired result. i using webclient download html. so guess have few questions ask here. how can use wildcard assume name , length of image name? and how can trim html containers away target image in document? in short, using approach you've described: can't. http requires each individual requested resource accessed name, cannot ask http server return set of resources names match pattern (be wildcard expression or regex). if, however, know names exist between particular range , follow pattern create series of requests , handle 404 errors accordingly, so: string resource = "/images/aestheticallyattractivehumanfemaleswithoutclothing/img_{0}.jpg"; for(int i=1;i<100;i++) { string thisresource = string.format(cultureinfo.invariantculture, resource, i); httpwebrequest request = new (h...

javascript - How to toggle between two string values like boolean True/False inside AngularJS? -

i have button, clicking on should show/hide area. button(ng-click="areastatus='on'") .area(ng-class="areastatus") i want not use ng-show/ng-hide , assign boolean areastatus, want more complex things on/off/hidden/transparent/whatever. is there way toggle areastatus between 'on' , 'off' on click without having write function it, inline expression? you can (html): <button ng-click="value = { 'on': 'off', 'off':'on'}[value]">on/off</button> jsfiddle but it's ugly. create method on scope change state, if it's more complicated toggling 2 values. however, if areastatus change area class, think should drop it, , instead change class accordingly model state. this: function ctrl($scope) { $scope.state = 'on'; $scope.changestate = function() { $scope.state = $scope.state === 'on' ? 'off' : 'on'; } } ... <...

Wordpress Custom Taxonomy Template -

found on here earlier today , hoping again creating custom template. :-) i have wordpress custom post type set in functions.php i have custom taxonomy called "classifications" under taxonomy have terms/categories: old research (parent) --- sub cat 1 --- sub cat 2 i have created file "taxonomy-classifications-oldresearch.php" changes layout me. however, not hold layout in sub categories. can alter creating "taxonomy-classifications-subcat1-oldresearch.php" have lot of sub categories want use 1 template for. way don't have create new template file every new category. have solution me? thank you! there great post on wordpress stack exchange addresses issue. problem wordpress uses template hierarchy load php templates based on slugs of each term.

javascript - Input Math With JS or/and HTML5 -

i need help. need put in site place when people can digit questions, math , needs simple input math symbols (like integrals , derivatives), don't know how can it. i search libs. anybody knows how me? ps: sorry english error. i'm brazil , don't have best english yet. =x ps: site in rails :) thanks. em português, onde posso ser mais claro :) então, no site eu preciso que pessoas possam fazer certas perguntas (nas áreas de matemática e física, mas ela precisa entrar de maneira simples (e mais visual ou via atalhos) com integrais, derivadas, somatórios e símbolos matemáticos de modo geral. procurei e não achei nenhuma lib js pra isso, queria saber se alguém conhece alguma coisa pra isso que possa recomendar. obrigado. mathml worth looking @ - though not yet supported browsers. possibility use latex syntax, done in many wikis. there latex-rendering libraries available ruby. other solutions presented here: http://www.intmath.com/blog/wp-content/ma...

.net - Is IIS a web server or an application server? -

is iis web server or application server? or both? what difference between (or similarity between) web , application servers in .net? thanks! update: on further investigation, concluded following: depends on protocol used 'serving' web server: http, , app server: any, including http. not sure if iis has other protocols deviate http, (and if doesnt,) maybe in stricter sense, is web server ! ( http://technet.microsoft.com/en-us/library/cc268242.aspx ) application servers, definition, should able serve (any) 'application'; not browsers. (web services being problematic area in context) correct above if wrong... again. iis 6.0 web server, extension, aspnet_isapi.dll, handles asp.net functionality. in iis 7.0 , above, .net handling has been integrated webserver itself, , iis might considered application server, hosting .net applications (asp.net). if looking similar java bean container in .net, there no such concept. can use windows services, ...

extjs - Adding a message box to a button icon -

i trying add message box when user clicks on button. code have: { text: 'button icon', id: 'buttonicon', cls: 'x-btn-text-icon', launch: function() { ext.messagebox.show({ title: "", msg: "message text", icon: ext.messagebox.warning, buttons: ext.messagebox.okcancel, fn: function(buttonicon) { if (buttonicon === "ok") { alert("done!") } } }); ...

nagios - puppet: Syntax error at 'target'; expected '}' - parsing error -

syntax error while parsing puppet resource. class nagios::export { @@nagios_host { $::fqdn: address => $::ipaddress, use => "linux-server", check_command => 'check-host-alive!3000.0,80%!5000.0,100%!10', hostgroups => 'all-servers', target => "/etc/nagios/resource.d/host_${::fqdn}.cfg" } @@nagios_service { "check_ping_${hostname}": check_command => "check-host-alive!100.0,20%!500.0,60%", use => "generic-service", host_name => "$fqdn", notification_period => "24x7", #target => "/etc/nagios/resource.d/service_${::fqdn}.cfg" service_description => "${hostname}_check_ping" target => "/etc/nagios/resource.d/service_${::fqdn}.cfg" } } when run puppet apply , following error seen.. [r...

cassandra - how to perform "not in" filter in cql3 query select? -

i need fetch rows without specific keys. sample: select * users user_id not in ("mikko"); i have tried "not in" , response: bad request: line 1:35 no viable alternative @ input 'not' "not in" not supported operation in cql. cassandra @ heart still based on key indexed rows. query same "select * users", have go through every row , figure out if not match in. if want type of query want setup map reduce job perform it. when using cassandra want de-normalize data model queries application performs end querying single partition (or few partitions) results. also find great webinars , talks on cassandra data modeling http://www.youtube.com/watch?v=t_wrc_gjrd0&feature=youtu.be http://youtu.be/x4q9jeliyno http://www.youtube.com/watch?v=hdjlsozvgwm&list=plqcm6qe9lgkjzvvwhprow9h7kmpb5hcuu&index=10

ruby on rails - CSV import - with confirmation - standard solution/gem? -

in application wish allow user upload csv file , presented view of data mapped columns user can confirm data correct. ideally allowing them edit incorrect data. are there existing solutions via gem, other standard solution or resources might want achieve. help appreciated. you can like: require 'csv' file_content = file.read(params[:file].tempfile.path) csv = csv.parse(file_content, :headers => true) file.unlink(params[:file].tempfile.path) depends on params passed controller, cvs can parse file written tmp dir if uploaded, presentation of result view layer

javascript - scrollLeft: to END OF MAIN DIV not offset().left -

i have problem following сode. <script type="text/javascript"> $(function() { $('ul.nav a').bind('click',function(event){ var $anchor = $(this); /* if want use 1 of easing effects: $('html, body').stop().animate({ scrollleft: $($anchor.attr('href')).offset().left }, 1500,'easeinoutexpo'); */ $('html, body').stop().animate({ scrollleft: $($anchor.attr('href')).offset().left }, 1000); event.preventdefault(); }); }); </script> my aim click on 1 of nav links (see screenshot). should scroll vertical red line (main div class "#incontent"). here "home" link scrolls end of site. (see screenshot on left hand side) http://i.stack.imgur.com/7yxkv.jpg Сan m...

html - Center different size images horizontally and vertically in a fixed div -

i'm having bit of struggle here positioning image inside div. div fixed 219x197px images loaded wordpress , need proof if image smaller or larger that, centered , overflow hidden if larger , either stretched or centered if smaller (what happens when smaller doesn't matter). i not want resize image, want show centered , whatever fits on div shown while rest hidden overflow. i found question around managed center horizontally, cannot vertically. i tried margin-left percentage not constant different image sizes. tried stuff line-height , vertical-align nothing seems work properly. does know try? in advance! here's html , css works center horizontally: <div class="img_article"> <span> <?php get_post_image($post->id,'large'); ?> </span> </div> .img_article { border-bottom: 1px solid #ef5589; overflow: hidden; width: 219px; height: 197px; text-align: center; } .img_article > span { disp...

sql server - Inconsistent SUM when using OVER PARTITION in MSSQL -

on static table, i'm trying run following query in ssms (to latest transaction each user , sum dollar value): select sum(nmoney) totalmoney ( select row_number() on (partition ngroup, nuser order dtransaction desc) seqnum , nmoney [mydb].[dbo].[mytable] ) mysubquery mysubquery.seqnum=1 this table 2,701,510 rows , nmoney column of type decimal(12,2). when run multiple times, varying result: 2317367341.75 2317370443.45 2317449819.62 2317360649.43 2317449819.62 what causing inconsistent result? for floating point arithmetic order numbers added in can affect result . but in case using decimal(12,2) precise. the issue duplicate values ngroup, nuser, dtransaction row_number not deterministic different runs can return different results. to deterministic behaviour can add guaranteed unique column(s) end of order by act tie breaker.