Posts

Showing posts from March, 2013

c# - wpf, register DP, bindable converter parameter -

[valueconversion(typeof(object), typeof(object))] public class bindableconvertor : dependencyobject, ivalueconverter { public object bindableparameter { { return getvalue(mypropertyproperty); } set { setvalue(mypropertyproperty, value); } } public static readonly dependencyproperty mypropertyproperty = dependencyproperty.register( nameof(bindableparameter), typeof(object), typeof(bindableconvertor), new propertymetadata(string.empty) ); public object convert(object value, type targettype, object parameter, cultureinfo culture) { // actions here... } public object convertback(object value, type targettype, object parameter, cultureinfo culture) { throw new notimplementedexception(); } } xaml: <application.resources> <local:bindableconvertor x:key="myconvertor" bindableparameter="{binding anytargetproperty}" />

Count the number of lines in a file - C -

i'm receiving input file, bunch of lines. want able count lines analyse them. the input many lines of code integers. ex: 3 2 1 2 2 3 4 3 1 2 2 3 3 4 here's tricky part: first line has 2 numbers: 3 , 2. (the 3 isn't relevant now). 2 important. represents number of lines have read , save. so, according example have save lines 1 2 2 3 so why there other lines? - ask. well, let's see input blocks. after line 3 2 read 2 lines. it's block ended. then, line 4 3 came along. means have exact same thing did first block. so, line 4 3 know have read , save next 3 lines. meaning lines 1 2 2 3 3 4 i've been head on hills , can't seem find possible solution when you've got problem this, it's useful think of structure first. here's 1 method in simple pseudocode main algorithm started. people can't unless present code , problem it. declare line buffer array while (read line buffer == succeeds) { scan buffer 2 numbers (m, n

java - How to access command line arguments in Spring configuration? -

i have spring boot application uses spring integration stored procedure inbound channel adapter. pass command line argument stored procedure. spring boot doc says springapplication convert command line option arguments starting ‘--’ property , add spring environment. correct way access property in int-jdbc:parameter element? application.java import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.context.configurableapplicationcontext; @springbootapplication public class application { public static void main(string[] args) throws exception { configurableapplicationcontext ctx = new springapplication("integration.xml").run(args); system.out.println("hit enter terminate"); system.in.read(); ctx.close(); } } integration.xml <int-jdbc:stored-proc-inbound-channel-adapter stored-procedure-name="sp_get_some_records&

javascript - Appending a to-do list -

i trying make "to list" app. trying append put in input list under "to do" "done" button. here have far: html: <!doctype html> <html> <link rel="stylesheet" text="text/css" href="doneit.css"> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> </head> <body> <div id="container"> <input type="text" id="task" placeholder="new task"/> <button id="enter">enter</button> <div class="todo"> <ul id="chores"><h2>to do:</h2></ul> </div> <button id="reset">new list</button> </div> <script type=

php - Joomla: can't find code of something -

i need change information in block in sidebar. found need in temples/mytemplate/index.php file. here can see such tag (_rss_news): enter image description here how can find code of _rss_news example? _rss_news example, need thing. main question it? , how find it? <?= _variable ?> i tried find need in database, , tried open lot of files , seatch tag. efforts unsuccessful... i'm using old joomla. problem doesn't here. please me! thank much! do use ide netbeans ??i has hint or autocomplete,and perfect.i more dreamweaver shouldn't ( never) try finding methods,varrible test , errors. netbeans work easly conditionally function defined. should developing web should extentions webdevoloper , firebug easy in devoloping. goodluck

c++ - error C2664: 'pthread_create' : cannot convert parameter 3 from 'void *(__clrcall *)(void *)' to 'void *(__cdecl *)(void *) -

i trying use pthread library. what cause of error? error c2664: 'pthread_create' : cannot convert parameter 3 'void *(__clrcall *)(void *)' 'void *(__cdecl *)(void *) here's code: pthread_create(&thread1,null,sub_m,(void *)data); void *sub_m(void* data) make void __cdecl sub_m(void *data) . in managed code, need proper calling convention.

sql - Unable to comprehend why a WHERE clause is being accepted -

this question has answer here: sql - having vs where 7 answers i trying understand difference between having , where. understand having used group statements. however, cannot understand why following statement accepted: select sum(child_id) children child_id = 5 group child_id shouldn't correct statement select sum(child_id) children group child_id having child_id = 5 ? where clauses executed before grouping process has occurred, , have access fields in input table. having performed after grouping pocess occurs, , can filter results based on value of aggregate values computed in grouping process.

Creating multiline strings in JavaScript -

i have following code in ruby. want convert code javascript. what's equivalent code in js? text = <<"here" multiline string here update: ecmascript 6 (es6) introduces new type of literal, namely template literals . have many features, variable interpolation among others, importantly question, can multiline. a template literal delimited backticks : var html = ` <div> <span>some html here</span> </div> `; (note: i'm not advocating use html in strings) browser support ok , can use transpilers more compatible. original es5 answer: javascript doesn't have here-document syntax. can escape literal newline, however, comes close: "foo \ bar"

ios - Ionic push notification api in c# -

so based on tom raz post ionic push notification api in c# webapi . tried implement method send push notification using ionic push notifications api here code: public void sendtoionic(string regid, string msg) { using (var client = new httpclient()) { string data = "{ \"user_ids\":[\" "+ regid + "\"],\"notification\":{\"alert\":\" "+ msg + "\"}}"; string json = newtonsoft.json.jsonconvert.serializeobject(data); client.baseaddress = new uri("https://push.ionic.io/api/v1/push"); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.add("x-ionic-application-id", "1d74b1f2"); var keybase64 = "basic %s" + "53a03dc7d9ce58511263e40580294f62af36b89be7cc4db2"; client.defaultrequestheaders.add("authorization", keybase64);

go - Can I compare variable types with .(type) in Golang? -

i'm quite confused .(type) syntax interface variables. possible use this: var a,b interface{} // code if first.(type) == second.(type) { } or reflect.typeof() option check if underlying types of , b same type? comparison making in code above? someinterface.(type) only used in type switches. in fact if tried run you'd see in error message. func main() { var a, b interface{} = 1 b = 1 fmt.println(a.(type) == b.(type)) } prog.go:10: use of .(type) outside type switch what instead a.(int) == b.(int) , no different int(a) == int(b) func main() { var a, b interface{} = 1 b = 1 fmt.println(a.(int) == b.(int)) } true

ruby - Rails 3 update scope with conditions, include, and args to Rails 4 -

i'm upgrading rails 3 code base rails 4 , have been updating use new scope style , querying interface. i'm unsure how switch on scope using include conditions in scope's lambda. scope :search_stuff, lambda { |search| search_conditions = array.new(4, "%#{search}%") { :include => {:sponsor => [], :routing_form_pi_users => [:user], :item => []}, :conditions => ["id ? or title ? or users.name ? or sponsors.name ?", *search_conditions] } } when compare documentation query interface in different versions of rails guide can see interface eager loading of multiple associations didn't change much. the example in rails 2.3.8 syntax: category.find 1, :include => {:posts => [{:comments => :guest}, :tags]} the example rails 4.2 syntax: category.includes(articles: [{ comments: :guest }, :tags]).find(1) therefore should possible copy old nested hash new syntax: scope :search_stuff, l

javascript - Angular2 Nested Components : Error: core_2.Input is not a function Error loading http://localhost:9080/app/boot.js -

i have 3 components. 1. rubric editor 2. rubric criteria editor 3. rubric descriptor editor rubric editor main component loaded in router outlet. rubric editor loads rubric criteria editor expects input object, , rubric criteria editor loads rubric descriptor editor expects input object. but this, doesnt works. , core2.input not function error on @input line in rubric descriptor editor. (the error blocks boot.ts , nothing runs) full stack trace: error: core_2.input not function error loading http://localhost:9080/app/boot.js stack trace: .execute/rubricdescriptoreditorcomponent<@http://localhost:9080/app/components/rubric/rubric-editor-descriptor.js:44:21 .execute@http://localhost:9080/app/components/rubric/rubric-editor-descriptor.js:37:48 ensureevaluated@http://localhost:9080/node_modules/systemjs/dist/system.src.js:2981:5 ensureevaluated@http://localhost:9080/node_modules/systemjs/dist/system.src.js:2973:11 ensureevaluated@http://localhost:9080/node_modules/systemjs

html - Line-height causing uneven divs -

Image
i 2 divs sit beside each other , aligned @ bottom. have button , when set line-height on drops slightly. i'll show example images. what desire: what happening: the following codepen shows drop: http://codepen.io/basickarl/pen/kvxqxr?editors=110 html: <div class="div1"> hello<br> hello<br> hello<br> hello<br> hello<br> hello<br> </div> <div class="div2"> <button class="butt">push meh</button> </div> css: .div1 { display: inline-block; background: red; } .div2 { display: inline-block; background: lime; } .butt { line-height: 40px; background: lightblue; } i understand text in button aligned , line-height creates kind of bubble around it. ways them aligned anyhow? add vertical-align:bottom .div2 (and/or .div1 ): .div2 { display: inline-block; background: lime; vertical-align:bottom; } codepen example the defaul

rest - Accepting api keys in HTTP headers or JSON POST data -

i have http json endpoint localhost:8000/resource/ takes json data input , returns json output. adding api key based authorization endpoint. there 2 ways accept api key @ endpoint: method a: in request headers example python code: import requests headers = { 'api-key': '<my-api-key>', } r = requests.post('http://localhost:8000/resource/', json={'input': <value>}, headers=headers) method b: in json data itself example python code: import requests r = requests.post('http://localhost:8000/resource/', json={'input': <value>, 'api-key': '<my-api-key>'},) i notice method a being adopted. there wrong latter approach in api key passed along other json data? i think has clarity, api key isn't relevant input, it's form of authorization. large frameworks deal routing , such able filter based on specific heade

c++ - Visual Studio 2010 Creating Packages/Folders in project -

i new visual studio 2010 c++ , trying create packages in project in java eclipse surprise option found available creating folder selected , created several folders added classes them tried including header files in folders had created keeps giving me error hat cannot locate file, checked in project directory , folders not in there visible , editable visual studio , tried manually adding folder classes windows explore , still not locate them in vc the logic organized different in eclipse. with visual studio, create solution (one directory) in create one or more projects (either in solution's directory, or in 1 or several subdirectories. have in components shared library example, put in separate project. the source files in each project organized in same directory . if use folders in project, these virtual , not materialized in os directories. remark: if want organise project files within "hard" subdirectories, can force directory in item creat

sql - Why are redundant records being inserted with this TSQL Stored Procedure? -

when run portion of stored procedure in linqpad: create table #temp1 ( memberno varchar(25), memberitemcode varchar(25), shortname varchar(25), itemcode varchar(50), wvitem varchar(25), wvitemcode varchar(25), wvdescription varchar(250), week1usage varchar(25), week1price varchar(25) ) insert #temp1 (memberno, memberitemcode, wvitemcode, wvdescription, week1usage, week1price) select memberno, itemcode, wvitemcode, description, sum(qtyshipped), price invoicedetail unit=@unit , invoicedate between @begin , @enddate group description, memberno, itemcode, wvitemcode, price select * #temp1 order memberitemcode; ...i hope for, namely 1 row of data each memberitemcode, qtyshipped summed in column. however, when populate related table "week2" values, , combine them, this: create procedure [dbo].[pricevariancetest] @unit varchar(25), @begdate datetime, @enddate datetime declare @week1end datetime = dateadd(day, 6, @beg

ruby on rails - How can I make this method more concise? -

i warning when running reek on rails project: [36]:arborreloaded::userstoryservice#destroy_stories has approx 8 statements (toomanystatements) here's method: def destroy_stories(project_id, user_stories) errors = [] @project = project.find(project_id) user_stories.each |current_user_story_id| unless @project.user_stories.find(current_user_story_id).destroy errors.push("error destroying user_story: #{current_user_story_id}") end end if errors.compact.length == 0 @common_response.success = true else @common_response.success = false @common_response.errors = errors end @common_response end how can method minimized? first, find class , method size useful finding code might need refactoring, need long class or method. , there way make code shorter around such limits, might make less readable. disable type of inspection when using static analysis tools. also, it's unclear me why you'd expect have error

javascript - Meteor : redirect if user didn't create page -

in meteor have product edit page. want user created product see page. otherwise redirected. is there way redirect iron router only? if not i'll take solution. router.js var onbeforeactions; onbeforeactions = { ownerrequired: function(pause){ if(!meteor.userid()){ router.go('home'); }else if(meteor.userid()._id != ....something?....){ router.go('home'); }else{ this.next(); } } }; router.onbeforeaction(onbeforeactions.ownerrequired, { only: ['editproduct'] }); router.route('/editproduct/:_id',{ template: "editproduct", name: "editproduct", data: function(){ return products.findone({_id: this.params._id}); } }); so if want know how solve without iron router . this. (note check onbeforeaction if user logged in.) template.editproduct.oncreated(function(){ if(this.data.user === meteor.userid()){ }else{ router.go('home'

algorithm - Non-recursive breadth-first traversal without a queue -

in generic tree represented nodes having pointers parent, siblings, , firs/last children, in: class tnode { def data tnode parent = null tnode first_child = null, last_child = null tnode prev_sibling = null, next_sibling = null tnode(data=null) { this.data = data } } is possible iterative (non-recursive) breadth-first (level-order) traversal without using additional helper structures such queue. so basically: can use single node references backtracking, not hold collections of nodes. whether can done @ theoretical part, more practical issue whether can done efficiently without backtracking on large segments. yes, can. tradeoff , cost more time. generally speaking, 1 approach understand 1 can implement traversal without memory in tree . using that, can iterative deepening dfs , discovers new node in same order bfs have discovered them. this requires book-keeping, , remembering "where came from", , deciding next based

javascript - Trying to use Jasmine spies and getting "is not a function" errors -

here class: class clock { // runs callback while continues // returns truthy values constructor(callback, delay) { this.callback = callback; this.delay = delay; this.timerid = null; } start() { this.timerid = settimeout(() => { if (this.callback.call()) this.start(); }, this.delay); } // want kill time? kill() { cleartimeout(this.timerid); } } export default clock; and relevant tests: import clock '../../src/js/lib/clock.js'; describe("clock", function() { it("has callback , delay", function() { let clock = clockfactory(); expect(clock.callback).tobedefined(); expect(clock.delay).tobedefined(); }); describe("is clock", function() { let observer, clock; beforeeach(function() { jasmine.clock().install(); observer = { callback: function() {} }; spyon(observer, 'callback') console.log(observer) clock = clockfacto

Unix remove duplicates,sort and display the max count -

3/12/2013 12:00 639 count 3/12/2013 12:06 693 count 3/12/2013 12:12 636 count 3/12/2013 12:18 649 count 3/12/2013 12:24 658 count 3/12/2013 12:30 926 count 3/12/2013 12:36 721 count 3/12/2013 12:42 797 count 3/12/2013 12:48 717 count 3/12/2013 12:00 639 count 3/12/2013 12:06 700 count 3/12/2013 12:12 636 count 3/12/2013 12:18 649 count 3/12/2013 12:24 658 count 3/12/2013 12:30 726 count 3/12/2013 12:36 721 count 3/12/2013 12:42 850 count 3/12/2013 12:48 900 count 3/12/2013 12:00 639 count 3/12/2013 12:06 693 count 3/12/2013 12:12 636 count 3/12/2013 12:18 649 count 3/12/2013 12:24 658 count 3/12/2013 12:30 926 count 3/12/2013 12:36 721 count 3/12/2013 12:42 797 count 3/12/2013 12:48 950 count output should below: 3/12/2013 12:00 639 count 3/12/2013 12:12 636 count 3/12/2013 12:18 649 count 3/12/2013 12:24 658 count 3/12/2013 12:30 926 count 3/12/2013 12:36 721 count 3/12/2013 12:06 700 count 3/12/2013 12:30 726 count 3/12/2013 12:42 850 count 3/12/2013 12:48 900 count

ios - NSDate conversion to NSString doesn't follow NSDateFormatter -

this question has answer here: what best way deal nsdateformatter locale “feechur”? 4 answers i have problems nsdate nsstring conversion, have following code in method nsdateformatter *formatter = [[nsdateformatter alloc] init]; nstimezone *timezone = [nstimezone timezonewithname:@"utc"]; [formatter settimezone:timezone]; [formatter setdateformat:@"yyyy'-'mm'-'dd't'hh':'mm':'ss'.'zzz'"]; return [formatter stringfromdate:date]; if i´m not mistaken should return string "2016-01-15t22:45:40.gmt" but resulting string depends on device configuration, meaning if device shows date 24 hour result above, on other hand if device configured show house a.m. p.m. "2016-01-15t10:46:50 p.m..gmt" from documentation: although in principle format string specifies fixed

angularjs - Jasmine (via TypeScript) test to verify scope $on is called -

i have search around few places ideas on this. how unit test $scope.broadcast, $scope.$on using jasmine $scope.$on not working in jasmine specrunner it has helped think seems still missing something. trying test controller has $rootscope.$on in code. in unit test trying trigger $broadcast $on gets , code runs. current code not working. here controller: constructor($state: ng.ui.istateservice, store: angular.a0.storage.istoreservice, jwthelper: angular.jwt.ijwthelper, $rootscope: any) { this.currentdate = new date(); this.state = $state; this.store = store; this.jwthelper = jwthelper; this.userfullname = ''; $rootscope.$on('$statechangestart', (event: any, tostate: any, toparams: any, fromstate: any, fromparams: any, error: any) => { var jwttoken = this.store.get('token'); if (jwttoken != null) { var decodedtoken: = this.jwthelper.decodetoken(jwttoken); }

git - Github revert error "Unable to revert commit" -

so trying revert previous version of program when corrupted. now, in code have various lines of code scattered throughout effect of: <<<<<<< head ======= >>>>>>> parent of 410c297... "safe version" ======= etc. when try revert previous point again, says, "unable revert commit, (digits) (name) i have basic understanding of git terminal, can't fix myself. can pointers? reverting creates new commits change existing committed files. you've got merge in progress, means can't revert. most likely, want reset: want go existing commit , pretend haven't done work. common way of doing rid of changes , in-progress merges resetting head this: git reset --hard head afterwards, if want go earlier version, can revert or maybe checkout older version. or can both @ same time using ~ notation: git reset --hard head~3 means undo , go 3 commits.

mongodb - mongo installation and data in different locations -

i installed mongodb in usr/local/mongodb data in project directory desktop/root/data/db i want use mongo shell @ data. if run usr/local/mongdb/bin/mongo show me data in project/data/db directory? or there command need run .../bin/mongo tell data is? i tried --dbpath didn't work

javascript - datatables does not load json (array with objects) -

i'm trying setup datables sorced data ajax. file outputs array objects: [{"column":"content","column":"content"}] but it's not loading data, keeps proccessing. $('#example').datatable( { processing: true, lengthchange: false, ajax: '/get?op=2', language: { "url": "//website.com/js/datatables-spanish.json" }, columns: [ { data: 'id' }, { data: 'columns' } // more columns ], select: true }); this code of file: if ($op === 2) { $result = $functions->get_prop_table_test(); header('content-type: text/json'); header('content-type: application/json'); echo json_encode($result); } the error see in console: typeerror: f undefined datatables.min.js:60:375 ia/<() datatables.min.js:60 ra/i() datatables.min.js:47 ra/o.success()

javascript - Primefaces Mobile - DataTable - select row, before event taphold occurs -

i have problem in primefaces mobile datatable , event taphold. problem: if use event taphold in datatable, event occurs, before row can selected. the desired behaviour: the click or finger touch selects row (visually through different background color row too). event taphold occurs, if press long enough, additionally. first ideas, solve problem i think, problem is, row selection .mouseup()-event responsible , not mousedown()-event example. so, have change event, select row, before taphold-event occurs. don't know how. current source code: <p:datatable id="music_songs" var="music" value="#{musicplayerbean.musicsongs}" selectionmode="single" selection="#{musicplayerbean.selectedmusicsong}" rowkey="#{music.id}" style="background: white;" paginator="true" rows="25" tablestyleclass="ui-table-columntoggle" emptymessage="keine musik-songs

mysql - SQL RegEx Create Split: Include SET -

i'm writing regex pattern split mysql create statements column definition arrays. far, works great aside set columns. here's process: $lines = explode("\n", $create_sql); foreach ($lines $line) { $line = str_replace('not null', 'not_null', $line); $pattern = '/`(.*)`[\s]*([^\s]*)[\s]*(not_null|null)[\s]*(.*),/'; $search = preg_match($pattern, $line, $matches); if ($search !== false && count($matches) === 5) { $columns[$matches[1]] = array( 'type' => $matches[2], 'null' => $matches[3] === 'null', 'extra' => $matches[4], ); } } this process works great on column definition this: `id` int(11) not null auto_increment, ...but fails on set columns. how can best accommodate quotes , parentheses in line? `platform` set('ios', 'android') null default n

language agnostic - What is the name for reverse lens? -

lens function perform immutable record modification: copies record modifying part of content. lenses library allows combine lenses attain more complicated modifications. i'm searching correct term defines reverse abstraction. function compares 2 objects , return difference between them. such functions produce system. each modification represented simultaneously fine-grained description "field inside field b inside field c inside record" or coarse "field c inside record". can pattern match modification desired grade of accuracy. i need write code comparing records , reacting modifications inside them. avoid reinventing wheel. tried google reverse lenses drowned in non-relevant output. you can refer differential synchronisation algorithm this. algorithm based on diff , patch operations. diff part may useful you. for further reference : https://neil.fraser.name/writing/sync/

How to copy plain text value from using Javascript -

function copytext(text) { var textfield = document.createelement('textarea'); textfield.innertext = text; document.body.appendchild(textfield); textfield.select(); document.execcommand('copy'); textfield.remove(); } i found code on reddit , thought work logical create element select after execute command 'copy'. surprised didn't , not know why. no error given when running script on chrome dev console want execute , that's why don't want hear answer any api has copying. if can tell me how use api on chrome dev tools feel free let me know that. if there things left out or have questions about. the code wont work without user interaction, if try run console, not work. the way run code bind function button or that. function copytext(text) { var textfield = document.createelement('textarea'); textfield.innertext = text; document.body.appendchild(textfield); textfield.select();

java - What is the appropriate place to include Action Listner Block -

okay, have 3 classes. 1.) program driver-main class 2.)toppanel 3.) frame action listener logout button working okay kind of thought maybe there's better way separate blocks action listeners. please bear me i'm new this. best way separate action listeners block? need implement action listener on class everytime or can same thing did here here's code. toppanel class public class toppanel extends jpanel{ //declaration jbutton logoutbutton = new jbutton("logout"); toptabbedpane toptabbedpane = new toptabbedpane(); private final border mylineborder = borderfactory.createlineborder(color.black, 2); //constructor public toppanel(){ setpanelinitialproperties(); addcomponents(); } //methods private void setpanelinitialproperties(){ setlayout(new gridbaglayout()); setborder(mylineborder); //sets line border panel //setbackground(color.red); } private void addcomponents(){ gridbagconstraints toptabbedpanegbc = new gridbagconstraints

c# - WebClient() never reaching DownloadStringCompleted on WPF application -

so i'm confused, why webclient not accessing downloadstringcompleted . after reading possible problems webclient being disposed , before can finish download. or exceptions not being caught during downloaddata or uri inaccessible. i've checked against these problems, , webclient has not yet accessed downloadstringcompleted . pmid webclient class /// <summary> /// construct new curl /// </summary> /// <param name="pmid">pmid value</param> public pmidcurl(int pmid) { this.pmid = pmid; stringbuilder pmid_url_string = new stringbuilder(); pmid_url_string.append("http://www.ncbi.nlm.nih.gov/pubmed/").append(pmid.tostring()).append("?report=xml"); this.pmid_url = new uri(pmid_url_string.tostring()); } /// <summary> /// curl data pmid /// </summary> public void curlpmid() { webclient client = new webclient(); c

c# - localSettings.Containers[containername] - The given key was not present -

i looping through code looking localsettings. when container null gives error message "the given key not present in dictionary". how can check see container null doesn't crash code? if ((windows.storage.applicationdatacontainer)localsettings.containers[containername] != null) this gives same error var container = localsettings.containers[containername]; windows.storage.applicationdatacontainer settings = windows.storage.applicationdata.current.localsettings; //this checks if given container name exists or not if(settings.containers.containskey("containername")) { if(settings.containers["containername"].values.containskey("your data key")) { //do } } hope helps

swift - Warning: Attempt to Present ViewController on whose ViewController isn't in the view hierarchy (3D Touch) -

basically, trying implement home screen quick actions app. when tap on 1 of quick actions error: warning: attempt present theviewcontroller on viewcontroller view not in window hierarchy! i have looked @ other stack on flow posts had same issue, solutions didn't work me. also, in applicationdidenterbackground method added self.window?.rootviewcontroller?.dismissviewcontrolleranimated(true, completion: nil). here of relevant 3d touch methods have included in app delegate: func application(application: uiapplication, performactionforshortcutitem shortcutitem: uiapplicationshortcutitem, completionhandler: (bool) -> void) { let handledshortcutitem = self.handleshortuctitem(shortcutitem) completionhandler(handledshortcutitem) } also, have these helper methods: enum shortcutidentifier: string { case first case second init?(fulltype: string) { guard let last = fulltype.componentsseparatedbystring(".").last else { return ni

javascript - THREEjs resizing canvas with click -

i'm trying find way resize threejs/webgl canvas function function resize(){ $('#canvas').css('height', '100%'); $('#canvas').css('z-index', '1'); camera.aspect = window.innerwidth / parseint($('#canvas').css('height')); camera.updateprojectionmatrix(); renderer.setsize( window.innerwidth, parseint($('#canvas').css('height'))); } it gets job done, jumps 100% , wondering if there way smooth transition you can use css transitions if aren't strict on backward compatibility. https://developer.mozilla.org/en-us/docs/web/css/css_transitions/using_css_transitions

excel vba - With VBA how do i make the row above the "active row" in a table -

when insert row in table, inserts row above current row, fine. need able make row inserted active row. how that? structure of code is: for each row in [table] if [condition] row.insert 'this inserts row above "current" row 'here want move row inserted activesheet.cells(row.row, [table[col]].column) = 5 'arbitrary value end if next row try offset (row_no, col_no) 'to go previous row use activecell.offset(-1, 0).activate 'to got next row use activecell.offset(1, 0).activate you can try below code :) sub test() = activecell.row - 1 rows(a).activate end sub incorporated code for each row in [table] if [condition] row.insert 'this inserts row above "current" row 'here want move row inserted = activecell.row - 1 rows(a).activate end if next row

How to connect Mendix to SQL Server? -

Image
i'm learning how use mendix , i'm running problem. have database holds things such landing zones, county, , helicopter information. can't seem figure out how connect sql server database application. ideas? if want data database, have use appservices or webservices. alternatively, can connect application mssql database settings -> profile create entities in domainmodel data, , import data table using sql tool of preference ( sql express ) this work static data. if data dynamic, need webservices read more on how import or publish webservice and here on consuming one if data in mendix application, might need consume published appservice it. finally, might more feedback on mendix forum

Which one is a best file up-loader extension for Yii1.x framework? -

i using coco file up-loader extension in yii1.x framework not working properly. 1: if want delete uploaded file name status area not working. 2: not able make limit upload files if want edit file. 3: have ui issues. i using coco this. widget('ext.coco.cocowidget' ,array( 'id'=>'cocowidget1', 'oncompleted'=>'function(id,filename,jsoninfo){ }', 'oncancelled'=>'function(id,filename){ alert("cancelled"); }', 'onmessage'=>'function(m){ alert(m); }', 'allowedextensions'=>array('jpeg','jpg','gif','png'), // server-side mime-type validated 'sizelimit'=>2000000, // limit in server-side , in client-side 'uploaddir' => 'assets/', // coco @mkdir // arguments used send notification // on specific class when new

jquery - Unable to retrieve element by id from an HTML string -

i have php returns html snippet string in following format: echo '<tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><span id="morerows">1</span>'; now @ client, using jquery (2.1.4) extract text of #morerows (in example, 1) local var ifmore , remove <span> original html before further processing. following trying testing purposes: var hr = createxmlhttprequestobject(); ... var return_data = hr.responsetext; var rdashtml = $(return_data); var ifmore = $('span#morerows', rdashtml); alert(ifmore.text()); but alerts blank. http request processing fine because alert(return_data); shows value expected. extraction of <span> element somehow not working. there missing out? you have wrap code in div , because jquery parsing first tag , ignoring r

How does Python perform during a list comprehension? -

def thing(mode, data): return [ item item in data if { 'large': lambda item: item > 100, 'small': lambda item: item < 100, }[mode](item) ] this list comprehension generates dictionary of lambdas, retrieves 1 lambda via mode argument , applies list item being processed. question this: performance characteristics of this? is entire dictionary created scratch during each iteration of listcomp? or created once , used on each item? is entire dictionary created scratch during each iteration of listcomp yes. or created once , used on each item? no. fortunately, in case (and others can think of), it's easy build dict ahead of time: d = { 'large': lambda item: item > 100, 'small': lambda item: item < 100, } return [item item in data if d[mode](item)] or even, func = { 'large': lambda item: item > 100,

paypal - How do I reset a balance of a sandbox business account in the new developer UI? -

i testing mass payout functionality. use test business account hold balance, , pay out customers, verify fund has been transferred. with old ui, used able 'reset' sandbox account once in while put cash balance. with new developer ui, however, there doesn't seem way that. has able reset balance of sandbox business account? we’ll pass feedback along add functionality. in meantime, should able send payment 1 of other test accounts (we'll call account a) account that’s sending mass pay transactions (account b), giving balance. to so: log in account a> click send money > enter email address account b > enter amount want send > click continue > click send money. account b have balance , able send mass payments.

php - Try to get selected value from multiple selected value -

i have form select multiple values. showing selected value along showing error notice: undefined offset: 5 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1559 notice: undefined offset: 3 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1559 notice: undefined offset: 5 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1571 notice: undefined offset: 5 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1571 notice: undefined offset: 6 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1559 notice: undefined offset: 4 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1559 notice: undefined offset: 6 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1571 notice: undefined offset: 6 in /var/www/lo/g8_tool/g8_gusr/test.php on line 1571 for($g8_i=0;$g8_i<$g8_count;$g8_i++) { if($g8_j!=count($g8_groupy_arr)) { if($g8_groupy_arr[$g8_i] == $g8_group_y[$g8_j]) { $g8_selected = "selected"; #echo $g8_groupy_arr[$g8_i]."<br>"; $g8_j++; $g8_str.

android - I am trying to implement a View Pager with controlled swiping.But I am getting a binary inflate exception on the custom view page -

i trying disable or enable viewpager's swiping custom viewpager..but getting inflating exception on viewpager .please me. mainactivity public class mainactivity extends fragmentactivity { timer timer; int page = 0; viewpager pager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); pager = (viewpager) findviewbyid(r.id.view_pager); pager.setadapter(new mypageradapter(getsupportfragmentmanager())); pager.setenabled(false); //pageswitcher(3); } ////extending viewpager class public class hackyviewpager extends viewpager { private boolean enabled; public hackyviewpager(context context) { super(context); } public hackyviewpager(context context, attributeset attrs) { super(context, attrs); this.enabled = true; } @override public boolean ontouchevent(motionevent event) { if (this.ena

C++ converting an int to a string -

i know extremely basic i'm new c++ , can't seem find answer. i'm trying convert few integers strings. method works: int = 10; stringstream ss; ss << a; string str = ss.str(); but when need convert second , third ones this: int b = 13; stringstream ss; ss << a; string str2 = ss.str(); int c = 15; stringstream ss; ss << b; string str3 = ss.str(); i error: 'std::stringstream ss' declared here do need somehow close stringstream? i've noticed if put them far away each other in code compiler doesn't mind doesn't seem should do. have suggestions? you're trying redeclare same stringstream same name. can modify code in order work : int b = 13; stringstream ss2; ss2 << a; string str2 = ss2.str(); or if don't want redeclare : int b = 13; ss.str(""); // empty stringstream ss.clear(); ss << a; string str2 = ss.str(); you can use , quicker : int c = 42; std::string s = std::to_str

c - How do you read the arrow keys? -

extensive searching on use of raw mode termios , xterm leads numerous references "timing trick" required distinguish between escape-sequence , lone appearance of escape character. so how do it? i don't want use curses because don't want clear screen. calculator-style program, it's important retain "ticker-tape" interface. finally found nice detailed description in old usenet thread . quote relevant message in entirety. path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!ncoast!allbery from: all...@ncoast.org (brandon s. allbery kb8jrr) newsgroups: comp.unix.programmer subject: re: how read arrow keys? message-id: date: 1 jan 91 03:56:56 gmt references: reply-to: all...@ncoast.org (brandon s. allbery kb8jrr) followup-to: comp.unix.programmer organization: north coast computer resources (ncoast) lines: 68 quoted brn...@kramden.acf.nyu.edu (dan bernstein): +--------------- | it&

java - How extract files from response entity -

i have servlet gives clients many files in 1 request. put files(image,pdf,...) or other data (like json,...) byte array in response : multipartentitybuilder builder = multipartentitybuilder.create(); bytearraybody pic1 = new bytearraybody(imagebytes1, "pic1.png"); bytearraybody pic2 = new bytearraybody(imagebytes2, "pic2.png"); builder.addpart("img1", pic1); builder.addpart("img2", pic2); stringbody sb = new stringbody(responsejson.tostring(),contenttype.application_json); builder.addpart("projectsjson", sb); string boundary = "***************<<boundary>>****************"; builder.setboundary(boundary); httpentity entity = builder.build(); entity.writeto(response.getoutputstream()); i response (in client side) : string body = entityutils.tostring(response.getentity()); system.out.println("body : " + body); and body : --***************<<boundary>>****

mysql - Return number of users for each month by type -

Image
i not know how possible is: i have database in (sqlfiddle)[ http://sqlfiddle.com/#!9/d7a8f/3] , database want return following : i want return number of user created in each month based on type. there 4 role in database (administrator, no role, super user, user). just elaborate on query how want information like: e.g. january 2016, 4 , 3 ,5, 8,20. january 2015 month, 4 administrators, 3 no role, 5 super user, 8 users, , 20 overall total. user type must sorted in ascending order. i have tried following: select date_format(timestamp,' %b %y') month,usertype,count(userid) user group month,usertype you use bunch of count functions on case expressions break data respective roles: select date_format(timestamp, '%b %y') `month`, count(case usertype when 'administrator' 1 end) administrator, count(case usertype when 'no role' 1 end) norole, count(case usertype when 'super user' 1 end) superuser,