Posts

Showing posts from May, 2015

Declare a variable in RedShift -

sql server has ability declare variable, call variable in query so: declare @startdate date; set @startdate = '2015-01-01'; select * orders orderdate >= @startdate; does functionality work in amazon's redshift? documentation , looks declare used solely cursors. set looks function looking for, when attempt use that, error. set session startdate = '2015-01-01'; [error code: 500310, sql state: 42704] [amazon](500310) invalid operation: unrecognized configuration parameter "startdate"; is possible in redshift ? no, amazon redshift not have concept of variables. redshift presents postgresql, highly modified. there mention of user defined functions @ 2014 aws re:invent conference, might meet of needs. update in 2016: scalar user defined functions can perform computations cannot act stored variables.

c# - await/async odd behaviour -

i have simple console application using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace consoleapplication2 { public class program { static void main(string[] args) { mockapi api = new mockapi(); task t = api.getversion(); var placebreakpoint = "breakpoint"; } } public class mockapi { public async task<string> getversion() { return await apiversion(); } private async task<string> apiversion() { await task.delay(3000); return "v1.0"; } } } when ran first time executed expect seeing code go way await task.delay(3000); and returning to var placebreakpoint = "breakpoint"; before returning return "v1.0"; when delay had been completed. running code thereafter sees code execute befo...

C++ Same name local variables keeping values between loops -

i have following 2 loops in c++ code: for (int hcount = 0; hcount < height; hcount++) { (count = 0; count < width; count++) { cout << character; } cout << endl; } cout << endl; (int hcount = 0; hcount < height; hcount++); { (count = 0; count < width; count++) { cout << character; } cout << endl; } the problem running after using variable hcount in first loop, variable hcount in second loop initialize value had in first loop. not sure why both being initialized seem local variables , set equal 0. the problem here: for (int hcount = 0; hcount < height; hcount++); you end loop ; , no-op. hcount in case visible in scope of loop. after loop execution (i.e. after ; ), inner loop starts executing. debugger displays last value taken hcount .

java - Executable Jar cannot find typesafe/config application.conf on classpath -

i have command line app downloads reports, processes them, uploads data google drive. i'm using typesafe-config magic strings need. typesafe-config looks on classpath application.conf file , uses hocon map config objects fields in class, this: from ~/configs/application.conf : my.homepageurl = "https://my.home.com" from myclass.java : private static config config = configfactory.load(); private static final string home_url = config.getstring("my.homepageurl"); i'm using maven-shade-plugin build executable .jar easy deployment on remote server. plugin looks this: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.4</version> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.reso...

php - Error converting PDF to PNG Imagemagick: unable to create temporary file -

i have written php script programmatically create png thumbnail every pdf in folder. use imagemagick it, executing following command: exec('convert file.pdf[0] file.png'); everything working i've started error every time try: convert: unable create temporary file file.pdf : Ó“?u|svu?t???[u @ error/pdf.c/readpdfimage/381. convert: missing image filename file.png @ error/convert.c/convertimagecommand/2940. of course, i've tried directly in command line , same happens. any idea? ps: i´m working imagemagick 6.6.0-4 i´ve seen temp directory full of files created imagemagick. don´t know reason why still there. if delete them, starts work again.

javascript - SoundManager on 100% HTML5 mode stuck on "stalled" -

