Posts

Showing posts from April, 2014

ios - How can i create array in ascending order when multiple Dictionary in Array -

i have 1 array multiple dictionary object keys date , type want arrange array in ascending order date key. my array : ( { date = "06 september 2016"; type = photo; }, { date = "06 september 2016"; type = video; }, { date = "07 september 2016"; type = photo; }, { date = "07 september 2016"; type = video; }, { date = "06 september 2016"; type = photo; }, { date = "06 september 2016"; type = photo; }, { date = "07 september 2016"; type = photo; }, { date = "01 october 2016"; type = photo; }, { date = "06 september 2016"; type = photo; } ) please me. how can arrange in ascending order date. you need use sortedarrayusingcomparator way sort date string. first convert date string nsdate using nsdateformatter , compare. nsdateformatter *df = [[nsdateformatter alloc] init]; [df set

php - Variable not returning a boolean yii 2 -

i have been working on code return boolean value, happens variable gets overwritten true or false looks row in foreach statements. when pass in view file no value taken/appears. can me why happening , how pass boolean? view file echo testcontroller::showprerequisites(29005); model $validator; foreach($prereq $values){ if(finishedsubjects::find()->where(['subjectname' => $values['col']])->exists()){ $validator = true; } else { $validator = false; } } return $validator; controller public function showprerequisites($trno){ $model = new testmodel(); return $model->showprerequisites($trno); } edit view update $preq = testcontroller::showprerequisites(29005); if($preq = true){ echo 'pre requites completed/read'; } else if($preq = false) { echo 'pre requisites not completed/not read'; } you have logical error in code, assigning value in if condition , checking, return true. ins

angularjs - javascript how to create function service (constructor) -

in angularjs if invoke service method: app.service('nameservice', function(){ this.service = function (){console.log('hello')} } then can use service (object) : nameservice.service() question how can write function have 2 arguments(name, function) function service ( name, function ){ // how angular declare object value of first argument ? } i'm ask how write function service(name,fn){} ? angularjs use dependency injection inject service. "service" method available on angular object because on prototype. angular.prototype.service = ... you can read more prototype inheritance, mdn - inheritance , prototype chain

regex - Notepad++ Removing text between two strings if third string is present between other strings -

i remove text between 2 strings, including strings, if , if third string present between 2 strings. prefer if use replace functionality in notepad++ this. here's mock-up of need altered: asdfnjaslfjsa asdfjaskldfsafkldj asdfjsadfk string_1 sanjvnlamf fas g gsegvrs string_2 string_1 asf sf gfsjasak qweuwiouqnv string_3 awi iavbfa c anfiab string_2 string_1 asmorancm anib fas string_2 sdabfashbdfbc ds changed this: asdfnjaslfjsa asdfjaskldfsafkldj asdfjsadfk string_1 sanjvnlamf fas g gsegvrs string_2 string_1 asmorancm anib fas string_2 sdabfashbdfbc ds what looking can achieved following construct: string_1 (?:(?!string_2)[\s\s])*? string_3 (?:(?!string_2)[\s\s])*? string_2 this matches string_1 string_2 if string_3 present in between (the technique called tempered greedy token ). can put in 1 line well: string_1(?:(?!string_2)[\s\s])*?string_3(?:(?!string_2)[\s\s])*?string_2 see a demo on regex101.com .

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null .

html - Iframe not going full screen -

as title says, can't manage have full scren iframe. here code: <div data-role="page" id="p'+item.id+'"><div data-role="header" style="background-color: #ffffff;border:none;" data-position="fixed"><a href="#" onclick="location.href=\'documenti.html\'" data-role="button" data-icon="back" data-iconpos="notext" class="ui-btn-left">home</a><img src="images/app/logo.png" id="navimg"/></div><iframe src="https://docs.google.com/gview?embedded=true&url=http://' + item.path + '" width="100%" height="100%" align="center" ></iframe></div> demo: https://jsfiddle.net/579sxg8s/ you can add first div element: style="width: 100vw; height: 100vh;" set height , width of div 100% of viewportheight / viewportwidth since

java - Remove all characters after certain sequence -

i wanted remove characters after end of first number sequence. edit: (sorry ambiguity) the string may or may not start letters, in case starts letters should preserved. after first sequence of numbers, should removed. e.g. qwee1232rty -> qwe1232 123rty -> 123 12342 -> 12342 str.replaceall("[^a-z][^0-9]+",""); this should work it's giving unexpected output , not printing repeated "2". my ideone code attempt , it's respective outputs import java.util.*; import java.lang.*; import java.io.*; class ideone { public static void main (string[] args) throws java.lang.exception { string str = "bctc27452asdfccc"; system.out.println(str.replaceall("[^a-z0-9]","")); // bctc27452asdfccc system.out.println(str.replaceall("[^a-z0-9]$","")); // bctc27452asdfccc sys

javascript - Why do my phantomjs script output no screenshot (command line args version) -

i modified basic phantomjs example here http://phantomjs.org/screen-capture.html accept command line args. when pass http://google.com argument console.log outputs correct 0: index.js 1: http://google.com but don't thumbnail.png in folder why ? var page = require('webpage').create(); var system = require('system'); var args = system.args; var url; if (args.length === 1) { url = 'http://github.com/'; } else { args.foreach(function(arg, i) { console.log(i + ': ' + arg); if (i > 0) { page.open(arg, function() { page.render('thumbnail' + '.png'); }); } }); } phantom.exit(); page.open asynchronous function, therefore phantom.exit being called before callback render thumbnail. move phantom.exit inside callback specified in docs var page = require('webpage').create(); page.o

powerbi - Use Slicer selection in calculated column (Parameter) -

Image
i have: - slicer dates , table 'log' column 'date' dates , column 'max' numbers (e.g. 0,31) i need calculate average of values in column 'max' when date before slicer selection date - , average after. end result: card visualisation average of values before selected date , card visualisation average of values after selected date. create 3 measures: avg = average('log'[max]) averageafterselecteddate = calculate ( [avg], filter ( ( 'log' ), [date] > minx ( 'log', 'log'[date] ) ) ) averagebeforeselecteddate = calculate ( [avg], filter ( ( 'log' ), 'log'[date] < minx ( 'log', [date] ) ) ) just use averagebeforeselecteddate , averageafterselecteddate measures in cards. for data: it produces: let me know if helps.

bash script read server and not read password -

i use curl open username , password router curl http://192.168.1.1 --user admin:admin |grep -i "stats" but when made code use curl bash script have problem read server , password file `links_file="server" pass="passwd" link in `cat "$links_file"` pass in `cat "$pass"` res=$(curl -m 1 "http://${link}:8080" --user admin:${pass} ) if echo $res | grep -i "stats"; `

search - SQL query over multiple inputs -

i've got table containing number of text columns, , need able query table using search term. single terms, simple... select * things @searchterm in (column1, column2...columnx) however, need search on multiple terms in single query, like... select * things @searchterms in (column1, column2...columnx) ...where @searchterms collection of values, rather single value. there way emulate behaviour in sql? update: thank @tedo g., unfortunately need query use and between different terms. i've added change yours group results , ensure count per distinct result matches number of terms... select * things inner join @searchterms b on b.[fieldname] in (column1, column2...columnx) group column1, column2...columnx having count(column1) = @numberofsearchterms ...this works, there better way? one other way achieve make table variable , fill search term values, join : select * things inner join @searchterms b

javascript - How can I set a default property for an object that's passed into a constructor? -

i'm trying make change in 1 spot affect config object passed instantiations of object. object made available globally follows: function crayons(){ return { foo: thirdpartyfoo } } the object initialized in project var myfoo = new crayons().foo({color: "red"}); i'd make {color: "blue"} default, if doesn't pass in color, blue set. i tried doing function crayons(){ var foowithdefaults = function(){ = new thirdpartyfoo(arguments); //this invalid this.color = "blue"; //and overwrite color if set } return { foo: foowithdefaults } } but new keyword throwing me off, don't know how create javascript constructor says this = new 3rdpartyfoo . what missing? you can either decorate constructor: function crayons(){ function foowithdefaults() { 3rdpartyfoo.apply(this, arguments); // you're looking if (!this.color) // or whatever detect "not set" this.color = "bl

c# - Deserialization of IOrderedEnumerable<T> with JSON.NET -

my team , came accross weird behavior json.net deserialization in c#. we have simple viewmodel iorderedenumerable<long> : public class testclass { public iorderedenumerable<long> ordereddatas { get; set; } public string name { get; set; } public testclass(string name) { this.name = name; this.ordereddatas = new list<long>().orderby(p => p); } } then, want post/put viewmodel in api controller [httppost] public ihttpactionresult post([frombody]testclass test) { return ok(test); } calling api json : { name: "tiit", "ordereddatas": [ 2, 3, 4 ], } with call, saw constructor wasn't called (which can explained fact it's not default constructor). strange thing if change type of collection ienumerable or ilist , constructor called. if change constructor of testclass default 1 : public class testclass { public iorderedenumerable<long> or

android - universal image loader not working for Relative layout in ArrayAdapter -

Image
i have list of image path's in json response. prompt set images background of relative layout path. on have been advised , used arrayadapter , universal image loader achieve this.i hope myself 95% have done this. problem loaded 1 image in ui 2 images have in json response. here tried in arrayadapter class inside getview() method relativelayout laycontentoflistview; // initialize relative layout container laycontentoflistview = (relativelayout)rowview.findviewbyid(r.id.laycontentoflistview); // load image, decode bitmap , return bitmap callback imagesize targetsize = new imagesize(150, 100); // result bitmap fit size imageloader.loadimage(fullimagepath, targetsize, new simpleimageloadinglistener() { @override public void onloadingcomplete(string imageuri, view view, bitmap loadedimage) { if (loadedimage != null) { drawable d = new bitmapdrawable(context.getresources(), loadedimage);

javascript - jsreport-core: using header with phantom-pdf receipe -

i've jsreport-core based app, content template renderd fine, header not renderd. here the basic steps in app: import jsreportcore 'jsreport-core'; import jsreportfsstore 'jsreport-fs-store'; import jsreporttemplates 'jsreport-templates'; import jsreportjsrender 'jsreport-jsrender'; import jsreportphantompdf 'jsreport-phantom-pdf'; import jsreportexpress 'jsreport-express'; // ... jsreport.use(new jsreportfsstore({datadirectory: "data", syncmodifications: true})); jsreport.use(new jsreporttemplates()); jsreport.use(new jsreportjsrender); jsreport.use(new jsreportphantompdf()); jsreport.use(new jsreportexpress({app : app})); // ... const jsreport = new jsreportcore({ loadconfig: false, autotempcleanup: true, connectionstring: { 'name': 'fs' }, tasks: { allowedmodules: '*' } }); // ... jsreport.render({ template : {name: "foo",engine: "jsrender",recipe:&qu

javascript - Iframe content not loading in firefox -

i have iframe in pop up. content of iframe's set $('.document-acceptance-container .documentiframe').contents().find('body').html(this.model.get('data').documentrecord.documentbodypath); it work's fine in chrome , content of iframe loaded, in firefox iframe empty. set security.mixed_content.block_active_content false , disabled addblock. but didn't me.if set breakpoint on line in debug mode in firefox - content loaded. have idea? p.s: documentrecord.documentbodypath html code

Need to rank a dataset based on 3 columns in R -

this question has answer here: generate sequence within group in r [duplicate] 1 answer i have dataset ordered using function order() in r , same shown below a b c 1 1 85 1 1 62 1 0 92 2 1 80 2 0 92 2 0 84 3 1 65 3 0 92 i've print rank based on column , expected output shown below a b c rank 1 1 85 1 1 1 62 2 1 0 92 3 2 1 80 1 2 0 92 2 2 0 84 3 3 1 65 1 3 0 92 2 request expertise in r a simple base r solution using ave , seq_along is df$rank <- ave(df$b, df$a, fun=seq_along) which returns df b c rank 1 1 1 85 1 2 1 1 62 2 3 1 0 92 3 4 2 1 80 1 5 2 0 92 2 6 2 0 84 3 7 3 1 65 1 8 3 0 92 2 seq_along returns vector 1, 2, 3, ... length of argument. ave allows user apply function groups determined here variable a. data df <

ffmpeg buffer queue drop overflow, dropping -

i got buffer queue drop overflow, dropping error when try run code ffmpeg.exe -i input.mkv -i logo.png -loop 1 -report -filter_complex "overlay=20:15,subtitles ='sub.srt'" -c:a copy -q:v 1 -f segment -segment_time 600 "out_%d.ts" but if removed overlay in complex filter works find produce video without logo the following command working without logo ffmpeg.exe -i input.mkv -i logo.png -loop 1 -report -filter_complex "subtitles ='sub.srt'" -c:a copy -q:v 1 -f segment -segment_time 600 "out_%d.ts"

html - What does "overflow" do for this <ul> tag? -

i creating header menu using <ul> , wanted stretch top of page. first used width:100% didn't work.then saw similar example somewhere , had used overflow:hidden when used streched list end.i wanted know overflow in here , why width:100% can not similar action? ul { list-style-type: none; padding: 0; margin: 0; overflow: hidden; background-color: black; } li { background-color: black; color: red; float: left; } li a{ display: inline-block; color: white; text-decoration:none; padding: 20px; text-align: center; } li a:hover{ background-color:red; } <!doctype html> <html lang="fa"> <head> <link rel="stylesheet" type="text/css" href="menu.css"> </head> <body> <ul> <li><a target="_blank" href="http://www.google.com">google</a></li> <li><a target="_blank" hr

ios - Trouble Getting JSON Array -

i'm having issue getting json array using swift. func getbenefitjson() -> [anyobject] { let urlstring = string("https://www.kyfb.com/kyfb/includes/themes/codeblue/display_objects/custom/remote/webservices/services.cfc?method=getmemberbenefits") let url = url(string: urlstring!) var data = data() { data = try data(contentsof: url!) } catch { } print("url data: \(data)") { let json = try jsonserialization.jsonobject(with: data, options: jsonserialization.readingoptions()) as! [anyobject] print("json: \(json)") return json } catch { print("could not json") return [] } } i data url empty array returned. doing wrong? url data: 42769 bytes not json below response of json [{"image":"https://cdn.kyfb.com/kyfb/cache/file/70162997-e06b-e9b6-88514280ca8397cc_medium.

xamarin.android - Convert StackLayout as Image in Xamarin -

i'm working on xmarin forms(pcl) project, want convert stacklayout image / buffer , send printer hard print. can suggest how in (xamarin.android & xamarin.ios). you can't. xamarin not have kind of feature. should write renderer uicomponent. fortunately there objective-c ios implementation, , android 1 well. can inspire them.

testing - Where is the ISO for Test Agents for Visual Studio 2015? -

Image
we have tfs2015 , trialling visual studio enterprise 2015 (no installation disk). i looking iso microsoft test agents visual studio 2015 . documentation vs 2015 states these isos should available: i can web installer (exe) agents here, can iso? please note : need iso hold of test controller 2015 run load tests , having agents not enough. also, have tried using test agents 2015 test controller 2013, , agent configuration fails time out (whilst attempting restart service). and finally, have tried using test agents 2013 tfs2015, fails "registry lookup failed" error on "agent deployment" build step in our build definition (the powershell scripts used in step assume there path installed test agent 2015 in registry). problem fixed providing path test agent 2015 installer in "test agent location" property of build step. so, i trying locate iso test agents visual studio 2015 - know can from, please? it announced test agent 2015 no lon

java - How to add mouselisteners outside the constructor -

in example below, both button , button2 supposed become unclickable when press them. when press reset button, 2 disabled buttons supposed work again. since made 2 buttons unclickable removing mouselisteners, how add mouselisteners using check() method still function in same way again? public static boolean isreset = false; public static jbutton button = new jbutton("disable button 1"); public static jbutton button2 = new jbutton("disable button 2"); public static jbutton reset = new jbutton("reset buttons"); test() { settitle("button test"); setsize(420, 80); setlocationrelativeto(null); setdefaultcloseoperation(jframe.exit_on_close); jpanel buttons = new jpanel(new gridbaglayout()); gridbagconstraints gc = new gridbagconstraints(); gc.fill = gridbagconstraints.both; gc.gridheight = 1; gc.gridwidth = 1; gc.gridx = 0; gc.gridy = 0; buttons.add(button, gc); gc.gridx = 1; gc.gridy =

mysql - Efficient SQL statement -

Image
on getting random associative array pairs fields product_option_id:product_option_value_id {"230":"23","228":"19"}, have minimum quantity respective rows in above tablex. currently, query database through php based on each pair, , store quantity. i.e.- if there 3 pairs, query database 3 times based on each pair 3 quantities. loop through quantities least one. if random {product_option_id:product_option_value_id} pairs {"230":"23","228":"19"}, can make efficient sql statement gets minimum quantity . i have tried select quantity tablex product_option_id=variable_product_option_id , product_option_value_id=variable_product_option_value_id i run in php loop pair values. store quanity, , least 1 through php you may try query one: select product_option_id, product_option_value_id, min(quantity) product_option_value (product_option_id = 230 , product_option_value_id = 43)

Config transform error setting up Episerver 9 Commerce project -

i following instructions set new episerver 9 commerce site. i've followed instructions at: http://world.episerver.com/documentation/items/installation-instructions/installing-episerver/#commerce when install nuget package episerver.commercemanager following error: an error occurred while applying transformation 'web.config' in project 'webcommerceapplication' no element in source document matches '/configuration/system.servicemodel/services' what do wrong? it seems have transform element that's missing in web.config . make sure have element like... <configuration> <system.servicemodel> <services /> <system.servicemodel> <configuration> ...in web.config .

If error, next iteration in a for loop in R -

i'm looking simple way move on next iteration in loop in r if operation inside loop errors. i've recreated simple case below: for(i in c(1, 3)) { test <- try(i+1, silent=true) calc <- if(class(test) %in% 'try-error') {next} else {i+1} print(calc) } this correctly gives me following calc values. [1] 2 [1] 4 however once change vector in include non-numeric value: for(i in c(1, "a", 3)) { test <- try(i+1, silent=true) calc <- if(class(test) %in% 'try-error') {next} else {i+1} print(calc) } this loop doesn't work. hoping same calc values above vector excluding non-numeric value in i. i tried using trycatch following: for(i in c(1, "a", 3)) { calc <- trycatch({i+1}, error = function(e) {next}) print(calc) } however, following error: error in value[[3l]](cond) : no loop break/next, jumping top level could please me understand how achieve using loop in r? as dason noted, atomi

How to remove duplicates from where in rails -

i have code here popular = impression.select('impressionable_id, count(impressionable_id) total').group('impressionable_id').order('total desc').limit(9) @events = event.where(id: popular.map(&:impressionable_id)) however what's happening @ moment @events returning duplicate names. i'm wondering how return them without returning names match. update here's mean, basically @events working fine, can call @events.eventname , 9 different events in view. however, if example charity fun day appears twice (has 2 different ids) wouldn't want event name appear twice in this. @events = event.where(id: popular.map(&:impressionable_id)).uniq will give unique event items. if there events different same names can @events = event.where(id: popular.map(&:impressionable_id)) @events.uniq{|event| event.name }

java 8 - javafx-TableView as combobox popup (Tried and able to achieve partially. need help further) -

Image
what need: need editable combobox filters data on popup upon typing , first matching item should highlighted , should set text in combo upon pressing enter. the popup should tableview 2 or 3 columns. (screen shot attached.)(in image textfield prefer combo if user not sure values, can click combo button , see entire list , select one.) i binding data source tableview should act popup combobox. know should go custom control dont know start? reference url: enter link description here thanks in advance. what have tried far: guys, with idea guys gave, have tried far , able achieve. (for now, not showing tableview dynamically below text field (eventually dats wat want)) 1. tableview static data loaded , added scene. 2. having text field below tableview. (this named txt) 3. having text field below first text field(this named txt1) (when press tab previous text field cursor should come here) i have predicate set table , updating predicate user types in txt. (working) a

c++ - how can returning a type instead of a object be valid, misunderstanding a code fragment -

i tried out boost msm lite nice state machine implementation. try understand how working , found code fragment can't understand. as remark: not post whole file boost here, here: https://github.com/boost-experimental/msm-lite/blob/master/include/boost/msm-lite.hpp the test code understanding things behind curtain: auto x2 = "test"_t; //compiles fine! that should go code fragment: template <class t, t... chrs> auto operator""_t() boost_msm_lite_noexcept { return event<aux::string<chrs...>>; // ??? how can work? } my (mis)understanding here is, return type instead of instance of type? compiles... why? event defined as: template <class> struct event { template <class t, boost_msm_lite_requires(concepts::callable<bool, t>::value)> auto operator[](const t &t) const boost_msm_lite_noexcept { return transition_eg<event, t>{*this, t}; }

c# - Array indexer signature returns object - does it box? -

i stumbled on fact indexer this[int index] { get; } works differently array of structs list of structs. namely, indexer in case of t[] returns reference element within array whereas indexer in case of list<t> returns copy of element. this big semantic , performance difference, , i'm glad t[] allows work around performance limitation of list<t> . however, i'm puzzled actual implementation. code array in .net reference sources reads thus: object ilist.this[int index] { { return getvalue(index); } set { setvalue(value, index); } } where getvalue defined follows: public unsafe object getvalue(int index) { if (rank != 1) throw new argumentexception(environment.getresourcestring("arg_need1darray")); contract.endcontractblock(); typedreference elemref = new typedreference(); internalgetreference(&elemref, 1, &index); return typedreference.internaltoobject(&elemref); } the return type of indexe

amazon web services - environment variables in shiny-server -

i'm trying deploy shiny app using shiny-server . app uses aws.s3 package read files s3 bucket, requires aws credentials either stored in environment variables or in .renviron file. understandably, shiny-server scrubs environment variables before launching r . there way square circle? other mechanism use pass credentials aws.s3?

java - WebView Placed in a Fragment doesn't load -

let's start code. main activity: package it.mdibonito.futuroremoto; import android.app.activity; import android.graphics.bitmap; import android.support.design.widget.tablayout; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.view.viewpager; import android.os.bundle; import android.view.keyevent; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.textview; public class mainactivity extends appcompatactivity {