Posts

Showing posts from January, 2012

Android push notification for adf mobile: Message is coming blank -

we trying implement push notification adf mobile. followed these 2 below blogs our implementation http://deepakcs.blogspot.in/2013/06/adf-mobile-push-notifications-with.html and server side have refered information present here http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/ we facing issue while receiving notification message gcm. when send notification our provider application receive notification alert sound , client app name message coming blank or null . our onmessage() method(this method invoke when push notification arrives in client app follows) public void onmessage(event event) { //parsing payload json string jsonbeanserializationhelper jsonhelper = new jsonbeanserializationhelper(); try { payloadserviceresponse serviceresponse = (payloadserviceresponse)jsonhelper.fromjson(payloadserviceresponse.class, event.getpayload()); map session = (map)adfmfjavautilities.evaluate...

c++ - ffplay compilation with a custom header -

i re-compile ffplay custom header , library (which libosc) could tell me how pass library linker in makefile i following error: http://pastebin.com/1z3sijjq libosc has been compiled , libosc.a file in libosc source folder i compile test program implementing testoscheader.h (my custom header) testoscheader.c , compiling gcc gcc -o testoscheader testoscheader.c htmsocket.c ../libosc/libosc.a the htmsocket.c htmsocket.h can found here http://archive.cnmat.berkeley.edu/osc/src/sendosc/ libosc can found here http://archive.cnmat.berkeley.edu/osc/src/libosc/ could me compile ffplay header update:: there errors rid of 1 puzzling: in file included htmsocket.c:40:0, testoscheader.h:3, ffplay.c:47: /usr/include/netinet/in.h: @ top level: /usr/include/netinet/in.h:368:17: error: expected ‘)’ before ‘__hostlong’ there include "netinet/in.h" in ffplay.c , there no errors when compile without custom header. raises error if ad...

ruby - Internal rails notifications -

i'm creating rails app, imports stuff external service. @ end of import, user should info how many new items has been imported (it's periodical check, adds new items local database. not of them each time.). whole process , method-chain quite complex i'm looking best-practice on how pass such information nested method. schema looks more or less that: some_controller.rb -> model.method() -> lib1.method1() -> lib2.method2() -> lib3.method3() -> lib4.method4() -> lib5.method5() -> items_import_method() and need somehow pass info how many new items has been imported items_imported_method() some_controller.rb (or other place import fired). obvious way of doing passing new_items_count var way though whole method chain seems bit wrong me. isn't there better way? i thinking kind of internal events/messages system let me subscribe custom channel, activeresource events maybe there well-known ...

Populate Combobox from a pre-stored parametriced Access-Query -

i'm workin ms access 2010 database. need combobox show result of sql select sentence time sql sentence long asigned rowsource property of combobox. to solve problem have created accesss-query , stored in access database queries section name "myquery". it's sql code similar longer following query: parameters [myparameter] long; select field1, field2, field3 [mytable] [mytable]![fieldn] = [myparameter] as can see, query has parameter. once created query changed vb code this: me.mycombo.rowsource = "myquery" 'the name of query created before me.mycombobox.requery 'execute query populate combobox it works fine before each execution ms-access shows pop-up window asking value of parameter. ¿how can avoid pop-up window , asign or bind value parameter each time new population needed? like me.mycombo.rowsource = "myquery" 'the name of query created before me.mycombobox.rowsource.parameters("[myparameter]...

c# - Incorrect results while decrypting AES-128-ECB text -

i have piece of base64 text, know encrypted in aes-128-ecb mode , , know key ( yellow submarine , 16 bytes). i'm using following code decrypt it. textbox1 contains cyphertext; textbox2 contains key private void button6_click(object sender, eventargs e) { byte[] ctbytes = system.convert.frombase64string(textbox1.text); byte[] keybytes = new byte[textbox2.textlength]; string key = textbox2.text; aes decryptor = aes.create(); decryptor.mode = ciphermode.ecb; decryptor.blocksize = 128; (int icounter = 0; icounter < textbox2.text.length; icounter++) keybytes[icounter] = convert.tobyte(textbox2.text[icounter]); decryptor.keysize = keybytes.length * 8; decryptor.key = keybytes; decryptor.padding = paddingmode.none; icryptotransform decr = decryptor.createdecryptor(); byte[] plaintext = null; us...

sql - Why does Sybase ASE throw a truncation error in a division followed by a subtraction? -

