Posts

Showing posts from June, 2013

visual studio 2015 - What is needed to run Roslyn on Teamcity? -

with visual studio 2015 having been released yesterday dev team interested in upgrading , using new c# 6.0 features , have msdn possible. however worried our teamcity builds fail without performing work upgrade build agents. so has gone through process yet, or know needed? edit: did research teamcity , noticed on what's new page version 9.0 , 9.1 adds support vs 2015, cover needed? , since running teamcity 8.0 there way add roslyn support without upgrading? you can install either microsoft build tools 2015 , or else install microsoft.net.compilers , nuget package in project use roslyn compilers.

CSS not loading in Heroku, working in local foreman -

i using angular app working fine locally, using foreman start -p 9000 web also using grunt serve when deploying heroic, getting errors on missing css files. 1 example https://rc-batchentry-dev.herokuapp.com/components/batch-review.css failed load resource: server responded status of 404 (not found) i using grunt build tool. web.js (relevant section) // static files if (/development/.test(app.get('env'))) { console.log('environment: development'); app.use('/', express.static(__dirname + '/app')); app.use('/', express.static(__dirname + '/.tmp')); app.use('/bower_components', express.static(__dirname + '/bower_components')); } if (/production/.test(app.get('env'))) { console.log('environment: production'); app.use(express.static(__dirname + '/dist')); } // start server app.listen(process.env.port || 9000, function () { console.log('app started:',

java - Hibernate MappedSuperClass in another project -

we building complex project consist of multiple projects. , amongst these projects, 2 of them used defining base entities (like interfaces). normally, if these projects 1 run without error codes below. but these codes placed in seperate projects, entities derived superclass (from baseentity) causing error : caused by: org.hibernate.annotationexception: no identifier specified entity: com.unalcable.department.security.model.approvalhistory so i've searched causes, , i've found out defining baseentity in hibernate's configuration concrete class other fix it. didn't... here codes : hibernate's configuration <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="annotatedclasses"> <list> <value>com.unalcable.gener

xml - How to iterate over IDREFS values in XSLT 1.0? -

i have xml uses idrefs field. need extract id put in own element. here's basic structure think need don't know use in select functions. <xsl:template match="node_with_idrefs_field"> <xsl:for-each select="each id in @idrefsfield"> <xsl:element name="newelement"> <xsl:attribute name="ref"><xsl:value-of select="the idref"/></xsl:attribute> </xsl:element> </xsl:for-each> <!-- keep rest of content --> <xsl:apply-templates select="@*|node()"/> </xsl:template> so node <node_with_idrefs_field idrefsfield="id1 id2"/> the result be <node_with_idrefs_field> <newelement ref="id1"/> <newelement ref="id2"/> </node_with_idrefs_field> thanks help. you need tokenize value of idrefsfield attribute. xslt 1.0 has no native tokenize() function, need ca

javascript - AngularJS(ui-router) and dynamically linked scripts -

i have 1 problem. use angularjs ui-router. so.... write states dynamically named controllers: .config(function ($stateprovider, $urlrouterprovider) { function geturl ($stateparams){ return "module/" + $stateparams.path; } function getctrl ($stateparams){ var url = $stateparams.path.split("/"); alert(url [url.length - 1] + "ctrl"); return url [url.length - 1] + "ctrl"; } $urlrouterprovider.when('' , '/#'); $stateprovider.state('home', { url : "/", views : { '' : { templateurl : '/resources/template/indextemplate.html' } } }).state('modules',{ url : '/{path:.*}', views : { '' : { templateurl : geturl, controllerprovider : getctrl } } }); }); i have 1 simple c

Entity Framework varchar To nVarchar -

i have column in database datatype varchar , when issue command using linq in following example: context.x.columnname=="somevalue" , generated query uses nvarchar . understand entity framework uses nvarchar strings. tried use solution decorate column in entity class typename="varchar" , works in above scenario. [column(typename="varchar")] public string columnname{get;set;} but when tried write query following way: context.x.columnname.contains("somevalue") the generated query still has nvarchar ...i tried solutions provided still having issue. tried setting data type in map file , tried set isunicode(false) , non of them works. can please me figure out solution problem... i appreciate response...

php - Why does array_map() with null as callback create an "array of arrays"? -

today learned special case of array_map() in php, mentioned side note in documentation: example #4 creating array of arrays <?php $a = array(1, 2, 3, 4, 5); $b = array("one", "two", "three", "four", "five"); $c = array("uno", "dos", "tres", "cuatro", "cinco"); $d = array_map(null, $a, $b, $c); print_r($d); ?> the above example output: array ( [0] => array ( [0] => 1 [1] => 1 [2] => uno ) [1] => array ( [0] => 2 [1] => 2 [2] => dos ) [2] => array ( [0] => 3 [1] => 3 [2] => tres ) [3] => array ( [0] => 4 [1] => 4 [2] => cuatro ) [4] => array ( [0] => 5

