Posts

Showing posts from August, 2011

eclipse - create a custom shortcut to generate the getter and setter -

Image
i know traditional way in windows generate getter , setter of attributes in class: highlighting fields --> right click --> source --> generate getters , setters there anyway create own shortcut that? what should enter name , pattern in case? java editor templates aren't powerful following best pattern come with. name / description referencing template can anything. public ${type} get${variable}() { return this.${variable}; } public void set${variable}(${type} ${variable}) { this.${variable} = ${variable}; } to use in open java editor . . . ctrl+space --> select name of template (or start typing template name autocomplete) --> enter variable type --> tab --> enter uppercase variable name --> tab --> enter lowercase variable name --> enter or tab the upper/lower case names there follow java naming conventions. there no substring or default functions can find process variable text, otherwise you'd have enter variabl

java - passing arrayList in Custom adapter -

i calling arraylist in customadapter, custom_row.xml contains desired row. want first 2 elements of arraylist side side in row, , third , fourth element in other row , on. wrote code, print first element arraylist. if remove comments , run, same error when putting comments. don't know going wrong. or maybe should right way. class customadapter extends arrayadapter { list<string> names; layoutinflater inflater; context context; public customadapter(context context, list<string> names) { super(context,r.layout.custom_row ,names); this.names=names; this.context=context; } @override public view getview(int position, view convertview, viewgroup parent) { inflater=layoutinflater.from(getcontext()); view customview=inflater.inflate(r.layout.custom_row,parent,false); string data=names.get(position); //string data1=names.get(position+1); textview tv=(textview)customview.findviewbyid(r.id.teama); tv.settext(data); //textview tv1=(

raspberry pi - Apache loads other old website after rebooting -

i've got little problem: whenever restart raspyberry pi b, old version of website gets loaded. before restart, changed whole files , deleted some. deleted files restored after rebooting rapsberry. it's annoying if new website gets thrown away ... i don't know if it's apache service or different. anyone knows solution that? thanks in advance!

c# - Lambda variable capture in loop - what happens here? -

i trying head around, happens here ? sort of code compiler produce? public static void vc() { var listactions = new list<action>(); foreach (int in enumerable.range(1, 10)) { listactions.add(() => console.writeline(i)); } foreach (action action in listactions) { action(); } } static void main(string[] args) { vc(); } output: 10 10 .. 10 according this , new instance of actionhelper created every iteration. in case, assume should print 1..10. can give me pseudo code of compiler doing here ? thanks. in line listactions.add(() => console.writeline(i)); the variable i , captured, or if wish, created pointer memory location of variable. means every delegate got pointer memory location. after loop execution: foreach (int in enumerable.range(1, 10)) { listactions.add(() => console.writeline(i)); } for obvious reasons i 10 , memory content pointers present in action (s) pointing, becomes

amazon web services - AWS IAM Instance Profile to Administer EC2 Instances With that Profile -