i using sybase ase 15. in following sql, there truncation error, if division of 2 numbers followed subtraction. declare @p1 decimal (30,16) declare @p2 decimal (30,16) select @p1 = 0.0000504412630951 --sixteen decimal places select @p2 = 0.0000512178647912 select 'this succeeds:' select @p1, @p2, (@p1 / @p2) --this succeeds: displays values select 'this fails:' select @p1, @p2, (@p1 / @p2) - 1.0 --this fails truncation error. why? select 'why succeed?' select @p1, @p2, round( (@p1 / @p2), 46 ) - 1.0 --this succeeds 46 or less, fails 47 or greater - why? thanks in advance. bob the 1.0 not decimal datatype @p1 , @p2 , it's created float since not specify precision , scale (or cast numeric/decimal data type). first attempt succeeds because there no implicit conversion, you're dividing 2 decimals same precision/scale. 2nd attempt fails because subtracting 1.0 subtracting float v...

excel - How to paste data to specific cell range? -

i'm new vba , need little help. have sheet named "archive" have 12 sets of data displayed/structured in of table format. goal pull data other sheets within same workbook , paste in specific range corresponds appropriate "table" data. here code data being pulled sheet named "daily db" , being pasted "archive" sheet. sub getdailydatabyweek() dim cw integer ' current week dim lr long 'last row of data dim long ' row counter 'clear exsisting contents worksheets("archive").range("a5:e11").clearcontents 'get week number , year of current date cw = format(date, "ww") worksheets("daily db") ' find last row of data lr = .cells(rows.count, 1).end(xlup).offset(1, 0).row = 2 lr if format(.cells(i, 1).value, "ww") = cw .range(.cells(i, 1), .cells(i, 5)).copy worksheets("archive").range("a" & row...

How to deal with dark areas of R perspective plot -

Image
i'm having strange problem persp() function inside r. i'm using split.screen() function arrange 3 plots. i've produced mwe below: f <- function(x,y) { return(x*y) } u <- seq(0,5, = 0.1) v <- seq(0,5, = 0.1) z <- outer(u, v, f) persp(u,v,z, ticktype="detailed", col = rgb(0.2,0.6,1)) pdf("~/desktop/test.pdf", width = 10, height = 10) # adjust path necessary split.screen( figs = c( 2, 1 ) ) split.screen( figs = c( 1, 2 ) ) screen(2) persp(u,v,z, ticktype="detailed", col = rgb(0.2,0.6,1)) screen(3, new = false) persp(u,v,z, ticktype="detailed", col = rgb(0.2,0.6,1)) screen(4, new = false) persp(u,v,z, ticktype="detailed", col = rgb(0.2,0.6,1)) close.screen(all = true) dev.off() looking @ resulting pdf, surfaces quite dark, in left side. when print file darker (too dark). i've attached screenshot of plot zoom of 1 of 3 plots in rstudio. looks better. i'd 3 plots plot zoom in rstudio, when...

jQuery synchronous Ajax request returns 'undefined' -

