Posts

Showing posts from July, 2015

Facebook php sdk4 and app -

i'm developing laravel package post on facebook. code responsible obtaining , storing access token of page post link besides test makes operation correctly app have created test fb . problem create app on facebook put production , second app facebook created the same configuration work when publishing gives me following error: (# 200 ) user hasn 't authorized application perform action . this code snippet use testing . public function gettest(){ //$accesstoken = new accesstoken($this->getparam('token')); try { $page_post = (new facebookrequest($this->session, 'post', '/'.$this->getparam('page_id').'/feed', array( 'access_token' => $this->getparam('token'), 'link' => 'link', 'description' => 'hola mundo desde laravel', 'picture' => 'link/img.png',

decimal to hex converter function (python) -

so code , dictionary have created: def dectohex (number, dectohex_table): final_dectohex='' if number in dectohex_table: final_dectohex+=dectohex_table[number] print(final_dectohex) dectohex_table={'0':'0', '1':'1', '2':'2', '3':'3', '4':'4', '5':'5', '6':'6', '7':'7', '8':'8', '9':'9', '10':'a', '11':'b', '12':'c', '13':'d' , '14':'e', '15':'f'} is there way use code using dictionary (since must) convert numbers higher 15? i'm guessing homework (since python has hex function built-in) what should modulo operation % , loops :) i don't want spell out think how break base 16 number using modulo.. hint: try following: print(423 % 10) print( (423/10) % 10) print( ((423/10)/10

javascript - Dojo Memory Store Periodic Refresh -

i have dojo method make xhrrequest latest list of items db , periodically using setinterval() . there other better way without using setinterval() automatically update memory store whenever new item added db?.. current code below <div data-dojo-type="dojo/store/memory" data-dojo-id="datastore"> <script type="dojo/method"> var mystore = this; setinterval(function(){ require(["dojo/request/xhr"], function(xhr){ xhr("myurl", { handleas: "json" }).then(function(data){ if (data && data.length > 0) { mystore.setdata(data); } }, function(err){ // handle error condition }, function(evt){ // handle progress event request if // browser supports xhr2 }); }); }, 2000); </script> </div> well, use dojo/store/jsonrest in stead of dojo/store/memory .

JMS queue not found in JNDI lookup when it's there -

i have created sample setup test jms message queues. setup follows: wildfly 8.1.0.final server switchyard projects (i'll have switchyard assignment soon). added jms queue server using following code snippet: if (outcome != success) of /subsystem=messaging/hornetq-server=default/jms-queue=helloqueue:read-resource jms-queue add --queue-address=helloqueue --entries=java:/jms/queue/helloqueue, java:jboss/exported/jms/queue/helloqueue end-if i received following response wildfly: 20:13:36,647 info [org.jboss.as.messaging] (serverservice thread pool -- 59) jbas011601: bound messaging object jndi name java:/jms/queue/helloqueue i created switchyard project bound queue, , prints received through queue standard output. created simple client send messages through queue. client code: package soi.syhello.jms.client; import java.util.properties; import java.util.logging.logger; import javax.jms.connectionfactory; import javax.jms.destination; import javax.jms.jmscontext;

php - Why won't my foreign key create in MySQL? -

i've tried many different ways create table foreign key , trying insert phpmyadmin. however, not working expected. here i've far: create table user ( user_id bigint(10) unsigned auto_increment primary key, user_name varchar(50) not null, user_password varchar(50) not null); this works fine. however, if try add table foreign key thus, refuses create: create table article ( article_id int(20) unsigned auto_increment primary key, article_title varchar(100) not null, article_content varchar(1000) not null, user_id int(10) not null, foreign key (user_id) references user (user_id)); this not work expected , not add table mysql database. error: cannot add foreign key constraint how can fix it? we discovered in comments if primary key defined thus: user_id bigint(10) unsigned then foreign key not work, since needs match on signedness (and think type too): user_id int(10) not null this works fine: user_id bigint(

c - List structure - checking for sublist -

as i'm new c programming, i'll posting entire (not long code). tasks i've been given implement insertion of element inside list, while list stays in order, print it, , check if 1 list sublist of another. although insert , print methods work, bunch of warnings: warning: passing argument 1 of 'insert' incompatible pointer type [enabled default]| . how can fix code in order remove these warnings? also, logically, think contains method ok, why doesn't work? work when comparing 2 lists of single element. code looks this: #include <stdio.h> #include "stdlib.h" typedef struct book{ int id; char name[50]; float earnings; } book; struct node{ struct book data; struct node* next; }; void insert(struct node** list, struct book k) { struct node* previous; struct node* current; struct node* newnode; newnode=(struct node*)malloc(sizeof(struct node)); newnode->data = k; newnode->next = null;

html - wants to include a jsp page in another jsp page on button click -

this success.jsp page having button name employee list, opens new page viewemployee.jsp, want include viewemployee.jsp page inside success.jsp page on button click <html> <body> <form action="index.jsp"> <table> <tr> <td align="left">welcome !! <%=session.getattribute("user")%></td> <td align="right">&nbsp; <input type="submit" value="logout"></td> </tr> </table> <hr> <h2>choose action perform...</h2> <table align="center"> <tr> <td><h3> <input type="button" value="employee list" onclick="window.location='viewemployee.jsp'" /> | </h3></td> <td><h3> <a href="addemp

ruby on rails - CarrierWaveDirect passthrough uploading doesn't seem to be creating alternate :thumb version in s3 -

i'm trying thumbnail image saved s3 once original saved, doesn't seem work. original file there, however. my guess since s3 being submitted image directly, thumbnail creation callback doesn't happen or something. i've tried doing .recreate_versions! , , saw s3 doing stuff see on invocation, image.url(:thumb) still gives link 404 result. here's uploader's code: include carrierwave::minimagick include carrierwavedirect::uploader version :thumb process :resize_to_fill => [100, 100] end storage :fog def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end here's template code generates direct submission form s3: <% badge.image_uid.success_action_redirect = "http://" + request.host_with_port + "/badge_builders/" + badge.badge_builder.id.to_s + "/edit" %> <%= direct_upload_form_for badge.image_uid |f| %> <div class="form-group"> <

laravel - Unit test not triggering try/catch statement -

the test class below fails following error. method error() mockery_15_illuminate_log_writer should called 1 times called 0 times. i trying assert modelnotfoundexception thrown , code in catch section being run. seems exception being thrown correctly reason stops there. couldn't find in docs first time testing try/catch may missing something. thanks in advance. let me know if need more info. note: $this->userrepo mocked object being injected through constructor. in case wasn't clear. class: public function fire() { try{ //if useremail option specified, run email specific user if($this->option('useremail')) { // point exception thrown $user = $this->userrepo->findby('email', $this->option('useremail')); // other non-important code } else { // other code } } catch(modelnotfoundexception $e) { // code not being run when excep

sql server - How do you send emails to multiple people, with different criteria, using dbmail in MS SQL -

i have below sql query building send automated emails various people. right have setup email table 1 person. what send specific query results specific people based on condition. example want send email containing data sc = 20 abc@email.com, , separate email sc = 30 xyz@email.com. in addition, if there no data particular sc not send email them. how can adjusted accommodate that? i'd appreciate feedback. thank you. use dst14000busd declare @tablehtml nvarchar(max) ; set @tablehtml = n'<h1>data issues</h1>' + n'<p>this automated email. please review , correct these issues possible. thank you.</p>' + n'<p>periods in address or city field. periods not allowed in addresses because not supported other systems.</p>' + n'<table border="1">' + n'<tr><th>issue</th><th>status</th>' + n'<th>school</th><th>id&

java - Exceptions, failed deploy when using Gemfire source with SpringXD -

i have following stream definition in springxd: stream create datalistener --definition "gemfire --regionname=data --uselocator=true --host=lithium --port=10334 | null" --deploy but gives me following errors, , marks 'failed': [error 2015/04/09 16:09:20.265 art <pooltimer-client-pool-2> tid=0x59] unexpected error in pool task <com.gemstone.gemfire.cache.client.internal.liveserverpinger$pingtask@5a422dfd> java.lang.linkageerror: loader constraint violation: when resolving method "com.gemstone.gemfire.cache.client.internal.pingop.execute(lcom/gemstone/gemfire/cache/client/internal/executablepool;lcom/gemstone/gemfire/distributed/internal/serverlocation;)v" class loader (instance of org/springframework/xd/module/support/parentlasturlclassloader) of current class, com/gemstone/gemfire/cache/client/internal/liveserverpinger$pingtask, , class loader (instance of sun/misc/launcher$appclassloader) resolved class, com/gemstone/gemfire/cache

spring - save camel messages between routes -

we use spring dsl define camel routes. in 1 case message headers disappear. our design requires audit trail debug issues, , prove messages moving designed. use , reference audit processor create message file name 2 headers, 1 constant, other unique variable. can't use setheader in case of variable one. here generic example includes commented attempts failed: <route id="msg_in"> <from uri="direct:msg_in" /> <wiretap ref="audit" processorref="auditpreprocessor" /> <to uri="direct:to_json" /> </route> <route id="to_json"> <from uri="direct:to_json" /> <!-- below seemed have failed --> <!-- <setproperty propertyname="saveid"> --> <!-- <simple>${in.header.uniqueid}</simple> --> <!-- </setproperty> --> <bean ref="jdbcprocessor1" />

Rest, Spring own OAuth2 server + OAuth2 providers like Facebook, Google, Yahoo -

in spring boot application have secured spring mvc rest endpoints spring security , spring oauth2. have own authorization\resource servers in order comunicate our api, client(angularjs) needs obtain acesstoken api authorization server. everything works fine authentication/authorization on api, user needs create account , provide username/password. i'd simplify process , propose user authenticate on api via google/facebook/twitter oauth providers. right have no clear understanding how must work.. example 1 of ideas - facebook issue own accesstoken , pass api. based on accesstoken api issue own accesstoken , pass client application(angularjs). or should pass facebook accesstoken directly client app ? what correct architecture described case ? how should work ? maybe there example demonstrates architecture based on spring framework ? if want delegate authentication external provider can use oauth2clientauthenticationprocessingfilter , or convenience annotations

swift - TestFlight: No SKSpriteNodes -

Image
i try test spritekit game in testflight. when install build via testflight app shows gray screen admob banner have integrated in storyboard. seems whole gamescene not loaded. installing directly cable works fine. could related fact have deleted gamescene.sks file? i error message times: i using xcode 6.3 , swift 1.2 okay, solved problem. problem was, deleted gamescene.sks file. restored file works.

Generate scala source for a class instance using reflection -

assuming have instance of class. best approach generate valid scala source code, written out file , compiled, of instance during runtime? (utilizing scala reflection-api/macros?) possible parse ast representation source code? no it's not possible. class file contains jvm byte-code has nothing scala. can try use java-decompiler ( http://varaneckas.com/jad/ example), wouldn't able readable. as unserstand scala moving towards new platform (dotty), , maybe in future possible.

xcode - Can I customize where the iOS Simulator saves its screenshots to? (Instead of the Destktop) -

i'm continually frustrated simulator saving screenshots (from command+s in simulator) desktop, flooding after few weeks. can have save them somewhere else? i know use grab.app or cmd+shift+4, simulator crops out top bar, shadows, etc. nice, i'd keep it. xcode 8.x & earlier : no. saved on desktop. there no option change that. xcode 9.x : select file, save screenshot while holding down option key. prompt location save screenshot. check box make location default screenshots going forward.

javascript - Find element height, including margin -

i'm making simple , fun drawing app, , in structure follows: header canvas footer i'm trying canvas full height of window, minus header height , footer height. i've tried multiple things like: canvas.height = window.height - (document.getelementbyid("header").offsetheight + document.getelementbyid("footer").offsetheight); and i've tried: function getheight(id) { id = document.getelementbyid(id); return id.offsetheight + id.style.margintop + id.style.marginbottom; } canvas.height = window.height - (getheight("header") + getheight("footer")) but no avail. in console id.style.margintop returned empty string, although margintop set in css... not set margintop, it's set margin: 8px 0 8px 0; is there way, without using jquery, obtain rendered height of element, including margin? i'm assuming we'd have separate margin: 8px 0 8px 0; separate variables, using id.style.margin ... i'm not

javascript - Using JS how to dynamically change the text background color in a displayed html file -

i have log file ( .log ) , wanted open log file html page. , specific strings, have change text color, e.g. if text apple there in log file, wanted show text apple in green color. any help? having program converts log file html wrap "apple" strings in final html this <span class="myappleclass">apple</span> and either using css file or style tag inside head tag css class green this <head> <style> .myappleclass { color: green; } </style> </head> would work.

Testing vim plugin private functions -

i'm creating vim plugin has couple of private functions , i'm trying add unitary testing using vim-vspec . what best way invoke these private functions in test file? for now, created public function invokes private one, don't think that's approach because i'm loosing point of having private function. here's of code " file foo.vim (the plugin) " private function fu! s:foo(arg) ... endfu " public function fu! invokefoo(arg) call <sid>foo(a:arg) endfu " file foo-unittest.vim (the test file) runtime! plugin/foo.vim describe 'foo function' 'should have behavior' call invokefoo(...) " expectations ... end end i tried creating maps private functions when call exe map_combination doesn't have effect on testing buffer. i found solution question here , , gives 1 approach variables , functions. variables for variables, used vim's scopes. calling :help intern

java - JTabbedPane, data inside the JTable's -

Image
i have problem data, inside cell in selected tab contains jtable want calculations. made 3 tabs 3 tables, each cell of table have integers tests. want select tab index=1 try make easy formula sum(x+y), work of course not data index=1 lastindex of jtabbedpane. can tell me how solve problem? public class tabbedtable extends formpanel implements changelistener{ private jtabbedpane jtabbedpane; private int spreadcount; private taskpane taskpane; private multioptionpane multioptionpane; private spreadsheet[] spreadsheet; public tabbedtable(string col,string row){ super(col, row); initializepanel(); initializetaskpane(); this.setborder(borderfactory.createbevelborder(1, colors.mygray.color().darker(), colors.mygray.color().brighter())); jtabbedpane.setui(new tabbedui()); jtabbedpane.addchangelistener(this); jtabbedpane.setfont(fonts.calibri.font()); } private void initializepanel(){ this.spreadcount = 3; this.createtabbedpane(); } private voi

c# - Unity3d attach texture to the cube problems -

i have created cube in scene , want attach texture cube scripting. problem there no error of code cube doesn't change after press run in program... here code using unityengine; using system.collections; public class testing : monobehaviour { void start(){ texture2d tex = (texture2d)resources.load("bluecolortex.png", typeof(texture2d)); renderer.material.maintexture = tex; } } void start() { texture2d tex = (texture2d)resources.load("bluecolortex", typeof(texture2d)); renderer.material.maintexture = tex; } resources.load not use extensions. common mistake. returns asset @ path if can found otherwise returns null. objects of type t returned. path relative resources folder inside assets folder of project, extensions must omitted. from: http://docs.unity3d.com/scriptreference/resources.load.html

database - Query is much faster in c# above System.Data.SQLite if first load SQLite table into .NET DataTable and then use DataTable.Select. why? -

i have tables in sqlite database. use c# , system.data.sqlite dll access database. test shows following query slow: string sql = "select column1, column2 table_1 column1=1 , column2=2" sqlitecommand mycommand = new sqlitecommand(cnn); mycommand.commandtext = sql; sqlitedatareader reader = mycommand.executereader(); tb.load(reader); reader.close(); but if first load whole table .net datatable below, , use datatable.select(), it's faster: string sql = @"select * '" + data_table_name + "'" + ";\n"; sqlitecommand mycommand = new sqlitecommand(cnn); mycommand.commandtext = sql; sqlitedatareader reader = mycommand.executereader(); tb.load(reader); reader.close(); datarow[] rows = tb.select("column1=1 , column2=2"); the difference more significant if have multiple queries after loading whole table. this cache whole table in .net. tried different kind of tables different sizes , primary keys, behave same. for now, k

sms - Twilio message sent to Mexico with different number from the one bought on twillio -

i'm using twillio sending sms rails app. integration easy, found problem. when send message recipient receive sms different number 1 have configured on twillio web interface. in case recipients automatically reply message , need reply twillio numbers in order process texts. twillio numbers based while recipient's number mexico. update: in cases – , mexico 1 of – due limitation provider of country sender id translated local number. solution use local mexican number , had request beta global numbers since mexico numbers not yet open.

javascript - How to replace YUIDoc's index partial with the classes partial? -

Image
i'm trying build docs source on 1 of plugins. works fine index page empty , useless. want replace index partial content of classes partial since that's useful info plugin. it looks index partial doesn't have access data that's available in classes partial? i've attached 2 screenshots illustrate i'm talking about. second screen shot want show on index page. i've tried importing partial there nothing rendered except static heading. you're not able easy because index template of theme doesn't have classes , modules data. please feel free file issue on github, or patch welcome.

csv - Powershell looking through all columns searching for a keyword -

using powershell, lets have csv file contains fname,lname,id,etc.. is there way use where-object through of columns instead of one. for example, instead of doing: import-csv location |where-object {$_.fname -eq "hi"} next line: import-csv location |where-object {$_.lname -eq "hi"} , on. it like: import-csv location |where-object {any -eq "hi"} yes, iterate on $_.psobject.properties inspect every column , return $true if 1 of them matches: import-csv document.csv |where-object { foreach($p in ($_.psobject.properties |? {$_.membertype -eq 'noteproperty'})) { if($p.value -match "hi"){ $true } } }

java - Blue Pelican Add 'Em Up Project -

i've been working on blue pelican java project called add 'em several hours now, , can't figure out how work. project description this: consider following program allows 8 + 33 + 1,345 +137 entered string input keyboard. scanner object uses plus signs (and adjoining whitespace) delimiters , produces sum of these numbers(1523). import java.io.*; import java.util.*; public class tester { public static void main(string args[]) { scanner kb = new scanner(system.in); system.out.print("enter 8 + 33 + 1,345 +137 : "); string s = kb.nextline( ); scanner sc = new scanner(s); sc.usedelimiter("\\s*\\+\\s*"); int sum = 0; while(sc.hasnextint( )) { sum = sum + sc.nextint( ); } system.out.println("sum is: " + sum); } } the output typically this: enter 8 + 33 + 1,345 +137 : 8 + 33 + 1,345 + 137 sum is: 1523 modify program allow either plus or minus signs. don’t forget allow leading plus or minus sign on first number in sequence. if leading number ha

sql - Insert or replace not replacing in some cases with python sqlite3 -

i writing script scans through bunch of news articles , stores in sqlite database of individual words , how many times each word appears. in order using insert or replace described in this question. problem i'm having doesn't replace when should. think causing since sql queries happen in parallel, 1 word being inserted database , time script finds next appearance of same word, hasn't finished inserting database makes new entry (i.e. inserts instead of replaces). valid concern? if so, how make script wait until previous sql query has finished before executing next one? here code inserting/replacing: def incremement_or_insert(subject, word): db = connect_to_db() c = db.cursor() query = "insert or replace subject_words (subject, word, count) values (?, ?, coalesce((select count + 1 subject_words subject = ? , word = ?), 1));" c.execute(query, (subject, word, subject, word)) db.commit() db.close

python 3.x - Need help calculating a percentage of GC content in a DNA sequence -

i know simple need add code calculate percent of gc content in sequence of dna. easiest way add this? #!/cygdrive/c/python34/python #this program takes dna sequence (without checking) , shows length, #individual base composition (the percent of each kind of base), , gc content #(also percent) of user supplied sequence. dnaseq = "acgt" dnaseq = input ("enter dna sequence: ") dnaseq = dnaseq.upper() #convert uppercase .count() function dnaseq = dnaseq.replace(" ","") #remove spaces print("sequence:", dnaseq) seqlength = float(len(dnaseq)) print("sequence length:", seqlength) baselist = "acgt" base in baselist: percent = 100 * dnaseq.count(base) / seqlength print("%s: %4.1f" % (base,percent)) try this: gcount = dnaseq.count('g') ccount = dnaseq.count('c') gccontent = round((gcount + ccount) / seqlength, 4) print(gccontent)

Hadoop: Unable to allocate more than 8 GB Memory to my nodes -

my hadoop setup allocating 8 gb of ememory each node tough machines have 126gb ram , 32 cpu. i added following properties yarn-site.xml allocate 24 gb memory each node. <property> <name>yarn.scheduler.minimum-allocation-mb</name> <value>1024</value> </property> <property> <name>yarn.scheduler.maximum-allocation-mb</name> <value>2048</value> </property> <property> <name>yarn.nodemanager.resource.memory-mb</name> <value>24576</value> </property> i added following mapred-site.xml <property> <name>mapreduce.tasktracker.map.tasks.maximum</name> <value>32</value> </property> <property> <name>mapreduce.tasktracker.reduce.tasks.maximum</name> <value>16</value> </property> <property> <name>mapreduce.job.reduce.slowstart.completedmaps</name> <value>0.

numpy - python image not found after paraview brew install -

i runing python scripts on mac , after "brew install paraview" lot of packages not working anymore : import vtk, or import scipy.linalg ... here example 1 of bug: would have idea how fix this? traceback (most recent call last): file "mv15.py", line 3, in <module> import scipy.linalg slin file "/usr/local/lib/python2.7/site-packages/scipy/linalg/__init__.py", line 159, in <module> .misc import * file "/usr/local/lib/python2.7/site-packages/scipy/linalg/misc.py", line 5, in <module> . import blas file "/usr/local/lib/python2.7/site-packages/scipy/linalg/blas.py", line 145, in <module> scipy.linalg import _fblas importerror: dlopen(/usr/local/lib/python2.7/site-packages/scipy/linalg/_fblas.so, 2): library not loaded: /usr/local/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/libgfortran.3.dylib referenced from: /usr/local/lib/python2.7/site-packages/scipy/linalg/_fblas.so reason: image not

.htaccess - Add trailing-slash in URL structure -

can please me write correctly .htaccess file. have this: rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l] so rewrites domanname.com/page.php domanname.com/page - if type in domanname.com/page/ goes 404 page. should change correct problem. thanks. adding trailing slash @ end i received many requests asking how add trailing slash @ end. ignore first snippet , insert following code. first 4 lines deal removal of extension , following, addition of trailing slash , redirecting. link html or php file shown above. don’t forget change code if want applied html file. rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^/]+)/$ $1.php rewriterule ^([^/]+)/([^/]+)/$ /$1/$2.php rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !(\.[a-za-z0-9]{1,5}|/)$ rewriterule (.*)$ /$1/ [r=301,l] more info: http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htacces

swift - iOS Storyboard: Not able to instantiate view controller properly -

Image
i'm having trouble instantiating custom view controller. this storyboard set up. third view controller 1 i'm trying present. i've tried both of these methods. 1: results in black screen. var searchcontroller: searchcontroller = searchcontroller() self.presentviewcontroller(searchcontroller, animated: true, completion: nil) 2: results in white, empty view controller popping up. let mainstoryboard = uistoryboard(name: "main", bundle: nsbundle.mainbundle()) let searchcontroller : uiviewcontroller = mainstoryboard.instantiateviewcontrollerwithidentifier("searchcontroller") as! uiviewcontroller self.presentviewcontroller(searchcontroller, animated: true, completion: nil) here code actual view controller: class searchcontroller: uiviewcontroller { lazy var searchbar: uisearchbar = uisearchbar(frame: cgrectmake(0, 0, 200, 20)) override func viewdidload() { super.viewdidload() var leftitem = (uibarbuttonitem)(custo

tcp - Synchronization in C# networking -

i have simple tcp server class class server { private tcplistener tcplistener; private thread listenthread; public server() { this.tcplistener = new tcplistener(ipaddress.parse("127.0.0.1"), 3000); this.listenthread = new thread(new threadstart(listenforclients)); this.listenthread.start(); console.writeline("hello"); } private void listenforclients() { this.tcplistener.start(); while (true) { //blocks until client has connected server tcpclient client = this.tcplistener.accepttcpclient(); //create thread handle communication //with connected client thread clientthread = new thread(new parameterizedthreadstart(handleclientcomm)); console.writeline("new connexion"); clientthread.start(client); } } private void handleclientcomm(object client) { tcpclie

javascript - Ember serializers & adapters not loading -

i have ember-cli app using ember 1.11.1, ember-data 1.0.0-beta.16.1 & ember-cli 0.2.1 i have serializer in app/serializers/role.js generated via ember g serializer role import ds 'ember-data'; export default ds.restserializer.extend({}); and have adapter in app/adapters/application.js: import ds 'ember-data'; export default ds.restadapter.extend({namespace: 'api/1'}); when load app, chrome ember inspector shows no sign of serializer or adapter in container section. the correct code appear in /assets/frontend/frontend.js when view source in browser: define('frontend/serializers/role', ['exports', 'ember-data'], function (exports, ds) { 'use strict'; exports['default'] = ds['default'].restserializer.extend({}); }); define('frontend/adapters/application', ['exports', 'ember-data'], function (exports, ds) { 'use strict'; exports['default

java - Comparing items in a String Array with items in an ArrayList of Hashmaps -

so have 2 string arrays: string[] = {"tony", "33", "male", "new york"}; string[] b = {"john", "33", "male", "chicago"}; then have arraylist of hashmaps: arraylist<hashmap<string, string>> list = [{"name": "john", "age": "33", "gender": "male", "city": "chicago"}], [{"name": "tony", "age": "33", "gender": "male", "city": "new york"}]; so array or b first method. want compare 'name' or value @ index 0 in string or b same 'name' value in arraylist, string or b value @ index 1 '33' same 'age' value in arraylist , forth. have tried following: for(int = 0; <= list.size(); i++) { assertequals(b[0], list.get(i).get("name")); assertequals(b[1], list.get(i).get("age"));

java - How to find the selected row in the JTable to remove it? -

i tried make jtable has 1 column jbutton removing selected row. still don't know add in buttons actionlistener identify row , remove it. here code: public class javaapplication81 { jframe frame; jpanel panel; jtable table; jscrollpane tablescroll = new jscrollpane(); defaulttablemodel tablemodel; public javaapplication81(){ frame = new jframe("frame"); panel = new jpanel(); string col[] = {" ", "file", "remove"}; tablemodel = new defaulttablemodel(col,0); table = new jtable(){ private static final long serialversionuid = 1l; //returning class of each column allow different //renderes used based on class @override public class getcolumnclass(int column){ return getvalueat(0, column).getclass(); } }; table.setmodel(tablemodel); table.setpreferredscrollableview

python - Intersection of lists, look for on length -

if looking intersection of 2 lists, b1 = set(alist).intersection(alist2) print(b1) however if want intersection of 2 lists of words of length 4 only. for example. so if alist = ["james", "kobe", "ball"] and alist2 = ["jimmy","james","kobe"] i expect b1 = ["kobe"] because kobe of length 4 while james not do need take out words of length 4 list first ? or there way check while doing intersection ? you can use comprehension this: four_letter_intersection = { word word in set(list_a).intersection(list_b) if len(word) == 4 }

javascript - Timer Stops Only After Second Click? -

not sure why happening. when start timer , click stop, not stop. when click stop twice, stops. tried re-arranging logic flow , can not find conclusion. function stoptimer(); 1 stops function. input appreciated! js bin: http://jsbin.com/baxuxamoso/2/edit html <h1><div id="time">00:00:00</div></h1> <div id="result"></div> <button id="start" onclick="startclock();">start</button> <button id="stop" onclick="stoptimer();">stop</button> <button id="clear" onclick="resettimer();">reset</button> js var currenttime = document.getelementbyid('time'); var hundreths = 0; var seconds = 0; var minutes = 0; var t; function timer() { t = settimeout(add, 10); } function add() { hundreths++; if (hundreths > 99) { hundreths = 0; seconds++; if (seconds > 59)

dictionary - How to share the key across the different map in c++? -

i'm working on map, stored data 2 different map(it nested map) having same key, way store data single ds rather 2 different nested maps. following 2 nested maps: std::map<keystruct, std::map<classobjsharedptr, std::set<classobjsharedptr> > > map1; std::map<keystruct, std::map<classobjsharedptr, std::set<classobjsharedptr> > > map2; here map1 , map2 have same key values. i have maintained 2 different maps specific purpose. can store both maps in single ds? each key (i.e. each key have 2 internal map). why not use single std::map required data? example code struct data { std::map<classobjsharedptr, std::set<classobjsharedptr> > mdata1; std::map<classobjsharedptr, std::set<classobjsharedptr> > mdata2; }; std::map<keystruct, data> mmapdata;

mysqli - PHP, MySQL(i) and Dropzone -

i wondering if can tell me i'm doing wrong. goal pretty simple. using dropzone or php upload file , insert record database. able post record except 1 field showing "array" entry. i've tried changing variable names, inserting , removing quotes, etc no avail. suggestions appreciated. here code. <?php $ds = directory_separator; //1 $storefolder = 'uploads'; //2 if (!empty($_files)) { $tempfile = $_files['file']['tmp_name']; //3 $targetpath = dirname( __file__ ) . $ds. $storefolder . $ds; //4 $targetfile = $targetpath. $_files['file']['name']; //5 move_uploaded_file($tempfile,$targetfile); //6 } $servername = "localhost"; $username = "root"; $password = "***************"; $dbname = "drop"; // create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // check connection if (!$conn) { die(

javascript - Adding Desktop Notifications to Your Web Applications even if user not in the Web Application or user logged off from the site -

i trying implement browser notification if user not in web application(asp.net mvc web application), can push notifications through browser.is there possible way implement this?also tried http://blog.teamtreehouse.com/adding-desktop-notifications-to-your-web-applications also.can please help? if use signalr communicate client-server ,can notification if user close browser,and users session exist in browser? if understand question correctly, asking not possible web based application. in order post kind of notification desktop not directly triggered web app, in user not have app open in browser, need have process running on user's system polling updates display, falls outside of original question. if asking how can create notifications directly app itself, whether or not tab in focus, have posted answer yourself.

node.js - Lodash forEach function won't line break yeoman generator integration -

in yeoman generator's index.js file have code snippet this.fs.copytpl( this.templatepath('/index2.html'), this.destinationpath('app/index2.html'), { title: [this.templatedata.test1, this.applicationname], h1: this.applicationname } ); i trying run lodash foreach statement in html file , won't line break no matter try. <% _.foreach(title, function(title) { %><li><%- title %></li>\n<% }); %> the result is: <li>star wars!</li>\n<li>foundation5application</li>\n what expect is <li>star wars!</li> <li>foundation5application</li> is there can correct foreach statement? use actual line break: <% _.foreach(title, function(title) { %><li><%- title %></li> <% }); %>

c# - Authorize on Ajax call -

so have mvc5 project , have ajax call when clicking button, controller called have custom attribute made framework can redirect login page similar non-ajax [authorize] . custom attribute: public class ajaxauthorizeattribute : authorizeattribute { protected override void handleunauthorizedrequest(authorizationcontext context) { if (context.httpcontext.request.isajaxrequest()) { dynamic urlhelper = new urlhelper(context.requestcontext); context.httpcontext.response.statuscode = 403; context.result = new jsonresult { data = new { error = "notauthorized", logonurl = urlhelper.action("registration", "membership") }, jsonrequestbehavior = jsonrequestbehavior.allowget }; } else { base.handleunauthorizedrequest(context); } } } controller : [httppost()] [ajaxauthorize()]

javascript - Changing button value on button click -

just starting out in xpages , ran silly problem: i have button (id- "button2") , has label "aaa". i'm trying change value of button on button click value "kappa123". i've included javascript in "client" tab in script editor. javascript: var elem = document.getelementbyid("button2"); if (elem.value=="aaa") elem.value="kappa123"; else elem.value = "aaa"; i don't error , nothing happens. doing wrong? use var elem = document.getelementbyid("#{id:button2}"); if (elem.innerhtml=="aaa") elem.innerhtml="kappa123"; else elem.innerhtml = "aaa"; you can't use element id in client side code direct id gets "renamed" xpages. #{id:button2} rendered id.

Rails invalid byte sequence in UTF-8 (ArgumentError) -

all doing rails s code downloaded server, running without problem, stubborn go past error rails s => booting thin => rails 4.0.2 application starting in development on http://0.0.0.0:3000 => run `rails server -h` more startup options => ctrl-c shutdown server exiting /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/builder.rb:36:in `[]': invalid byte sequence in utf-8 (argumenterror) /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/builder.rb:36:in `parse_file' /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app' /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in

perl - Signal handler not working with double eval -

i have code timeout long-running process ( sleep in case): #!/usr/bin/env perl use strict; use warnings; die "usage: $0 sleep timeout\n" unless @argv == 2; ( $sleep, $timeout ) = @argv; $|++; eval { local $sig{alrm} = sub { die "timeout\n" }; alarm $timeout; eval { # long-running process print "going sleep ... "; sleep $sleep; print "done\n"; }; alarm 0; # cancel timeout }; die $@ if $@; when run ./alarm 5 2 , expect die saying "timeout". exits 0 , says nothing. works expected when remove inner eval block (not block's content, eval ) though. can explain why that? thanks. because trap error in first eval block , second eval block not have exception , clears $@ . eval { local $sig{alrm} = sub { die "timeout\n" }; alarm $timeout; eval { # long-running process print "going sleep ... "; a: sleep $

payment method - Opencart 1.5.6.4 : COD orders jumps to missing orders -

i've read other threads missing orders, makes different i'm using "free checkout" , "cash on delivery" payment methods, don't need make external call payment processor. i've checked think of , can't seem figure out. i've been using opencart 1.5x while no issues. do have 'confirm' function in catalog/controller/payment/cod.php? class controllerpaymentcod extends controller { protected function index() { $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['continue'] = $this->url->link('checkout/success'); if (file_exists(dir_template . $this->config->get('config_template') . '/template/payment/cod.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/cod.tpl'; } else { $this->template = 'default/template/payment/cod.tpl

javascript - OnClick event is not working in mobile browser -

i have html page in have added onclick event in div tag. in onclick event have used location.href = url open url. working fine in web browser not working in mobile browser. reason ? code - <html class="swipebox-html swipebox-touch"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <link rel="stylesheet" href="../css/swipebox.css"> <script src="../js/jquery-2.1.0.min.js"></script> <script src="../js/jquery.swipebox.js"></script> <script type="text/javascript"> jquery(function($) { window.onload = function(e) { e.preventdefault(); $.swipebox([ { href : '../img/sari1.jpg' }, { href : '../img/sari2.jpg' }, { href : '../img/sari3.jpg

debugging - How to make android debug stable? -

usually when debugging application , run code step step , debugger lost connect. happens in complex operation code. how make debug stable? you may compile gdb statically , push on device, , may run debugger right on device.

Different classification results in Weka: GUI vs Java library -

i've problems when comparing weka gui classification results java program, performing tree (j48) iris dataset. i'd grateful if me. i'm working iris dataset, , i'm trying develop java program classify new instances. this, i've used weka gui obtained model ("iris_tree(cv).model"), trained , validated (cross-validated 10 folds). results weka gui , expected: 4 incorrectly classified instances. after save model used later java program. when load model "iris_tree(cv).model" in java program, , try classify new instances (testing dataset), results different: java programm classifies 'setosa' , 'virginica', not 'versicolour'. these results: classification: setosa classification: setosa classification: virginica classification: virginica classification: virginica classification: virginica when expected obtain: classification: setosa classification: setosa classification: versicolour classification: versicolour classifi