Posts

Showing posts from June, 2010

asp.net mvc 4 - Adding SQL Server Express to mvc 4 project -

i new asp.net mvc 4, trying hard connect sql server express database in project. not getting right. have been researching many days. i not able exact steps. please provide me step step procedure connect asp.net mvc 4 project sql server express typically link setup . http://msdn.microsoft.com/en-us/library/ms171890.aspx or http://msdn.microsoft.com/en-us/library/vstudio/ms171890(v=vs.110).aspx cheers

Scala 2 dimensional Array and Arrays -

this question has answer here: how create , use multi-dimensional array in scala? 2 answers i trying write java ode in scala , think need help. problem: java: public static int[][] scorematrix = new int[5][20]; scala: var scorematrix: array[array[int]] = new array[array[int]](5, 20) it's not working, don't know why? error "too many arguments constructor array(_length:int)array[array[int]]" for initializing 5*20 2d int array can use: var scorematrix: array[array[int]] = array.ofdim[int](5, 20) your code doesn't work because array constructor has 1 argument, array length.

c# - Cannot implicitly convert type 'bool' to 'system.threading.tasks.task bool' -

i have error: "cannot implicitly convert type 'bool' 'system.threading.tasks.task bool'" in service implementation code. correct code please. public task<bool> login(string usn, string pwd) { dataclasses1datacontext auth = new dataclasses1datacontext(); var message = p in auth.users p.usrname == usn && p.usrpass == pwd select p; if (message.count() > 0) { return true; } else { return false; } } you need specific whether want operation happen asynchronously or not. as example async operation : public async task<bool> login(string usn, string pwd) { dataclasses1datacontext auth = new dataclasses1datacontext(); var message = await (from p in auth.users p.usrname == usn && p.usrpass == pwd select p); if (message.count() > 0)

c - Segmentation fault & core dumped with changing window size -

i make program using ncurses using window(?). there strange problem!! (i use putty) if change window size, deletetree() not working well. if maintain window size, deletetree() working well!! the function of deletetree() max_child = 100 enum day {mon, tue, wed, thu, fri, sat, sun}; enum tree_type {header,day,place,room}; typedef struct _tree { enum tree_type type; union _info info; struct _tree* link[max_child]; } tree; typedef tree* tnode; tnode troot; void deletetree(tnode* twalk) { int i; if (*twalk == null) return; (i=0;i < max_child;i++) { if ((*twalk)->link[i] != null){ deletetree(&(*twalk)->link[i]); (*twalk)->link[i] = null; }else break; } free(*twalk); *twalk = null; } and void deletetree(tnode twalk) { int i; if (twalk == null) return; (i=0;twalk->link[i]!=null;i++) { deletetree(twalk->link[i]); free(twalk->

uitableview - create a UITableViewController programmatically in Swift -

i'm trying to, title say, set uitableviewcontroller programmatically. after few hours of trying hope can me. and, yes, hve checked out other posts on matter: import uikit class mainviewcontroller: uitableviewcontroller { init(style: uitableviewstyle) { super.init(style: style) // custom initialization } override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // #pragma mark - table view data source override func numberofsectionsintableview(tableview: uitableview?) -> int { return 1 } override func tableview(tableview: uitableview?, numberofrowsinsection section: int) -> int { return 5 } override func tableview(tableview: uitableview?, cellforrowatindexpath indexpath: nsindexpath?) -> uitableviewcell? { var cell = tableview?.dequeuereusab

PHP $_GET not giving me required result -

i writing php code in adobe dreamweaver. code shown below. expecting code output 2 boxes, write something. , when click on submit button, expect see 2 separate things entered box concatenated. i'm not getting concatenation. in fact, nothing happens when click on submit. confused. code not should using dreamweaver for? relatively new php , not understand bits. suspicion dreamweaver not recognize "twofieldform.php". can please tell me how can overcome issue? <!doctype html> <html> <head> </head> <body> <h1>form filler</h1> <?php function joined($s1, $s2) { return array($s1.$s2, strlen($s1.$s2)); } $first = $_get[fieldone]; $second = $_get[fieldtwo]; $answer = joined($first, $second); echo "the concatenated string \"{$answer[0]}\" , length \"{$answer[1]}\"; ?> <form action = "twofieldform.php" method = "get"> fi

Compile error with `let` in Swift switch statements -

in swift, can slice of array using range operator, this: let list: string[] = ["first", "middle", "last"] let cdr = list[1..list.endindex] assert(cdr == ["middle", "last"]) i'm trying same thing in recursive function takes string[] parameter, not having luck: func last(xs: string[]) -> string? { switch xs { case let (singleitemlist) singleitemlist.endindex == 1: return singleitemlist[0] case let(multiitemlist) multiitemlist.endindex > 1: let cdr: string[] = multiitemlist[1..multiitemlist.endindex] // compilation error! return last(cdr) default: return nil // empty list } } last(["first", "middle", "last"]) last(["last"]) last([]) the middle case statement doesn't compile. fails error: playground execution failed: error: <repl>:14:29: error: not find overload 'subscript' accepts supplied arguments

Java Swing Timer Not Starting? -

i wrote program test out swing's timer. compiles fine , has no run-time errors, stops starts , nothing pops on screen. it's modified version of example code found online, should work fine. have no idea what's wrong code: import java.awt.event.*; import javax.swing.*; public class time { int sec=0; int min=0; public time() { actionlistener taskperformer = new actionlistener() { int sec=0; int min=0; public void actionperformed(actionevent evt) { if(sec==60) { sec = 0; min++; } system.out.println("time passed: " + min + ":" + sec); if(min==2) system.exit(0); } }; timer timer = new timer( 1000 , taskperformer); timer.start(); } public static void main(string[] args) { time timer = new time(); } } javax.swing.timer uses daemon thread @ it's core. means once main

Scala: Enforcing A is not a subtype of B -

i trying overload method based on whether or not parameter extends given class, , have been having trouble. using an approach miles sabin , produced following code: object extendedgenerictypes { trait <:!<[a, b] // encoding "a not subtype of b" // use ambiguity rule out cases we're trying exclude implicit def nsubambig1[a, b >: a]: <:!< b = null implicit def nsubambig2[a, b >: a]: <:!< b = null // implicit substitutions implicit def nsub[a, b]: <:!< b = null } and use case: import extendedgenerictypes._ class foo def foobar[t](x: t)(implicit ev: t <:< foo) = "hello" def foobar[t](x: t)(implicit ev: t <:!< foo) = 5 println(foobar(new foo())) unfortunately, results in ambiguity, , compiler not know of 2 methods invoke. i'm looking both explanation why there ambiguity in case (as opposed other simpler cases outlined in miles' gist) , how circumvent hurdle. note need perform check on

linker - Redefinition errors of static variable in C++ -

i have been getting redefinition errors when compile these files. have looked through questions on regarding same, unable find wrong. here files :- #ifndef utility_h #define utility_h //------------// //header files// //------------// #include <string> #include <map> #include <fstream> //----------------------------// /* declaration of class. */ // ---------------------------// class utility { public: static std::ofstream out ; static std::ofstream music ; static std::ofstream video ; static std::ofstream document ; static std::ofstream mp3 ; static std::ofstream mp4 ; static std::ofstream html ; static std::ofstream deb ; static std::ofstream cpp ; static std::ofstream c ; static std::ofstream py ; static std::ofstream php ; static std::ofstream java ; static std::ofstream _class ; static std::ofstream ; static std::ofstream master ; static std::string lastpath ; static std::map<

mysql - Reuse result of IF condtion in true or false result expression -

i have following nested query: select `messages`.*, if((select `status` messages_status messages_status.message_id = messages.id , user_id = 149) null, 'unread', messages_status.status) `status` `messages` what do, if there no messages_status.status set (i.e. if null), should return 'unread'. however, if set, should return value. currently, returns error: unknown column 'messages_status.status' in 'field list' do have idea how fix this? you can't refer result of if 's condition in other places. repeat query: if((select `status` messages_status messages_status.message_id = messages.id , user_id = 149) null, 'unread', (select `status` messages_status messages_status.message_id = messages.id , user_id = 149)) status but it's clearer use join instead: select m.* , coalesce(ms.status, 'unknown') messages m left join messages_statu

css - How to override position of primefaces OneMenu? -

Image
how override primefaces onemenu in order see on captcha, ie below? selectonemenu have no changes. my guess menu panel doesn't have enough space fit in lower part, instead it's positioned above, aligning of panel being set javascript ( primefaces.widget.selectonemenu.alignpanel ), using jquery ui .position() method allows position element relative window, document, element, or cursor/mouse, without worrying offset parents, , default value collision attribute flip ( in primefaces 5 it's flipfit ) resulting positioned element overflows window in direction, or move alternative position. in case implement 1 of these 3 solutions: extend space on lower part, maybe adding margin captcha, in way panel fit in bottom. or change hight of panel <p:selectonemenu height="100" > making bit shorter can fit. or can override primefaces.widget.selectonemenu.alignpanel function set collision attribute none , in position function: primefaces 5

c# - Stored Procedure and Entity Framework Insert Query - Performance -

i have simple insert statement, table inserting data has millions of rows. problem insert statement being executed every 2 -3 seconds. my cpu usage reaches 80%+ usage, due insert statement. i need ask that, if write stored procedure insert, increase performance? stored procedures stored in sql there performance improvement because sql knows procedures has , can optimize execution. furthermore entity framework presents kind of wrapper around database functionality. means little bulky, because classes , methods/properties. try it, bring improvement. that said, don't think problem because of ef vs stored procedures dilemma. due millions of records in table. when performing insert , database checks kinds of things, such foreign keys, constraints, triggers triggered etc. other things, influence performance , database related, such size of transaction log etc. i try 2 things: i create identical table identical triggers, indexes, primary keys, foreign keys, ... e

animation - Scrolling an image inside a imageView in android -

i working on application in having large image , need display image in imageview of small size . thinking view whole image scrolling image inside image view automatic.can posible ? i have tried following not getting satisfaction. android how zoom , scroll bitmap created on fly android autoscroll imageview http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/ in short need develop ken burns effect i tried https://github.com/flavioarfaria/kenburnsview getting error follows : java.lang.nullpointerexception @ com.flaviofaria.kenburnsview.mathutils.getrectratio(mathutils.java:44)

ios - Parse.com object disappears after saving -

this bit of crazy one. have ios app saves object parse.com's datastore. until couple of days ago worked well. now, suddenly, object not going database. put code here doesn't seem issue, gets more bizarre: when go directly data browser , insert row manually, shows right there. but when refresh data browser -- object gone. looking @ forums here's more data: when save app, have existing current user. the object exists. the permissions on class "public." the app codes correct (i'm able read database.) i'm seeing saveinthebackground success block getting called, , printing out object has valid object id!!! but goes pooooooffff , gone. any idea what's happening? edit: added different class exact same columns, changed appropriate fields in app, , works. alarming, class stops saving objects of sudden. idea why?

Shorthand in Swift -

so i'm going through "a swift tour" tutorial @ apple site. ( https://developer.apple.com/library/content/documentation/swift/conceptual/swift_programming_language/guidedtour.html#//apple_ref/doc/uid/tp40014097-ch2-xid_1 ) my confusion comes @ section sort/shorthand. example given sort([1, 5, 3, 12, 2]) { $0 > $1 } i println'd closure see happening , here got: the $0 5 , $1 1 $0 3 , $1 5 $0 3 , $1 1 $0 12 , $1 5 $0 2 , $1 12 $0 2 , $1 5 $0 2 , $1 3 $0 2 , $1 1 on first line, notice $1 1 while $0 5. question why isn't number "1" assigned $0 (rather $1) since falls first in array. understand algorithm , all...it's shorthand attribution bothering me. guess it's nickpicky, if can clear me, appreciate it! this has nothing shorthand, it's optimisation in internal implementation of sorting. doesn't matter order arguments passed closure, internally they'll passed in whatever order happens efficient. looking @ order

objective c - Importing sqlite3.h to a Swift project via a Obj-C bridging header doesn't work -

i have created file called bridgingheader.h , contains 1 line: #import <sqlite.h> and of course framework libsqlite3.dylib imported either. in build settings i've set value of objective-c bridging header <projectname>/bridging-header.h but… when add import sqlite3 swift class says cannot find module sqlite3 . for want use sqlite 3 directly, see gist: https://gist.github.com/zgchurch/3bac5443f6b3f407fe65

java - How to shutdown Ehcache CacheManager in standalone application -

i have simple api clients use in standalone application. behind scenes api uses ehcache performance. everything works fine except client needs invoke shutdown() method in api invoke cachemanager.shutdown() without ehcache continues run in background though main thread completed. is there way can avoid shutdown() call client? i tried using @predestroy spring annotation invoke call, didn't work? here adding sample client program. public class clientapp{ @autowired private iclientservice service; public static void main(string[] args){ try{ service.getclients(); ... } { service.shutdown(); // shutdown cache background thread } } } in clientserviceimpl.java, have following lines public void shutdown(){ logger.info("shutting cache down..."); ehcachemanager.shutdown(); } your example confirms standalone application setup. ehcache should not prevent jvm shutting do

r - Shiny slider - retrieving values - list, or..? -

i have shiny app using renderui in server.r create set of sliders, since not know ahead of time how many sliders need created. works on webpage end, i'm having trouble retrieving set values. here renderui function in code: output$sliders <- renderui({ if (input$unequalpts == "no") return(null) updatetabsetpanel(session, "intabset", selected = "unequal") theshp <- myshpdata() thestrata <- unique(as.character(theshp$shnystr)) numstrata <- nlevels(theshp$shnystr) lapply(1:numstrata, function(i) { sliderinput(inputid = paste0("strata", i), label = paste("strata ", thestrata[i]), min = 0, max = 100, value = c(0, 100), step = 1) }) }) here how trying retrieve values in later reactive function of server.r: print("getting slider values...") mysliders<- null theshp <- myshpdata() numstrata <- nlevels(theshp$shnystr) mysliders <- lapply(1:numstrata, function(i) { input[[

html - Redirect based on query string -

i'm hosting things on home server, ip address changes. don't have domain name, can't give people bookmark. fix this, made small perl script spits out html file dropbox, can let people bookmark that. know, that's not best solution, seems working far. the issue is, i'd make nicer. want have optional query string, ?path=wiki or something, , when loads that, it'll automatically redirect http://(my_ip)/wiki unfortunately don't know how make redirect happen, , haven't seen who's got answer. optional, dynamic 1 that, although should simple if understand right. purely in html don't see happening but javascript, if anyhow spit out custom html page, replace ipadres of targeturl in example below <!doctype html> <html> <head> <title>test redirect</title> <script type="text/javascript"> var targeturl = 'http://127.0.0.1'; function querystring(paramname) { var url = doc

html - Reusable jQuery select/option filter based on another select -

like title suggests i'm trying create jquery function filter select options based on the value of select/option. so far have managed create function works great single use, breaks when try use more once. here's have far: html <tr class='car-selection'> <td class='label'>car 1: </td> <td>manufacturer: <select class="manufacturer"> <option>select manufacturer</option> <option class="audi" value="audi">audi</option> <option class="bmw" value="bmw">bmw</option> <option class="mercedes-benz" value="mercedes-benz">mercedes-benz</option> </select> </td> <td>model: <select class="model"> <option class="audi">select model</option> <option value="a1" class="audi">

sql - How to remove certain rows if there are two values for same login id -

loginid status ======================== jo deleted jo active jo discard kir active user1 active user1 deleted the results shoud give me kir active rest login id should not there. can plesase query this should trick: select * yourtable loginid in (select loginid yourtable group loginid having count([status]) = 1) the having clause ensures loginid values have single status mapped them selected. note query select required rows. if want delete offending rows, can so: delete yourtable loginid in (select loginid yourtable group loginid having count([status]) > 1)

sql - Oracle query to get month wise data and give 0 for month not available -

following table data time_stamp name 01-mar-14 02-mar-14 b 02-mar-14 c 01-may-14 d 02-may-14 e 01-jun-14 f output required: (3,0,2,1) (month wise count 0 if month doesn't exist) i have created following query : select listagg(count(1),',') within group (order extract(month time_stamp)) ps_bqueues_host time_stamp between to_date('01-mar-14', 'dd-mon-yy') , to_date('01-jun-14', 'dd-mon-yy') group extract(month time_stamp) this gives me output : (3,2,1) (month of apr 0 not there). please suggest how group on months. thanks. you should join original table table months in given period. if inside 1 year we need 1,2,3,...12 sequence . select listagg(count(name),',') within group (order m.rn) (select * ps_bqueues_host time_stamp between to_date('01-mar-14', 'dd-mon-yy') , to_date('01-jun-14', 'dd-mon

How does Windows know if a file was downloaded from the Internet? -

if open file in windows, downloaded chrome or browser windows popups warning, file downloaded internet. same documents open in microsoft word. but how windows know file originate internet? think it's same file every other file on hard drive. has file properties? harry johnston got it! had nothing temporary folder or media cache. it's ntfs stream. further reading: msdn file streams this blocking information archieved following commands on cli: (echo [zonetransfer] more? echo zoneid=3) > test.docx:zone.identifier this creates alternative file stream.

Can Paypal allow unlimited withdraws with a single user agreement -

i have merchant site. wonder if following scenario possible : customer subscribes "full shop access" , can withdraw money it's paypal account when purcahses something. not have login paypal or @ anytime moment chose "full shop access". given money amount differents. i found lot of thing recurrent payment it's on given periods , given amounts therefore it's not @ need. i want customer paypal once : "ok, trust website, can money anytime needs to". so if it's possible, can give me link documention ? regards 1) create token using setexpresscheckout l_billingtype0 set merchantinitiatedbilling 2) create billing agreement using createbillingagreement , pass token response after redirecting user paypal. 3) charge billing agreement id using doreferencetransaction . this method requires approval paypal use reference transactions.

c++ - Deducing template parameter from default parameter -

this question has answer here: why can't compiler deduce template type default arguments? 3 answers why doesn't c++11 program work: template <typename t> void f(t t = 42) {} int main() { f(); } why can't t deduced default argument 42 ? 14.8.2.5 [temp.deduct.type] : 19 - template type-parameter cannot deduced type of function default argument. [...] the example given substantially same yours.

Emacs linum border to wide -

Image
my linum margin wide (about 6 characters). in examples on web, it's not. how can changed? there no specific parameters set myself. using emacs mac port. there custom theme, set anything. linum-format controls formatting. if (setq linum-format 'dynamic) should adapt width on fly. if want hardcode number of columns, do, say, (setq linum-format "%5d") 5-column number.

sql - TSQL query with group by error -

i have query running return stats tool. working returning information have added new column able totals location , stuck. below query: select b.[segmentname], count(a.[segmentid]) total, a.[meetingid], c.[center] focus_meetings_segments inner join focus_segments b on a.[segmentid] = b.[id] join focus_meetings c on c.[id] = a.[meetingid] c.[center] = @location group a.[segmentid], b.[segmentname] order total desc xml path ('segment'), type, elements, root ('root'); the new column added center focus_meetings table. the error getting meetingid not contained in aggregate or group clause. is there way write query can run? change group a.[segmentid], b.[segmentname] to group b.[segmentname], a.[meetingid], c.[center]

excel - On error message -

i trying put on error message below code (so if there runtime error, want msgbox appear , code stop running when user clicks on error message. gave shot below having issue code doesn’t run to. wondering if me. dim hl hyperlink each hl in activesheet.hyperlinks on error goto errormsgbox hl.range.offset(0, 1).value = hl.address hl.range.offset(0, 1).value = filedatetime(hl.range.offset(0, 1).value) exit sub errormsgbox: msgbox ("error") resume next next end sub your error handling needs go outside of loop. also, since want code stop running , should not use resume next statement. also, have exit sub inside for...next loop, maybe confused, means "loop" operate once , not desire. revised: dim hl hyperlink each hl in activesheet.hyperlinks on error goto errormsgbox hl.range.offset(0, 1).value = hl.address hl.range.offset(0, 1).value = filedatetime(hl.range.offset(0, 1

How to disable theme updates on WordPress to avoid losing my changes? -

i trying modify template should use child-theme (using wordpress) so, when parent template updates wont lose changes. well, problem created template using parts of other templates. thinking set style , that, maybe missed update command , if parent template update might lose work. how can sure not add information updates on customized template?? thanks open style.css file , change theme name , information in comment @ top. turn theme child theme , no updates affect it. /* theme name: theme name author: name author uri: url description: theme is... version: 1.0 */

clojurescript - Differences between :init-state vs :state at build function -

i understand can initiate state of component passing map value of :init-state keyword. passing map value of :state keyword, example, between component , child component, can share same state? it? thanks. the difference when childs state gets set. :init-state set once, when component mounted. :state set on each render. therefore, :init-state should used (as name suggests), initialise state. on other hand, :state used set state changes on time.

ios - UIViewController "mysteriously" resets to origin=0,0 when answering an incoming call -

i have uiviewcontroller in app rests original position when i'm answering incoming call. how set breakpoint catch when happens? any idea might causing this? i tried disabling autoresize , auto rotate nothing seem make difference.

gradle - Eclipse/Tomcat publishing unnecessary/problematic dependencies -

so first off, little background. i working on converting eclipse java web project gradle. use vaadin framework , manage project ant/maven/ivy. have project contains common code web project depends on. in both projects our library files, jars, included in source , committed our vcs. switch gradle using preferred method of pulling our dependencies repository; maven central. i have completed creating gradle build scripts correspond our current ant build scripts. have 1 gradle build script each project, 1 @ root configuration injection along settings file. using java , eclipse plugins both projects , additionally war , vaadin plugins web project. now problem. when use gradle construct war works , web-inf/lib directory contains jars expect, based on dependency configuration. however, when use tomcat inside eclipse publish project end bunch of additional jars in web-inf/lib directory. of jars harmless , unnecessary, why have excluded them war, there couple problematic because

java - Field not populating from database -

database table create table wies.department ( dept_id integer not null generated default identity ( start 100, increment 1), dept_nme varchar(20) , sequence_no integer , active_ind char(1) default 'y' ); entity class @entity @table(name = "department", schema = "wies") public class department implements jpaobjectwithname, serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.identity) @column(name = "dept_id", unique = true, nullable = false) private integer departmentid; @column(name = "sequence_no") private int sequence; @column(name = "dept_nme") @size(max = 20, message = "error.department.name.length") private string name; @transient private boolean

website - Powershell Script Changed Site to New App Pool in the GUI, but not in the Advanced Properties -

i'm running w2k8 r2 web server multiple applications in each app pool. had move sites 1 app pool another, ran script: import-module webadministration get-content c:\applications.txt | foreach-object {set-itemproperty –path “iis:\sites\default web site\$_" applicationpool –value pool02} the result applications changed viewed in gui. when right click pool list it's been correctly moved. however, when drill advanced settings of application itself, application pool value hasn't changed , it's still running in old pool , using memory though doesn't show in gui. any ideas? if have app in destination pool can this: import-module webadministration get-content c:\applications.txt | foreach-object { $destapppool = (get-spwebapplication <any app in desired destination pool>).applicationpool $webapp = get-spwebapplication "iis:\sites\default web site\$_" $webapp.applicationpool = $destapppool $webapp.provisionglobally

How to improve enumerable find in ruby? -

i making request webservice api , have several ids pointing location. in order re assign results api contains id (sid). have following code: location.all.each |city| accommodations = accommodation.within_distance(city.lonlat, [1, 2]) lookups << lookup.new(city.id, accommodations.select(:supplier,:sid).to_a.map(&:serializable_hash)) end after webservice call try re assigning results ids (sid's) cities: results = call_to_api lookups.each | lup| res << {:city=> lup.city, :accommodations => lup.accommodations.map{ |j| results.find { |i| i.sid == j['sid'] } } } end the lookups iteration in incredibly slow , takes 50s 4000 entries. so how can improve performance point of view? imagine have 3 lookups have accomodations a , b , , c . the way done now, first lookup perform map , search a , b , , c . second lookup perform map , search a , b , , c . and on. given basic nature of search criteria, doesn&

java - How to sort the string ArrayList? -

i parsing json array successfully. have string has numbers. want sort data according numbers. had been checked many examples couldn't implement them in code.so please me. here code. here "count" the, string threw want sort data. a.java @override protected void doinbackground(void... params) { servicehandler servicehandler = new servicehandler(); string jsonstr = servicehandler.makeservicecall( jsonurl.categoriesurl, servicehandler.get); log.d("response categories:", ">" + jsonstr); if (jsonstr != null) { try { jsonobject jsonobj = new jsonobject(jsonstr); categoriesjsonarray = jsonobj .getjsonarray(jsonurl.tag_data); (int = 0; < categoriesjsonarray.length(); i++) { jsonobject c = categoriesjsonarray.getjsonobject(i); gridviewitem gridcategoriesitem = new gridv

mysql - Is it possible to put an <if> Condition in a select Query -

mysql> select * categories ; +-------------+--------------------+-----------------+--------------------- | category_id | t1 | t2 | t3 +-------------+--------------------+-----------------+--------------------- | 2 | popcorn | bucket | null | 3 | popcorn | jumbo | null | 3 | popcorn | jumbo | null 6 | popcorn | combo relish | null | 7 | soft drinks | fountain | apple | 7 | soft drinks | fountain | apple | 8 | soft drinks | fountain | orange | 8 | soft drinks | bottled | orange | i have table called categories shown above . for t2 values t3 can null or can have value . i have got query shown below select t1, t2, group_concat(concat(t3,'(',cate

Deauthentication through Dropbox JSON API (webhooks) -

we're using dropbox api in our app haven't found way succcessfully deauthenticate. currently call disable_access_token on logout, works (i.e. subsequent calls using token fail). unfortunately, next time oauth2 login process initiated session gets revived without asking user credentials, meaning until app uninstalled, 1 dropbox user can authenticated. this seems regression issue working few weeks ago (that is, session not being revived automatically). edit to clear, i'm looking way deauthenticate user in such way when oauth process run again user presented login page. compulsory behaviour, i'm hoping has found way. for interested, have found solution. send request to: http://www.dropbox.com/logout?access_token=xxxxx this disable access token , prevent oauth process automatically reviving.

send data to a different machine through javascript -

i need send data ( name, place, birth of year ) different machine ( ip:70.80.203.55 port:5555) through javascript. new javascript. can u please tell me how can ? you can use jsonp sending cross site data javascript. more details on jsonp can refer following links http://learn.jquery.com/ajax/working-with-jsonp/ http://en.wikipedia.org/wiki/jsonp what jsonp about?

HDFS - NFS gateway configuration - getting exception for NFS3 -

i trying configure nfs gateway access hdfs data, , followed http://hadoop.apache.org/docs/r2.4.0/hadoop-project-dist/hadoop-hdfs/hdfsnfsgateway.html .. in brief, above link, have followed below steps: sudo service rpcbind start // start portmapper , nfs daemons. sudo netstat -taupen | grep 111 // confirm propgram listenining port 111 rpcinfo -p ubuntu // tells programs listening rpc clients. sudo service nfs-kernel-server start // start mountd rpcinfo -p ubuntu // should show mountd sudo service rpcbind stop // start system’s portmapper sudo netstat -taupen | grep 111 // make sure no other program running port 111. if yes, use “kill -9 portnum” sudo ./hadoop-daemon.sh start portmap // start portmap using hadoop program sudo ./hadoop-daemon.sh start nfs3 sudo mount -t nfs -o vers=3,proto=tcp,nolock 192.168.125.156:/ /var/hdnfs mount.nfs: requested nfs version or transport protocol not supported above error gone (make sure stop system nfs calling service

javascript - jQuery prepend() to Elements that contain Divs -

i trying prepend() div each contains @ least 1 div. similar works: if ($('.tooltip-item').children('div').size() > 1) { $('.tooltip-item').prepend('<div class="star">*</div>'); } my html set this <a id="filteritems" class="tooltips" href="#">xbox <span class="tooltip-container"> <div class="tooltip-item">controller</div> <div class="tooltip-item">console <div class="filter-item">in stock</div> <div class="filter-item">pre-order</div> </div> </span> </a> in example prepend() "console" each method have tried end div each item or no item. how can prepend "console" div contains divs? loop through each element, otherwise take first element, $('.tooltip-item').each(function () {

racket - how to save the state of a game scheme -

for example have game: this game move bird on keyboard or mouse (define-struct estado (ancho alto vel tiempo mov punto)) (define mapa (bitmap "mapa.png")) (define projo (bitmap "projo.png")) (define mario (bitmap "mario.png")) (define (crear-mundo estado) (big-bang estado [to-draw pintar] [on-tick tiempo-nuevo] [on-mouse click] [on-key cambiar-al-nuevo-mundo-teclado] [stop-when fin-juego])) (define (pintar nuevo-mundo) (cond [(colisión nuevo-mundo area) (place-image projo (posn-x (estado-punto nuevo-mundo)) (posn-y (estado-punto nuevo-mundo)) (place-image (text (string-append "tiempo: " (number->string (quotient (estado-tiempo nuevo-mundo) 28))) 12 "red") 40 20 mapa) )] [else (place-image projo (posn-x (estado-punto nuevo-mundo)) (posn-y (estado-punto nuevo-mundo))

Python get most recent file in a directory with certain extension -

i'm trying use newest file in 'upload' directory '.log' extension processed python. use ubuntu web server , file upload done html script. uploaded file processed python script , results written mysql database. used this answer code. import glob newest = max(glob.iglob('upload/*.log'), key=os.path.getctime) print newest f = open(newest,'r') but not getting newest file in directory, instead gets oldest one. why? the problem logical inverse of max min : newest = max(glob.iglob('upload/*.log'), key=os.path.getctime) for purposes should be: newest = min(glob.iglob('upload/*.log'), key=os.path.getctime)

python - Calculate tf-idf of strings -

i have 2 documents doc1.txt , doc2.txt . contents of these 2 documents are: #doc1.txt good, bad, great #doc2.txt bad, restaurent, nice place visit i want make corpus separated , final documenttermmatrix becomes: terms docs bad great restaurent nice place visit doc1 tf-idf tf-idf tf-idf 0 0 doc2 0 tf-idf 0 tf-idf tf-idf i know, how calculate documenttermmatrix of individual words (using http://scikit-learn.org/stable/modules/feature_extraction.html ) don't know how calculate documenttermmatrix of strings in python. you can specify analyzer argument of tfidfvectorizer function extracts features in customized way: from sklearn.feature_extraction.text import tfidfvectorizer docs = ['very good, bad, great', 'very bad, restaurent, nice place visit'] tfidf = tfidfvectorizer(analyzer=lambda d: d

what is the concept of "live container" in javascript? -

in answer of following question: https://stackoverflow.com/questions/1684917/what-questions-should-a-javascript-programmer-be-able-to-answer i've got question: "live" contianer? couldn't reference on topic googling. can please describe concept of "live container" in brief? regards mahbubul haque i'm guessing refers live nodelist , updates results of query automatically.

Why do I need to edit the hosts file to make my ASP.NET projects work properly with IIS? -

this way have been taught: add website iis , point asp.net files. add host name within iis , example of be: myaspproject.local.co.uk add same host name in host file , example of be: 127.0.0.1 myaspproject.local.co.uk why need edit host file have above? please explain story point user enters url in browser. what looking @ here called 'domain name resolution'. can complicated subject simplified explination show doing here. when type name browser asking browser retrieve page. let's assume typed in 'www.stackoverflow'com'. computer cannot connect www.stackoverflow.com because computers talk using number, not letters; in case number talking 'ip address'. need ip addresss associated 'www.stackoverflow'com'. the way computer reach out domain name server (dns) , ask "what ip address associated name 'www.stackoverflow.com' ?". dns return ip address of stack overflow , computer talk server on address. no

android - Activity not shown through LockScreen -

i trying show activity through lockscreen. second 1 in app, first 1 works without problem. using wakelock : powermanager pm = (powermanager)getsystemservice(context.power_service); //mwakelock = pm.newwakelock(powermanager.partial_wake_lock, tag); mwakelock = pm.newwakelock(powermanager.partial_wake_lock, tag); mwakelock.acquire(); and using expected code within activity "getwindow().addflags(windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_turn_screen_on | windowmanager.layoutparams.flag_keep_screen_on); i tried option : windowmanager.layoutparams lp = getwindow().getattributes(); lp.flags |= windowmanager.layoutparams.flag_show_when_locked; lp.flags |= windowmanager.layoutparams.flag_dismiss_keyguard; lp.flags |= windowmanager.layoutparams.flag_turn_screen_on; lp.flags |= windowmanager.layoutparams.flag_keep_screen_on; getwindow().setattributes(lp); the big difference betwee

node.js - Socket.IO + Express: Obtaining the socket associated with an express session -

i looking raise application wide events express http route handlers. e.g user modifies record , event emitted other interested users. in cases want broadcast clients except client making (http) request. possible broadcasting against socket wish exclude, not have access socket associated session authenticating http request. i have seen examples demonstrate how retrieve express session user socket request (i.e obtain session id cookie, retrieve session sessionstore). is possible work in inverse , perhaps store socketid against session later retrieval? can identify immediate caveats or gotchas approach? also there implications if sockets distributed across servers via redis store? can foresee scenario in per user, http requests coming in different node socket requests. many thanks!

java - Remotely get notifications in order to update a progress monitor -

i have complex application containing server , frontend part. i trying in frontend part update progress monitor according action takes place in server part. action server part called remotely frontend. having trouble getting notifications real time update monitor. my code structure looks this: class frontend_class1{ public void method { list<string> strings = initializestrings(); progressmonitor.begingtask("", noofsteps); reponse = frontend_class2.method2(strings); progressmonitor.worked(1); } class frontend_class2{ public responsetype method2(list<string> strings){ serverclassremote remote = new serverclassremote(); response = remote.servermethod(strings); return response; } class server_class{ public servermethod(list<string> strings){ othermethod(strings); } public othermethod(list<string> strings){ s