in smart-tv app, i'm using soundcloud api, through cross domain request - $.getjson() etc. app uses soundmanager2 api on 100% html5 mode (no flash) load tracks .stream_url retrieved soundcloud. problem begins when trying play loaded tracks. app loaded 10 tracks, of them won't play. noticed log stating: 0040 sound0: play(): loading - attempting play... 0041 sound0: abort 0042 sound0: waiting 0043 sound0: loadstart 0044 sound0: stalled where stays forever. issue happens same tracks, while other tracks streamable, , playable, showing log: 0078 sound2: durationchange (191190) 0079 sound2: loadedmetadata 0080 sound2: stalled 0081 sound2: suspend 0082 sound2: loadeddata 0083 sound2: canplay 0084 sound2: onload() 0085 sound2: playing ♫ the code used create sound object, , play it: soundobject = soundmanager.createsound({ // load current track url: "https://api.soundcloud.com/tracks/" + trackids[elements][index-1] + ...

IO reading (java) -

if have loop so: while(st.hasmoretokens() ) { array[i] = st.nexttoken(); array[(i+1)] = st.nexttoken(); i++; } will array[i] , array[i+1] end having same word or put 1 word in array[i] , next word in array[i+1]? i'm trying read in 2 words @ time until line runs out of words. thanks. yes "will put 1 word in array[i] , next word in array[i+1] ". note nexttoken() returns next token st string tokenizer. careful nosuchelementexception - if there no more tokens in st tokenizer's string. try this: while(st.hasmoretokens() ) { array[i] = st.nexttoken(); if(st.hasmoretokens()) // check again whether next toaken available or not array[(i+1)] = st.nexttoken(); i++; }

actionscript 3 - Activerecord Rails 4 perform something like a join that still returns rows that don't have the association -

if after reading question have suggestion better title, please add comment. having trouble succinctly saying wanted. have situation this. class artist < activerecord::base has_many :album_artists has_many :albums, :through => :album_artists end class album < activerecord::base has_many :album_artists has_many :artists, :through => :album_artists end class albumarist < activerecord::base belongs_to :album belongs_to :artist end i want query on artists return result if either artist's name or album title artist associated match query. can achieve join. artist.joins(:albums).where("artists.name ? or albums.title ?", query, query).uniq what know how return artists name matches query not happen have albums associated them. goal in single query, prefer not perform 2 sequential queries. please ask more clarification if need it. it seems left outer join looking for. created scopes in models this: class artist < activereco...

Can't put PartialFunction in scala class constructor -

there appears restriction can't use partialfunction literals in class constructors: scala> case class x(a: partialfunction[any, any]) { def this() = this({case x => x}) } <console>:7: error: implementation restriction: <$anon: => any> requires premature access class x. case class x(a: partialfunction[any, any]) { def this() = this({ case x => x}) } my first question why partial function literal need access "this". second question/observation in scala repl, running same code again crashes repl: scala> case class x(a: partialfunction[any, any]) { def this() = this({ case x => x}) } java.lang.nullpointerexception @ scala.tools.nsc.global$run.compilelate(global.scala:1595) @ scala.tools.nsc.globalsymbolloaders.compilelate(globalsymbolloaders.scala:29) @ scala.tools.nsc.symtab.symbolloaders$sourcefileloader.docomplete(symbolloaders.scala:369) ... and lastly, there workaround issue? your first question answ...

nsbutton performClick not working -

i have nsbutton btnone , when user clicks on button, want simulate click on button btntwo. btntwo has action displays message when clicked. - (ibaction)btnoneclicked:(id)sender { [btntwo performclick:self]; } - (ibaction)btntwoclicked:(id)sender { nslog(@"btntwo clicked"); } when run program , click on btnone, performclick not seem simulate click on btntwo no message displayed. i've tried overriding performclick() of btntwo in nsbutton subclass display message. -(void)performclick:(id)sender { nslog(@"performclick"); } this not happening. message not getting displayed. what doing wrong? thanks. i know it's late answer, better late never, right? :) add [super performclick:sender] at end of overridden performclick method. why doesn't call action method in first place (without overriding performclick) thing can have many problems. buttons connected action methods?

c# - How to connect to a local SQL server database in asp.net using Visual Studio 2013? -

how connect local sql server database in asp.net using visual studio 2013? i'm not talking remote access connection. in case, sql database located in app_data folder @ root of web application. want able query database c# file connected asp.net application , display data on label. have searched answer on hour , nothing seems show up. for web.config connection string, try like: <add name="connectionstringname" providername="system.data.sqlclient" connectionstring="data source=(localdb)\v11.0;attachdbfilename=c:\inetpub\wwwroot\webite\app_date\databasefilename.mdf;initialcatalog=databasename;integrated security=true;multipleactiveresultsets=true" /> (modified accordingly)

user interface - how to avoid Java graphics2D components to erase when minimizing or pooping up of Joptionpane? -

i working on java class representing graph data structure collage , , have problem when use graphics2d component draw graph . panting nodes of graph on spacifiec range randomly , when press add vertex button , have put drawing code on action of add vertex button , makes me not using paintcomponent() or paint() method , when minimize or joptionepane popped , entire graphics had drawn disappears !! and here code, note : graph , stackx , queue classes implementations made me on same package package graphs; import javax.swing.jlayeredpane; import javax.swing.joptionpane; import javax.swing.jpanel; import javax.swing.jrootpane; import javax.swing.jtextfield; import javax.swing.jbutton; import javax.swing.border.titledborder; import java.awt.color; import java.awt.font; import java.awt.graphics; import java.awt.graphics2d; import javax.swing.jscrollpane; import datastrucutres.trees.btnode; import java.awt.event.actionlistener; import java.awt.event.actionevent; import ...

python - Fixed file name length of increasing numbers with bash -

i have files names fixed 4 characters in length. like: 0000.png, 0001.png, ... , 0027.png, ..., etc... they're increasing integers, 0, 1, ..., n. zeros padded additional space number not fill full file name 4 characters. in python, can loop through these files like: for in range(n): file_name = '0'*(4-len(str(n))) + str(n) + '.png' how achieve same effect bash? i'm not great bash, '0' padding part throwing me off. try this: n=5 ((i=0;i<=$n;i++)); printf -v file_name "%0.4d.png" $i echo $file_name done output: 0000.png 0001.png 0002.png 0003.png 0004.png 0005.png

IOT Mosquitto mqtt how to test on localhost -

i'm playing around mosquitto ans mqtt protocol following video https://www.youtube.com/watch?feature=player_embedded&v=we7gvifrv7q trying test on localhost in terminal window run : mosquitto_sub -t "nodeconf/eu" -v but when run snippet: var mqtt = require('mqtt'); var client = mqtt.connect(); client.on('connect', function () { client.subscribe('nodeconf/eu'); client.publish('nodeconf/eu','hello'); }); client.on('message', function (topic, message) { // message buffer console.log(message.tostring()); client.end(); }); i don't see (in terminal window) hello. what's wrong, please ? btw i'm looking tutorial , guide on topic thanks. you have add console.log second (the javascript) client see why doesn't publishes hello properly. but can typical test mosquitto clients: 1) subscribing topic: mosquitto_sub -d -h localhost -p 1883 -t "myfirst/test" ...

arrays - At most k adjacent 1s (Maximum Value limited neighbors) -

in algorithms course, there's question in book goes follows: "you given array a[1..n] of positive numbers , integer k. have produce array b[1..n], such that: each j, b[j] either 1 or 0. array b has adjacent 1s @ k times. sum(a[j]*b[j]) 1 <= j <= n maximized." example given array [10, 100, 300, 400, 50, 4500, 200, 30, 90] , k = 2 array b can = [1, 0, 1, 1, 0, 1, 1, 0, 1] maximizes sum 5500. the solution uses dynamic programing when discussing friends said recurrence relation of form m(i, j) = max(m(i-2, j) + a[i], m(i-1, j-1) + a[i]) can explain why so? or if have different form of solving such problem. find dynamic programing bit hard grasp. thank you. m[i, j] max sum 1 i, j adjacent 1s m[i,j] can computed max of 3 situations: b[i]=0 => s=m[i-1, j] // a[i] not added sum, b[1..i-1] has same number of adjacent 1s (j) b[1..i] because b[i] 0 b[i]=1 , b[i-1]=0 => s=m[i-2, j]+a[i] // a[i] added sum, b[1..i-2] has same number of adjacenc...

c# - In-Memory Database - How to Generate MVC Model classes? -

i new mvc4 asp.net , in-memory databases. apologize if answer basic , stupid. have created asp.net mvc application uses in-memory db(sqlite3)by using sqliteconnection con=new sqliteconnection(data source=:memory:;version=3;new=true;); i want know if database , tables created "in-memory", how model , classes generated can use in controller/views. in memory database populated @ runtime xml. edit here how create table in memory using (sqliteconnection connection = new sqliteconnection("data source=:memory:;")) { connection.open(); connection.createmodule(new sqlitemoduleenumerable("samplemodule", new string[] { "one", "two", "three" })); using (sqlitecommand command = connection.createcommand()) { command.commandtext ="create virtual table t1 using samplemodule;"; command.executenonquery(); } using (sqlitecommand command = connection.createcommand()) {...

tsql - SQL OVER(Partition) issue - selecting a subset -

i'm trying specific subset of data using "over(partition)" syntax. i've created sample data illustrate. running following cte results in small example result set. i need calculate 2 date ranges using following definitions/pseudocode 1: days close = closedate stat = 'closed' minus opendate partitioned problem 2: days solve = "closeddate stat = 'solved' minus opendate partitioned problem. i can #1 using over(partition) syntax, cannot figure out #2. with cte ( select 114110712007835 'srnumber', 214110712007835004 problemnumber, 'open' 'stat', 314110712007835004001 tasknumber, convert(datetime, '2015-03-02 19:47:43',120) opendate, convert(datetime, '2015-03-03 19:36:37',120) closedate union select 114110712007835 'srnumber', 214110712007835004 problemnumber, 'investigate' 'stat', 314110712007835004002 tasknumber, convert(datetime, '2015-03-04 00:29:13',120) op...

android - How to undo a ParseUser.setPassword() call? -

i letting user change credentials. types new username, email , password , go like: parseuser user = parseuser.getcurrentuser(); user.setusername("my new name"); user.setemail(email); user.setpassword("my new pw"); user.saveinbackground(...); so what? save() call might fail, big number of reasons (example: username taken else). can tell in case none of above fields gets updated, fair: show error, user knows went wrong. things complicated if notice that, after parseexception , user above keeps dirty fields, couldn't saved server. i.e. //saveinbackground fails //... user.getusername().equals("my new name") // true! issue now, able these fields right values calling user.fetch() , doesn't work password field. this particularly unwanted, because future call save() or such (which might not fail because maybe it's different call) update password too! i.e. //later parseuser user = parseuser.getcurrentuser(); user.put("stuff...

oop - Is my understanding of abstraction correct? -

i've read other posts discussing abstraction , encapsulation, i'm not confident understand them; or maybe understand them feel unsatisfied clarity of content. here understandings of abstraction , encapsulation. in regards accurate/inaccurate/complete/incomplete? "abstractions data types created programmers extend language when primitive data types insufficient. primitive data types, abstractions have specifications list inputs require , outputs return, specifications not overwhelm programmers methods, functions, , variables used operate on inputs. class example of abstraction. api example of abstraction." "encapsulation state of having abstract data types — i.e. classes — isolated each other methods, functions, , variables not conflict each other, , programmers can reuse existing class in other programs without being concerned doing interfere rest of program (presuming programmer correctly provides required inputs , correctly handles data returns)." ...

javascript - Slider toggle switch inside JQuery Collabsible -

i'm trying place jquery toggle switch (slider) inside collapsible. button appears inside collapsible intended can't state in javascript code. seems switch invisible js code. i'm to: html: <div data-role="fieldcontain"> <label for="flipmin">switch:</label> <select id="switch" data-role="slider"> <option value="0">off</option> <option value="1">on</option> </select> </div> javascript: $(document).on('pageinit','#page1',function(){ $("#lightswitch").change(function() { var args = $("#lightswitch option:selected").val(); console.log(args); }); }); any advice? thanks! uhmm did it: $(document).ready(function(){ console.log("asd"); $(".fieldco...

php - IF-Statement Combination with mb_strlen doesn't work -

i have form following if-statement's doesn't work. first verification "if empty" work not second 1 mb_strlen, why? that's php-code: elseif(empty($_post['project_title']) or (mb_strlen($_post['project_title'], 'utf-8') <= 3)){ echo "please correct project title";} i don't error. have syntax mistakes in code? from can tell, code works fine. little test script ran: <?php echo test_title( '' ); echo test_title( 'pdf' ); echo test_title( 'this 1 works' ); function test_title( $title ) { echo "testing '$title'. "; if( empty( $title ) || mb_strlen( $title, 'utf-8') <= 3 ){ return "please correct project title\n"; } return "looks fine\n"; } will output following: testing ''. please correct project title testing 'pdf'. please correct project title testing 'this 1 works'...

loops - mainloop() function in python -

i confused put mainloop function in python. when use code: from tkinter import * import sys window = tk() def mainfunct(): while true: label = label(window,text="hello world") label2 = label(window, text = "hello world2") menu = input("please input something") if menu == "a": label.pack() if menu == "b": label2.pack() if menu == "c": sys.exit() window.mainloop() mainfunct() i want label packed when user inputs , when user inputs b want label2 packed. not sure when , why use mainloop. right when run program, gui pops after have inputted , can't input else , think has thing window.mainloop() function because loops on , on again instead of running while true loop again. i able understand question better based off of comment. let me know if you're looking for: import tkinter tk class helloworld(tk.tk): ...

pyside - Creating a toggleable text widget in qt -

instead of using traditional checkbox, i'd display options using more human-readable format. show want, have implemented in language i'm familiar with. would possible recreate following example using qt? if so, pointers on how it, it's not obvious me how in non-hacky fashion. var $ = document.queryselector.bind(document); var toggle = $('.toggle'); var first = toggle.firstchild; var last = toggle.lastchild; last.style.display = "none"; function hide(el) { el.style.display = "none"; } function show(el) { el.style.display = "inherit"; } var current = false; toggle.addeventlistener("click", function () { current = !current; if (!current) { hide(last); show(first); } else { show(last); hide(first); } }); span.toggle { border-bottom: 1px dashed; } span.toggle:hover { cursor: pointer; } <p class="example">i start <span class="...

mysql - SQL- SELECT something AS with multiple where -

i'd output of sql query appear below. |count_a|count_b|count_c|count_d| | 2 | 3 | 4 | 5 | the current output using union is |count_a| 2 3 4 5 select count(ins_name) count_a table_a ins_name in ( select ins_name table_b ins_id in (select ins_map_id ten_to_inst_map t_in_map_id = (select t_id tw tnam = 'abc'))) , t_date between '2015-01-01' , '2015-07-01' , ins_name not 'x%pr%' , ins_name 'x%y%' , and ins_name not 'x%y%z' union select count(ins_name) count_b table_a ins_name in ( select ins_name table_b ins_id in (select ins_map_id t_in_map t_in_map_id = (select t_id tw tnam = 'abc'))) , t_date between '2015-01-01' , '2015-07-01' , ins_name not 'x%pr%' , ins_name 'x%as%' union select count(ins_name) count_c table_a ins_name in ( select ins_name table_b ins_id in (select ins_map_id t_in_map t_in_map_id = (select t_id tw tnam = 'abc'))) , t_date between...

Is there a built in Kotlin method to apply void function to value? -

i wrote method apply void function value , return value. public inline fun <t> t.apply(f: (t) -> unit): t { f(this) return } this useful in reducing this: return values.map { var other = it.toother() dostuff(other) return other } to this: return values.map { it.toother().apply({ dostuff(it) }) } is there language feature or method build in kotlin? i ran same problem. solution basicly same yours small refinement: inline fun <t> t.apply(f: t.() -> any): t { this.f() return } note, f extension function. way can invoke methods on object using implicit this reference. here's example taken libgdx project of mine: val sprite : sprite = atlas.createsprite("foo") apply { setsize(size, size) setorigin(size / 2, size / 2) } of course call dostuff(this) .

javascript - Konami code changing every color -

okay want change websites colors on press of button. have code: $( window ).konami({ code : [38,38], // up cheat: function() { $('*').filter(function() { var match = 'rgb(255, 165, 0)'; // match background-color: black /* true = keep element in our wrapped set false = remove element our wrapped set */ return ( $(this).css('color') == match ); }).css('color', 'purple'); // change background color of black spans } }); now problem want add bunch of other attributes background-color, border-color , active , hover color - though these 2 might problematic code snippet think. any adding named attributes fray welcomed - i'm not javascript expert no means. also bonus question webpage on angularjs , when used konami code, seems work on colors on display. on different pages have enter keys a...

java - Minecraft Modding Forge .isRemote() and worldObj -

i new minecraft modding , part understand lot of it, reason, can't grasp worldobj.isremote() means. isremote() returns if world client or server sided. mean? don't understand. usually, when remote, means on other end of network, or not on client side. did little coding forge, , if remember correctly, world.isremote() used tell if world on server client connected to, or if on computer minecraft running on(the client). example, playing singleplayer. none of available worlds remote because on client, isremote() never return true these. if, however, logged in server, worlds remote worlds. hope made sense!

javascript - Determining Powers of 2? -

i creating simple bracket system , need way check if there correct number of teams, or if program needs compensate bye rounds. right now, checking "powers of two" function: function validbracket(data) { var x = data.teams.length; return ((x != 0) && !(x & (x - 1))); } this works pretty well, needing know how many bye rounds add. instance, if had 16 teams , not need add anymore teams. however, if had 12 teams , need first 4 teams bye round. how can calculate number of bye rounds add bracket? , hard-coding array of powers of 2 better? in pseudo code, thinking of: if(validatebracket(data)) { // valid number of teams (power of two). keep going. } else { var byerounds = calculatebyerounds(); } note: rather not use array of powers of 2 below: var powersoftwo = [2,4,8,16,32,...]; the reasoning behind limiting number of teams put in system (however, don't think person have on 256 teams). var needed = (1 << math.ce...

javascript - Ionic/AngularJS ng-click event not firing? -

i playing around withe ionic/angularjs. can't alert window show ? started ionic blank template. app launches in browser window, when button pressed, nothing happens. // ionic starter app // angular.module global place creating, registering , retrieving angular modules // 'starter' name of angular module example (also set in <body> attribute in index.html) // 2nd parameter array of 'requires' var app = angular.module('freshlypressed', ['ionic']); app.run(function($ionicplatform) { $ionicplatform.ready(function() { // hide accessory bar default (remove show accessory bar above keyboard // form inputs) if(window.cordova && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if(window.statusbar) { statusbar.styledefault(); } }); }); app.controller( 'appctrl' , function($scope, $log) { $scope.refresh = function() { ...

documentation - How do I link to the most recent version of a file on ruby-doc.org? -

this link enumerable , example, pegged @ ruby 2.2.2, , there doesn't appear /latest or /current path. there path lands on latest version? removing version path trick, leaving behind /core . same works /stdlib paths. 2.2.2: http://ruby-doc.org/core-2.2.2/enumerable.html latest: http://ruby-doc.org/core/enumerable.html

javascript - How to condense this into a single function? -

i new js/jquery, cant figure out how keep code d.r.y, if possible @ don't know. using jquery on hover effect image. box1 being div , img_hover_effect being overlay on hover. js: $('.box1').hover(function () { $('.img_hover_effect').fadein(500); }, function () { $('.img_hover_effect').fadeout(400); }); $('.box2').hover(function () { $('.img_hover_effect_2').fadein(500); }, function () { $('.img_hover_effect_2').fadeout(400); }); $('.box3').hover(function () { $('.img_hover_effect_3').fadein(500); }, function () { $('.img_hover_effect_3').fadeout(400); }); you can use loop that. an anonymous function inside loop used prevent breakage jquery events, try: for(var = 1; <= 3; i++){ (function(num){ $('.box' + num).hover(function() { $('.img_hover_effect' + (num == 1 ? "" : num)).fadein(500) }, function(){ ...

javascript - Meteor HTTP request structuring -

i playing around api in meteor , trying use http package access it. example give formats request curl command : curl -x post https://api.locu.com/v2/venue/search/ -d '{"fields":["name","menu_items","location","categories","description"],"menu_item_queries":[{"price":{"$ge":15},"name":"steak"}],"venue_queries":[{"location":{"locality":"san francisco"}}],"api_key":"your_api_key"}' how convert http.call()? use data argument see listed in docs? params? content? variations have tried far haven't worked. this equivalent. it's bit prettier in javascript. server side code: var result = http.post("https://api.locu.com/v2/venue/search", { data: { "fields": ["name", "menu_items", "location", "categories", "description...

riot.js - Riot JS unmount all tags in a page and then mount only one tag is not working -

i using riot js , in index.html, have 3 custom tags - header, login-panel , candidates-panel inside body. in main app.js, in callback function of $(document).ready, execute current route , register route change handler function. in switchview, unmount custom tags , try mount tag pertaining current view being switched. here code. if unmount, nothing displayed on page index.html <body> <header label="hire zen" icon="img/user-8-32.png"></header> <login-panel class="viewtag" id="loginview"></login-panel> <candidates-panel id="candidatesview" class="viewtag"></candidates-panel> <script src="js/bundle.js"></script> </body> app.js function switchview(view) { if(!view || view === '') { view = 'login' } //unmount other panels , mount panel required //todo: unmount view panels , mounting required pan...

Delphi - extract string between tags (duplicate tags) -

i'm trying write function extract string between 2 tags. problem first tag duplicate in string unknown count e.g. str := 'delphi app hello hello sometext here hello hello hello test!'; what want extract hello test! tagf last hello word tagl test! the duplicate count of tagf random. function sextractbetweentagsb(const s, lasttag, firsttag: string): string; var i, f : integer; stemp : string; begin stemp := s; repeat delete(stemp,pos(firsttag, stemp),length(firsttag)); until ansipos(firsttag,stemp) = 0; f := pos(lasttag, stemp); result:= firsttag+' '+copy(stemp, 1, length(stemp)); end; the output is: hello delphi app sometext here test! function sextractbetweentagsb(const s, lasttag, firsttag: string): string; var plast,pfirst,pnextfirst : integer; begin pfirst := pos(firsttag,s); plast := pos(lasttag,s); while (plast > 0) , (pfirst > 0) begin if (pfirst > plast) // find next lasttag plas...

java - How to use charAt() and length() to write a whether is substring method -

i want write boolean method substring() judge if string s1 substring of s2 . the requirement use charat() and length() methods of string . e.g. substring("abc","abcd")-> true substring("at","cat")->true substring("ac","abcd")->false indexof() cannot used. here got far. public class q3 { public boolean substring(string str1, string str2) { string s1 = str1.tolowercase(); string s2 = str2.tolowercase(); (i = 0; < s1.length; i++) { (j = 0; j < s2.length; j++) { if (s1.charat(i) == s2.charat(j)) return true; } } return false; } } test class : public class q3test { public static void main (string arg[]){ q3 q3object = new q3(); system.out.println(q3object.substring("ac","abcd")); } } it fails substring("ac","abcd...

Om/Clojurescript: Issue rendering a reset application state -

i trying display component om, data needed widget arrives. came following (roughly): (def data (atom {})) (go (let [response (<! (http/get "../rest/ds" ))] (reset! data (:result (:body response))))) (om/root (fn [app owner] (reify om/iinitstate (init-state [_] (prn "(1) returning initial state now") {:text "hello world!"}) om/irenderstate (render-state [this state] (prn state) ; <-- here: not state reset! before original state (do-something ...)))) data {:target (. js/document (getelementbyid "app"))}) it seems state within render-state never set reset! although re-rendering seems triggered. using wrong he...

Objective-C generics not working for methods? (Xcode 7 Beta (build: 7A120f)) -

so, obviously, after wwdc i'm playing new stuff presented during last week. know apple introduced generics world of objective-c note: answer somehow follow-up question: are there strongly-typed collections in objective-c? i tried code in method, works great nsmutablearray<nsstring*> *array = [[nsmutablearray alloc] init]; [array addobject:@""]; [array addobject:@(54)];incompatible pointer types sending 'nsnumber *' parameter of type 'nsstring * __nonnull' // great, generics works expected. however have method want transform generics in header file: - (nsarray <nsstring*> *)objectstosearch; implementation: - (nsarray <nsstring*> *)objectstosearch { nsstring *first = @"1"; nsstring *second = @"2"; nsstring *third = @"3"; nsnumber *test = @(55); return @[first, second, third, test]; // no-error!!! } am doing wrong or clang not support generics + literals or th...

Android ImageView margins -

Image
creating layout , can not solve margins , above imageview (and don't understand why appear). logo without these margins. use layout_width="250dp" same buttons. , layout_height="wrap content". layout code here: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/menu_background" android:gravity="center" android:layout_gravity="center" android:orientation="vertical" > <imageview android:layout_width="250dp" android:layout_height="wrap_content" android:src="@drawable/game_logo" /> <button android:id="@+id/start_button" style="@style/menubuttonstyle...

logging - Play 2.4 - Display Ebeans SQL statement in logs -

how display sql statements in log ? i'm using ebeans , fails insert reasons can't see what's problem. i tried edit config to: db.default.logstatements=true and add logback.xml <logger name="com.jolbox" level="debug" /> to follow answers found online, doesn't seem work 2.4… logging has changed play 2.4. starting now, display sql statements in console, add following line conf/logback.xml file: <logger name="org.avaje.ebean.sql" level="trace" /> it should work fine.

Reset Android Studio settings to default setting on linux -

everyone. used develop android application on mac. installed android development environment on thinkpad running xubuntu. i imported android studio settings on mac android studio on xubuntu via file-> import settings. but after have done this, goes wrong. hotkey, java path ecc. i tried delete android studio, , download again, settings still there. on internet can find nothing this, know how reset android studio settings default setting? thanks! it's simple. depending on androidstudio version, settings stored in ~/.androidstudio , ~/.androidstudio1.1 or ~/.androidstudio1.2 . open terminal , run following code: ls -a | grep android # see of 3 folders above have. rename each of settings folders have appropriate mv command: mv .androidstudio .androidstudio.bak mv .androidstudio1.1 .androidstudio1.1.bak mv .androidstudio1.2 .androidstudio1.2.bak

angularjs - Add new text box on click of a button in angular js -

how add new text box when submit button pushed. have tried , know there's thing wrong. still new angular js. example: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>example - example-ngcontroller-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> <script> angular.module('controllerasexample', []).controller('settingscontroller1', function ($scope) { $scope.contacts=[] $scope.addcontact = function() { $scope.contact.push({$scope.contact}) } }); }; </script> </head> <body ng-app="controllerasexample"> <div id="ctrl-as-exmpl" ng-controller="settingscontroller1"> ...

text to speech - android TextToSpeech; switching between male and female voices -

i trying app can switch between google's default en-uk male voice (en-gb-x-rjs-phone-hmm) , female voice (en-gb-x-fis-phone-hmm). using 2 text-to-speech objects and, after initializing engine each one, assign corresponding voice each of them setvoice(voice). mtts1 = new texttospeech(this, oninitlistener, packname); mtts2 = new texttospeech(this, oninitlistener, packname); and in oninit() method, when both initialized: mtts1.setvoice(voice1); mtts2.setvoice(voice2); 'voice1' , 'voice2' obtained calling getvoices(), , when voice name, obtain 'en-gb-x-rjs-phone-hmm' , 'en-gb-x-fis-phone-hmm' respectively, make me think voices correctly stored. when display 2 buttons making them speak, female voice speaks in both cases. think it's fact of default voice. happens having female voice default voice. when set male voice default one, happens opposite. something should know i'm missing...? thank all,

Create Mac .dmg file from Java -

i create dmg file java. the reason why needs java twofold: must part of our build farm (which runs on non mac os x platform) , our build uses maven (which pretty means java). as far can tell inside dmg file can iso9660 file system. can create such beast using this still need part whole thing wrapped in dmg format. iso2dmg tool except need java. when answering: forget maven part. if have java solution can figure out maven stuff myself. (e.g. creating own little maven plugin if need to). you can use javapackager tool. a simple, explained, step step tutorial on how create dmg java here: http://centerkey.com/mac/java/

pip - Python script - get installed packages in other virtualenv -

i'm creating virtual environment during runtime using virtualenv.create_environment. if env created skip installation, check , see if package installed. right i'm running command activating env , pip list . my question if can import pip virtual env , pip.get_installed_distributions() ?

In AngularJS, any inline javascript code that included in HTML templates doesn't work -

in angularjs, inline javascript code included in html templates doesn't work. for example: main.html file: <div ng-include="'/templates/script.html'"></div> and script.html file: <script type="text/javascript"> alert('yes'); </script> when open main page, expect alert message 'yes' nothing happens. think security restrictions in angularjs preventing inline scripts, couldn't find workaround that. note: don't use jquery or other framework, angularjs 1.2.7. jqlite not support script tags. jquery does, recommendation include jquery if need functionality. from angular's igor minar in this discussion : we looked supporting script tags in jqlite, needs done cross-browser support involves lot of black magic. reason decided going recommend users use jquery along angular in particular case. doesn't make sense rewrite 1 third of jquery working in jqlite. here...

xml - How to pass Authentication Header to node-soap -

i trying use wsdl service client cannot find how set headers. the reason need because wsdl trying use requires username , password via headers. wsdl > post /service.asmx http/1.1 > host: 210.12.155.16 > content-type: text/xml; charset=utf-8 > content-length: length > soapaction: "http://yyyy.com:1002/apability" > > <?xml version="1.0" encoding="utf-8"?> > <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" > xmlns:xsd="http://www.w3.org/2001/xmlschema" > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:header> > <authheader xmlns="http://yyyy.com:1002/"> > <username>string</username> > <password>string</password> > ...

angularjs - Automatically update selected option in the angular controller to a select within a nested repeat -

i have select input want update within model selected based on rest api service. i've created simple fiddle example illustrates issue. first has select options inside of nested ng-repeat, selection saved in person object: <tr ng-repeat="person in people"> <td ng-bind="person.name"></td> <td> <select ng-options="color.name color in person.availablecolors" ng-model="person.favoritecolor"></select> </td> <td ng-bind="person.favoritecolor.name"></td> </tr> in model initialize $scope full of people each favoritecolor : var red = new color('red', true); var orange = new color('orange', false); var pink = new color('pink', false); var blue = new color('blue', true); var michael = new person('michael', red, [red, orange, pink]); var jack = new pe...

java - Third party Class requires deprecated ActionBarActivity as a parameter -

i attempting utilize side-menu github repo. animation menu requires class viewanimator take parameter actionbaractivity , given in sample this (i.e. mainactivity , extends actionbaractivity ). due actionbaractivity being deprecated, , mainactivity extending appcompatactivity , statement shows error. is there way around this? 1) use actionbaractivity. 2) download source code of github repo, import project (not gradle, or .jar, mean actual source code), , modify function accept appcompatactivity instead of actionbaractivity. (this require testing see if still worked expected). 3) make issue on github repo , hope original developer can/will out modifying code. you can't trick thinking it's getting actionbaractivity if isn't it's getting.

windows 10 - SystemMediaTransportControl GetForCurrentView() fails in audio background task on Desktop Device Family (UWP C# -

i'm trying bring on c# wp 8.1 background audio task uwp , works, except trying uvc using windows.media.playback.systemmediatransportcontrols.getforcurrentview() throws current exception on desktop devices: "could not find appropriate view associated instance of mediaplaybackcontrol. please make sure view has been initialized". behavior has yet converged, or need control , update uvc via app on desktop class device? there api change in windows 10. seems should use backgroundmediaplayer.current.systemmediatransportcontrols. not in documentation yet. can find in windows 10 sample repository: https://github.com/microsoft/windows-universal-samples/tree/master/backgroundaudio

asp.net - How can access sublayout control from another sublayout in Sitecore? -

Image
i have master layout , 3 sublayout header, content, footer. in header sublayout have search textbox , search button, on click of search button result display on content sublayout, on content sublayout have repeater not able access repeater control in header sublayout. i've dealt similar problems in sitecore sites before. there 2 ways of doing i'd suggest consider: 1) custom code, layout can act intermediary sublayouts define sort of "receive results" interface can implemented sublayout wants handle search results. example: interface irendersearchresults { void renderresults(ienumerable<searchresultdata> resultset); } make "content" sublayout implement interface, when sends search results, can handle them: public class contentsublayout : sublayout, irendersearchresults { public void renderresults(ienumerable<searchresultdata> resultset) { repeatercontrol.datasource = resultset; // whatever other data bindi...

java - How can I force order of execution of instructions in Scala -

i have noticed, scala doesn't execute instructions in order. example, if have following instructions. var = command1.! var b = command2.! the second instruction may executed before first 1 because doesn't have dependency on instruction. so, question is, how can force second instruction executed after first instruction. answering question, how compose processbuilder?, doc says: two existing processbuilder can combined in following ways: they can executed in parallel, output of first being fed input second, unix pipes. achieved #| method. they can executed in sequence, second starting first ends. done ### method. the execution of second 1 can conditioned return code (exit status) of first, either when it's zero, or when it's not zero. methods #&& , #|| accomplish these tasks.

jquery - Calling two php files on form submit -

i have coded form gets 2 kinds of values user, 1 promo details , other asks photo (the photo optional). need photo uploaded in folder , have slideshowed. question how send photo folder , insert promo details database , slideshow tool should use picks out random images on folder? here code form asks user input , photo: <form action="insertpromo.php" method="post"> <div class="form-group"> <label class="control-label col-sm-2" for="txtpromoname">promo title:</label> <div class="col-sm-10" id="divcmbservice""> <input type="text" class="form-control" name="txtpromoname" id="txtpromoname" placeholder="promo name"> </div> </div> <div class="form-group"> <label class...