Posts

Showing posts from January, 2013

java - How to detect long presses of the volume key in a service? -

i want detect long presses in volume key in service. here options: a) let user control volume lock screen i wan't detect if user has held down volume button in service while screen off. tried (for 2 days) doing contentobserver , problem contentobserver detects volume changes, , volume doesn't change when screen off. there way can let user control volume lock screen? b) detect long press volume button service how can this? there broadcast receiver's can use while screen off? there way implement dispatchkeyevent in service? i have seen this , me second answer doesn't work in background. think easiest way option a because have set when user changes volume, can let user control volume lock screen? if not, there else can do? thanks much, ruchir

jquery - Alternately reorder nodeList based on class -

i have nodelist set following: <div id="container"> <div class="class-a"></div> <div class="class-a"></div> <div class="class-a"></div> <div class="class-b"></div> <div class="class-b"></div> <div class="class-b"></div> </div> i'm trying reorder div inside #container such output alternating class names: <div id="container"> <div class="class-a"></div> <div class="class-b"></div> <div class="class-a"></div> <div class="class-b"></div> <div class="class-a"></div> <div class="class-b"></div> </div> what best approach handle issue? although in example there equal class-a , class-b items, there number or none of either. long there either of 2 altern

lex - Stop program execution when there is error -

i like stop execution of program when facing error. how when using lex? can call normal c exit like: exit( status ); or there more neat way lex? you can - but: just printing message standard error , exiting lex does—when encounters fatal error, e.g., buffer allocation problems. see example yy_fatal_error, used purpose. can overridden, e.g., error recovery routine. a typical lexer not exit error: returns state information parser decides whether state legal. if lexer serves parser, exiting lexer make sense. further reading: does yy_fatal_error require call exit? re: ungraceful handling of fatal flex errors flex yy_fatal_error exist that. want handler application

Android Studio Error: String literal in setText cannot be translated -

Image
this first app , i'm having trouble. when run app crashes , don't know how fix error. public class mainactivity extends appcompatactivity {\ textview outputbottom = (textview)findviewbyid(r.id.output); } public void play_the_big_lie(view view) { the_big_lie.start(); outputbottom.settext("obamacare, big lie"); } string literal in settext cannot translated this not error , can safely ignore (unless need translation in app). it notification android studio should using string resource file instead of hard-coded string. if had guess @ source of issue since did not post logcat, this. you can't use findviewbyid before setcontentview because there no view "find". please try following code public class mainactivity extends appcompatactivity { private textview outputbottom; protected void oncreate(bundle b) { super.oncreate(b); setcontentview(r.layout.activity_main); outputbo

java - How to implement MouseWheelListener for JPanel without breaking its default implementation? -

simply; have jpanel inside jscrollpane ; as expected; jscrollpane default listens mousewheelevent scrolling working when wheel rotating , while cursor hovering on jpanel . but after that; updated jpanel implements mousewheellistener , , added mouse wheel listener jpanel itself. @override public void mousewheelmoved(mousewheelevent e) { if (e.iscontroldown()) { if (e.getwheelrotation() < 0) { system.out.println("mouse wheel up"); } else { system.out.println("mouse wheel down"); } } } the jpanel responds implementation when both; ctrl pressed down , wheel rotating , while cursor hovering on jpanel . default behaviour of jscrollpane unexpectedly lost!!! when rotate wheel while cursor hovering on jpanel scrolls of jscrollpane not responding!!! it seems that; implementation of mousewheellistener breaks default of jpanel . so; how implement mousewheellistener jpanel without breaking

c# - Cannot read section from app.config -

i have simple config section follows <configuration> <configsections> <section name="test" type="system.configuration.dictionarysectionhandler"/> <section name="test1" type="system.configuration.dictionarysectionhandler"/> </configsections> <test> <add key="foo" value="1"/> </test> <test1> <add key="bar" value="20"/> </test1> </configuration> and accessing code as var blah = configurationmanager.getsection("test"); but null. tried not figure out whats going on. please me this? thanks,

arrays - Combining filter() and map () methods in javascript -

