Posts

Showing posts from August, 2013

c# - replace static AutoMapper API; replace a Map method inside a Profile -

i'm replacing static automapper api: so, before had profile like: public class digitalresourceprofile : automapper.profile { protected override void configure() { automapper.mapper.createmap<dto, domain>(); automapper.mapper.createmap<domain, dto>() .formember(dst => dst.attachs, opts => opts.mapfrom(src => automapper.mapper.map<list<attachdomain>, list<attachdto>>(src.attachs))) .formember(dst => dst.timestamp, opts => opts.mapfrom(s => s.timestamp.touniversaltime())); automapper.mapper.createmap<attachdto, attachdomain>(); automapper.mapper.createmap<attachdomain, attachdto>() .formember(dst => dst.timestamp, opts => opts.mapfrom(s => s.timestamp.touniversaltime())); } } from on, profile class like: public class digitalresourceprofile : automapper.profile { protected override void configure() { this.cr...

python - creating a new list by copying from an old list -

this first post here, please excuse me if not make myself clear. searched problem beforehand, didn't know terms phrase in. code part of larger program, tried cutting out other variables , problem still remains: what want create function categorizes list of numbers in 7-number sublists. there must 1 sublist each item in 'player' list, why copied player list , ran loop replace each element (previously names of players) corresponding 7 numbers. number of sets there should drawn 'player' list, , numbers drawn 'playermodifier' list, both of defined elsewhere in program. players=['paul', 'darren'] playermodifiers=[4,5,7,2,8,4,7,3,9,4,6,2,6,4] def modifiersort(): n=1 global playermodifierssort global playermodifiers playermodifierssort=players x in playermodifierssort: playermodifierssort[n-1]=playermodifiers[7*(n-1):7*n] n=n+1 playermodifiers=playermodifierssort this sorts list want to, however, som...

colors - Apply grayscale effect to a javafx application -

is possible apply effect whole application change color? apply grayscale example. i have seen [coloradjust][1] effect i'm not sure can use grayscale effect. in fact, it's pretty simple. apply effect whole application, use seteffect method on root node. grayscale effect, set saturation of coloradjust value -1 coloradjust grayscale = new coloradjust(); grayscale.setsaturation(-1); stage.getscene().getroot().seteffect(grayscale);

java - How to restrict queries fired by quartz-scheduler -

i have quartz scheduler spring part of application, deployed in clustered environment. problem quartz keeps firing lot of queries (hundreds per minute) though jobs scheduled run once per hour (the jobs triggered correctly). there way avoid/delay these quartz queries? edit: adding queries fired quartz update qrtz_triggers set trigger_state = 'acquired' sched_name = 'sw_quartz_scheduler' , trigger_name = 'createcrontriggerfactorybeanforpsdjob' , trigger_group = 'spring3-quartz' , trigger_state = 'waiting' insert qrtz_fired_triggers (sched_name, entry_id, trigger_name, trigger_group, instance_name, fired_time, state, job_name, job_group, is_nonconcurrent, requests_recovery, priority) values('sw_quartz_scheduler', 'sw-jayz-5413692078375651369207837517', 'createcrontriggerfactorybeanforpsdjob', 'spring3-quartz', 'sw-jayz-541369207837565', 1369207800000, 'acquired', null, null, 0, 0, 0) select *...

php - elm and database transactions -

i have static website content rendered elm. right data hard-coded elm source code. in future add small amount of database interaction project. the web server use support mysql databases , php. i thinking nice able use get function in elm http package point php script on server, query database, , return json data elm program interpret , render. i know if: this approach possible there better (more convenient or correct) way what describe way it. see chapter in elm-tutorial covers http://www.elm-tutorial.org/080_fetching_resources/cover.html as alternative seed data in html , pass via ports.

.net - C# SilverLight. The tab key does not change focus for the text boxes -

i have got little problem. i use listbox control textboxes. i set focus on first textbox , try jump on following textbox key tab. not work. what wrong? thanks in advance! <listbox name="box" scrollviewer.horizontalscrollbarvisibility="disabled" background="transparent" borderthickness="0"> <listbox.itemcontainerstyle> <style targettype="listboxitem"> <setter property="template"> <setter.value> <controltemplate> <stackpanel orientation="horizontal" margin="40,2,0,2"> <textblock text="{binding label}" minwidth="20" /> <textbox tabindex="{binding index, mode=oneway}" text="{binding information, mode=twoway}...

r - extracting unique rows of data using dplyr -

