Posts

Showing posts from August, 2012

javascript - How to nest Sequelize associations? -

i trying nest associations using node/sequelize/postgresql. common scenario (i believe), have yet determine how it. here scenario. person -- location (1:m) ----- sublocation (1:m) the person model has belongstomany association working great. have personlocation table holds ids of both person , location , location(s) returned person query. here's gets tricky. need associate personlocation sublocation needs 1:m relationship. person.belongstomany(location, {through: 'personlocation'}); --this how envision work, since defined personlocation association, cannot access way. personlocation.belongstomany(sublocation, {through: 'personlocationsublocation'}); the person have 1:m locations, each of locations have multiple 1:m sublocations. when doing query on person, want see person/locations/sublocations person. the database person id name location id name sublocation id name personlocation id personid locationid pers...

authentication - Google service account doesn't see project ID -

i'm trying authorize using gcloud service account: gcloud auth \ activate-service-account "${gc_service_account}" \ --key-file <filename> \ --project <project name> it authorizes successfully, can't seem find project showing following error commands: error: (gcloud.compute.copy-files) not fetch instance: - resource 'projects/<project name>' not found p.s. works fine gcloud auth login for sake of else encounters problem: looks transient issue. please generate new service account , try again. if doesn't work, please comment on answer.

Spring/AngularJS- receiving null data on server -