i have been working through study guide on github , trying work through problem chains filter , map answer. so, have array , i'm supposed use 2 methods select ids of videos rating of 5.0. here's array: function() { var newreleases = [ { "id": 70111470, "title": "die hard", "boxart": "http://cdn-0.nflximg.com/images/2891/diehard.jpg", "uri": "http://api.netflix.com/catalog/titles/movies/70111470", "rating": 4.0, "bookmark": [] }, { "id": 654356453, "title": "bad boys", "boxart": "http://cdn-0.nflximg.com/images/2891/badboys.jpg", "uri": "http://api.netflix.com/catalog/titles/movies/70111470", "rating": 5.0, "bookmark": [{ id:432534, time:65876586 }] }, { "id": 654

What is the limit size of file upload (mp4 video) when using Okhttp in Android? -

i trying upload video file ruby on rails backend. using okhttp this. it working when less mb files uploaded. large files, not working , entering block @override public void onfailure(request request, ioexception e) { // handle error log.d(tag, "video upload request failed" + request.body().tostring() + "error = " + e.getmessage()); } curious thing error when printed comes null i have tried upload 60 mb file using postman using same api , worked beautifully. no issues server end. ] here code reference : private static final mediatype media_type_png = mediatype.parse("video/mp4"); public static boolean uploadvideoonserver(final context mcontext, final video video) { final okhttpclient client = new okhttpclient(); client.setconnectionpool(new connectionpool(0, 60000)); string url = constants.url_memory_upload + tjpreferences.getactivejourneyid(mcontext) + "/videos"; try { requestbody requestbody = new mul

append - How to display the title attribute of an input field in a Jquery map function -

i have following script appends list of input values textarea. <script> function showvalues() { var fields = $(".content :input").serializearray(); var tokens = jquery.map(fields, function(field) { return (field.value) ? (field.value + ' ' + field.name) : null; }); $("#contentlist_copy").val(tokens.join(', ')); } $("input").change(showvalues); showvalues(); </script> instead of displaying name attribute field.name of returned field, i'd display title attribute. i've tried few tricks, nothig giving. i should point out follow-up question topic: how hide appended input names when value empty the title attribute isn't stored in serializearray . you'll have use .map directly on $(".content :input") function showvalues() { var tokens = $(".content :input").map(function() { return (this.value) ? (t

ios - Delgator's delegate property points to two Delegators and not to the Delegate class -

Image
i have following class conforms protocol sentencedelegate class sentencemarkov : sentencedelegate{ var ultimatesentence : sentence { didset { ultimatesentence.sentencedelegate = self} } var penultimatesentence : sentence init(ult : sentence, penult : sentence){ self.ultimatesentence = ult self.penultimatesentence = penult } func startchain(){ self.penultimatesentence.sentencedelegate = self self.penultimatesentence.start() } func sentencedidfinish(){ self.nextsentence(self.ultimatesentence.type, penulttype: self.penultimatesentence.type) } //etc. } i define sentencedelegate follows: protocol sentencedelegate: class{ func sentencedidfinish() } finally, delegator class, sentence defined follows: class sentence : nsobject { var type="" var eventarray:[soundevent] = [] weak var sentencedelegate: sentencedelegate? weak var soundeventdelegate: soundeventdelegate? = nil { didset { eventarr

encryption - Meteor accounts-password: get the password of logged in user -

i trying encrypt fields in collection in meteor. encryption requires user's login password . password can obtained when user logs in. stored temporarily variable in meteor. however, when user refreshes browser, variable lost value though user still logged in. without password, encryption cannot done correctly. i using accounts-password package handle user login , sign-up, , wondering if it's possible app call function user's login password whenever want encryption. if helps answer question, using meteor version 1.3 beta 0.4. thanks! you can use amplify package store password temporarily , continue process it. remember clear password after process done

regex - How to validate a string is in YYYY-MM-DD form (C#) -

most of ways have seen on have involved validating c# date object not want do. i'm working on, user enter string in format example, 1999-02-23. validate string enter follows format of yyyy-mm-dd. solutions have come seem overly complex. try var stringtovalidate = "1999-02-23"; datetime dt; bool ok = datetime.tryparseexact( stringtovalidate, "yyyy-mm-dd", cultureinfo.invariantculture, datetimestyles.none, out dt );

Proper function naming and import in Python -

i've developed project package/module/function structure resembles one: project/ │--mainfunc.py | └───functions/ │--__init__.py |--func_caller.py │ ├───subfolder1/ │ │--__init__.py │ │--func11.py │ │--func12.py │ └───subfolder2/ │--__init__.py |--func21.py |--func22.py each of funcxx.py modules contains python function inside, named e.g.: # /project/functions/subfolder1/func11.py def do_func11(args): # return some_value the func_caller.py file calls functions defined in each of funcxx.py modules 1 @ time. top section of func_caller.py (where imports are) looks like: from subfolder1.func11 import do_func11 df11 subfolder1.func11 import do_func12 df12 subfolder2.func21 import do_func21 df21 subfolder2.func22 import do_func22 df22 this seems unnecessarily complicated way this. though of naming functions inside each funcxx.py module main() , able import them with: import subfolder2.func22

javascript - CSS apply property to just the first created element -

i'm appending buttons div detailed here - append button div using javascript every button gets added through addbtns(); function call. hence, css applied gets applied every button gets appended div. the problem have want buttons aligned @ bottom right hand corner of div. tried setting top-margin & left-margin properties. left-margin , problem have margin gets applied every button & hence spacing between buttons changes. i'd left-margin applied first button gets created in div in case button labelled 'a' could please request achieve i'm after? you can achieve pure css: input:first-child { margin-left: 30%; } it work dynamically created elements well. had add width:50%; appendtome because did not have width originally. additionally, added margin-left:30% instead of 300% because goes outside of boundaries. check out on codepen

Determine which computer a git commit came from -

lately i've been exploring vast , terrible world of intellectual property law , people seem think if create something(software) on time, equipment, typically belongs you. know there many exclusions , couple of , informative posts on subject. i'm curious means violating agreement proven guilty. my question is, possible link specific git commit computer committed with? how? when push git repository on http, https, or ssh, remote server creates logs of time connection occurred , ip address originated from. however, companies employ nat, resulting in multiple computers on network sharing same public ip address. some examples logs: # ssh feb 8 01:08:37 git-server sshd[12619]: accepted publickey git 192.168.1.100 port 63012 ssh2: rsa sha256:xxxxxxxxxxxxxx feb 8 01:08:37 git-server sshd[12619]: pam_unix(sshd:session): session opened user git (uid=0) # apache http(s) 192.168.1.100 - - [8/feb/2016:22:03:18 +0000] "get /repos/info/refs http/1.1" 200 153

boolean - TCL 0 not equal to FALSE -

i try expr 0==false returns 0 instead of 1. according http://wiki.tcl.tk/16295 , false values case-insensitive words no, off, false, unique abbrevations, , 0. it weird, or understanding wrong? while specifying operands expr command, validate against boolean value, should use string is command. % expr {0==false} 0 % expr {[string false 0]} 1 simply validating against boolean equal == treat them if literal string/list. reference : expr

JSON Decode into php array -

i using json square brackets , decode 2 multidimensional array. this json: "results" : [[ /* winner bracket */ [[3,5], [2,4], [6,3], [2,3], [1,5], [5,3], [7,2], [1,2]], [[1,2], [3,4], [5,6], [7,8]], [[9,1], [8,2]], [[1,3]] ], [ /* loser bracket */ [[5,1], [1,2], [3,2], [6,9]], [[8,2], [1,2], [6,2], [1,3]], [[1,2], [3,1]], [[3,0], [1,9]], [[3,2]], [[4,2]] ], [ /* finals */ [[3,8], [1,2]], [[2,1]] ]] and looking decode above type of php array shown below: $winner_results = array ( array("match1",3,5), array("match2",2,4), array("match3",6,3), array("match4",2,3), array("match5",1,5), array("match6",5,3), array("match7",7,2), array("match8",1,2), array("match9",1,12), array("match10",3,4), array("match11",5,6), array("match12",7,8), array("match13&

Spring-dispatcher-servlet.xml to Java Config -

hi i'm trying convert xml configuration java config. i'm lost now. here spring-dispatcher-servlet.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- package of spring controller --> <

correct form of struct for strings (or byte array) when importing Labview DLL into python (using ctypes) -

i'm trying import dll (created in labview) python. i've reduced simple labview vi, string goes cluster, cluster function in dll i.e. function is: void testcluster(cluster *outputcluster) can strings , arrays read in cluster. think don't have correct struct (?). has done this? there's partial guide: http://www.ni.com/white-paper/8911/en/ it might due little knowledge of ctypes in python too. sample python code import: #!/usr/bin/env python import sys, os, string ctypes import * class bytearraystructure(structure): _fields_ = [("dimsize", c_int),("bytes", c_uint8 )] class clusterstructure(structure): _fields_ = [("stringfield", c_char*4 ), ("bytearray", bytearraystructure )] dll = cdll.loadlibrary("test.dll") libc = cdll.msvcrt def testmain(): retvalue = 0 try: clusterin = clusterstructure() dll.testcluster( byref(clusterin) ) print clusterin.bytear

mysql - PHP PDO error 1064 -

i'm having small issues, when submit data on forum error: sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'explain, country, ip, hostname) my code this: $sth = $dbh->prepare("insert `applications` (`username`, `email`, `age`, `reason`, `explain`, `country`, `ip`, `hostname`) values ($username, $email, $age, $reason, $explain, $country, $ip, $hostname)"); $sth->execute(); i can't seem find problem. you're not using pdo correctly, creating massive sql injection problems. values put sql need escaped properly. the placeholder method dictates doing way: $sth = $dbh->prepare("insert `applications` (`username`, `email`, `age`, `reason`, `explain`, `country`, `ip`, `hostname`) values (:username, :email, :age, :reason, :explain, :country, :ip, :hostname)"); $sth->bindparam(':username', $username);

sql server - Multi column foreign key, with hard coded reference value -

i have validationstatus table, following (primary key) columns: attribute code address invalid address refuted address store address verified email invalid email refuted email store email unknown email valid email verified is possible establish foreign key between address table , one? specifically each address has validation status; if hard code text, be: alter table dbo.addresses add constraint fk_addresses_validationstatus foreign key('address', validationstatus) references dbo.validationstatus(attribute, code) you cannot that. solution changing design below: add identity or unique integer dbo.validationstatus create foreign key point new integer field alter table dbo.addresses add constraint fk_addresses_validationstatus foreign key(validationstatus) references dbo.validationstatus(newuniquefield) add constraint address table limit range of address validation range. sample assume address validation 1,2,3 , 4. create check

javascript - Chrome push notifications. Message identification -

while send notification client, have data: $> curl --header "authorization: key=$key" --header content-type:"application/json" https://gcm-http.googleapis.com/gcm/send -d "{\"registration_ids\":[\"$subs\"]}" {"multicast_id":5959734605210485936,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1454898928592704%592683fbf9fd7ecd"}]} this multicast_id , message_id params. my question is: how can 1 of (or both) these params serviceworker script? self.addeventlistener('push', function (event) { ... // need that: msgid = event.message_id; m_castid = event.multicast_id; ... }); in other words, need of possible way determine message inside serviceworker script. thanks in advance, with best regards, nikolai solved! i don`t know how message id, found how identify subscription: self.addeventlistener(&

mysql - Problems with Quotes in python twitter streamer -

user = "'" + "@%s" % data['user']['screen_name'] + "'" coordinates = "'" + ",".join(str(e)for e in data['coordinates']['coordinates']) + "'" tweet = "'" + data['text'].encode("ascii", "ignore") + "'" query = "insert tweets (location, tweet, author) values (" + coordinates + "," + tweet + "," + user + ")" i have having issues tweets are passed in have apostrophe (') or random quote marks breaks insert query. advice appreciated reduce errors tweets inserting. thanks sample error message: (1064, "you have error in sql syntax; check manual corresponds mysql server version right syntax use near 's stadium https://t.co/uj2u2tcxlr','@pucker21')' @ line 1") this 1 of reasons why you should not manually construct query via string interpolatio

java - JVM Garbage Collector suddenly consumes 100% CPU after running for several hours -

Image
i've got strange problem in clojure app. i'm using http-kit write websocket based chat application. client's rendered using react single page app, first thing when navigate home page (after signing in) create websocket receive things real-time updates , chat messages. can see site here: www.csgoteamfinder.com the problem have after indeterminate amount of time, might 30 minutes after restart or 48 hours, jvm running chat server starts consuming cpu. when inspect nr (new relic) can see time being used garbage collector -- @ stage have no idea it's doing. i've take number of screenshots can see effect. you can see number of spikes, spikes correspond large increases in cpu usage because of garbage collector. free cpu have restart jvm, have been relying on receiving cpu alert nr in slack account make sure jump on these quickly....but need root of problem. my initial thought was possibly holding onto socket reference when client closed @ end, not case

sql server - Hi,How to get last 5 days from current date -

how last 5 days current date below sqlquery please me in advance. select b.emp_code, b.emp_name,b.general_shift g, b.first_shift f, b.second_shift s, b.third_shift t,b.dt ( select a.* ( select emp.emp_code,emp.emp_name, et.general_shift, et.first_shift, et.second_shift, et.third_shift, --et.day, et.month,et.year, convert(date,'20'+convert(varchar(10),et.year,120)+'-'+ convert(varchar(10),et.month,120)+'-'+ convert(varchar(10),et.day,120)) dt emp_fponm_emp_time_sheet et, emp_fponm_employee_information emp et.emp_id = emp.emp_code , emp.dept_id = 44 , emp.status='present' , emp.emp_code = 'onm_001903' , emp.site_id=20 ) dt between getdate()-5 , getdate() ) b dateadd fix problem : where dt between dateadd(day,

algorithm - Data structure for a set of keys with efficient find-missing -

i'm looking data structure supports following operations integer keys k ranging 0 m-1. o(1) or o(log n) insert(k) , erase(k) , lookup(k) . o(1) or o(log n) special operation find_missing_key() returns key not present in structure. o(n) or o(n log n) space. in particular. should not o(m). an obvious implementation "list-of-free-keys" structure, implemented heap; take o(m) space. there data structure fulfills of requirements? use binary segment tree. each node in tree represents range of integers [a,b], , either leaf [a,a] or divides 2 nodes representing ranges [a,m] , [m+1, b] m (a+b)/2. only expand nodes when necessary, have root node range [0,m-1] (or [0,m) if prefer) in each node, keep count of how many used/free spots have in subtree. insertion, lookup, , deletion of x o(log n): keep subdividing until reach [x,x], , update on path node root. find_missing_key o(log n): since know size of each segment , how many free elements in it, can

asp.net - getting an ajax error after returning from generic handler -

Image
i think posting json data server because when debug on server looks fine me. it's when comes guess i'm getting error on callback. error doesn't make sense me. any ideas? isn't expecting receive back? seems jquery trying parse json , you're not sending json it. try sending (json) , maybe it'll able parse it.

html - Changing InnerHTML with a helper method in rails -

i'm pretty new rails, , have website has js function uses onchange method <select> . code kind of this: var text = document.getelementbyid("dude"); text.innerhtml = "bro"; the thing is, want rewrite in ruby. there way use helper method pass argument , change value of html? <p><%= text = "hey" %></p> <% helper_method(text) %> i've been looking around answer , saw rjs? not sure if related, don't know start. thanks javascript the big problem have you're confusing roles of ruby & js . ruby server-side language; runs on server compile pure html browser. html passed front-end client (browser), rendered. -- ruby == php -- cannot interactively change elements after "dom" has loaded. javascript can , , why you'll not able translate code js. the only way capture onchange (events) use js / jquery handle them: onchange="return js_function();" (ja

java - How to speed up the consume time of ibm jms message -

my application being ibm client consume message sent ibm mq server. sent big number of messages(e.g:50000). our client application can not "eat" message quickly. what i'v been tried: use caching connection factory, not much. org.springframework.jms.connection.cachingconnectionfactory i can't open multiple threads listener speed consuming speed(currently set 1) because of our business requirement. thanks in advanced! edit: for each message processing time like: (e.g:0:00:00. 079 ) wait start process next message take long time (e.g:0:00:00. 534 ) consider transactional , persistence requirements of messages. there number of options within mq enabled here speed delivery. mq optimized either persistent/transactional or non-persistent/non-transactional workloads. don't mix them, example sending persistent messages in non-transactional session. if using non-persistent/non-transactional messaging read_ahead options stream messages dow

c# - Check password on a pdf file without opening -

i'm trying make brute force attack method find password on pdf files. use method check password using itextsharp public static bool ispasswordvalid(string pdffullname, byte[] password) { try { pdfreader pdfreader = new pdfreader(pdffullname, password); return true; } catch (badpasswordexception) { return false; } } it works. take long time when pdf file size large. there way check password without loading file memory?. a couple of things. first, in blog post here found using constructor overload takes randomaccessfileorarray fastest. tested again source code i've got sitting around (5.5.6.0) , still twice fast string-based path method (for large files). however, constructor overload marked obsolete , might in fact removed in more recent versions you'll need deal/live that. pdfreader pdfreader = new pdfreader(new randomaccessfileorarray(pdffullname, true), password); to clear, overload removed reason might want co

hibernate - Remove join entities from proxy object on demand JPA -

i have class entity contains other class entities join result. should remove unwanted join proxy object on demand? @entity @table(name = "jobs") public class job implements serializable{ @column(name = "id", nullable = true) private int id ; private string deliveryconfigxml; private string djobconfigxml; @temporal(temporaltype.timestamp) @column(name = "date") private date date; @onetomany(mappedby = "processedjob") private list<processedjob> processedjobs; @onetomany(mappedby = "deliveredjob") private list<deliveredjob> deliveredjobs; } when fetch entity database, give proxy object. then, using proxy object, can other entities through lazy loading. list<deliveredjob> list = jobs.getdeliveredjobs(); //lazy loading as whole response through java jackson library, in cases, don't want these deliveredjobs , processedjob, due jack

scala - Slick: Avoiding asInstanceOf[T] and Improving Type signature -

the code below works, can't think doing inappropriate asinstanceof[b] cast. essentially, after passing tablequery of type, want mapper turn action take results , map list of daos according function pass it. what stuck on type of function, or perhaps how expose inner type of tablequery type. want [b <: tableelementtype] f: b => a instead of potentially brutal cast b. i guess think know going agencyrow in example below map agencydao, how can capture in type signature of method? mapper def mapper[a <: basedao, b <: databaseaccessobject, t <: tablequery[e], e <: abstracttable[_]](query: t, f: b => a) : seq[a] = { val result = exec(query.result) result.map(o => f(o.asinstanceof[b])) } def exec[t](action: dbio[t]): t = await.result(db.run(action), 4 seconds) consuming mapper (test code) val list = mapper[agencydao, agencyrow, tablequery[agency], agency](agencies, agencydaodomainobject.convertfromrow) list.length sh

algorithm - using Python to represent merge-sort,how to avoid a IndexError -

i know it's not correct,and have found another method without infinite number ,but still want know if corrected usage of infinite number. def mergesort(a): if len(a) > 1: mid = len(a) / 2 left = a[0:mid] right = a[mid:] mergesort(left) mergesort(right) w = float("inf") left.append(w) right.append(w) i,j = 0,0 k in range(len(a)): if left[i] <= right[j]: a[k] = left[i] += 1 else: a[k] = right[j] j += 1 the problem within for k in range(len(a)): loop; happens when have exhausted values in left there values remaining in right (or vice-versa)? the linked method adds test looks like if (left still has values) , ((right has no values) or (next_left < next_right)): take value left your code above instead adds guard value, ensuring if on left guard value guaranteed grea

mysql - How to use left join in rails? -

i using rake file , code task :terminate_conference_channel, [ :circle ] => :environment |t, args| abort "no circle" unless args[:circle] activerecord::base.transaction begin circlenum = args[:circle] circle = circle.find_by circle_number: circlenum if circle.present? if circle[:conference2_total_channels].present? conf = confbridge.find(:first, :conditions => ["confbridges.cid = ?",circle.circle_number], end end rescue exception => e activerecord::rollback logger.info "error terminating" end end end how can select statement using join how can convert stament rails? select c.id, c.confno, c.max_member, (c.max_member - 5) additional, (c.max_member - ifnull(p.active,0)) vacant confbridges c left join (select confbridge_id, count(uid) active confbridge_participants

swift - How to navigate ViewController when clicking button in alertView -

given code below, when click "accept" button, doesn't navigate secondviewcontroller , shows black screen. appreciated. let alertcontroller = uialertcontroller(title: tit!, message: "book now!", preferredstyle: .alert) let declineaction = uialertaction(title: "decline", style: .cancel, handler: nil) alertcontroller.addaction(declineaction) let acceptaction = uialertaction(title: "accept", style: .default) { (_) -> void in let nv=secondviewcontroller() self.presentviewcontroller(nv, animated:true, completion:nil) } presentviewcontroller(alertcontroller, animated: true, completion: nil) alertcontroller.addaction(acceptaction) to open uiviewcontroller must instantiate it. , doing creating object of class. to so: let nv = self.storyboard!.instantiateviewcontrollerwithidentifier("storyboardidentifier") as! secondviewcontroller self.presentviewcontroller(nv, animated:true, comp

Read data from a table in .MDB file into Excel 2013 with VBA -

Image
i'm trying import data access .mdb file excel 2013 spreadsheet. so far, i've tried converting database 2007 format hasn't worked (2 methods i've tried far) is there simpler way of importing data straight table in .mdb file sheet in excel 2013 spreadsheet? (end result) sub convertaccessdb() application.convertaccessproject _ sourcefilename:="c:\new\pabxcalls.mdb", _ destinationfilename:="c:\my documents\pabxcalls2007.accdb", _ destinationfileformat:=acfileformataccess2007 end sub ' **** gives runtime error 438 - object doesn't support property or method *** and sub command7_click() dim app new access.application app.visible = true app.automationsecurity = msoautomationsecuritylow app.syscmd 603, "c:\new\pabxcalls.mdb", "c:\new\pabxcalls_new.mdb" set app = nothing end sub ' *** runs, not output file required *** thanks guys!!! found out didn't have convert database. pull data using query

ios - How to Sort NSMutable Array -

i having nsmutablearray containing objects [1,10,100,101,32a,32b,75,76,77,gaothan] , want sort array in ascending order. using below code not working, don't have key in array. if having solution please let me know. nssortdescriptor *descriptor = [[nssortdescriptor alloc] initwithkey:@"self" ascending:no]; nsarray *descriptors = [nsarray arraywithobject:descriptor]; nsarray *reverseorder = [datearray sortedarrayusingdescriptors:descriptors]; i got it -(void)sortarray { nsmutablearray *unsortedarray = [nsmutablearray arraywithobjects:@"1",@"10",@"100",@"32a",@"32b",@"gaothan", nil]; nsarray *sortedarray = [unsortedarray sortedarrayusingcomparator:^(id firstobject, id secondobject) { return [((nsstring *)firstobject) compare:((nsstring *)secondobject) options:nsnumericsearch]; }]; nslog(@&

how to convert jquery hide/show+animation to javascript? -

i want create left side menu. i want open , close button. currently use jquery code: <script> $("#openmenu").click(function() { var menu = $("#menu"); if ($(menu).is(":visible")) { $(menu).animate({width: 0}, 1000, function() {$(menu).hide();}); } else { $(menu).show().animate({width: 200}, 1000); } }); </script> how can pure javascript? as gomzy says can use css display property hide menu. however if want animate need this: (function () { var menu = { //node menu container wish manipulate node : document.getelementbyid("menu"), //is menu open? open : false, //a handle our interval interval : null, //how wide open menu? openwidth : 200, //how many pixels should open/close per frame? (speed of transition determined here) pixelperframe : 10, //load elements has "tog

objective c - Low pixel density when rotation UIImage -

Image
i have found couple algorithm our application rotate annotations on mkmapview, , in every algorithm pixel density of image crashing. here example, green arrow annotation: maybe knows algorithm or extension perform correct rotation of image? rather uigraphicsbeginimagecontext , use uigraphicsbeginimagecontextwithoptions 0 last parameter. maximize screen resolution match device's screen (e.g. retina). even when create retina resolution image, when rotate bitmap, you're going introducing further pixelation. may sharper results if draw (e.g. in drawrect of annotation view's subclass): @interface customuserannotationview : mkannotationview @property (nonatomic) cgfloat angle; @property (nonatomic) cgfloat linewidth; @property (nonatomic, strong) uicolor *strokecolor; @property (nonatomic, strong) uicolor *fillcolor; @end @implementation customuserannotationview - (instancetype)initwithannotation:(id<mkannotation>)annotation reuseidentifier:(nss

php - Set cell background using column and row index -

i setting cell value in phpexcel using below method setcellvaluebycolumnandrow() $objphpexcel->getactivesheet()->setcellvaluebycolumnandrow($col,$xlsrow,$plan); now requirment set background color this. i not able use below method aligned rows , columns numbers. $objphpexcel->getactivesheet()->getstyle("a1")->getfill() ->setfilltype(phpexcel_style_fill::fill_solid) ->getstartcolor()->setrgb($color); i searching way provide cols , rows (2,3) not ('a1:e1') please suggest alternative way set background color using column , row numbers. you cannot style row in phpexcel, cell or range of cells $objphpexcel->getactivesheet() ->getstyle('a1:e1') ->getfill() ->setfilltype(phpexcel_style_fill::fill_solid) ->getstartcolor() ->setargb('ff808080'); or $objphpexcel->getactivesheet() ->getstyle('a1:e1') ->applyfromarray( array(

javascript - How to make a nav tab active from outside with a button? -

<ul class="nav nav-tabs piluku-tabs " role="tablist"> <li role="presentation" class="active"> <a href="#home" aria-controls="home" role="tab" data-toggle="tab">personal detail</a> </li> <li role="presentation"> <a href="#join" aria-controls="join" role="tab" data-toggle="tab">joining detail</a> </li> <li role="presentation"> <a href="#education" aria-controls="education" role="tab" data-toggle="tab" id ="id2">education detail</a> </li> <li role="presentation"> <a href="#experience" aria-controls="education" role="tab" data-toggle="tab">experience detail</a> </li> </ul> <

jquery - find on page/element widget javascript -

is there widget or function in javascript duplicates functionality of browser "find on page?" want user type in search input, finds each occurrence of value , highlights. includes found # of # next , previous buttons. great if there widget. if not maybe function find multiple occurrences of string? find on page you can use window.find search element on page. searching in dom , window parent object. <form action="" id="form2"> <div> <input type="text" id="search"> <input type="button" id="submit_form" onclick="checkinput()" value="submit"> </div> </form> function checkinput() { var query =document.getelementbyid('search').value; window.find(query); return true; }

How to disable the disabling of an android application (which can be done through settings)? -

all android apps in settings can disabled. want make application cant disabled settings. can done that? nothing, because if possible, it, , nullify point of letting user sole decision maker disabling app.

.htaccess - Redirect All Subdomain URLs to Home Page -

the website in question had sub domain ecommerce platform, we've added ecommerce functionality main site, want entire shop sub domain redirect home page. i'm using following code in .htaccess file: rewritecond %{http_host} ^shop.domain.co.za$ [nc] rewriterule ^(.*)$ http://www.domain.co.za%{request_uri} [r=301,nc,l,qsa] this redirects url on sub domain same url on main site, shop.domain.co.za/product redirect www.domain.co.za/product , want redirect home page, since url structure has changed. so in other words, want url on shop.domain.co.za rediect home page, www.domain.co.za , how can done? any appreciated. thanks willem you can replace rule rule: rewritecond %{http_host} =shop.domain.co.za rewriterule ^ http://www.domain.co.za/? [r=301,l] using %{request_uri} cause original uri copied in target. trailing ? in target strip off pre-existing query string.

angularjs - facing issue using $scope and $rootscope -

i facing issue print text using angualrjs $scope , $rootscope. please find code below , let me know did mistake. <body ng-app="x"> <div ng-controller="ctrl1"> hello {{name2}} </div> <div ng-controller="ctrl2"> hi {{name1}} how {{name3}} </div> <script> var app= angulr.module("x",[]); app.controller("ctrl1" ,['$scope', '$rootscope',function($scope, $rootscope){ $scope.name2 = "sir"; $rootscope.name3 = "are you!"; }]); app.controller("ctrl2", function($scope){ $scope.name1 = "madam"; }); </script> </body> please run following code. problem solved. spelled angular incorrectly , dont need put scope , rootscope in bracket in ctrl1 in

c# - Back Button on first page when NavigationPage used -

i have custom listview on xamarin.forms apps has switch control multi selection. have issue in backbutton on first page of app. button on first page not required redirects black page. know has navigation.pushasync. not figure out change required. if can direct me in correct way wil helpful. here selectmultiplebasepage.cs page: using system; using system.collections.generic; using system.componentmodel; using system.linq; //using system.reflection.emit; using system.text; using xamarin.forms; namespace _____ { public class selectmultiplebasepage<t> : contentpage { public class wrappedselection<t> : inotifypropertychanged { public t item { get; set; } bool isselected = false; public bool isselected { { return isselected; } set { if (isselected != value) {

VHDL Counter ones errors -

i done code, , can work, however, when try write test bench, got troubles on that. input x sets 8 bits, , x: in bit_vector (n -1 downto 0). when write test bench connot enter bits number. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity count_ones generic (n: integer := 8); -- number of bits port ( x: in bit_vector (n -1 downto 0); y: out natural range 0 n); end entity ; architecture behavioral of count_ones type count array (n downto 1) of natural; signal : count; begin a(0) <= 1 when (x(0) = '1') else 0; gen: in n-1 downto 0 generate a(i+1) <= (a(i)+1) when (x(i)='0') else a(i); end generate; y <= a(n-1); end behavioral; the test bench: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity count_ones_tb end count_ones_tb; architecture behavior of count_ones_tb component count_ones port( x : in std_log