i have iam user launches cloudformation stack containing - ec2 instance - iam instance profile associated - iam role in aws::cloudformation::init block, ec2 instance performs actions require call ec2:* api actions. however, instance should able call these actions instance itself. the user launches stack has permission attach set of predefined policies , create roles. this "cloudformationstacklauncher": { "type": "aws::iam::managedpolicy", "properties": { "description": "allows attached entity attach , detach required policies roles creates.", "policydocument": { "version": "2012-10-17", "statement": [ { "effect": "allow", "action": [ "iam:attachrolepolicy", "iam:detachrolepolicy" ], "resource": "*", &quo

sql server - need help in TSQL query that select policy id = 1 -

i want in query selects data having policy_id 1 the query using is select policy_id policy_dim policy_id '%1'; the problem select data having 1 @ last digit eg 21, 31 ,41 the data in data warehouse policy id policy_id 1 01 001 0001 try this: select policy_id policy_dim cast (policy_id int) = 1;

c++ - GNU make - accelerate non-parallel makefile without modification -

i have project consisting of set of makefiles cannot run make --jobs=n because dependencies not specified tightly enough make correctly execute recipes in correct order (ie race conditions). i using huddle, electric-cloud.com, , need: parses makefile , executes jobs in parallel , accounts unspecified dependencies. question: there free or free-er thing this? yes know re-write makefiles project management says "no way". update #1 i understand i'll have some work functionality similar electric-cloud's functionality. i know electric-cloud parses makefile(s) find dependencies wouldn't same thing accomplished using makedepend ? i'm thinking: run makedepend on existing makefiles feed in output using include <makedepend.output> make --jobs=64 update 2 turns out makedepend specific c/c++: merely runs pre-processor on source files , parses #include statements; not need. i need guy asking for: build makefile dependency / inherit

javascript - Fill a Textbox with a Link? -

i have link , want prepare fill textbox value. link http://www.lolking.net/ , want if go site fill texbox write ("summore name..."). how can make this? must write script site ? or can prepare link fill textbox? this question site textbox, name of textbox f12 , want prepare links how fill textbox greetz you reasonably write chrome extension this. you'd have add logic each site want work on, replacing text in box (i assume want automatically search summoner name) simple 1 line: document.getelementsbyname("name")[0].value="<your summoner name>"; but example work on lolking.net. make more general, replace "name" in following way: document.getelementsbyid("<input id>")[0].value="<replacement text>";

javascript - tab containers in ReactJS: only render selected child vs. using `display:none` -

i built simplistic tab container in reactjs using idea container component keeps in state integer index denoting tab pane display , renders child (from this.props.children array) found @ index position. the gist of approach was: const tabcontainer = react.createclass({ props: { tabnames: react.proptypes.arrayof(react.proptypes.string).isrequired }, getinitialstate: function() { return { activeindex: 0 }; }, settab: function(n) { this.setstate({activeindex: n}); }, render: function render() { const childtorender = this.props.children[this.state.activeindex]; return ( <div classname='tab-container'> <tabs tabnames= {this.props.tabnames} active = {this.state.active} settab = {this.settab} /> <div classname='tab-pane'> {c

spring - receive "Injection of autowired dependencies failed" in SpringMVC Java based configuration -

Image
i can't autowire repository, although have @componentscan annotation in configuration class. but there no green bean icon in repository file itself. (not sure if should there, present when configured similar projects via xml configuration). pom.xml http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <modelversion>4.0.0</modelversion> <groupid>com.websystique.springmvc</groupid> <artifactid>springjavaconfigexample</artifactid> <packaging>war</packaging> <version>1.0.0</version> <name>springjavaconfigexample</name> <properties> <springframework.version>4.1.7.release</springframework.version> <hibernate.version>4.3.10.final</hibernate.version> <mysql.connector.version>5.1.31</mysql.connector.version> <spring.data.

arrays - Calling $scope in custom filter (angular) -

i'm using angular filter filter out objects in array localteam_id properties match value held in $scope.whichmyteam . works fine. view <div ng-repeat="fixture in getfixtures | filter: {localteam_id: whichmyteam} "> i want extend filter however, include section criterion: will, in effect, be: <div ng-repeat="fixture in getfixtures | filter: {localteam_id: whichmyteam && visitorteam_id: whichmyteam} "> ...but a) doesn't work, , b) if did, it's getting little cumbersome , seems justify making custom filter. so, tried make one. problem ran need reference $scope.whichmyteam value in filter, seems filter module can't accept/understand $scope . crucial filter work in instance, i'm not sure how resolve this. my filter far looks this: app.filter('myfixtures', function() { return function(input) { angular.foreach(input, function(o) { output = []; if (o.localteam_id === $sc

asp.net - Ajax Control Tool kit HTML Editor value not reading in c# -

i using ajax control toolkit html editor. trying retrieve editor value getting error <%@ register assembly="ajaxcontroltoolkit" namespace="ajaxcontroltoolkit.htmleditor" tagprefix="cc1" %> <asp:gridview id="uxresultsgrid" runat="server" width="100%" allowsorting="true" autogeneratecolumns="false" pagesize="25" allowpaging="true" backcolor="white" bordercolor="#cccccc" borderstyle="none" borderwidth="1px" rowstyle-verticalalign="top" rowstyle-horizontalalign="left" onpageindexchanging="uxresultsgrid_pageindexchanging" onsorting="uxresultsgrid_sorting" onrowediting="uxresultsgrid_rowediting"> <columns> <asp:templatefield head

javascript - Chart.js ignoring canvas height & width -

following chart.js documentation trying draw small chart: <canvas id="mychart" width="400" height="400"></canvas> <script> var ctx = document.getelementbyid("mychart"); var mychart = new chart(ctx, { type: 'line', data: { labels:['15-2016','16-2016','17-2016',], datasets:[ { label:'yes', data:[3.4884,1.1628,1.3514,], backgroundcolor:'rgba(75,192,192,1)', bordercolor:'rgba(75,192,192,1)', pointradius:0 }, { label:'maybe', data:[0.5571,1.3298,0.791,], backgroundcolor:'rgba(255,206,86,1)', bordercolor:'rgba(255,206,86,1)', pointradius:0 }, { label:'no', data:[0,0,0,], backgroundcolor:'rgba(255,99,132,1)', bordercolor:'rgba(255,99,132,1)', pointradius:0 }

json - How can I track network traffic in chrome devtools while browsing? -

the way know how use network tab in chrome devtools open network tab first reload page i'm interested in. many times though browse little while on page test things. clicks on page though take me inspect html element clicked. missing? can leave inspect mode, continue browse, while track files on network tab? sure. can leave developer tools open (and record requests). the problem you're using shortcut inspect; not developer tools shortcut. in windows , linux use f12. on mac, check @ menu.

ajax - How set the selected option on a dynamic loaded secondary select with VueJS? -

i have city select: <select v-model="city"> <option value="" selected>cidade aonde vocÊ estuda</option> <option value="city1">city 1</option> <option value="city2">city 2</option> <option value="cityx">city x</option> </select> and a school select: <select v-model="school"> <option v-for="item in schools" v-bind:value="item.name" v-bind:selected="school == item.name" > @{{ item.name }} </option> </select> this data (filled laravel blade view), may or may not come city , school: data: { ... city: '{{ input::old('city') }}', school: '{{ input::old('school') }}', schools: [], }, i have watch on city: watch: { 'city': '__citychanged', }, this event handler: __citychanged:

swift - Unable to change protocol conformance of an object -

in code, wheeled , vehicle protocols, bike class conforms both of protocols protocol wheeled { var numberofwheels: int { } } protocol vehicle { var maker: string { } var owner: string {get set} var ownerkid: string { } } class bike: vehicle, wheeled { let numberofwheels: int = 0 var ownerkid: string = "junior" var maker: string { return "ford" } var owner: string { { return "bob" } set { ownerkid = "\(newvalue) junior" } } } let bike: bike = bike() var thebike: vehicle = bike // #1 var thebike: wheeled = bike // #2 error: invalid redeclaration of 'thebike' when check properties of thebike , in #1, thebike object has properties conform vehicle protocol; while in #2 thebike object has properties conform wheeled properties therefore, feel thebike in #1 , #2 different, why tells me invalid redeclaration? question:

angularjs - Angular application with Node + Express web API returning JSON resources vs server side template engine -

i'm quite new node , express , i'm having difficulties understanding concept of server side rendering template engines (like jade) or without. my experience web development solely based on angular applications consume resources in json format restful web api , render html using angular's two-way data binding. what pros , cons of approach, , benefits of rendering html pages on server when there's flexibility angular? this quora answer best description i've found when digging topic several months. but let me answer question height of experience: these approaches not mutually exclusive each over, complementary. pros of server-side rendering: very speedy initial loading of pages (use ajax/mvc subsequent updates); good seo. cons: it may bit difficult set initially. i'd recommend build app in traditional angular way, , add server-side rendering if feel app slow respond.

Python return a linear/cumulative pairs of a list of numbers -

i have pandas dataframe has messy concatenation of many different tables. want segment these tables out , perform operations on them. have list of table header locations looks this: [1, 4, 5, 7, 9, 12, 15] - header of first table @ index 1, header of second table @ index 4, etc. goal use list slice dataframe , extract information each slice , munge data pretty. i'm trying list of pairs this purpose: [[1,4], [4,5], [5,7], [7,9], [9,12], [12,15]] i tried function, not quite returning want, returns pairs this: 1,4, 5,7, 9,12 - making me skip on every other table :/. def pairwise(iterable): #this wrong = iter(iterable) return izip(a, a) am missing something? i'm going crazy here. why not [[a[x], a[x+1]] x in range(len(a)-1)] ? assuming a= [1, 4, 5, 7, 9, 12, 15]

java - Configure Apache Ant to be used behind a proxy -

i trying configure apache ant used behind proxy, using mac os el capitan, , have bash_profile know being sourced terminal, have in bash_profile configure ant proxy: export ant_opts=-dhttp.proxyhost=myproxyhost -dhttp.proxyport=8080 -dhttp.proxyusername=myproxyusername -dhttp.proxypassword=myproxypassword -dhttps.proxyhost=myproxyhost -dhttps.proxyport=8080 after open terminal can echo $ant_opts , can see being loaded, when running ant script trying download url indeed picking ant_opts because going thru proxy, every single time getting: [get] error opening connection java.io.ioexception: server returned http response code: 407 it tries 3 times , bails out. if remove ant_opts time out error expected. i know error code telling me credentials incorrect or not provided, have made sure correct, there way proxy credentials should provided ant_opts ?, tried -dhttp.proxyusername , -dhttp.proxyuser no avail. this ant version: apache ant(tm) version 1.9.7 compiled on april 9

webview - Android showing progress inside Web View for multiple Web Views -

i have scenario on page can have multiple webviews can dynamically load, @ same time. example user may have defined google , yahoo link on same page. fine , dandy. need though way show web view being loaded without standard loading progress dialog since freeze screen. rather either show image in web view saying web view loading or have indicator inside webview not affect users ability add data in case loading of multiple web views takes while. i attempted load image in web view(s) before loading real urls, seems either ignored or overwritten. thanks!

android - MPAndroidChart vertical values -

i want delimit on vertical values between 13 , 14 not how looks linear chart, starts on 0 starting limit, want around 13. please see image on next link see talking about, attaching piece of code enter image description here linechart linechart = (linechart) rootview.findviewbyid(r.id.chart); linedata data = new linedata(labels, dataset); dataset.setcolors(colortemplate.colorful_colors); // dataset.setdrawcubic(true); dataset.setdrawfilled(true); linechart.setdata(data); linechart.animatey(5000); finally got answer this, can check here linechart linechart = (linechart) rootview.findviewbyid(r.id.chart); linedata data = new linedata(labels, dataset); linechart.getaxisleft().setlabelcount(2, true); linechart.getaxisright().setenabled(false); linechart.getaxisleft().sets

php - I'm making a newsletter for a website and it does not connect to the server -

i'm making newsletter promo website , doesn't work me, simple form, register.php , connect.php connect database php. code looks this: the connect.php <?php $servername = "localhost"; $username = "root"; $password = "laidinis69"; $database = "promo"; $con = mysqli_connect($servername, $username, $password, $database); ?> the register.php <?php include('connect.php'); $form_name = $_post['name']; $form_email = $_post['email']; $query = 'select * subscribers name="' .$form_name. '";'; if($result = mysqli_query($con, $query)) { if(mysqli_num_rows($result) == 0) { $query = 'insert subscribers (name, email) values("'.$form_name.'","'.$form_email.'")'; if(mysqli_query($con, $query)) { echo "registered"; } } else { echo "already exists"; } } header('lo

android - BroadcastReceiver before Activity onPause()? -

Image
when on activity , incoming call coming, send parameter broadcastreceiver receives call activity before onpause() starts. possible ? suggest me alternative ? in tests, activity.onpause() starts before broadcastreceiver. i've tried use internal broadcastreceiver in activity , external 1 can't achieve this. here little schema of problem. thanks did try use telephonymanager listen phonestatelistener linstening phone state change ? oncallstatechanged(int state, string incomingnumber) callback invoked when device call state changes.

Connection Refused for Android Device Web Service SYMFONY 3 -

connect android device web service on local host following previous thread , im able connect android device local host using wamp but still cannot connect symfony server , api datas i sarted symfony's internal server : "server running on http://127.0.0.1:8000 " i used internet permission on androidmanifest.xml <uses-permission android:name="android.permission.write_external_storage"></uses-permission> <uses-permission android:name="android.permission.read_external_storage"/> <uses-permission android:name="android.permission.internet"></uses-permission> <uses-permission android:name="android.permission.access_network_state"></uses-permission> <uses-permission android:name="android.permission.read_phone_state"></uses-permission> <uses-permission android:name="android.permission.download_without_notification" /> my mainactivity.java code p

json - polymer iron-form PUT method pass parameters in url -

Image
i have problem , want use put method json data it's passing parameters in query string parameters , not in json, , can't find mistake. i'd not use 'iron-ajax' if possible. <form is="iron-form" method="put" action="http://localhost:5000/users/" id="loginform" content-type="application/json"> <paper-input name="username" label="username" required auto-validate></paper-input> <paper-input name="password" label="password" type="password" required auto-validate></paper-input> <paper-button raised onclick="_submit(event)" disabled id="loginformsubmit"> <paper-spinner id="spinner" hidden></paper-spinner>submit</paper-button> <paper-button raised onclick="_reset(event)">reset</paper-bu

algorithm - LinkedList in Objective C will object be released? -

i making delete method in linked list in objective c . want delete node in list, however, in delete code, set "head" element's "next" node deleted's "next". cause node deleted not freed memory? if so, how fix? the list node follows @interface listnode : nsobject @property (nonatomic, assign) int data; @property (nonatomic, strong) listnode* next; @end the code delete below. -(bool)deleteelementwithhead:(listnode*)headnode andnodetodelete:(listnode*)deletenode{ if (!head || !deletenode) { return false; } listnode *element = head; if (deletenode == head) { listnode *temp; temp = element.next; head = nil; head = temp; return true; } while (element) { if (element.next == deletenode) { element.next = deletenode.next;//set pointer element node delete's "next" property points next 1 in list deletenode = nil; return true;

Is there an easy way to tell if an R script made use of any function in a loaded package? -

for example, if ran script.a : library(ggplot2) <- 12 and script.b library(ggplot2) b <- runif(100) qplot(b) i'd able tell script.a did not make use of ggplot2 , whereas script.b did. load library , trace functions in package environment (and in namespace). i'll use small helper function this: trap_funs <- function(env) { f <- sapply(as.list(env, all.names=true), is.function) for( n in names(f)[f] ) trace(n, bquote(stop(paste("script called function", .(n)))), where=env) } example: library(data.table) trap_funs(as.environment("package:data.table")) trap_funs(asnamespace("data.table")) this second statement needed ensure calls such data.table::xxx() trapped. example: > as.data.table(mtcars) tracing as.data.table(mtcars) on entry error in eval(expr, envir, enclos) : script called function as.data.table note code interrupted.

Which ORM to use for Python and MySql? -

so have database stores lot of information many different objects; simplify it, imagine database stores information weights of 100 dogs , 100 cats on period of few years. made gui, , want 1 of tabs allow user enter newly taken weight or change past weight of pet if wrong. i created gui using qt designer. before, communicated database using sqlalchemy. however, pyqt4 offers qtsql, think orm? explain me how orm works, , difference between sqlalchemy, qtsql, , sql connector? qt sql sql framework comes qt library. provides basic (and classic) classes access database, execute queries , fetch results.*qt can recompiled support various dbms such mysql, postgres etc. sql connector assume refer mysql connector ? if so, it's set of c++ classes access natively mysql database. classes same in qtsql. don't have support wrapper layer of qt. of course, cannot access database mysql. sql alchemy it's hard briefly explain complexity of orm. object relation mapping. wiki

android - Canvas won't draw -

i don't it, have other custom views in can draw canvas fine. new views i'm creating don't draw canvas @ all! can't find discernible difference between doing , now, it's still same "canvas.drawline()" calls afterall. here's example view not draw regardless of try (note background black, white color should show up) public class testview extends view { public testview(context context) { super(context); } public testview (context context, attributeset attrs) { super(context, attrs); } public void ondraw(canvas canvas){ paint paint = new paint(); paint.setcolor(0xffffff); paint.setstyle(paint.style.stroke); paint.setstrokewidth(4); canvas.drawline(0,0, 500, 500, paint); canvas.drawcircle(0,0, 40, paint); logy.print("drew top:" + gettop() + " left:" + getleft() + " right:" + getright() + " bottom:" + getbott

winforms - C# in Windows Form Application, how can I get the label to auto-refresh from UDP client? -

right now, have button creates event decimal read udp listener (in different class), , being converted tostring() label. if run udp listener in console window, updates in real time fine. here, updates label in first instance, , stops refreshing. i've tried calling udplistener asynchronously still unable auto-refresh label. private void btnbopit_click(object sender, eventargs e) { string firstticker, secondticker; int mycurrentport; string portnumber = textportnumber.text; mycurrentport = convert.toint32(portnumber); firstticker = textfirstticker.text; secondticker = textsecondticker.text; //i call udpmethod asynchronously right here, , have async outside btn loop calludpmethod(mycurrentport, firstticker, secondticker); this.labelspread.refresh(); } private async void calludpmethod(int port, string symb1, string symb2) { var result =await myudpmethodasync(port, symb1,

wso2 - Creating Server/Client service with ESB -

i'm interested in following if possible create server client implementation esbs. me clear these web services, i'm talking different protocols , implementations. for example possible create messaging router supports on both server , client side smpp protocol ( stateful tcp based protocol ) have handle many connections on both server , client side. persistent connections required. i have idea use esb router, protocol translation, field manipulation etc... so main question if wrapped around esb idea? preferably looking use netty connection handling , connection mapping. 1 more requirement able make direct connection mapping between server , client endpoints. if possible what's best way done, possible usage of j6ee framework/spring ? thanks, tiho yes. smpp transport available in wso2 esb. the latest code transport can found https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.2.0/dependencies/transports/1.1.0-wso2v9/modules/sms/ also, following

python - Error when importing Matplotlib using Anaconda IDE -

i have installed anaconda 3 , i'm trying use pylab plot function . when using line code : from matplotlib import * , following error , i've been trying solve 3 days . tried conda update -all, or instaling previous version of matplotlib . here error : runfile('c:/users/usuario/.spyder2-py3/temp.py', wdir='c:/users/usuario/.spyder2-py3') traceback (most recent call last): file "<ipython-input-1-9b55d1cb87fc>", line 1, in <module> runfile('c:/users/usuario/.spyder2-py3/temp.py', wdir='c:/users/usuario/.spyder2-py3') file "c:\anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile execfile(filename, namespace) file "c:\anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile exec(compile(f.read(), filename, 'exec'), namespace) file "c:/users/usuario/.spyder2-py3/temp.py", lin

vsts - Reference commit message in VS Team Services -

i have release definition associated build definition in vs team services. in task of release definition need commit message of changes associated corresponding build. how it? there variable can directly? there no pre-defined variable this. can add powershell script task , use following code commit message via rest api(you need enable alternative credential code): [string]$buildid = "$env:build_buildid" [string]$project = "$env:system_teamproject" [string]$projecturi = "$env:system_teamfoundationcollectionuri" $username="alternativeusername" $password="alternativepassword" $basicauth= ("{0}:{1}"-f $username,$password) $basicauth=[system.text.encoding]::utf8.getbytes($basicauth) $basicauth=[system.convert]::tobase64string($basicauth) $headers= @{authorization=("basic {0}"-f $basicauth)} $url= $projecturi + $project + "/_apis/build/builds/" + $buildid + "/changes?api-version=2.0&

c# - Basic JSON Parsing Query -

so using json.net research based project. sample json file looks this. file huge bear me, need process 1 part of it: { "connectionname" : "example.com", "connectionport" : 443, "sni" : "example.com", "sslv3" : { "suiteselection" : "server", "suites" : [ { "id" : 49169, "name" : "ecdhe_rsa_with_rc4_128_sha", "strength" : 3, "forwardsecrecy" : true, "anonymous" : false, "serverkeytype" : "rsa" }, { "id" : 49171, "name" : "ecdhe_rsa_with_aes_128_cbc_sha", "strength" : 3, "forwardsecrecy" : true, "anonymous" : false, "serverkeytype" : "rsa" }, { "id" : 49172, "name&qu