this question has answer here: remove duplicated rows 6 answers i'm trying extract rows when b unique value per a . here sample data a <- c(1,1,2,2,3,3,4,4,5,5,5,6,6,7,7,8,8,9,9,9,9,9,10,10,10) b <- c(1,2,1,1,5,5,6,1,1,1,3,2,2,1,1,2,3,1,2,3,4,4,1,2,2) df1 <- data.frame(a, b) and using dplyr package library(dplyr) unique <- df1 %>% group_by(a) %>% filter(n_distinct(b)) the desired output should data frame length 18 we can try library(dplyr) df1 %>% distinct() or in base r unique(df1)

py.test - custom assert in pytest should overrule standard assert -

i wrote custom assert function compare items in 2 lists such order not important, using pytest_assertrepr_compare. works fine , reports failure when content of lists differ. however, if custom assert passes, fails on default '==' assert because item 0 of 1 list unequal item 0 of other list. is there way prevent default assert kick in? assert ['a', 'b', 'c'] == ['b', 'a', 'c'] # custom assert passes # default assert fails the custom assert function is: def pytest_assertrepr_compare(config, op, left, right): equal = true if op == '==' , isinstance(left, list) , isinstance(right, list): if len(left) != len(right): equal = false else: l in left: if not l in right: equal = false if equal: r in right: if not r in left: equal = false ...

.net - Is there a disadvantage in too much granularity in structuring projects? -

i have many classes in bll. supposed have itembll, itemtype bll, employeebll etc., there disadvantage in placing them in separate project each? of them logically groupable there problem in placing each class in separate project (lets maintaining them isn't problem). how benefits of grouping them? complexity biggest problem. more assemblies have, more have keep track of. if application needs one, there possibility need have reference others anyway if inner connected. this isn't having more assemblies bad. there can advantages having them separate, such ones loaded memory when (they loaded on demand when application needs them). there no hard , fast rule 1 better, depends on situation. personally, unless have reason have them separate, combine them. makes deployment , administration easier in long run. keeping classes in same assembly (at least in c# internal modifier ), gives ability give them ability access functions internal assembly while blocking r...

r - Plot one graph with many variables on x and y axis using ggplot2 -

Image
this data. localities variable1 variable2 variable3 variable4 snp 5 1 2 0 bnp 1 2 4 2 mwc 0 3 1 3 i use reshape2 package combine data. clueless script should use. want put localities in x axis, , variables in y axis. need melt 2 things here? variables need put in different colour well. want put piloint graph. this have tried, before plotting graph. cv=c("variables 1", "variables 2", "variables 3", "variables 4"), id=variables) if use reshape2 melt data, like > library(reshape2) > melt(df) using localities id variables localities variable value 1 snp variable1 5 2 bnp variable1 1 3 mwc variable1 0 4 snp variable2 1 5 bnp variable2 2 6 mwc variable2 3 7 snp variable3 2 8 bnp variable3 4 9 ...

bash - Options menu with array -

i trying make script ip list file , show on screen select option, , make ssh ip selecting. file below; name1 1.1.1.1 name2 2.2.2.2 name3 3.3.3.3 name4 4.4.4.4 below script can read list file , shows on screen menu.it show both name , ips selection, want show selection menu name. how can achieve this? ps3='please enter choice: ' readarray -t options < ./file.txt select opt in "${options[@]}" ifs=' ' read name ip <<< $opt case $opt in $opt) ssh $ip;; esac done 1) name1 1.1.1.1 2) name2 2.2.2.2 3) name3 3.3.3.3 4) name4 4.4.4.4 please enter choice: 1 i'm assuming bash, not sh. the select command isn't used. problem you're having you're slurping whole lines in $options readarray , , select command doesn't provide way format or trim output. one approach split array after reading it: #!/usr/bin/env bash declare -a opt_host=() # initialize our arrays, make sure they're empty. declar...

python - Cannot modify item of list within for loop -

i've found out while executing for loop on list of mutable items cannot modify item, able modify element of item if element mutable. why? # create alist contain mutable alist = [[1, 2, 3],] #1 loop x in alist: x = x + [9,] print alist # let's replace alist[0] list contain 1 , try modify alist[0] = [[[1,2],3]] print2 alist # [[[[1, 2], 3]]] #2 loop x in alist: x[0] = x[0] + [9,] # list modified ... print alist # [[[[1, 2], 3, 9]]], modified ! i aware modifying list iterating on isn't practice (it's better iterate on copy of it), please don't point me moment. the reason of such behaviour while performing for loop #1 new list produced applying + operator list( can tracked getting id of x ). however in for loop #2 access element of item index x[0] object in memory being modified. can found calling id on x while iterating on alist # create alist contain mutable alist = [[1, 2, 3],] #1 loop x in alist: print id(x), id(alist[0]),...

amazon web services - Error when install AWSCLI to Arduino Yun board -