Spring- Security :java.lang.NoClassDefFoundError: org/springframework/security/context/DelegatingApplicationListener -

i upgrading spring-security version 3.2.5 4.0.1. unfortunately have stumbled across road-block , appreciate help. posting error log, securityapplicationcontext.xml , pom.xml. kindly have look. error log : javax.servlet.servletexception: java.lang.nosuchmethoderror: org.springframework.security.web.access.expression.websecurityexpressionroot.setdefaultroleprefix(ljava/lang/string;)v org.apache.jasper.runtime.pagecontextimpl.dohandlepageexception(pagecontextimpl.java:916) org.apache.jasper.runtime.pagecontextimpl.handlepageexception(pagecontextimpl.java:845) org.apache.jsp.web_002dinf.views.common.footer_jsp._jspservice(footer_jsp.java:231) org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70) securityapplicationcontext.xml : <security:http pattern="/resources/**" security="none"/> <security:http create-session="ifrequired" use-expressions="true" auto-config="false" disable-url-rewrit

Scala - Explicitly stating the short circuiting in defining && and || functions -

in scala source code boolean ( here ), said functions && , || can not defined using => syntax. // compiler won't build these seemingly more accurate signatures // def ||(x: => boolean): boolean // def &&(x: => boolean): boolean but can't see problem definitions! the source code said won't rather can't, maybe have wrongly interpreted it. if see line 56 of boolean.scala, find explaination ||. this method uses 'short-circuit' evaluation , behaves if declared def ||(x: => boolean): boolean . if a evaluates true , true returned without evaluating b . same && in source code. sum up, can define there no need because of short-circuiting.

conditional - (Javascript) multiple condition set for ternary operator issue -

for (var days = 1; days <= 31; ++days) { console.log( (days == (1, 31, 21) ? days + 'st':'') || (days == (2, 22) ? days + 'nd':'') || (days == (3, 23) ? days + 'rd':'') || days + 'th' ); } trying display (1st, 2nd, 3rd) (21st, 22nd, 23rd) (31st) (multiple th) i'm getting strange result here, i'm not quite sure i've done wrong, appreciated. i did try google , figure out, promise, appreciate relatively detailed explanation why behaving strange. you've typed in code syntactically correct, doesn't mean apparently expect mean. this: (days == (1, 31, 21) ? days + 'st':'') is in effect same as (days == 21 ? days + 'st':'') the (1, 31, 21) subexpression involves comma operator, allows sequence of expressions (possibly side-effects) evaluated. overall value value of last expression. if want compare value list of

sql - mysql. can't create schema when using composite UNIQUE key. ERROR 1005 (HY000): (errno: 150) -