this question has answer here: how return response asynchronous call? 21 answers i trying jquery synchronous ajax call return boolean value, when test return value 'undefined'. jquery code: function foo() { var username = "hello" if (checkusernameexist(username)) { //do here } } function checkusernameexist(username) { return $.ajax({ type: 'post', url: "check_username.php", data: { username: username}, async: false, }).responetext; } php code: <?php //sets connection (among other things) include 'common.php'; //check have username post var if(isset($_post['username'])) { //check if ajax request, exit if not if(!isset($_server['http_x_requested_with']) , strtolower($_server['http_x_requested_with']) != 'xmlhttpreq...

php - How to create Codeigniter language files from database? -

i'm building multi-language online site codeigniter. question how pass data database codeigniter language files . logic far run foreach query, populate language file translation_key , value. problem language files aren't extended ci_class classes , don't know how move on. how approach problem? documentation doesn't nothing how use language class database. you on right track. you’ll want create language file on fly (e.g. whenever update language contents of database) 1st: database layout create table lang_token columns id , category , description , lang , token , populate fields this: create table if not exists `lang_token` ( `id` int(11) not null auto_increment, `category` text not null, `description` text not null, `lang` text not null, `token` text not null, primary key (`id`) ) engine=innodb default charset=latin1 auto_increment=3 ; insert `lang_token` (`id`, `category`, `description`, `lang...

javascript - Get element by id not working -

i trying google maps display several locations onclick shown below not getting function b. doing wrong? thanks javascript function b(){ dlat=40.856771; dlng=0.578294; alert(dlat); getloc(); } function init() { document.getelementbyid("click").onclick = b; } window.onload = init html <ul data-role="listview" data-split-icon="star" data-split-theme="a"> <li><a href="#1"><h1>task1</h1></a><a href="#popup" id="click" data-rel="popup" data-position-to="window" data-transition="fade"> </a></li> </ul> <div data-role="popup" id="popup" data-overlay-theme="a" data-theme="a" data-corners="false" data-tolerance="15,15"> <a href="#" data-rel="back" data-role="button" data-theme=...

jquery ui - Undesired effect on focusout and mouseover - jQueryUI's tooltip -

i'm using jqueryui's tooltip , strange behavior when mouseover or focusout events happen. if try lot of times, you'll see, including tooltip stops working. <input id="test" type="text" title="." /> $('#test').tooltip({ disabled: true, track: false, show: { effect: 'highlight' }, open: function (event, ui) { var tipelement = $(this); settimeout(function () { $(ui.tooltip).hide(); tipelement.tooltip('disable'); tipelement.tooltip('close'); }, 7000); } }); $('#test').on('focusout', function () { $(this).tooltip("option", "content", 'texto.'); $(this).tooltip('enable'); $(this).tooltip('open'); $(this).focus(); }); fiddle

json - Render metadata for pagination from Grails RestfulController index/search actions -

i looking best practices / solution make 'respond' method generate metadata in resulting json along collection of entities got db. basically wanted implement pagination using metadata in frontend single-page-application (spa) built angularjs , restangular plugin. ps: angularjs's $resource or restangular expect collection results js array. standard grails jsoncollectionrenderer/jsonrenderer ignores metadata supplied 'respond' in map argument. i came across following article implementing custom jsonrenderer, looking simpler/flexible solution make 'respond' output metadata via tweaking custom jsoncollectionrenderer in resources.groovy http://groovyc.net/non-trivial-restful-apis-in-grails-part-2/ my restfulcontroller: @secured(value=["hasrole('role_user')"]) class drugcontroller extends restfulcontroller<drug> { static scaffold = true static responseformats = ['html', 'json', 'xml...

uiapplication - Can an iOS App Switch to Safari Without Opening a Page? -

i know app can open particular url in safari doing this: [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"http://www.example.com/"]]; but, there way have app switch on safari without opening url? i'd switch safari, let keep showing whatever page had open last time user looked @ it. unfortunately no, unless can figure out how launch app bundle id in non-jailbroken environment. otherwise, if in jailbroken environment, can use following launch app bundle id: usage: [self launch:(@"com.apple.mobilesafari")]; code: #pragma mark - launch application -(void)launch:(nsstring *)bundle { class sbapplicationcontroller = objc_getclass("sbapplicationcontroller"); id appcontroller = [sbapplicationcontroller sharedinstance]; nsarray *apps = [appcontroller applicationswithbundleidentifier: bundle]; if ([apps count] > 0) { //wait .5 seconds.. launch. [self performselector:@selector(launc...

c# - Flaw in ToolStripItemCollection.AddRange method? -

i convinced in implementation of toolstripitemcollection.addrange mistake: i made windows forms application 2 menus, each 1 containing 2 items. first menu second menu (excuse me, don't have enough reputation post images). next, implement button click handler: private void button1_click(object sender, eventargs e) { menu1.dropdownitems.addrange(menu2.dropdownitems); } and system.argumentoutofrangeexception thrown. i extremely curious why happening , decompiled toolstripitemcollection assembly ilspy. here saw: public void addrange(toolstripitemcollection toolstripitems) { if (toolstripitems == null) { throw new argumentnullexception("toolstripitems"); } if (this.isreadonly) { throw new notsupportedexception(sr.getstring("toolstripitemcollectionisreadonly")); } using (new layouttransaction(this.owner, this.owner, propertynames.items)) { int count = toolstripitems.count; (int =...

tsql - How to improve performance for update statement? -

suppose have lookup table mylookup(lkid, lkname, ...) then have other 2 tables: mytab(id, parentid, name, lookname, ...) yourtab(id, parentid, ...) --id, parentid coming mytab then have update try lkid , it's parent lkid, sql like: update yourtab set columnx = case when (select lkid mylookup join mytab b on a.lkname = b.lkname b.id = c.parentid ) > 3 , (select lkid mylookup join mytab b on a.lkname = b.lkname b.id = c.parentid ) > (select lkid mylookup lkname = c.lkname ) 1 else 0 end yourtab c this sql performance not good. (select lkid mylookup join mytab b on a.lkname = b.lkname b.id = c.parentid ) called 2 times each row in yourtb. how rewrite sql improve performance case? maybe this.. it's untested need sqlfiddle sample data understand inner workings. update yourtab set columnx = case when not null ( select lkid mylookup inner join mytab b on a.lkname = b.lkname b.id = c...

javascript - Backbone script executing before document fully loaded -

i building first rails app backbone , because of asset pipeline javascript getting called/executed before document loads. so, none of event handlers getting attached. if place javascript after html tags @ end of document, seems work fine. how can have code execute after page loaded? can use jquery's document.ready(), hoping backbone has inbuilt process deal it. <script type="text/javascript"> (function() { "use strict"; var app; app = {}; app.appview = backbone.view.extend({ el: "body", initialize: function() { this.playaudio(); }, events: { "click .play-audio": "playaudio" }, playaudio: function() { alert($("span").data("audio")); } }); app.appview = new app.appview(); }).call(this); </script> <div> <p>whatever!</p><span class="gl...

excel - QueryTables Method - irregular table size -

i handed vba macro written else no longer works company , asked add additional functions. macro uses querytables method, unfamiliar with, import data fixed-width text file excel. file has basic information in first row (date , time, recording number, etc.) , actual data begins in second row. text file has 4 columns , uses quotes indicate data 1 sensor ends , begins within column. example: 20140529 15:11:42 rec# 0001 'sensor1 ''sensor2 ''sensor3 ''sensor4 ' 0.00000 1500.00 1.05400e-01 0.123799e-02 0.100000 1510.00 -7.68900e-01 0.404716e-02 'sensor5 ''sensor6 ''sensor7 ''sensor8 ' 0.710000e-01 0.250000e-01 2.12500 1.87100 0.450000e-01 0.290000e-01 2.36200 2.19200 originally, mac...

ios - How to Sort an NSArray of UIColor Objects -

i wrote class has property of type uicolor called color. how can sort nsarray containing handful of instances of class color property? have tried code below error: [uicacheddevicergbcolor compare:]: unrecognized selector sent instance. best way sort uicolor objects? nssortdescriptor *sort = [[nssortdescriptor alloc]initwithkey:@"color" ascending:yes]; array = (nsmutablearray*)[array sortedarrayusingdescriptors:@[sort]]; you need use comparator return wether 1 color greater other. nssortdescriptor *sort = [[nssortdescriptor alloc]initwithkey:@"color" ascending:yes comparator:^(id obj1, id obj2) { if (do math determine color bestest) { return (nscomparisonresult)nsorderedascending; }else{ return (nscomparisonresult)nsordereddescending; } }];

Cant make simple Python program run through Windows command prompt -

so wrote simple python test file called test testprog.py , , looks this: import sys def adder(a, b): sum = a+b print sum if __name__ == "__main__": = int(sys.argv[1]) b = int(sys.argv[2]) adder(a, b) from question here , did command: python testprog.py 3 4 however following error message: file "testprog.py", line 5 print sum ^ syntaxerror: invalid syntax i not sure issue it... can run python command prompt no issue, why cant replicate questions' solution? thanks. edit: python 3.4 used it looks have python 3 installed. code running written python 2, has different syntax. example, need change print(sum) . in general, should search around information on difference between python 2 , 3, , careful note version used in code find on internet. code written python 2 not run as-is on python 3.

winforms - how to create a custom DataGridViewComboBoxCell with floating label on it -

i want have 2 controls in same datagridview column. i want customize datagridviewcomboboxcell show values of selected value , on floating label text. in past able checkbox , label problem datagridviewcomboboxcell comes out empty datasource when override paint event. i tried assign datasource again after used paint event although see values in datagridviewcomboboxcell , label showing right value, infinite loop see gui blinking constantly. 10x help. the code following: *when form loads mydgvcheckboxcolumn col = new mydgvcheckboxcolumn(); col.datapropertyname = "value"; col.datasource = list; col.displaymember = "yes"; col.valuemember = "value"; col.defaultcellstyle.alignment = datagridviewcontentalignment.middlecenter; this.datagridview1.columns.add(col); this.datagridview1.rowcount = 50; the class generic list: public class checkthis { public string yes { get; set; } public...

ask for android location in one intent and get it on another -

i know how gps location, there lot of tutorials out there. with enough time can gps location, time of essence. , ask current location when ap opens , leave ready use on intent; in new intent ask 1 update location set. right doing simple: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.settings); locationmanager = (locationmanager) getsystemservice(context.location_service); locationmanager.requestlocationupdates(locationmanager.gps_provider, 0, 0, this); } @override public void onlocationchanged(location location) { alertdialog alertdialog = new alertdialog.builder(this).create(); alertdialog.settitle("gps location"); alertdialog.setmessage("latitude:" + location.getlatitude() + ", longitude:" + location.getlongitude()); alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, i...

activemq - Java binding to ::0 on IPv4-only machine? -

i have java program listens incoming connections on port. i've been using 0.0.0.0 ip address accepts connections on ip on multihomed system. well, ipv4 address, is, , i'd switch ipv6 equivalent, ::0 , accept incoming ipv6 connections well... if code run on ipv4-only system, still work? update : binding, in case, expressed in form of url - it's configure activemq broker - can't provide null . don't specify listen-address @ all. pass null. listen on nics in whichever of ipv6 , ipv4 present on host,

java - getting value from other class -

i want id number user use log in display data related user id, if make sense. code index bean(index.java), getting id simple inputtext: private string id; public string getid() { return id; } public void setid(string id) { this.id = id; } and code user it(class table) public class table { index = new index(); final string pno=i.getid(); public list<index> getmylist() { list<index> list = new arraylist<index>(); preparedstatement pstmt = null; connection con = null; resultset rs = null; try { class.forname("com.mysql.jdbc.driver"); con = drivermanager.getconnection("jdbc:mysql://localhost:3306/try", "root", ""); string sql = "select task.tno, clientcase.name "+ "from clientcase join task on clientcase.cno = task.cno "+ "where task.responsiblepno = ? , (task.statue='opened'or task.statue= ...

javascript - UIRouter - Dynamically change ui-view attribute -

i dynamically change ui-view attribute such each time attribute changes, view changes too... i use multiple views follow: $stateprovider.state('main', {url: "/main", views: { '': { templateurl: "partials/main", controller: "mainctrl" }, 'clients@main': {templateurl: "partials/client-list", controller: "clientlistctrl"}, 'impexp@main': {templateurl: "partials/imp-exp", controller: "impexpctrl"} } } ); in mainctrl define $scope variable follow: $scope.main_view = 'clients'; and html/jade: div(ng-attr-ui-view='{{ main_view }}' the problem when change dynamically $scope.main_view, view doesn't change. is possible dynamically change ui-view? if is, how? stateprovider (possibly app.js) $stateprovider .state('main', { url: "/m...

Scraping .php websites -

i'v been having trouble scraping following website content: http://www.qe.com.qa/wp/mw/marketwatch.php using file_get_contents() never gets me right tag. scrape content of following tag: td aria-describedby="grid_offerprice" is website protected scraping? because when try same method diffrent websites works. if yes, work around ? the way see if scraping works output file_get_contents returns. if have nothing or error maybe ip has been restricted admin. if returns source code it's working maybe tag you're looking has not been found. eliminate failures in process answering these questions first, 1 @ time. i viewed source code , aria attribute searching doesn't appear exist. it seems load data on page source @ this page ( http://www.qe.com.qa/wp/mw/bg/readdata.php?types=selected&itype=so&dummy=1401401577192&_search=false&nd=1401401577279&rows=100&page=1&sidx=&sord=asc ) if want data page use file_get_conte...

reduceByKey method not being found in Scala Spark -

attempting run http://spark.apache.org/docs/latest/quick-start.html#a-standalone-app-in-scala source. this line: val wordcounts = textfile.flatmap(line => line.split(" ")).map(word => (word, 1)).reducebykey((a, b) => + b) is throwing error value reducebykey not member of org.apache.spark.rdd.rdd[(string, int)] val wordcounts = logdata.flatmap(line => line.split(" ")).map(word => (word, 1)).reducebykey((a, b) => + b) logdata.flatmap(line => line.split(" ")).map(word => (word, 1)) returns mappedrdd cannot find type in http://spark.apache.org/docs/0.9.1/api/core/index.html#org.apache.spark.rdd.rdd i'm running code spark source classpath problem ? required dependencies on classpath. you should import implicit conversions sparkcontext : import org.apache.spark.sparkcontext._ they use 'pimp library' pattern add methods rdd's of specific types. if curious, see sparkcontext:1296

jquery - Javascript - Swap input element on click -

saw on xe.com swap currency on form. need site also. not question, solve problem , sharing here: html <form target=""> <input name="input1" id="firstinput" value="input #1"> <input name="input2" id="secondinput" value="input 2"> </form> <a class="swap">swap</a> javascript $(document).ready(function () { $("a.swap").click(function(){ var axix = document.getelementbyid("firstinput").value; var byiy = document.getelementbyid("secondinput").value; document.getelementbyid('secondinput').value = axix; document.getelementbyid('firstinput').value = byiy; }); }); demo: http://jsfiddle.net/z5vse/ any better way it? share us. :) shorter (not "better"): $("a.swap").click(function () { $('#pickup').val([$('#destination').val(), $(...

jquery - Backbone : access model's data from collection's remove method -

i looking way remove 1 of model's data sets using collection's remove method. doesn't seem work in way. there way remove data in model collection's method? here code. helloworldmodel.set({things: value}); helloworldcollection.add([ {things: helloworldmodel.get("things")} ]); helloworldcollection.remove(?????????); thanks you need reference object add collection remove it; following possible solution. though create actual model containing slimmed down version of other model: helloworldmodel.set({things: value}); obj = {things: helloworldmodel.get("things")} helloworldcollection.add(obj); helloworldcollection.remove(obj);

Preview permalink page when customizing tumblr theme -

when developing tumblr theme using built-in tools, there way preview permalink page instead of index page? afaik isn't possible preview permalink page via tumblr customise / editor preview. the option choice between dummy posts or own posts.

xcode - UITabViewController hide / make appear a view in code -

i using xcode 5.1.1. have uitabviewcontroller , used storyboard add 10 views it. works great , "more" , table view free. i want show of tabs @ beginning. once user logs in google+ account (i got working), want rest of tabs appear, since content sensitive user logging in. i have found: [[[[self.tabbarcontroller tabbar]items]objectatindex:3]setenabled:false]; but not want items greyed out, want them removed until log in. get tabbarviewcontrollers , remove them specifying index of need follows: nsmutablearray *tabbarviewcontrollers = [nsmutablearray arraywitharray:[self.tabbarcontroller viewcontrollers]]; [tabbarviewcontrollers removeobjectatindex: 0 or 1 or 2]; [self.tabbarcontroller setviewcontrollers: tabbarviewcontrollers ];

git - Find the most recently introduced file -

using git, how can find newest file? note not same changed file, commit introduced file. git log --diff-filter=a this reveals commits introduced file. can modified show last commit introduced file git log --diff-filter=a -1 or printing diff of file git log --diff-filter=a -p or stat git log --diff-filter=a --stat example

reporting services - SSRS Espression for String to Date Time format -

Image
hi have sql stored procedure ssrs report. below query fetch date used. (convert(char(10), enter_dt, 103), '''') i not in position change query. dat format displayed "dd/mm/yyyy". i want display date format below using ssrs expressions. mm-dd-yyyy please guide me using ssrs expresions. please help. just change display format instead of converting tsql (stored procedure), follow steps go textbox properties, select number & category custom custom format whatever want

ember.js - Why do nested resource routes reset the namespace in Ember? -

let's have photo model , post model, , want both of have comment 's. in rails, routes this: rails.application.routes.draw resources :posts, only: [ :show ] resources :comments, only: [ :index ] end resources :photos, only: [ :show ] resources :comments, only: [ :index ] end end this generates following routes: get /posts/:post_id/comments(.:format) /posts/:id(.:format) /photos/:photo_id/comments(.:format) /photos/:id(.:format) okay, makes sense. if want path comment 's photo id of 9 , i'd use photo_comments(9) . if wanted create same routes in ember, i'd do: app.router.map () -> @resource 'posts', -> @resource 'post', { path: '/:post_id' }, -> @resource 'comments' @resource 'photos', -> @resource 'photo', { path: '/:photo_id' }, -> @resource 'comments' in ember, generates following urls: #/loading #/posts/loading #/posts/:...

plot - Embed in R markdown a googleVis chart generated using a function -

i have function creates same type of googlevis plot different data frames. these plots embedded in markdown file. embedding single plot result='asis' option fails achieve objective when chart object created function. following dummy code same: embedded googlevis plots ===================== text here ```{r} library(googlevis) op <- options(gvis.plot.tag="chart") ``` , plot ```{r result='asis', tidy=true} mark_func <- function(data) { data$mean=mean(data$popularity) cc <- gviscombochart(data, xvar='city', yvar=c('mean', 'popularity'), options=list(seriestype='bars', width=450, height=300, title='city popularity', series='{0: {type:"line"}}')) return(cc) } ``` ```{r result='asis', tidy=true} plt <- mark_func(citypopularity) plot(plt)` ``` i converting markdown file html ...

Get useful information about a JIRA board using the REST API -

i've been digging around documentation jira's latest rest api (6.0.1) try , dig out information particular dashboard (i'm playing around dashing create widget displaying number of open issues in particular sprint). according this: https://developer.atlassian.com/static/rest/jira/6.0.1.html jira.com/rest/api/2/dashboard/11311 give me like: { "id": "11311", "name": "blah", "self": "jira.com\/rest\/api\/2\/dashboard\/11311", "view": "jira.com\/secure\/dashboard.jspa?selectpageid=11311" } which doesn't give me lot of information. in greenhopper times, more useful information like: /rest/greenhopper/1.0/xboard/work/alldata.json?rapidviewid=#{board_id}" (taken here ) seems not work now..any ideas if there's endpoint might return more information? i managed via jql query. '914' agile board id (a neat way find checking last digits of 'report...

php - How can I access multidimentional associative array? -

this question has answer here: get value array 2 answers i have array return database query. i'm not sure how can retrieve value [url]? please advice. thanks. array ( [1] => array ( [0] => array ( [url] => '' [poster] => '' [skin] => siteorigin [ratio] => 1.777 [autoplay] => 0 [info] => array ( [grid] => 0 [cell] => 0 [id] => 0 [class] => '' ) ) [1] => array ( [title] => [text] => '' [filter] => 1 [info] => array ( [grid] => 1 [cell] => 0 [id] => 1 [class] => wp_widget_text ) ) ) this should work fine if you're legitimately trying value particular array: $arr[1][0]['url'] multidimensional arrays arrays within arrays, each bracket operator yields new array can additional dereferenced until value want.

java - Java3D JApplet Flickering with Rotation and Translation -

i'm making game using java3d. involves view translating "wasd" keys , rotating mouse. when rotate , translate @ same time, 3d shapes on screen flicker , forth. i tried researching problem , people need double-buffer java3d automatically double buffers. how can make program run smooth , flicker free? here's portion of code including setup , rotation , translation methods: import java.applet.applet; import java.awt.awtexception; import java.awt.borderlayout; import java.awt.graphicsconfiguration; import java.awt.point; import java.awt.robot; import java.awt.event.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.geometry.colorcube; import com.sun.j3d.utils.universe.simpleuniverse; import com.sun.j3d.utils.universe.viewingplatform; public class playermechanics extends applet implements keylistener, mouselistener, mousemotionlistener { runner runner; simpleuniverse universe; canvas3d c; branchgroup maingroup =...

sql - Hive returning no results on a simple select query -

i have table called processed . last column named monthid . data type column bigint . when fire simple query this, no results: select * processed monthid = 5 ; a few rows table have been shown below. can suggest what's wrong here? 11741 negative 11 69.55 1401172919 48 27 5 11741 negative 11 102.0 1401172997 48 27 5 11741 negative 11 145.78 1401173093 48 27 5 11741 negative 11 70.54 1401173137 49 27 5 11741 negative 11 85.2 1401173146 49 27 5 11741 negative 11 67.47 1401173156 49 27 5 11741 negative 11 92.76 1401173223 49 27 5 as can seen above sample data, last column has monthid = 5 . however, query returns me nothing. i believe problem here had partitioned above table based on column #6. hence, due either permissions issue or somthing funky, query returning nothing. after, dropped table , created again without partition, above query worked fine. more information on this, please refer...

android - Open installed own app from other app -

i trying open android app app(example gmail app) when user clicks specified url. i have succeed clicking sample url , example <data android:host="showonthecloud.com" android:scheme="http" /> </intent-filter> checked myself sending mail me url http://showonthecloud.com but url http://username.showonthecloud.com the username can after logged app. how replace username dynamically in manifest file?. finally got solution adding *. before can achieve it. <data android:host="*.showonthecloud.com" android:scheme="http" />

go - golang timer blocking in goroutines -

below code go example - timers package main import ( "time" "fmt" ) func main() { runtime.gomaxprocs(runtime.numcpu()) timer1 := time.newtimer(time.second * 1) <-timer1.c fmt.println("timer 1 expired") timer2 := time.newtimer(300) //change duration more shorter go func() { <-timer2.c fmt.printf("timer 2 expired") }() stop2 := timer2.stop() if stop2 { fmt.printf("timer 2 stopped") } } if run above code, output like(result one): timer 1 expired timer 2 stopped but if change body of anonymous func be: fmt.printf("timer 2 expired") <-timer2.c the output still before. i'm confused, why second output not like(result two): timer 1 expired timer 2 expired timer 2 stopped as per understanding <-timer2.c blocks remain of goroutine until timer channel value, if put fmt.printf("timer 2 expired") after <-timer2.c...

javascript - Angular Controller Scope -

i new angular js , binding following json html: { "companyname": "company ltd.", "products": [ { "productid": 1245, "name": "trial", "productitems": [ { "productid": 1254, "productitemname": "service 1", "productitemtype": "service" }, { "productid": 7789, "productitemname": "service 2", "productitemtype": "service" } ] } ] } my html table following: <table ng-controller="productcontroller productctrl"> <thead> <tr> <th id="companyname"> <h1 class="h1">{{p...

objective c - Mac SpriteKit - Can't create texture atlas at compile time -

i've been using spritekit while in ios; i'm developing app mac. i've setup texture atlas usual: enable texture atlas generation both project , target (i started "document based application" template, not "spritekit game". has different build settings). drag individual texture image files folder, rename folder "something.atlas" , add folder project, at runtime, create atlas name (i.e., [sktextureatlas atlasnamed:@"something"]; ). obtain individual "textures" name (i.e., [_atlas texturenamed:@"mytexture"]; ) , create skspritenode instances them. i preloading atlas asynchronously, completion handler never gets called (see comments): _atlas = [sktextureatlas atlasnamed:@"something"]; if (!_atlas) { nslog(@"error: failed create atlas!"); // line doesn't execute, atlas not nil. } [_atlas preloadwithcompletionhandler:^(void){ ...

angularjs - Adding scripts on route config -

upon learning angular route styles , it's easier apply different styles on different templates. since makes dynamic, wondering if there's library append scripts file(s) dynamically within route configuration on particular template angular route styles stylesheet? more (focusing more on js: "app/controller/template.js" ) $routeprovider.when("/", { templateurl: "template.html", controller: "templatectrl", css: "css/template.css", js: "app/controller/template.js" }); i planning write external js file controller of template. of course, removing property controller: "templatectrl" on configuration file. make things more easier code management.

javascript - Show/Hide content with Jquery, MVC -

i'm using mvc show on page comments on given post. code: @foreach (var comment in post.comments) { <div> <img src="@url.action("getimage", "post", new { userid = comment.userid })" height="50" width="50"/> @html.displayfor(c => comment.user.firstname) @html.displayfor(c => comment.user.lastname): @html.displayfor(c => comment.text) @html.displayfor(c => comment.datecomment) </div> <hr /> } so gives comments given post. how can show latest 3 post, , rest can loaded "more" button using jquery? order comments latest ones first, on each show more // if have comments class on each comment div $('div.comments').not(':visible')[0].show(); $('div.comments').not(':visible')[1].show(); $('div.comments').not(':visible')[2].show();

php - laravel how to create page restriction -

please tell me how restrict page using laravel, have 3 users. 1. admin, 2. client, 3. partner want if admin logged in open only- admin.index page , if client logged in open only- client.index page i used in route.php following code- route::group(array('before' => 'role'), function(){ route::resource('admin','admincontroller@index'); route::resource('client','clientcontroller@index'); route::resource('partner','partnercontroller@index'); }); using above code if no user login it's coming properly, , suppose if admin logged in, page redirect admincontroller but, if hard coded (url) hit clientcontroller or partnercontroller http://localhost/laravel-login/public/client client page coming. please tell me how avoid these sorry english.. you may use different route filters each route , create individual filters, example: route::group(array('before' => ...

What exactly is narrowing type conversion in java? -

this question has answer here: narrowing type conversion: why assignment of int byte in declaration allowed? 5 answers according knowledge in java, in narrowing type conversion if source in constant in range of byte following allowed: byte b=10; // allowed because 10 in range of byte , 10 constant but when type this: byte b=10l; // not allowed although 10 in range of byte , constant why ? can please tell exact rule these narrowing conversions take place in java. the technical answer — because spec says so. §5.2 "assignment contexts" of the java language specification , java se 8 edition , states in part: in addition, if expression [on right-hand-side of assignment statement] constant expression (§15.28) of type byte , short , char , or int : a narrowing primitive conversion may used if type of variable byte , short , or char ...