i try using pip install awscli on arduino yun kernel following error messages: traceback (most recent call last): file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/basecommand.py", line 209, in main status = self.run(options, args) file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/commands/install.py", line 299, in run requirement_set.prepare_files(finder) file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/req/req_set.py", line 359, in prepare_files ignore_dependencies=self.ignore_dependencies)) file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/req/req_set.py", line 576, in _prepare_file session=self.session, hashes=hashes) file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/download.py", line 809, in unpack_url hashes=hashes file "/usr/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg/pip/download.py", line 648, in unpack_http_ur...

ember.js - Ember Simple Auth 1.0 Testing Helpers -

i've upgraded 0.8 1.0 , app working correctly. one thing surprised me though , still don't understand how new acceptance test helpers should used. previously (0.8) write test , pass: test('sign in , sign out', function(assert) { visit('/'); andthen(function() { assert.ok(find(':contains("sign in")').length, 'expected see "sign in"'); }); authenticatesession(); andthen(function() { assert.ok(find(':contains("sign out")').length, 'expected see "sign out"'); }); invalidatesession(); andthen(function() { assert.ok(find(':contains("sign in")').length, 'expected see "sign in"'); }); }); however, after upgrading , rewriting them in new format: import { authenticatesession, invalidatesession } 'instatube-app/tests/helpers/ember-simple-auth'; test('sign in , sign out', function(asse...

python - Creating tuple pairs from a dictionary that has a list as value -

i trying list of tuple pairs dictionary has list value. d={ 'a': [1,2], 'b': [4,5], 'c': [7,8] } print(d.items()) >>[('a', [1, 2]), ('b', [4, 5]),('c', [7, 8]) ] how list in form [('a', 1),('a', 2), ('b',4),('b',5),('c',7),('c',8)] using simple list comprehension: d = {'a': [1,2,3], 'b': [4,5,6]} l = [(k, v) k in d v in d[k]] print(l) # => [('a', 1), ('a', 2), ('a', 3), ('b', 4), ('b', 5), ('b', 6)] there's other ways it, simplistic , doesn't require other libraries.

recursive code in java for calculation of money account in a bank -

i want implement recursive code in java calculation of money account in bank after years of investing ... here code public static double computecapital(double capital, int years, double interestrate) { if (years == 0) { return capital; } else { double newcapital = capital * math.pow(interestrate,year); return computecapital(newcapital , years+1 , interestrate); } } is code correct? thanks public static double computecapital(double capital, int years, double interestrate) { if (years == 0) { return capital; } else{ return computecapital(capital, years-1, interestrate)*(1+interestrate); } }

c++ - How overload operator < for sort method for objects? -

i have object, example class employee{ int id; string name; string secname; } my main : int main(){ vector<employee> vec = {employee(1, "andy", "good"), employee(5, "adam", "bad"), employee(2, "some", "employee")} sort(vec.begin(), vec.end()) } i know how overload sort method vector when have 1 parameter sorting. it's like: bool operator<(employee a, employee b ){ if (a.name<b.name) return true; else return false; } but point have sort not on 1 parameter, on all. how should change overloading method? i've tried way, doesn't work. bool operator<(employee a, employee b) { if (a.id < b.id) if (a.name < b.name) if (a.surname<b.surname)return true; else return false; else return false; else return false; } if want sort id, secondarily name , tertiary secname should work: bool operator<(employee a...

apache - PHP / .htaccess - Redirect to specific folder -

i creating php project, , folder structure looks like: includes/ pages/ config/ in theory, of pages go pages folder. but, whenever visits website, on specific page: (i.e.) www.mysite.com/help want inside pages/ folder, rather thinking on root of document. can achieve using php / .htaccess - have googled problem , cannot see relevant infomation you can use following rule in /root/.htaccess : rewriteengine on #if "/document_root/pages/foo" existent file rewritecond %{document_root}/pages/$1 -f #rewrite /foo /pages/foo rewriterule ^(.*)$ /pages/$1 [nc,l]

.net - PayPal tls 1.2 SSL Update 10002 -

i'm testing web site make sure compatible new tls 1.2 etc. i;m getting 10002 not have permissions make api call error when using test sandbox system. does mean can contact paypal , fine way? i'm using .net i suppose yes, tls connection successful if received api response paypal error. paypal has completed tls 1.2 upgrade in sandbox environment can prepare live upgrade in near future. more information on tls 1.2 upgrade: https://github.com/paypal/tls-update

powershell - Get latest build and latest released code from VSO -

i need tds sitecore folder latest successful build , last released code vso. need 2 tds sitecore folders can compare serialized items of current sitecore items in instance , new build supposed deployed . using vso api calls , powershell data project have not succeeded yet. please advice. vso api calls: https://www.visualstudio.com/integrate/api/overview

Android- Stop Telephony Manager service -

actually new android developer , having stop button in activity class , want stop telephony service not record call after stop button clicked not stoping service , itis recording call. please resolve problem my activity class is package com.jain.callrecorderdemo; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class mainactivity extends activity { button startbtn, stopbtn; @override protected void oncreate(bundle savedinstancestate) { setcontentview(r.layout.main); super.oncreate(savedinstancestate); startbtn = (button) findviewbyid(r.id.startbtnid); stopbtn = (button) findviewbyid(r.id.stopbtnid); startbtn.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent in = new intent(getapplicationcontext(), callrecordingservice.class); startservice...

r - Time-series plot for different seasons in the same plot -

i plot time series data different seasons of year (grouped cold or warm) in same plot , identify 2 periods. how can that? reproducible data follows: library(gamair) data(chicago) chicago$date<-seq(from=as.date("1987-01-01"), to=as.date("2000-12-31"),length=5114) data.cold <- subset(chicago, quarters(date) %in% c("q1", "q4")) data.warm <- subset(chicago, quarters(date) %in% c("q2", "q3")) these codes below create 2 separate plots 2 periods: with(data.cold,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in cold season")) with(data.warm ,plot(date,death,pch=".", ylab= expression("mortality count"), main = "daily mortality in warm season")) this following code creates 1 plot, there no clear demarcation of 2 periods. wish create identifiable plot 2 periods in single plot. with(chicago,plot(date,death,pch=...

How to bulk document delete in Alfresco -

i new alfresco user. have uploaded 18000 documents alfresco. noticed categories not correct. upload them again, don't know how delete existing documents. there way delete documents uploaded yesterday? the best way use code based method (javascript or cmis). so, easiest way create javascript file in data dictionary/script folder this: // execute lucene search across repository pdf documents in specific folder created exact day var docs = search.lucenesearch("path:\"/app:company_home/cm:myfolder//*\" , @cm\\:content.mimetype:\"application/pdf\" , @cm\\:created:2013-05-21"); var i; (i=0; i<docs.length; i++) { docs[i].remove(); } although 18k documents create memory issues in jvm. maybe script interrupt @ point, , you'll have restart machine , execute script again.

TFS Git repo authentication failed via API -

we have setup new tfs hosted git repository. able access repo via git bash or via tfs browser. the url looks like: http://mytfs.com:8080/tfs/defaultcollection/_git/sampletfsgit now have java application pulls out source code various git server using git api. particular tfs hosted git repo not able pass authentication. gives me http response code: 401 same url: http://mytfs.com:8080/tfs/defaultcollection/_git/api/v3/session does git api v3 not worked on tfs hosted git repo, or making mistakes here. please advice. no, not supported. git, there special source import api . details can refer github link: https://developer.github.com/changes/2016-02-19-source-import-preview-api/ or can use rest api achieve it: e.g. get http://mytfsserver:8080/tfs/defaultcollection/_apis/git/repositories more detail info: https://www.visualstudio.com/integrate/api/git/overview

python - ValueError: max() arg is an empty sequence again -

my code follows presents me error message saying valueerror: invalid literal int() base 10: '4\njohn'" on line players.append(player(elems[e], list(map(int, elems[e+1:e+4])))) code: from __future__ import division operator import attrgetter class player(object): def __init__(self, name, scores): self.name = name self.scores = scores self.highscore = max(scores) self.avgscore = sum(scores) / 3 open('classfilea.txt') f: l in f: l = l.strip(); # remove end of line char (\n) text = f.read() players = [] elems = text.split(',') e in range(0,len(elems),4): players.append(player(elems[e], list(map(int, elems[e+1:e+4])))) byhighscore = sorted(players, key=attrgetter('highscore'), reverse=true) byavg = sorted(players, key=attrgetter('avgscore'), reverse=true) print('') p in byhighscore: print('{0} {1:g}'.format(p.name...

pointers - How to pass a struct's method as a parameter into another function using golang -

sorry, post question again. i have been read solution before ask question. think can not me because question how pass function parameter? don't want call it. i want pass function can't edit (or don't want edit), , want use string variable point function funcname := "go" m.set(t.funcname) i think different question call struct , method name in go? for example i have function like: type context struct{} type myclass struct{} type handler func (c *context) func (r *myclass) set(ch handler) { } i can use way: type testclass struct {} func (t *testclass) go(c *context){ println("hello"); } t := &testclass{} m := &myclass{} m.set(t.go) and question is type testclass struct{} func (t *testclass) go(c *context){ println("hello"); } t := &testclass{} m := &myclass{} funcname := "go" m.set(t.funcname) any way can this? reflect?or what? if impossible, there other ways this? thanks...

Getting Object Property to String Using Lambda Expression in C# -

suppose have class: class myclass { public int myproperty { get; set; } } and want myproperty string (e.g. "myproperty") through lambda expression or other way "refactoring-friendly". is there syntax this: void bindtodatasource(ienumerable<myclass> list) { mycombobox.datasource = list; mycombobox.displaymember = typeof(myclass).getpropertytostring(c => c.myproperty); } i dont want code: mycombobox.displaymember = "myproperty" because not "refactoring-friendly". take @ answer this: workaround lack of 'nameof' operator in c# type-safe databinding? in case, if implement generic class: public class nameof<t> { public static string property<tprop>(expression<func<t, tprop>> expression) { var body = expression.body memberexpression; if(body == null) throw new argumentexception("'expression' should member expression");...

apache - Hive Unix Timestamp -

i'm not getting expected result unix_timestamp of hive for example : select from_unixtime(unix_timestamp('2015/02/01', 'yyyy/mm/dd')) table limit 1; output : 2014-12-28 00:00:00 time taken: 0.287 seconds, fetched: 1 row(s) i expected return 2015-02-01 , resulted else. understand because of epoch time ? you have caps in date format. try using lowercase: select from_unixtime(unix_timestamp('12/02/01','yyyy/mm/dd') table; results in: 2015-02-01 00:00:00 also can strip off time using: to_date(from_unixtime(unix_timestamp('12/02/01','yyyy/mm/dd')) results in: 2015-02-01

c# - aspx page do not postback input type email data -

this question has answer here: how can use html5 email input type server-side .net 6 answers i have 1 aspx page(3.5) , trying use html5 validation on it. <asp:textbox id="accountantemail" cssclass="form-control" type="email" runat="server" required /> this control after rendering looks alright me <input name="ctl00$contentplaceholdermain$accountantemail" id="ctl00_contentplaceholdermain_accountantemail" class="form-control" type="email" required=""> browser validations work email. when try submit form required , format exceptions. however, control has no data in postback event. it works if remove type="email" attribute. do need upgrade .net version? or missing anything? i using chrome 48, , controls in update panel. try adding prog...

android - How can we tile a vector image? -

with support library supporting vector images, i'm trying switch vector images as can in app. issue i'm running seems impossible repeat them. with bitmap images following xml used: <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/repeat_me" android:tilemode="repeat" /> this not work, vector images can not used in bitmaps: https://code.google.com/p/android/issues/detail?id=187566 is there other way tile/repeat vector images? thanks @pskink made drawable tiles drawable: https://gist.github.com/9ffbdf01478e36194f8f this has set in code, can not used xml: public class tilingdrawable extends android.support.v7.graphics.drawable.drawablewrapper { private boolean callbackenabled = true; public tilingdrawable(drawable drawable) { super(drawable); } @override public void draw(canvas canvas) { callbackenabled = false; rect bo...

c# - ViewModel does not exist.Simple MVVM WPF application -

hi im learing mvvm pattern wpf use in application. im not able bind anything, cause xaml code says "the name 'name' not exist in namespace 'namespace'". my xaml code: <window x:class="mvvm.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:mvvm.viewmodel" title="mainwindow" height="350" width="525"> <window.datacontext> <local:mainviewmodel/> </window.datacontext> <!--<window.resources> <local:mainviewmodel x:key="viewmodel"/> </window.resources>--> <grid> <button width="100" height="100" content="binding buttoncontent"/> </grid> </window> and have added mainviewmodel.cs. here code. using system; usi...

mysql - Keeping track of operations performed by database users -

i have 3 users database several privileges. want keep record of every user's actions. how can track operations have been performed users? first crate following table department table contain dno,dname,loc. create table dept_log ( usercode number(5), userevent varchar2(10), edate date, odno number(7), odname varchar2(10), oloc varchar2(10), ndno number(7), ndname varchar2(10), nloc varchar2(10) ) now create trigger fire after insert, update, , delete. create trigger tri_keep_track_on_operation after insert or delete or update on dept each row begin if inserting insert dept_log values(usercode,'insert',sysdate,null,null,null,:new.deptno,:new.dname,:new.loc); dbms_output.put_line(' after insert '); elsif deleting insert dept_log values(usercode,'delete',sysdate,:old.deptno,:old.dname,:old.loc,null,null,null); dbms_output.put_line(' after delete '); ...

c++ - How to activate an instance of a ref class -

say have class: public ref class page1 sealed : windows::ui::xaml::controls::page {}; i can activate instance of class this: auto page = ref new page1(); but how in raw c++? i have tried doesn't work: microsoft::wrl::wrappers::hstring classname; classname.set(l"app1.page1"); iinspectable *page; windows::foundation::activateinstance(classname.get(), &page); the above code work when specify windows runtime class name, (such "windows.ui.xaml.controls.button"), not own ref class "app1.page1". alternatively, given have declared public ref class named page1 in app1 namespace, how can activate instance of class iinspectable* hstring "app1.page1"? i think have figured out. well, answer not directly solve problem of activating arbitrary type, want. the devil in detail. xaml compiler generate bunch of files not visible in solution explorer. these files have extension .g.h , .g.hpp . can click "show files...

javascript - Regex for range 1-50 -

i want need regex create value like: 1-50 i need regex should allow values 1 50 "-" sign try following regex: /[1-9]{1}-([0-4]{1}[0-9]{1}|50)/gi check regexp.test method: var pattern = /[1-9]{1}-([0-4]{1}[0-9]{1}|50)/gi; console.log(pattern.test("1-09")); // true console.log(pattern.test("10-90")); // false console.log(pattern.test("2-49")); // true console.log(pattern.test("3-51")); // false

mysql - multiple row fetched with max number sql -

i have 2 tables following records: clients: cid | cname | ccountry ----------------------- 1 | john | australia 2 | mark | usa 3 | liz | england orders: oid | cid | oquantity --------------------- 1 | 1 | 100 2 | 1 | 100 3 | 2 | 50 4 | 2 | 150 5 | 3 | 50 6 | 3 | 100 i need find out client name(s) has maximum quantity of orders. run following query , got correct result. select cname, ccountry clients cid in (select cid orders group cid having sum(oquantity) = (select max(amount) (select sum(oquantity) amount orders group cid)t1)) 2 row(s) returned 'john', 'australia' 'mark', 'usa' but need know, whether can done more simple way. has become complicated once total quantity required returned. ...

php - Ansible mysql_user module not accepting encrypted password -

while writing playbook setup mysql , adminer i'm running problem adding encrypted root password. when using plain text password , not including encrypted=yes seems work. i'd include encrypted password [select password('test')] in playbook. as can see code below i've added encrypted password in password field , ~/.my.cnf file , added encrypted=yes play. but after running playbook error. please me figure out i'm making mistake or point me appropriate documentation or fix. i've searched stackexchange network , looked @ official documentation ansible , mysql_user module no luck. system: debian 8.1 error message: msg: unsupported parameter module: encrypted playbook code: --- - hosts: databases remote_user: admin sudo: yes tasks: #get current hostname - name: getting current hostname. raw: "hostname" register: current_hostname # update installed packages latest version - name: update installe...

Add double quotes in .CSV comma delimited file using awk -

hi need elaborate big csv file (20m rows) adding double quotes every comma delimited field. csv file got 8 fields coma delimited below: '2016-03-12','12393659','134',,'35533605',189348,9798,gmail.com;live_com.com '2016-03-12','12390103','138',,'35438006',5133,1897,google.com '2016-03-12','45616164','139',,'01318800',10945593,596633,facebook.com;tumblr.com;t.co '2016-03-12','45673436','38',,'86441702',4350985,150327,serving-sys.com;chartboost.com;admarvel.com;mydas.mobi;adap.tv;cloudfront.net as see first 3 fields between single quotes, 4th blank, 5th between single quotes , 6th 8th comma delimited. following result (also 4th field if empty need double quoted): "2016-03-12","12393659","134","","35533605","189348","9798","gmail.com;live_com.com" "2016-03-12",...

intellij idea - Android Studio ( Ubuntu ) -

Image
my android studio has changed editor font enormous. i'm on ubuntu, changing font size in settings (of android studio) doesn't change font. can do? in advance try change system font unitytweaktool .

Javadoc for Apache Camel not found in Spring Tool Suite (Eclipse) -

my spring tool suite not find javadoc (or sources) apache camel. e.g. when hovering on exchange.getin(), following message shown: note: element neither has attached source nor attached javadoc , hence no javadoc found. how can append javadoc? there other way including camel sources dependency in maven? i'm using sts 3.7.2, based on eclipse mars 4.5.1 camel 2.8.3 dependency in maven. when using eclipse maven can set configurations automatically download source code , javadocs libraries. window -> preferenes -> maven -select download artifact sources -select download artifact javadoc

java - How many objects are created by using the Integer wrapper class? -

integer = 3; = + 1; integer j = i; j = + j; how many objects created result of statements in sample code above , why? there ide in can see how many objects created (maybe in debug mode)? the answer, surprisingly, zero. all integer s -128 +127 pre-computed jvm. your code creates references these existing objects.

java - Getting error while recording JFR -

i trying record jfr java application hosted in tomcat server. have used following jvm args . -xx:+unlockcommercialfeatures -xx:+flightrecorder and using following linux command record jfr. /opt/java/perf/jdk1.7.0_79/bin/jcmd 32627 jfr.start duration=900s settings=/opt/profile.jfc filename=/opt/flight_17-mar-2016.jfr but getting error : **32627: java.text.parseexception: json object must begin '{', line=0, column=0 : <?xml version="1.0" encodi ng="utf-8"?> <configuration version="1.0" name="profiling" description="lo** please suggest if has idea this. in advance.

groovy - How to copy files from some source path with gradle script? -

i trying copy images javadocs gradle. currenly images located under myproject/src/main/resources/doc-files/images/ i refer these images this <img src="{@docroot}/doc-files/images/myimage.jpg"> now wish copy content under myproject/src/main/resources/doc-files/ myproject/build/docs/javadoc/doc-files/ , write in build.gradle : javadoc << { filetree docfilestree = filetree(dir: 'src/main/resources/doc-files') copy { docfilestree destinationdir } } this has 2 problems: 1) nothing :) 2) refers resources/doc-files/images/ explicitly, while deduce parameters. failed know how use here: https://docs.gradle.org/current/userguide/java_plugin.html i'm not sure mean want deduce resources/doc-files/images parameters. however, if want copy files 1 directory another, can create task such as: filetree docfilestree = filetree(dir: 'src/main/resources/doc-files') task copyjavadocsupportfiles(typ...

html - How to represent a link dynamically in php? -

Image
<?php $stmt = $con->prepare("select * user_tbl name = ?"); $stmt->bind_param('s', $_request['name']); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo '<br /><br />name: ' .$row['name']; echo '<br /><br />contact number: ' .$row['cont']; echo '<br /><br />email id: ' .$row['email']; echo "<br /><br /><a href='viewdtl.php' target='_blank'>view details</a>"; echo "<br /><hr />"; } } else { echo "0 records found"; } $stmt->close(); ?> this code runs fine 2 problems.. else part 0 records found shows want print after search placed , link .. can't click on it.. how can print link here ?

Initialize variable using another variable's initialized value in Swift -

so wanna is: let margin: cgfloat = 10 let width: cgfloat = 100 - margin // used self.margin but here's error i'm getting: instance member 'margin' cannot used on type 'historyviewcontroller' what should do? let margin: cgfloat = 10 var width: cgfloat { return 100 - self.margin } or lazy var width: cgfloat = 100 - self.margin this because @ instance variable initialization time, instance doesn't exist yet. using lazy initialization or computed property fix this.

afnetworking - Is NSURLCache cleared on iOS app reinstall? -

tl;dr:does know if requests made app via afnetworking / nsurlconnection stored , persisted in nsurlcache between re-installs of app ? background: troubleshooting bizarre bug affecting users of shipping app, persists across app-reinstalls , potentially explained bad cached copy of previous response. the app uses afnetworking, sits on top of nsurlconnection , , therefore uses nsurlcache . there no explicit nsurlcache configuration within app. hence i'm keen know whether responses can remain in nsurlcache past lifetime of app installation made request. depends on how app gets reinstalled, typically. in theory, if delete app completely, no, shouldn't possible app data persist, including url cache, sole exception being keychain items. said, difference between theory , practice.... with said, if want certain, can create new shared cache stores on-disk files in different location default. should fix problem if caused stale cache data.

php - PhpStorm insert & overwrite cursor style reversed -

i having problem editor cursor. when enter code in editor blinking cursor, cursor style of insert mode , overwrite mode reversed each other on screen. how can fix it? open menu "help" -> "find action...". type "overwrite" opened window , double-click "toggle insert/overwrite" item highlighted after typing. toggle current cursor mode. in windows, [toggling] may achieved hitting "ins" button on keyboard, no need find action in menu. default keyboard key toggles insert/overwrite mode in many programs. i'm not sure work because did not use phpstorm windows @ all.

php - How to get the X and Y axis of a string or a paragraph from a PDF file? -

i making module system called vtiger crm, system have module installed called pdfmaker allows me make pdf files using html, pdfmaker allows me create custom function insert in template. i have custom function, puts string called signature in html template. what need find x , y axis of string after has been converted pdf file due dimension changing when gets converted html template pdf file. what tried using .position function jquery, problem is, works html file, doesn't work pdf file, makes sense. now wondering how can find x , y axis paragraph or string in pdf file. the pdf files created example invoices, quotes , things that, a4 paper format, may vary. this custom function @ moment: <?php if(!function_exists('signature')){ function signature($string = 'signature'){ $xaxis = '<script> $(function(){ var p = $("#signature"); var position = p.pos...

swift - Provide concrete type for Generic Protocol implementation -

is possible following: protocol a: class { typealias t: anyobject } extension { func testa(a:self, _ t:t)->void{ print(a, t) } } class b:a { typealias t = string } in other words have protocol , want provide concrete type in class conforms it. that should fine. issue code have there string not anyobject . you need: protocol a: class { typealias t } extension { func testa(a:self, _ t:t)->void{ print(a, t) } } class b:a { typealias t = string }

unix - Convert big logfile to csv -

i have big text file withe following structure (folders , files): \folder1\ 3/21/2012 2:23:56 pm 2,178 100 myfile1.txt 3/21/2012 1:24:25 pm 253,928,960 100 myfile2.txt 3/21/2012 1:24:51 pm 6,430 100 myfile3.txt 3/21/2012 10:28:03 206,796 100 myfile4.txt \folder2\subfolder\ 3/21/2012 10:47:03 1,300 100 bla.txt 3/21/2012 10:42:56 76,226 100 xyz.txt 3/21/2012 1:25:08 pm 5,911,839,232 100 kkkkkk.txt 3/21/2012 10:33:33 1,202 100 mmmmm.txt 3/21/2012 10:33:16 3,412,079 100 mmmmmd.txt 3/21/2012 10:32:21 ...

javascript - Rate limiting with Bacon.JS -

i'm trying create rate limiting when accessing external api, using bacon.js the rate limiting works fine, using bufferwithcount , bufferingthrottle results when flatmapped, not each batch @ time. i've tries onend not seem triggered. here's fiddle: http://jsfiddle.net/9324jylr/1/ var stream = new bacon.bus(); stream .bufferwithcount(2) .bufferingthrottle(1000) .flatmap(batch => { batch = batch.map(x => x*2); //this should async api call returning bacon.frompromise(...) return bacon.fromarray(batch); }) // .bufferwithtime(1000)//one thang per interval .onvalue(val => $('#log').append(val)); (var i=0; i<10; i++) { stream.push(i); } you can use fold combine results , .end() cause bus end. stream .bufferwithcount(2) .bufferingthrottle(1000) .flatmap(batch => { batch = batch.map(x => x*2); //this should async op return bacon.fromarray(batch); }) .fol...

php - Formvalidator check even if value is empty -

thanks forum came across below form validator time work fine. however, have 1 problem. when submitting form empty textarea instance return empty field error. however, value not mandatory need correct somehow. <?php /** * pork formvalidator. validates fields regexes , can sanatize them. uses php filter_var built-in functions , regexes * @package pork */ /** * pork.formvalidator * validates arrays or properties setting simple arrays * * @package pork * @author schizoduckie * @copyright schizoduckie 2009 * @version 1.0 * @access public */ class formvalidator { public static $regexes = array( 'date' => "^[0-9]{4}[-/][0-9]{1,2}[-/][0-9]{1,2}\$", 'datetime' => "20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]))(t|\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])", 'amount' => "^[-]?[0-9]+\$", 'number' => "^[-]?[0-9,]+\$", ...

Best practice to declare character array in C -

i have read data device 4 bytes long have declared array like char data[4] = {0}; i parse per index , guarantee stop @ index 3. data[0]..data[3] in case there no room nul('\0'). i want know considered safe or should declare array as char data[5] = {0}; this array not used in str* series of functions. if data read string of 4 bytes or if greater 4 bytes , using char character array instead of string no need worry. otherwise have care '\0' .

java - Xtext: Export model as XMI/XML -

i have defined dsl xtext. let's looks this: model: components+=component* ; component: house | car ; house: 'house' name=id ('height' hubradius=double)? & ('width' hubradius=double)? 'end' 'house' ; car: 'car' name=id ('maxspeed' hubradius=int)? & ('brand' hubradius=string)? 'end' 'car' ; in generated eclipse ide, based on dsl, implemented model. let's looks following: house myhouse height 102.5 width 30.56 end house car mycar maxspeed 190 brand "mercedes" end car i export model xmi or xml file. the reason want is, have workflow, allows me change model parameters on fly, using xmi/xml file. instead of redefining model, can pass xml/xmi file workflow, automatically. short example: dsl allows defining components house , car . house allows parameters width , height , car allows parameters maxspeed , brand...

python - Appending select character of a string to list -

with string abcdefghijklm trying achieve following: abcdefghijklm 0123456789012 the first if statement works, else statement breaks with: position.append(str(x[1])) typeerror: 'int' object not subscriptable this code: number = [] count = 0 x in range(string): if count <= 9: number.append(str(x)) else: number.append(str(x[1])) count = count+1 number = ''.join(map(str, number)) print(number) how can resolve this? you can use hack : int(str(s)[1]) or (str(s)[1]) depending on wishes: >>> s = 12 >>> int(str(s)[1]) 2 >>> (str(s)[1]) '2'