i'm attempting create simple schema, see below. reason weird 150 error.i able narrow problem down unique key declaration: unique key (fk_im_savegroups_sgcode, sscode) . if refactor declaration this: unique key (sscode) - works. could explain me why can't use composite index? drop database if exists test447; create database test447 charset utf8mb4 collate utf8mb4_unicode_ci; use test447; create table im_savegroups ( id int unsigned not null auto_increment, sgcode varchar(20) not null, primary key (id), unique key (sgcode) ) engine=innodb charset utf8mb4 collate utf8mb4_unicode_ci; create table im_savespecs ( id int unsigned not null auto_increment, fk_im_savegroups_sgcode varchar(20) not null, sscode varchar(20) not null, max_w int unsigned, max_h int unsigned, ratio_x int unsigned, ratio_y int unsigned, quality int unsigned, format varchar(10), rel_dir varchar(400), is_retina tinyint unsigned default 0,

javascript - Nested view templates in Angular.js? -

i have in html file part of html code, repeats multiple times ( have multiple tables in html file...) <table> <thead> <tr> <th data-field="id">vorname</th> <th data-field="name">nachname</th> <th data-field="price">anzahlaktien</th> <th data-field="action">wert</th> <th data-field="action">einkaufsdatum</th> <th data-field="action">ort</th> <th data-field="action">aktion</th> </tr> </thead> <tbody> // different data is possible set "partial view" in angular.js? (like in meteor.js) can

Python - Sending multiple values for one argument to a function -

i few days new python if silly please excuse me.. is there method sending multiple variables single function? example: pe.plot_chart(conn,7760,'datasource1',123,save=true) this above function takes connection sql pulls data unique id 7760 datasource1 (uniqueid 123). can use method send multiple criteria datasource1 field? e.g. pe.plot_chart(conn,7760,['datasource1','datasource2'],[123,345],save=true) pe.plot_chart created me, modifications have made make work fine is type of operation possible perform? edit: adding on info. the plot_chart function.. plots chart, , saves location above. each call of function produces 1 graph, hoping sending multiple values parameter have function dynamically add more series plot. so if send 4 data sources function, end 4 lines on plot. reason not sure looping through data source collection (will produce 4 plots 1 line?) yes can send multiple arguments function in python, shouldn't surprise. cann

sql - Integration of Oracle Database in a Rails Application -

i have rails application , have sql database. using oracle sql developer manage it. question how integrate these 2 can display database data? this big subject, major steps can think of are: for each table in database want include in rail app, define model class inherits activerecord::base if database not respect rails conventions regard naming have provide class methods in each model define primary key column , table name. you create associations in models describe joins between tables.

PHP Allowed memory size of X bytes exhausted -

i'm using mpdf library create , download pdf files, example x1000 (singly using ajax) in loop. error message series of files "allowed memory size of 268435456 bytes exhausted (tried allocate 261900 bytes)" . read have set bigger memory_limit in configuration can't this, because 256m limit. is there other solution error? you can reduce memory usage 2 other ways without increasing memory limit... consider setting $mpdf->simpletables = true; if not need complex table borders, or $mpdf->packtabledata = true; if not mind processing time. packtabledata – use binary packing of table data reduce memory usage both of increase processing time in order save memory usage.

In Android, Facebook API V2.4 is not returning email id whereas V2.3 is returning. How to get email id in V2.4? -

when wrote following code api v2.3 giving me details including email id. , same code not giving me email id. can can email id? oncreate(..) { . . email_permission = new arraylist<string>(); email_permission.add("email"); uilifecyclehelper = new uilifecyclehelper(this, statuscallback); uilifecyclehelper.oncreate(savedinstancestate); session.openactivesession(this, true, email_permission, statuscallback); // callback when session changes state session.statuscallback statuscallback = new statuscallback() { @override public void call(session session, sessionstate state, exception exception) { // checking whether session opened or not if (state.isopened()) { } else { if (state.isclosed()) { } log.d(tag, state.tostring());

javascript - jquery remove/addClass being ignored -

i attempting make slider of own, without templates. have ran issue already . when attempt removeclass('active') or attempt addclass('active') after .children().fadeout(300) or .children().fadein(300) and possibly more , seems ignored. here code: $(document).ready(function() { var numofslides = $('div.slider > div').children().length; var = 0; while (i < numofslides) { $('div.slides div.count').append('<i class="fa fa-fw fa-circle-o"></i>'); i++; }; = 0; $('div.slider div.content:nth-child(1)') .addclass('active') .children().fadein(300); $('div.slides i.fa:nth-child(1)') .removeclass("fa-circle-o") .addclass("fa-circle"); window.setinterval(function() { $('div.slider div.active') .children().fadeout(300) .removeclass('active'); ///<-- issue }, 2000); });

css - Set Modal window height based upon browser window size using Bootstrap -

how set max-height modal window 80% of current browser window size using bootstrap. thanks one way achieve use wrapper. example use code this: html <div id="wrapper"> <!-- code here --> </div> css #wrapper { height: 80%; } so put #wrapper around of code (of course after body), , make max height of of content 80%.

javascript - Enable Scrolling on my sidenav -

i trying enable scrolling on sidenav in same way when overflow in normal divs, there nav preventing me being able this, such items on sidenav-list overflow screen cannot accessed. here sidenav code in html: <div pageslide ps-open="ctrl.checked" class="blue-grey darken-1 white-text"> <a ng-click="ctrl.toggle()" class="button">&#x2716;</a> <div style="padding:20px" id="demo-right"> <table class="bordered responsive-table"> <thead> <tr> <th data-field="id">company</th> <th data-field="name">shares owned</th> </tr> </thead> <tbody> <tr ng-repeat="stock i

ios - Method called on BringSubviewToFront? -

is there method called on view when using bringsubviewtofront? i have container view switch between list view , map view. want map zoom in location when switch it, since map view loaded before switch it, viewdidload method not called when switch. how around this? there method called when switching within container view? if understand correctly embed segue called on loading of container view? anyway, appreciated. if need post code, please let me know. thanks add method :- triggering new view layout event, following method fired:- -(void)viewwilllayoutsubviews { //this method fire while add or switch view or bringsubviewtofront in view controller } just put breakpoint, , check!

symfony - Symfony2 user timezone -

i building symfony2 app user can choose timezone. made neseccary model/form changes store timezone field in user object. to apply timezone inside specific controller action can use: $user = $this->get('security.context')->gettoken()->getuser(); date_default_timezone_set( $user->gettimezone() ); is there way without having modify every controller/action?

scala - How to invoke function of multiple arguments with HList? -

suppose have hlist of type a::b::c::hnil , function (a, b, c) => d val hlist: a::b::c::hnil = ??? def foo(a: a, b: b, c: c): d = ??? now need funciton a::b::c::hnil => d , uses foo return d . def bar(hslist: a::b::c::hnil): d = ??? how implement bar ? you can little more directly using shapeless's fntoproduct , provides toproduct syntax converting functionn function1 taking hlist : import shapeless._, syntax.std.function._ type = string type b = symbol type c = int type d = list[string] val hlist: :: b :: c :: hnil = "foo" :: 'x :: 1 :: hnil def foo(a: a, b: b, c: c): d = list.fill(c)(a + b) def bar(hslist: :: b :: c :: hnil): d = (foo _).toproduct.apply(hslist) in many cases wouldn't want separate bar definition.

javascript - New function returning new function -

i'm getting bit confused new keyword in javascript. take following example function (value) { this.a = value; } function b (value) { return new (value); } console.log ( b (0)); // { a: 0 } console.log (new b (0)); // { a: 0 } i want able create new instance of "a" without having use "new". have "b()", however, when call "new b()" appears same thing "b()", though "new" ignored. in both cases, instanceof equals "a". going on? from the mdn on new : the object returned constructor function becomes result of whole new expression. if constructor function doesn't explicitly return object, object created in step 1 used instead. (normally constructors don't return value, can choose if want override normal object creation process.) this extract shows that what new b isn't "normal" (there's no reason that) the value explicitely returned b return

xml - How can I pass html tags to xsl template? -

my xml file has html tags inside, built that: &lt;pre&gt; &lt;table border=""&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;time&lt;/th&gt; &lt;th&gt;result&lt;/th&gt; &lt;th&gt;test&lt;/th&gt; &lt;th&gt;method&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; 6:28:09 pm &lt;/td&gt; &lt;td bgcolor="#ff0000"&gt; fail &lt;/td&gt; &lt;td width="30%"&gt; test &lt;/td&gt; &lt;td width="70%"&gt; test_method &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/pre&gt; this table test report. i' dlike pass table xsl template , display iside generated file. <xsl:value-of select="$suite/testsuite/tests/command/summaries/report/output" /> bu in html see <pre> <t

javascript - How to disable weekdays and custom days in jquery datepicker? -

this code below need disable weekdays , given days how can ? can 1 me ? jquery fiddle $(document).ready(function(){ var desingndate = $('#designidunavialble').html(); var splitdate = desingndate.split(','); // console.log(splitdate.length); var arrdisableddates = {}; (var = 0; < splitdate.length; i++) { //console.log(splitdate[i]); arrdisableddates[new date(splitdate[i])] = new date(splitdate[i]); } $("#idate").datepicker({ dateformat: 'dd-mm-yy', beforeshowday: function (dt) { var bdisable = arrdisableddates[dt]; if (bdisable) return [false, '', '']; else return [true, '', '']; } }); }); working fiddle this may function deadlinedates(date) { dmy = date.getdate() + "-" + (date.getmonth()+1) + "-" + date.getfullyear(); var day = date.getday(); va

php - Symfony validate telephone in form field -

i have symfony 2.6 , form personal information in form field telephone, rhis +38 (918) 280-1594 and if developer write "_" or more digits, space. how in action check ? developer write +38 (918) 2 801_594 and set in db +38(918)2801594 what processes , decisions or bundles solve problem? ->add('telephone', null, array('label' => 'telephone', 'max_length' => 255, 'required' => false)); $builder->get('telephone')->addmodeltransformer(new callbacktransformer( // transform <br/> \n textarea reads easier function ($originaldescription) { return preg_replace('/[^0-9()]+/', "", $originaldescription); }, function ($submitteddescription) { // remove html tags (but not br,p) $cleaned = strip_tags($submitteddescription, '<br><br/><p>'); // transform \n real <br/> return str_replace("\n"

c# - How to use both ribbon(Xml) and ribbon designer in office addin(Power point) -

i facing situation have customize existing context menu of power point? have used ribbon designer ribbon interface .but context menu have use ribbon(xml).i have searched , found not possible use both ribbon(xml) , ribbon designer simultaneously . in situation how customize context menu , requirements .is there way can customize context menu of power point shape without using ribbon(xml)? is there way can customize context menu of power point shape without using ribbon(xml)? no, starting office 2010 need use ribbon xml markup customizing office context menus. see customizing context menus in office 2010 more information. command bars deprecated , not used longer. you may find walkthrough: creating custom tab using ribbon xml helpful.

javascript - jsTree (3.x) ajax config handlers runs only once? -

i read documentation how setup ajax data source jstree component. don't understand following code: 'data': { 'url': function (node) { return '/ajax/test-nodes'; }, 'data': function (node) { return {'id': node.id}; } } 1) why need use function 'url', how advantages gives? 2) why 'url' , 'data' handlers runs 1 time(i use console.log check it), despite ajax response contains many nodes: [{"id":1,"parent":"#","text":"n1"},{"id":2,"parent":"#","text":"n2"},{"id":3,"parent":"1","text":"child of n1"},{"id":4,"parent":"1","text":"child of n1"},{"id":5,"parent":"3","text":"subchil

How to retrieve data of CKEditor in code behind of an aspx page -

i'm trying integrate ckeditor application , i'm using below approach. <textarea name="editor1" id="editor1" rows="10" cols="80"></textarea> <script type="text/javascript"> ckeditor.replace('editor1'); </script> and in javascript set , data ckeditor i'm using code below function cksetdata(val) { ckeditor.instances.editor1.setdata(val); } var data = ckeditor.instances.editor1.getdata(); it working perfect when using javascript. but want set , data code behind want save data of ckeditor database. if using ckeditor control in aspx page i'm able retrieve data using .text property of ckeditor, unable data through javascript. i need retrieve data both javascript , codebehind. thanks ur answer mr.raymond kuipers.. im using work around problem.. as im able retrieve data in javascript im assigning data hidden variable , accessing value of

css - Make the value of the course type a unique color using rails -

i have different courses , want add unique color different types of courses. ex video course, reading course , speaking course. i understand code does. ask if type_of_course "video" in present, , is, how display "orange" color courses have "video" course type? <% @courses.each |course| %> <td class='<%= "type_of_course" if course.type_of_course? %>'> <%= course.title %> <% end %> courses.scss .type_of_course { color: orange; } course.rb def type_of_course? type_of_course = course.find_by(type_of_course: 'video').present? end sorry bad explanation. figured out after few hours! anyway! :) .level-easy .level { background-color:green; text-transform: uppercase; width: } .level-medium .level { background-color:orange; } .level-hard .level { background-color:red; } <tr class='level-<%= course.level %>'

php - Mongodb + php5-fpm not working -

i installed mongodb extension php5-fpm . output php -m: [php modules] bcmath bz2 calendar core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv json libxml mbstring mhash mongo mysql mysqli openssl pcntl pcre pdo pdo_mysql phar posix readline reflection session shmop simplexml soap sockets spl standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter zend opcache zip zlib [zend modules] zend opcache php --ini configuration file (php.ini) path: /etc/php5/cli loaded configuration file: /etc/php5/cli/php.ini scan additional .ini files in: /etc/php5/cli/conf.d additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini, /etc/php5/cli/conf.d/10-pdo.ini, /etc/php5/cli/conf.d/20-curl.ini, /etc/php5/cli/conf.d/20-gd.ini, /etc/php5/cli/conf.d/20-json.ini, /etc/php5/cli/conf.d/20-mongo.ini, /etc/php5/cli/conf.d/20-mysql.ini, /etc/php5/cli/conf.d/20-mysqli.ini, /etc/php5/cli/conf.d/20-pdo_mysql.ini, /etc/php5/cli/conf.d/20-rea

angularjs - JavaScript function won't work on phone -

i have script: function isitvisible() { var style = document.getelementbyid('product').style; if (style.visibility === 'hidden') { style.visibility = 'visible'; } else { style.visibility = 'hidden'; } } and part of html want hide or show: <div id="product"> <div ng-repeat="producto in productos"> <div class="figuranta" id="{{ producto.id }}" > <figure class="floating" id="{{ producto.id }}" onclick="details(id);"> <img ng-src="{{ producto.image }}" alt="image" class="rcorners3 img-responsive" alt="null"> <figcaption> {{ producto.name }}</figcaption> </figure> </div> </div> </div> eeverything works fine when trying on chrome (hides whole "product

actionscript 3 - HTML Hyperlink to a specific scene in a swf file -

i have swf file many scenes. able add multiple hyperlinks company intranet site (set on sharepoint) link specific scenes in swf file. possible? thank you! it's do-able... it's going depend on how access have actionscript, javascript, etc. in short you'll need able add necessary listeners required want do. i found example of communication between javascript , flash here: http://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370

javascript - console.log() async or sync? -

Image
i reading async javascript trevor burnham. has been great book far. he talks snippet , console.log being 'async' in safari , chrome console. unfortunately can't replicate this. here code: var obj = {}; console.log(obj); obj.foo = 'bar'; // outcome: object{}; 'bar'; // book outcome: {foo:bar}; if async, anticipate outcome books outcome. console.log() put in event queue until code executed, ran , have bar property. it appears though running synchronously. am running code wrong? console.log async? console.log not standardized, behavior rather undefined, , can changed release release of developer tools. book outdated, might answer soon. to our code, not make difference whether console.log async or not, not provide kind of callback or so; , values pass referenced , computed @ time call function. we don't know happens (ok, could, since firebug, chrome devtools , opera dragonfly open source). console need store logged values som

Placing same image at different places in QT -

i want display same image @ different position. image should display @ position. using qpixmap placing image. can 1 suggest how it?. you can use qlabel this: qlist<qpoint> points = qlist<qpoint>() << qpoint(0, 0) << qpoint(100, 100) << qpoint(200, 200); qpixmap pixmap; (int = 0; < points.size(); ++i) { qlabel* label = new qlabel; label->setpixmap(pixmap); label->setgeometry(qrect(points[i], pixmap.size())); label->show(); }

javascript - Canvas Colour Match Range -

my current code scans canvas colour removes canvas , moves onto next pixel. achieve intensity of colours search. find similar colours aswell, not 1 rgba color. is possible, here working code 1 colour. current code //1-225 threshold = 100; //get canvas element data imagedata = context.getimagedata(0, 0, canvasel.width, canvasel.height); data = imagedata.data; //rgb color = [120, 82, 31, 1]; (var = 0, n = data.length; <n; += 4) { if(data[i] === color[0] && data[i+1] === color[1] && data[i+2] === color[2]){ data[i+3] = 1; } } context.putimagedata(imagedata, 0, 0); disclaimer this answer based on op's code , may not best way of doing it. to check if actual pixel in range defined threshold, can use if statement like-so : if(data[i]>=color[0]-threshold/2 && data[i]<=color[0]+threshold/2 && data[i+1]>=color[1]-threshold/2 && data[i+1]<=colo

java - Check if a proxy can connect to a website? -

basically i'm building proxy checker check if can connect specific website. problem when proxy doesn't work takes huge amounts of time cancel try , move next. i've tried "setconnecttimeout();" parameter doesn't seem work properly. any appreciated, thanks. private void jbutton1actionperformed(java.awt.event.actionevent evt) {//gen-first:event_jbutton1actionperformed try { executeloop(); } catch (exception ex) { logger.getlogger(proxycheckergui.class.getname()).log(level.severe, null, ex); } }//gen-last:event_jbutton1actionperformed private void executeloop() throws exception{ string getproxies[] = jtextareaproxy.gettext().split("\n"); string proxyip; int proxyport; system.out.println("quantityoflines:" + getproxies.length); (int = 0; < getproxies.length; i++) { system.out.println("line: " + i); string proxy[] = getproxies[i].split(":");

Javascript: Get UTC Date Object by UTC Offset -

we're having lots of location-based data , 1 parameter each location/city timezone parameter, holds utc offset local timezone. for example: vienna: 1 denver: -7 now, want local time cities. up until using this: var date = new date( new date().gettime() + offset * 3600 * 1000); but today, realized hours +1 off. how can local times utc offset in javascript? use this: var d = new date() var n = d.gettimezoneoffset();

c++ - function pointer to a different class member -

i have following problem: class { public: a() {} int foo(int a) { return a; } }; class b { private: int (a::*pfoo)(int); public: b(int (a::*_pfoo)(int)) { this->pfoo = _pfoo; } int cfoo(int i) { this->pfoo(i); //this causes problem compiler says it's not pointer } }; a; b b(&a::foo); i've tried already int (*pfoo)(int) instead of int (a::*pfoo)(int) but there problems constructor , when used b b(&a.foo) there compiler error says have use b b(&a::foo) you trying call a:foo object of type b pointer member function of a requires instance of a . instead of saving pointer or reference a inside b can redesign code b little more generic: #include <functional> struct { int foo(int a) { return a; } }; class b { private: std::function<int(int)> pfoo; public: b(std::function<int(int)> foofunc) : pfoo(foofunc) { } int cfoo(int i) { return p

Xcode 7 beta 4 build error - com.apple.CoreSimulator.SimRuntime.iOS-9-0 -

the error when building working project: images.xcassets: failed find suitable device type simdevicetype : com.apple.coresimulator.simdevicetype.ipad-2 runtime simruntime : 9.0 (13a4305g) - com.apple.coresimulator.simruntime.ios-9-0 i've removed references of xcode , simulators on mac, restarted many times can't count. happened after last release of el capitan 2 days ago. project building , running fine before.. why error originate images.xcassets in first place? i can see xcode 7 beta 4 has simulators included in package, but list of available simulators empty. noted want run project on physical device , not simulator (which freezes when open) log coresimulator that's been showing since moment upgraded osx: jul 22 14:53:53 coresimulatorservice[787] : com.apple.coresimulator.coresimulatorservice 166~1 starting. managed narrow down removing images images.xcassets , adding appicon , launchimage that. builds ok, whenever attempt add other image build fail ag

mysql - Select TOP 1 from the result set -

i retrieve top 1 value of result set of query connected using union select top 1 * ( select paused_time end_time production_time created_time = curdate() union select resumed_time end_time pause_timer created_time = curdate() union select end_time end_time timer_idle created_time = curdate() ) end_time order end_time desc but not expected result. there no top keyword in mysql far aware. require limit : select * ( select paused_time end_time production_time created_time = curdate() union select resumed_time end_time pause_timer created_time = curdate() union select end_time end_time timer_idle created_time = curdate() ) end_time order end_time desc limit 1

java - hibernate: how to select all rows in a table -

i try select * logentry hibernate. insert works fine: import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persistence.persistence; [...] protected entitymanager manager; protected final string tablename = "logentry"; public databaseimpl(db_type db) { this.db = db; if (entitymanagerfactory != null && entitymanagerfactory.isopen()) { entitymanagerfactory.close(); } entitymanagerfactory = persistence.createentitymanagerfactory(db.getpersunit()); manager = entitymanagerfactory.createentitymanager(); } public void insert(logentry entry) { manager.gettransaction().begin(); manager.persist(entry); manager.gettransaction().commit(); } but when try inserted values using method: public logentrylist getall() { manager.gettransaction().begin(); query query = manager.createnativequery("select * " + tablename + ";"); arraylist<logentry> e

angularjs - Copy div content to dynamically create a modal window:possible? -

in application displaying graphs using angular chart directives. what i'd accomplish display small version of graphs in main page , then, pressing button, display bigger version of specific graph inside of popup window. graphs populated @ run time, once small version of graph populated matter of changing size , copy canvas code inside of popup window, have no idea on how accomplish i'm asking help. here's plunker "http://plnkr.co/edit/eajx7nqwhmu7obvi4u8b" you need directive like: app.directive('graph', [function() { return { restrict: 'a', scope: { x: '@', y: '@', width: '@', height: '@' }, template: '' // code draw graph. }; }]); in way, can reuse directive in multiple place, changing parameters: <div graph width="100" height="200"></div> <div graph width="

assembly - How to translate armasm options or switches to NDK -

i have sample written in armasm syntax , translate compile ndk. , not know syntax ndk uses. told may gas. validate can learn little both syntax , see how can translate 1 other. comment on differences between desired syntax , have appreciated. how call appropriate c libraries call arm code c files, , switches pass compiler please.

java - How to avoid automatic entity update on Hibernate ValidationException -

i having spring method: validating entity after constructing of object, fetched db. @transactional(rollbackfor={validationexception.class}) public object approve(command command) throws validationexception { object obj = merger.mergewithexistingobject(command); // fetching object db old values , construct new object validatorservice.validate( obj ); // throws validationexception return saveobject(obj); } but unfortunately after validationexception thrown. values still persisted in db. how can avoid situtation. you can evict entity on validationexception : try { validatorservice.validate( obj ); } catch (validationexception e) { entitymanager.detach(obj); //or hibernate api //session.evict(obj); throw e; }

Copy certain values from dictionary in python -

i implementing dictionary data structure store per day results of climate model. stability reasons first , last 5 days left out. need plot values. there effective way this? the data of form: dict = { 'day1': 200435, 'day2': 23354235, ..., 'day30': 32435 } plt(dict.keys(), dict.values()) you can use pandas both filtering , plotting of data. data = {'day1':200435,'day2':23354235} df = pd.dataframe.from_dict(data, 'index').sort_index() # plot selected days df['day5':'day25'].plot()

ios - How to add a detailed view to a page view controller on button click -

i doing project using page view presents label , picture of product. idea put button on each page present view controller detailed information product on current page. problem can't come idea how achieve this. thankful if me achieve this. thanks in advance i think new started develop ios apps. not give code snippet project can give tip achieve. you want create master - detail page view. it's common pattern in ios development. you can create master-detail application theme in xcode. if want information, can search on google or stackoverflow master-detail keyword. happy coding...

javascript - Jquery - Calling 3rd tag -

i need activate third party tag on website when webpage show message "choisissez la finition" the div show message <div id="vw_dbs_ihdcc_trimselector" class="container containercolquarter"><h2>choisissez la finition</h2> i've tried function (session, cb){window.addeventlistener("hashchange", function() { if(document.location.hash.indexof("carimage") > -1) { var len2 = jquery("h2:contains('choisissez la finition')").length; if (len2 > 0) { cb(); } } }); } any advice, ? many thanks, what need following. function dosomething(session, cb){ if(location.hash.indexof("carimage") > -1) { var len = $("h2:contains('choisissez la finition')").length; if (len) { cb(); } } }); //define callback function function mycb() {

java - Ternary operator is not a statement -

i've following ternary expression: ((!f.exists()) ? (f.createnewfile() ? printfile() : throw new exception("error in creating file")) : printfile()); for one, or more, reason don't know idea ide me isn't statement. why? this not valid, need return value printfile() : throw new exception("error in creating file") try one if(f.exists() || f.createnewfile()) { printfile(); }else{ throw new exception("error in creating file"); }

php - How to prevent duplicate users in a registration page? -

http://programmerguru.com/android-tutorial/android-multicast-push-notifications-using-gcm/ i still quite new php , mysql. doing project using gcm (google cloud messenging). i have problem code when want register allows me register same username or email , big flaw in project. error having in file viewusers.php ; there way can register , check database if there existing user same username if there is? the app restrict user registering, , function check database see if there match user , display area user residing. you can set username unique . stops being able create user username. you can run query check if user there: select * `your_table` `username` = "username register" then check how many results got. if resultcount higher 0, have stop registration-process. to last question - same query before. sql-table has save it: select * `your_table` `username` = "username check" also advice use dots. hard fight me through text.

c++ - Overloading (c)begin/(c)end -

i tried overload (c)begin / (c)end functions class able call c++11 range-based loop. it works in of cases, don't manage understand , solve 1 : for (auto const& point : fprojectdata->getpoints()){ ... } this line returns error: error c2662: 'mycollection<t>::begin' : cannot convert 'this' pointer 'const mycollection' 'mycollection<t> &' because fprojectdata pointer const. if make non-const, work. don't understand why, considering cbegin() & cend() developped exactness begin() & end() functions. here functions developped (in header file) in mycollection: /// \returns begin iterator typename std::list<t>::iterator begin() { return objects.begin(); } /// \returns begin const iterator typename std::list<t>::const_iterator cbegin() const { return objects.cbegin(); } /// \returns end iterator typename std::list<t>::iterator end() { return objects.end(); } /// \return

Phone number formatting in Android -

in app, user enters phone number. example, if enters: 123456 want him see: 12 34 56 how can that? you can add text watcher edit text , check size of text till 2 place , add space in follows callphoneedittext.addtextchangedlistener(new customtextwatcherforphonenumber()); the following class required thing needed public static class customtextwatcherforphonenumber implements textwatcher { // change want... ' ', '-' etc.. private static final char space = ' '; @override public void ontextchanged(charsequence s, int start, int before, int count) { } @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void aftertextchanged(editable s) { // remove spacing char if (s.length() > 0 && (s.length() % 5) == 0) { final char c =

vb6 - Function returns empty result -

i getting empty msgbox when call function . have on code bellow public function custom(byval tablename string, _ byval employeecode string, byval fieldname string, byval datatocheck string, _ optional byval codefieldname string = empty, optional byval codefieldvalue string = empty) boolean dim lstrsql1 string dim lrstemp1 adodb.recordset lstrsql1 = " select " & fieldname & " " & tablename & " id_card_no =" & datatocheck & "" 'msgbox (lstrsql1) if len(trim$(codefieldname)) <> 0 , len(trim$(codefieldvalue)) <> 0 lstrsql1 = lstrsql1 & " , " & codefieldname & " <> '" & codefieldvalue & "'" end if set lrstemp1 = cobjdbconn.executesql(lstrsql1) if lrstemp1 nothing custom = false elseif not (lrstemp1.bof , lrstemp1.eof) custom = true elseif lrstemp1.recordcount = 0 custom = false else custom = false end if i