on ui/form have <div ng-controller="myformcontroller"> <form name="dataform" ng-submit="submitform()"> first name:<br> <input type="text" ng-model="user.firstname" value="{{user.firstname}}"><br> last name:<br> <input type="text" ng-model="user.lastname" value="{{user.lastname}}"> <br><br> <input type="submit" value="submit"> </form> </div> and controller on ui-side configured mycontrollers.controller('myformcontroller', ['$scope','$http', function myformcontroller( $scope, $http){ $scope.user = { "firstname": "firsname", "lastname": "lastname", ...

r - why function rbind.data.frame behave different in do.call -

Image
i have question do.call, pretty strange 1. trying do i trying bind many data frames 1 single data frame, data frames in list t3, may see pic below: 2. methods 2.1 1 works t4 <- do.call(rbind.data.frame, t3) 2.2 not works t4 <- rbind.data.frame(t3) the error message below: 3. question i think rbind.data.frame behave same if remove do.call, why works if using do.call? in advance. the function do.call(fun, list) designed accept input function fun along list input list . applies function each element in list , aggregates results. in call t4 <- rbind.data.frame(t3) you trying rbind list of data frames, when rbind.data.frame function expecting single data frame instead of t3 input. you use rbind.data.frame without do.call if wanted to. assuming had 5 elements in list t3 , following should work: t4 <- rbind.data.frame(t3[[1]], t3[[2]], t3[[3]], t3[[4]], t3[[5]]) as can see, tedious (and not readable) quickly. advantage...

cordova - backbutton event is not been fired in phongap -

i developing mobile app using phonegap, have problem in handling backbutton event. code is, i have device ready in index.js var app = { // application constructor initialize: function() { this.bindevents(); }, bindevents: function() { document.addeventlistener('deviceready', this.ondeviceready, false); }, ondeviceready: function() { parseplugin.initialize("xxxxxxx", "xxxxxxx", function(){ //nothing required }, function(e){ alert('unable initialize parse!'); }); parseplugin.getinstallationid(function(id) { window.localstorage.setitem("devicetoken", id); }, function(e) { alert('unable devicetoken!'); }); app.receivedevent('deviceready'); window.location = "main.html" }, // update dom on received event receivedevent: function(id) { } }; app...

c++ - QT QIcon properties for custom widget in designer -

Image
i have been working little while on creating qt custom designer widget gui menus. idea being drag designer, select number of frames you'd like, how many buttons per frame, etc. , generates , sizes you. the way widget structured there properties configure each button frame in. example, use button0text field enter text under button0 while editing in frame 0, use again edit button0 in frame 1. both buttons retain individual changes each frame. the problem normally when switch frames of properties updated reflect status of frame. exception being qicon. correct icon retained in actual graphical representation , builds correctly, file path in property list of last edited property. think extremely confusing end user , have found no way fix it. example, if set text , icons in frame 0 switch frame 1 text in property list update reflect state of frame 1 icon path names still show last edit in frame 0 , not actual icon in frame 1. i have tried things simple as: setproperty(...

javascript - JS function to hide or show elements -

Image
i have json files, load them both 2 tables this: $(window).load(function(){ $.getjson('http://1xxxxxx/xxxxx_1_18.json', function(data) { var output="<div class='outer'>"; (var in data.lbclassic118) { output+="<div style='visibility:hidden;' class='lbclassic118'id="+"age" + data.lbclassic118[i].ageinweeks+">"+ '<table class="table table-responsive"><tr class="cabecera"><th colspan="3"><center><strong>age (weeks)'+ data.lbclassic118[i].ageinweeks+'</strong></center></th></tr><tr><td rowspan="3">body weight (g)</td><td>average</td><td><strong>'+ data.lbclassic118[i].average+'</strong></td></tr><tr><td>range min</td><td><strong>'+ data.lbclas...

Infinite Log with PaperClip and Ruby on Rails -

i got big weird issue when upload file, posted bug/issue on official git page: https://github.com/thoughtbot/paperclip/issues/1938 as press submit button of form, 5 min loop of logs console started rail server . here my model : class ship < activerecord::base belongs_to :user has_many :users, through: :votes has_many :users, through: :comments has_attached_file :shipimage, #:styles => { :thumb=> "100x100#", :small => ["150x150>", :jpg] }, :default_url => "/images/shipimages/missing_:style.png", :url => "/images/shipimages/:id_:style_:basename.:extension" #validates_attachment_presence :shipimage validates_attachment_content_type :shipimage, :content_type => [ "image/jpg", "image/jpeg", "image/png" ] # validates_attachment :image, presence: true, # content_type: { content_type: ['image/...

c# - How decorate in structuremap? -

i try decorate iprojectservice can't find documentation struturemap for<iprojectservice>().use<projectservicelogdecorator>(); for<iprojectservice>().use<projectservice>() .decoratewith((context, decorator) => context.getinstance<projectservicelogdecorator>()); what wrong? exeption: bi-directional dependency relationship detected! check structuremap stacktrace below: 1.) new projectservicelogdecorator( default of irepository , default of iunitofwork , default of iprojectservice , default of iprincipal , default of auditeventlogger ) 2.) project.services.projects.projectservicelogdecorator 3.) instance of project.services.projects.projectservicelogdecorator 4.) funcinterceptor of project.services.projects.iprojectservice: icontext.getinstance() 5.) project.services.projects.projectservice 6.) instance of project.services.projects.iprojectservice (project.services.p...

Android APK certificate matches prior APK but does not upgrade -

i have signed apk same private key earlier releases. i've compared certificates following command. unzip -p meta-inf/cert.rsa |openssl pkcs7 -inform der -out 1.txt -print_certs i run command above on 2 apks , diff output. when that, there no differences in file. yet, when attempt upgrade app, asked uninstall , install new app instead of in-place upgrade. any thoughts on why apk signature can match yet, can prompt take right actions.

cryptography - brainpool320r1 Elliptic Curve not supported in Java Card? -

i working on java card 3.0.1 applet on use ecc. card supports ecc gf(p) 320bits, tried use brainpool320r1 elliptic curve ( parameters ). problem cryptoexception don't understand... same kind of problem had few time ago: restricted elliptic curves in java card solution given doesn't match case (the curve defined 320bits prime). i post corresponding code : byte[] p = new byte[] { (byte) 0xd3, (byte) 0x5e, (byte) 0x47, (byte) 0x20, (byte) 0x36, (byte) 0xbc, (byte) 0x4f, (byte) 0xb7, (byte) 0xe1, (byte) 0x3c, (byte) 0x78, (byte) 0x5e, (byte) 0xd2, (byte) 0x01, (byte) 0xe0, (byte) 0x65, (byte) 0xf9, (byte) 0x8f, (byte) 0xcf, (byte) 0xa6, (byte) 0xf6, (byte) 0xf4, (byte) 0x0d, (byte) 0xef, (byte) 0x4f, (byte) 0x92, (byte) 0xb9, (byte) 0xec, (byte) 0x78, (byte) 0x93, (byte) 0xec, (byte) 0x28, (byte) 0xfc, (byte) 0xd4, (byte) 0x12, (byte) 0xb1, (byte) 0xf1, (byte) 0xb3, (byte) 0x2e, (byte) 0x27 }; byte[...

javascript - Google map polygon with outside map tinted -

this question has answer here: google maps api polygon “hole” in center 1 answer first of all, issue you're going read, used snippet of code highlight polygon : highlight polygon , tint rest of map using google maps here code (it's angular) : var boundaries = []; // big area var overlay = [ new $rootscope.googleapi.latlng(80.0, -90.0), new $rootscope.googleapi.latlng(-60.0, -90.0), new $rootscope.googleapi.latlng(-60.0, 90.0), new $rootscope.googleapi.latlng(80.0, 90.0) ]; // polygon angular.foreach(settings_boundaries, function(val, key) { boundaries.push(new $rootscope.googleapi.latlng(val[1], val[0])); }); // create polygon overlay first var poly = new $rootscope.googleapi.polygon({ paths: [overlay, boundaries], strokecolor: "blue", strokeweight: "1", fillcolor: "black", fillopac...

java - Date split - algorithm -

i have few date ranges have split there no overlapping sets. in below table, record 0 has split 2 (0-1/01/2014-1/11/2014), (0-1/12/2014-1/12/2014) differentiate first range range not overlapping other ranges , and second range overlapping record# 1 range. table1 record# start date end date 0 1/05/2014 1/12/2014 1 1/12/2014 1/23/2014 2 1/14/2014 1/16/2014 result table need this... table2 record startdate enddate 0 1/05/2014 1/11/2014 0 1/12/2014 1/12/2014 1 1/12/2014 1/12/2014 1 1/13/2014 1/13/2014 1 1/14/2014 1/16/2014 2 1/14/2014 1/16/2014 1 1/17/2014 1/23/2014 i have followed approach below, didn't give me desired results. prepare list: (1/05/2014, 1/12/2014, 1/14/2014, 1/16/2014, 1/23/2014) prepare interval list: (1/05/2014, 1/11/2014), (1/12/2014, 1/13/2014), (1/14/2014, 1/15/2014), (1/16/2014, 1/23/2014)

css - jQuery on load event do not trigger script -

first looking @ onload event, when read it, discovered or going deprecated, search , found info use on event check if image loaded: load() method deprecated? but simple animation trigger, not work. element not visible. works if reload browser. animation worked perfect until added load event. wrong , how can improve code work better? $("#intro-img").on("load", function() { $(".intro-content").animate({ left: '20px', opacity: '1.0' }); }); edit: script running after used window instead of id. $(window).on("load", function() {.... script should run when content on page has been loaded? guess there never guarantee work 100% images!? $('#book').on("load",function(){ //animate }); problem approach when image loaded cache load event has possibility never triggered.when image first downloaded jquery can have chance attach event before image loaded , work expected.but if im...

java - How to get a String from HTTP and use it to build a JSON Object? -

i try string (a json file in reality) http server store data twitch stream. the string got connecting : api.twitch.tv/kraken/streams/lainkk i string in string variable , build json object string. i wrote methods got systemerr in log while calling methods: this own twitch api class : package com.linkpulsion.bibix; import android.util.log; import org.json.jsonobject; import java.io.bufferedreader; import java.io.inputstreamreader; import java.net.url; import java.net.urlconnection; public class twitch { private string channel; public final static string twitch_api_server = "https://api.twitch.tv/kraken/"; /** * constructor of java twitch api json generator * @param channel cannel name infos */ public twitch(string channel){ if(channel != null){ this.channel = channel; } } /** * getter channel name * @return string channel name */ public string getchannel(){ return this.channel; } protected string getjson(string mode){ str...

android - Activity flags / launchmode / pendingintent -

i read lot on android documentation launchmode , activity flags can't figgure out. i'm using following code open activity nothification: intent intent = new intent(context, home.class); intent.setflags(intent.flag_activity_new_task | intent.flag_activity_single_top); pendingintent contentintent = pendingintent.getactivity(context, notification_id++, intent, pendingintent.flag_update_current); in manifest declared home activity android:launchmode="singleinstance" all works fine except when close app (not in background) onstart method gets called not oncreate , have no idea why?! i need following: app open , visible user: user click on nothification, existing home activity active , onnewintent gets calls (works fine) app in background (user pressed home button):: user click on nothification, existing home activity active , onnewintent gets calls (works fine) app closed: user click on nothification, home activity gets created because first run! (do...

mongodb - JavaScript - Convert 24 digit hexadecimal number to decimal, add 1 and then convert back? -

for objectid in mongodb, work 24 digit hexadecimal number. because need keep track of second collection, need add 1 hexadecimal number. in case, here's value var value = "55a98f19b27585d81922ba0b" what i'm looking is var newvalue = "55a98f19b25785d81922ba0c" i tried create function this function hexplusone(hex) { var num = (("0x" + hex) / 1) + 1; return num.tostring(16); } this works smaller hex numbers hexplusone("eeefab") => "eeefac" but fails miserably hash hexplusone(value) => "55a98f19b275840000000000" is there better way solve this? this version return string long input string, overflow ignored in case input "ffffffff". function hexincrement(str) { var hex = str.match(/[0-9a-f]/gi); var digit = hex.length; var carry = 1; while (digit-- && carry) { var dec = parseint(hex[digit], 16) + carry; carry = mat...

django - Allowing login depending on hostname (remote) -

i have django intranet reachable on http(s)://somename/ , http(s)://10.10.0.30/, using allowed_hosts setting: allowed_hosts = [u'10.10.0.30', u'somename',] now i'd allow certain users login website remotely well. first step i'll have add external url (like somename.com ) allowed_hosts ; no problem there. moment on, everyone account able log in, not want. i thinking in terms of having group called permitremotelogin - when user part of group, logging in host somename.com allowed. i'm unsure actual implementation and/or whether doable in first place (?). when searching e.g. djangopackages , no results found. idea whether has been done before? i've done similar things in past, it's quite easy actually. need replace normal authentication backend own: https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#writing-an-authentication-backend the default backend looks this: https://github.com/django/django/blob/master/d...

android - How can I parse stream video (byte array, H264) to ExoPlayer? -

i develop application android shows stream video received video server. takes video ip-cameras, codes them libav codec byte array , passes result byte array stream clients. mediacodec can't this. i've searching it, question asked there , no result. any ideas how use exoplayer task?

How to replace array values according to a value replace map in PHP? -

assume have array: $origin = ['value1', 'value2', 'value3', 'value4']; and replace map array: $replace_map = [ 'value1' => 'replace1', 'value2' => 'replace2', 'value8' => 'replace8', ]; i want replace $origin array , expect result be: $result = myreplace($origin, $replace_map); $result = ['replace1', 'replace2', 'value3', 'value4']; i can loop $origin , each items lookup $replace_map array_key_exists , , replace value in $replace_map , but think not best way, sounds not efficient. is there better way this? further more, if origin values integers, negative, keys in map array positive, like: $origin = [-12345, 23456]; $map = [12345 => 98765]; also need change -12345 -98765 . $origin = ['value1', 'value2', 'value3', '-2']; $replace_map = [ 'value1' => 'replace1...

Fullwidth Embeded Youtube Video -

i'm trying embed youtube video full screen. there's problem: video has black sides on right , left. here example: https://www.youtube.com/embed/vxy1g2jejo0?autoplay=1&modestbranding=1&controls=0&showinfo=0&rel=0&enablejsapi=1&allowfullscreen=true&wmode=transparent&iv_load_policy=3&html5=1 there's right , left bands on screen. i want make here: http://acwistanbul.com/ please, me. couldn't find solution. perhaps resource may http://embedresponsively.com explanation on said resource enter youtube video link , click embed. generate code fullscreen'd responsive embedded youtube video.

c# - Retrieve Account Number using account GUID in Dynamics CRM -

i'm new linq please apology if ask wrong question. want retrieve account number in dynamics crm using account guid , linq. unable find. i've following snippet gives me exception specified cast not valid accountid = (guid)contact["parentcustomerid"]; var account = in context.createquery("account") a.getattributevalue<guid?>("accountid") == accountid select new {accountnumber = a["accountnumber"] }; what accountid ? guid or nullable<guid> try below snippet: accountid = (guid)contact["parentcustomerid"]; var account = in context.createquery("account") a.getattributevalue<guid>("accountid") == accountid select new {accountnumber = a.getattributevalue<int>("accountnumber") }; you can use query expression . easy use: queryexpression queryexpression = new queryexpression("account"); queryexpression.columnset = new columnset("accountnumber...

ios - Accessing Data Outside of Closure -

i have array in class i'm trying fill within closure. however, when try access/print array contents, seems empty outside of closure. how store data use outside of closure? for index in 0..<6 { let picnumber = index + 1 if let pica = currentuser.objectforkey("pic\(picnumber)") as? pffile { pica.getdatainbackgroundwithblock({ (data:nsdata!, error:nserror!) -> void in if error == nil { self.pic1 = uiimage(data: data) var images = scaleimage(self.pic1!, and: 200) self.imagesforsection0.append(images) } }) println(self.imagesforsection0) } } it not empty outside closure the method getdatainbackgroundwithblock async ,it means return first.so,you see nothing in print function. document asynchronously gets data cache if available or fetches contents network. edit for index in 0..<6 { ...

java - JavaFX make content fit to Gridpane cell -

so, trying let user upload pictures gridpane so far managed pictures shown, problem if window size changed pictures stay same size. i tried using computed sizes margins doesn't work way want it. pic 1, way want be: http://imgur.com/1xjvpff pic 2, how gets displayed http://imgur.com/a/b2cmd edit: here's code of tab pictures: <tab closable="false" text="bilder"> <content> <gridpane> <columnconstraints> <columnconstraints hgrow="sometimes" minwidth="10.0" prefwidth="100.0" /> <columnconstraints hgrow="sometimes" minwidth="10.0" prefwidth="100.0" /> <columnconstraints hgrow="sometimes" minwidth="10.0" prefwidth="100.0" /> <columnconstraints hgrow="sometimes" minwidth="10.0" prefwidth="100.0" /> ...

ios - How to keep auto-sized table cells format consistent after edition/deletion of rows using UIKit? -

Image
i have simple table view unique label cell prototype. have been following recommendations in order have proper auto-sizing cells: setting auto-layout constraints label regarding leading, trailing, top , bottom spacing in content view, setting rowheight property uitableviewautomaticdimension , providing estimatedrowheight property (set 44), setting number of lines label 0. i have enabled default edit mode allows reordering , deletion of rows (exactly in alarm tab of apple clock app). now, on observed problem: i provide 2 labels, 1 short text , second longer text, second row has twice height of first row. i enter edit mode, , swap position of rows. far, keeps composure , sizing still correct, longer label being in top row. when swap positon again return original layout (short label on top , long label on bottom), longer text not spread on 2 lines in row should, turns one-line display ellipsis @ end. moreover, height of cell remains same , not fit single-lined...

c# - ASP.NET Web API Controller output is always buffered -

how send output without buffering? defined api controller way: public class defaultcontroller : apicontroller { [httpget] [route] public httpresponsemessage get() { var response = request.createresponse(); response.content = new pushstreamcontent( (output, content, context) => { using (var writer = new streamwriter(output)) { (int = 0; < 5; i++) { writer.writeline("eh?"); writer.flush(); thread.sleep(2000); } } }, "text/plain"); return response; } } output appears in browser @ once, looks waits start sending till completion. defined attribute: [attributeusage(attributetargets.class, allowmultiple = false)] class nobufferattribute : attribute, icontrollerconfiguration { public vo...

c# - Call Post method having multiple parameters in cshtml file -

i have declared method in mvc webapi as: [route("api/user/loginuser")] public string postlogin(string email, string password, string authkey) { // return ""; } now in cshtml file testing purpose calling method as: function loginuser() { $.ajax({ url: baseurl + "api/user/loginuser", type: "post", contenttype: 'application/json; charset=utf-8', data: json.stringify({ email: "xyz@gmail.com", password: "password", authkey: "1234" }), datatype: 'json', success: function (data) { // soemthing }, fail: function (data) { // failed } }); } but api never called. not getting problem. please me, stuck bigtime here. thanx in advance. kind of appreciated. let's make little examination. creating new webapi project, create testc...

python - Flask CORS - no Access-control-allow-origin header present on a redirect() -

i implementing oauth twitter user-sign in (flask api , angular) i keep getting following error when click sign in twitter button , pop window opens: xmlhttprequest cannot load https://api.twitter.com/oauth/authenticate?oauth_token=r-eufwaaaaaagjsmaaabtp8vcie. no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. i using python-cors packages handle cors, , have instagram sign in working correctly. believe has response being redirect have not been able correct problem. my flask code looks this: app = flask(__name__, static_url_path='', static_folder=client_path) cors = cors(app, allow_headers='content-type', cors_send_wildcard=true) app.config.from_object('config') @app.route('/auth/twitter', methods=['post','options']) @cross_origin(origins='*', send_wildcard=true) #@crossdomain(origin='') def twitter(): request_token_url = ...

How to stop Jenkins log from becoming huge? -

recently jenkins.log has started getting large, quickly, full of exceptions dns resolution. attempted use logrotate, log file grows rotated, , eats disk space, causes various services fail because cannot write files anymore. how avoid that? you can disable logging of these dns errors adjusting logging settings within jenkins. from jenkins web interface go to: manage jenkins -> system log -> log levels (on left) add following entry: name: javax.jmdns level: off this way can keep multicast dns feature without logging data.

c# - Generate password for AD user account that meets complexity policy -

i need create ad users automatically. problem is, making sure generated password meets password policy of ad . don't know policy be, there way determine @ runtime? i'm using can see complexity static length=16 , 4 non-alphanumeric chars , might not work. looking way password policy ad generated passwords correct. userprincipal = new userprincipal(oprincipalcontext); up.samaccountname = userid; up.setpassword(system.web.security.membership.generatepassword(16, 4)); up.enabled = false; up.expirepasswordnow(); up.save(); this i'm using. i'm getting password properties using directoryentry/ldap , use create password. directoryentry child = new directoryentry("ldap://machine/dc=domain,dc=com"); int minpwdlength = (int)child.properties["minpwdlength"].value; int pwdproperties = (int...

java - Meaningful XML comparison -

i trying achieve meaningful xml comparison. want compare 2 different xml know if 'meaningful' equal. example xml 1: <?xml version="1.0" encoding="utf-8"?> <al:moattribute> <al:name>impiid</al:name> <al:value>616731935012345678</al:value> </al:moattribute> <al:moattribute> <al:name>impuid</al:name> <al:value>tel:+16167319350</al:value> </al:moattribute> xml 2 : <?xml version="1.0" encoding="utf-8"?> <al:moattribute> <al:name>impuid</al:name> <al:value>tel:+16167319350</al:value> </al:moattribute> <al:moattribute> <al:name>impiid</al:name> <al:value>616731935012345678</al:value> </al:moattribute> in example both xmls 'meaningful' equal differs in seq...

outputstream - Java properties file is saved in system32 folder -

Image
so, have method saves data in properties file weird happens. see, lets have jar file on desktop. if open directly there (double click, etc) properties file saved in desktop, should be. however, if drag jar windows start list , open there, properties file saved in system32 folder. here method: private void saveancientsdata() { properties prop = new properties(); outputstream output = null; try { output = new fileoutputstream("ancients.data"); file file = new file("ancients.data"); // set properties value (int x = 0; x < currentlvlspinnerfields.size(); x++) { prop.setproperty(ancientnames[x], currentlvlspinnerfields.get(ancientnames[x]).getvalue().tostring()); } // save properties project root folder prop.store(output, null); joptionpane.showmessagedialog(this, "data saved in \n\n" + file.getcanonicalpath(), ...