Posts

Showing posts from April, 2015

mongodb - How would I develop a relationship User belongs to Groups in Mongoose & Node.js? -

i trying teach myself node.js, coming rails, , want establish relationship: a group has_many users, user belongs_to group how go doing in models? //for user var mongoose = require('mongoose'); var schema = mongoose.schema; var userschema = new schema({ name: string }); module.exports = mongoose.model('user', userschema); //for group var mongoose = require('mongoose'); var schema = mongoose.schema; var groupschema = new schema({ name: string }); module.exports = mongoose.model('group', groupschema); also allow moderator kick out of group if person obnoxious. how target user belonging group , delete user. seems more complicated traditional crud methods. need nested resources in rails, or equivalent? mongoose has feature called population can use set "relationships" (mongodb has limited support relationships). your schema this: var userschema = new schema({ name : string, group: { type: schema.types.obj...

How to make SQL Server 2008 table primary key auto increment with some prefix -

the given query in mysql format. want same query in sql server 2008. create table table1_seq ( id int not null auto_increment primary key ); create table table1 ( id varchar(7) not null primary key default '0', name varchar(30) ); now trigger delimiter $$ create trigger tg_table1_insert before insert on table1 each row begin insert table1_seq values (null); set new.id = concat('lhpl', lpad(last_insert_id(), 3, '0')); end$$ delimiter ; then insert rows table1 insert table1 (name) values ('jhon'), ('mark'); and you'll have | id | name | ------------------ | lhpl001 | jhon | | lhpl002 | mark | this may answer question -- create table 'abcd' prefix, combining identity column id create table dbo.persons ( id int identity (1,1) not null ,personid ('abcd' + convert(varchar(20), id)) persisted not null primary key ,name varchar(100) ); go -- not specify calculated column when inser...

benchmarking - java benchmark with Ellipticgroup / Brent Boyer -

i trying use java benchmark mentioned here: https://www.ibm.com/developerworks/java/library/j-benchmark2/ , can downloaded here: http://www.ellipticgroup.com/html/benchmarkingarticle.html i tried use basic example in article above: import bb.util.benchmark; public class shortindexesloop { public static void main(string[] args) throws exception { callable<integer> task = new callable<integer>() { public integer call() { return fibonacci(35); } }; system.out.println("fibonacci(35): " + new benchmark(task)); } protected static int fibonacci(int n) throws illegalargumentexception { if (n < 0) throw new illegalargumentexception("n = " + n + " < 0"); if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); } } but every execution of benchmark starts exception before running benchmark jun 13, 2015 1:45:37 pm stringutil warning: string not behave...

Restart job in Condor after certain amount time -

i running jobs on condor , have noticed reason subset of jobs run never complete. there setting in submit file kills , resubmits job if takes on amount of time complete? similar question condor timeout idle jobs except want condor not kill jobs, resubmit them well. thanks! you can use kill transition expression in machine class add file ( condor user manual ). like: start = true ... +maxjobexecutiontime = xxx #seconds kill = $(activitytimer) > maxjobexecutiontime like machine kill jobs take more maxexecutiontime. condor retry job.

ios - AVAudioPlayer wont play sound when called in other swift file -

i have 2 swift files - viewcontroller:uiviewcontroller , audioplayer:avaudioplayer. my audioplayer file has function func seagullsound() { var tmp = avaudioplayer() var seagullsound = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource("gulls", oftype: "mp3")!) avaudiosession.sharedinstance().setcategory(avaudiosessioncategoryplayback, error: nil) avaudiosession.sharedinstance().setactive(true, error: nil) var error:nserror? tmp = avaudioplayer(contentsofurl: seagullsound, error: &error) tmp.preparetoplay() tmp.play() println("this function got called!") } i'm trying call function in viewcontroller thru tapping button, using code: @ibaction func playsound(sender: anyobject) { var audio = audioplayer() audio.seagullsound() } the sound not played when click button. however, print statement works. can audio play if move seagullsound() viewcontroller file, know mp3 work. haven...

linux - Server-client in C: Weird behaviour when sending bytes -

i'm trying write server-client program in c wherein client send bunch of messages in form of 5 bytes: first byte contain command, , next 4 contain key. looks this: rc = write(sockfd, &op, 1); if (rc != 1) { printf("error! write() failed: %s\n", strerror(errno)); break; } uint32_t net_num = htonl(num); int nsent = 0; while (nsent < 4) { rc = write(sockfd, &net_num + nsent, 4 - nsent); if (rc <= 0) { printf("error! write() failed: %s\n", strerror(errno)); break; } nsent += rc; } if (rc <= 0) break; } on receiving end, have: while((bytes = recv(socket,buffer,5,0)) > 0) { //printf("%d\t%d\t%d\t%d\t%d\n",(int)buffer[0],(int)buffer[1], (int)buffer[2],(int)buffer[3],(int)buffer[4]); key = ((buffer[4] << 24) | (buffer[3] << 16) | (buffer[2] << 8) | (buffer[1])); ...

javascript - Meteor Collection returns none when deployed on production -

i'm working on meteor application has slider (revolution slider plugin exact) on homepage. have template helper pulls images on collection. works perfect locally, when deployed on meteor's free server, returns nothing collection. also, tried using imagesloaded plugin check if images loaded before running script trigger slider, however, still not work. i've checked developer tools , found out did not load @ all. 'sliders' helper returns nothing. what think might problem. have been solving issue quite time , run out of options. hope can me. thanks! by way, here's code helper: template.homepageslider.helpers({ sliders: function() { return _.map(homepagesliders.find({}, {fields: {url:1, client_name:1}}).fetch(), function(val, index) { return {value: val, active: (index == 0 ? "item active" : "item")} }); } }); html: <!-- slide --> {{#each sliders}} <li clas...

java - @AUTOWIRED : BeanCreationException -

i'm trying follow book title spring mvc beginner's guide , i'm stuck @ creating repository object. keep on getting beancreationexception. not sure else missed. i'm wondering if can me figure out issue. please find below code. thanks. beancreationexception org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [com.packt.webstore.domain.repository.productrepository] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)} xml file: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.sp...

c# - Referencing a non static member with an instantiated object -

i want class render grid each time instantiated, getting error, error cs0120: object reference required access non-static member `unityengine.gameobject.getcomponent(system.type)' so instantiate object of renderer called rend , set equal non-static member still getting error? appreciated have researched several hours , still can't figure out. using unityengine; using system.collections; public class setgrid : monobehaviour { public int x = 1; public int y = 1; void start() { renderer rend = gameobject.getcomponent<renderer>().material.maintexturescale = new vector2 (x, y); } } i assuming script part of grid game object has component of type renderer . the correct syntax scale texture of renderer following: public class setgrid : monobehaviour { public int x = 1; public int y = 1; void start() { // reference renderer component of game object. renderer rend = getcomponent<rend...

unity3d - Create random falling objects in unity C# -

i starting learn unity3d , developing 2d game need @ main menu. have coin texture spawn multiple times above screen , fall down create falling coin texture. spawn points should random , entities should destroyed after falling off screen, have no idea how it. appreciated. thank image upload: http://imgur.com/ol4vkr2 i give starting points done task. can read about` rigidbody(rigidbody2d) collider(collider2d) monobehaviour callbacks example ontriggerenter(ontriggerenter2d) or oncollisionenter(oncollisionenter2d) for randomness can read random class , methods random.randominsideunitcircle.

ios - self.extensionContext!.openURL open app but calls no method -

i trying wire today extensions app using following piece of code: override func tableview(tableview: uitableview, accessorybuttontappedforrowwithindexpath indexpath: nsindexpath) { let selection=buscollection[indexpath.row]; let palina=selection?.palina; let urlasstring = "widget://pathto/" + "\(palina)" let url = nsurl(string: urlasstring) self.extensioncontext!.openurl(url!, completionhandler: { (success: bool) -> void in print("completed") } ) tableview.deselectrowatindexpath(indexpath, animated: false) } yet activating method correctly opens app launches in standard way without calling: -(bool) application:(uiapplication *)application handleopenurl:(nsurl *)url what may issue? of course registered widget on info.plist file, otherwise app not have been opened. it did end calling delegate method.

java - How to set value of JSpinner to a certain date -

i have jspinner add jpanel set time : gregoriancalendar calendar jspinner spinner = new jspinner(); spinner.setmodel(model); pom.add(new jlabel("date", jlabel.right)); pom.add(spinner); how achieve illegalvalue exceptions. one should do: spinnerdatemodel model = new spinnerdatemodel(); model.setcalendarfield(calendar.day_of_year); jspinner spinner = new jspinner(); spinner.setmodel(model); simpledateformat format = new simpledateformat("dd/mm/yyyy"); java.sql.time time = new java.sql.time(osoba.getdatazatrudnienia().gettime().gettime()); spinner.setvalue(time);

node.js - npm installs packages and dependencies in the project root directory -

i switched windows mac. when i'm trying install npm modules, packages , dependencies created inside project root directory. on windows module installing ./node_modules, dependencies inside module folder. is there need configure make work before? edit i have both, node_modules folder , package.json in project dir: { "name": "react", "version": "0.0.1", "private": true, "dependencies": { "chokidar": "^1.0.3" } } and still, chokidar package , dependencies in project root. when use npm install , until finds package.json or node_modules folder , install package there. so if project structure this project_root/ modules/ mymodule/ node_modules and run npm install in mymod directory, module installed in project_root/node_modules

jsf - Can @ManagedBean and @XxxScope be placed in a base class? -

i have 2 @managedbean (javax.faces.bean.managedbean), parent , child. parent managed bean not abstract because have give liberty developer use parent if enough or inherit child holds funcionality. i have problems injections bean , @postconstruct annotated method in parent bean. the following code way found works. @managedbean(name = "mybean") @sessionscoped public class basebean implements serializable { @managedproperty(value = "#{servicemanagercontroller}") protected servicemanagercontroller servicemanagercontroller; @postconstruct public void init() { //do things } } and child bean public class childbean extends basebean { @postconstruct public void init() { super.init(); } } to override "mybean" bean , force app use child bean when needed have had declare child bean in faces-config.xml <managed-bean> <managed-bean-name>mybean</managed-bean-name> <managed-...

php - How do I write this mysqli query using joining multiple tables? -

i have hard time writing queries when need join multiple tables 1 result set. i have 3 tables this: store_stock: id itemweavetype itemmodel cost price 7 3 4 10.00 15.00 store_item_weaves: id weaveid 3 mc store_item_models: id modelid 4 hv i trying query gather of data item stock id of 7. finished result, array like: array ( [id] => 7 [itemweavetype] => mc [itemmodel] => hv [cost] => 10.00 [price] => 15.00) so, need join data tables store_item_weaves , store_item_models . a hastily put query - might work.... select * `store_stock` s left outer join `store_item_weaves` w on w.`id`=s.`itemweavetype` left outer join `store_item_models` m on m.`id`=s.`itemmodel` s.`id`=7; you select desired fields rather use * ~ ie: select s.`id`, s.`price`, m.`modelid` etc etc

javascript - Controller not a function, got undefined, while defining controllers globally -

i writing sample application using angularjs. got error mentioned below on chrome browser. error is error: [ng:areq] http://errors.angularjs.org/1.3.0-beta.17/ng/areq?p0=contactcontroller&p1=not%20a%20function%2c%20got%20undefined which renders argument 'contactcontroller' not function, got undefined code <!doctype html> <html ng-app> <head> <script src="../angular.min.js"></script> <script type="text/javascript"> function contactcontroller($scope) { $scope.contacts = ["abcd@gmail.com", "abcd@yahoo.co.in"]; $scope.add = function() { $scope.contacts.push($scope.newcontact); $scope.newcontact = ""; }; } </script> </head> <body> <h1> modules sample </h1> <div ng-controller="contactcontroller"...

java - Injected SolrTemplate Resource not connected to HttpSolrServer -

i using spring data solr 1.4 custom repository feature try implement count function per article: link i using solr configured use multiple cores. regular repository interface gets , uses correct solrtemplate , solrserver instances, custom repository not same instance of template. in addition using @resource inject bean, have tried getting spring application context , pulling bean it. in both cases getting solrserver bean reference not know core is, query fails when tries reach solr at: http://localhost:8983/solr instead of http://localhost:8983/solr/mycore the bean definition looks this: @bean @scope(value=configurablebeanfactory.scope_singleton) public solrserver solrserver() { solrserver server = new httpsolrserver(solrserverurl); return server; } @bean(name = "solrtemplate") @scope(value=configurablebeanfactory.scope_singleton) public solrtemplate solrtemplate(solrserver server) throws exception { solrtemplate template = new solrtemplate(server...

objective c - Views not displaying correctly after adding them to NSStackView programatically -

Image
so, i'm trying add views (nstextfield in example) nsstackview: i've added nsstackview instance xib file, linked outlet widgets document . in ...didloadnib i'm doing this: nstextfield *tf = [[nstextfield alloc] init]; tf.stringvalue = @"124"; [tf setframesize:nsmakesize(100, 20)]; [widgets addview:tf ingravity:nsstackviewgravityleading]; nslog(@"%f - %d", nsheight(tf.frame), [tf hasambiguouslayout]); nstextfield *tf2 = [[nstextfield alloc] init]; tf2.stringvalue = @"123"; [tf2 setframesize:nsmakesize(100, 20)]; [widgets addview:tf2 ingravity:nsstackviewgravityleading]; nslog(@"%f - %d", nsheight(tf2.frame), [tf2 hasambiguouslayout]); textfields placed stackview, they're placed same position, i.e. second overlaps first completely. still can select first [space+tab]. here's console output: 2015-06-13 17:11:00.736 celty-test[62306:9217679] 20.000000 - 1 2015-06-13 17:11:00.739 celty-test[62306:9217679] unable simu...

php - SQL query not providing results -

this question exact duplicate of: proper query in php hoping can figure out. this sqlfiddle shows construction on db/query: http://sqlfiddle.com/#!9/2667ba/1/0 , same schema modified query can't figure out why doesn't show results: http://sqlfiddle.com/#!9/6bb16/1/0 question being why doesn't second 1 show same results first? i need reference rows 'company' , 'newcost' need reference 'raiseby', should difference in price between maximum cost of brand/company , users maximumbid - company is. i want echo within loop let user know company/newcost fell within parameters companies fell short, , display difference in price (which how user need increase maximumbid use company). when removed $current_user->user_login reference in 2nd jsfiddle , hardcoded 'caseys' username, query appeared work. suggests me wrong inline replacement @ runtime.

vb.net - ExecuteReader: Connection property has not been initialized -

can explain why getting error? executereader: connection property has not been initialized protected sub btnlogin_click(byval sender object, byval e system.eventargs) handles btnlogin.click dim name = txtusername.text.trim dim pass = txtpassword.text.trim try dim conn sqlconnection conn = databasefunc.openconnection() dim sqlst string = "select * adminlog adminname = '" & name & "' , adminpassword = '" & pass & "'" dim selcmd sqlcommand = new sqlcommand(sqlst, conn) dim rrecset sqldatareader rrecset = selcmd.executereader() if rrecset.read() session("admin") = rrecset("adminname") response.redirect("~/adminpages/adminhome.aspx") else lblmsg.text = "<p>rong username or password</p>" txtusername.text = "" ...

Convert string date into date format in python? -

how convert below string date date format in python. input: date='15-march-2015' expected output: 2015-03-15 i tried use datetime.strftime , datetime.strptime . not accepting format. you can use datetime.strptime proper format : >>> datetime.strptime('15-march-2015','%d-%b-%y') datetime.datetime(2015, 3, 15, 0, 0) read more datetime.strptime , date formatting: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

r - Using ordinal variables in rpart and caret without converting to dummy categorical variables -

Image
i trying create ordinal regression tree in r using rpart , predictors being ordinal data, stored factor in r. when created tree using rpart , this: where values factor values (e.g. a170 has labels ranging -5 10). however, when use caret train data using rpart , when extract final model, tree no longer has ordinal predictors. see below sample output tree as see above, seems ordinal variable a170 has been converted multiple dummy categorical value, i.e. a17010 in second tree dummy a170 of value 10 . so, possible retain ordinal variables instead of converting factor variables multiple binary indicator variables when fitting trees caret package? let's start reproducible example: set.seed(144) dat <- data.frame(x=factor(sample(1:6, 10000, replace=true))) dat$y <- ifelse(dat$x %in% 1:2, runif(10000) < 0.1, ifelse(dat$x %in% 3:4, runif(10000) < 0.4, runif(10000) < 0.7))*1 as note, training rpart function groups factor levels together:...

integration - How to integrate Google Bigquery with c# console application -

if possible integrate google big query c# console application?. if yes how can do, searched on internet not find proper answer that. i want connection string format? have created client id google developer console how authentication has done? 1 time configuration or every time need login in google account authenticate. if there sample application connect sample data helpful. thanks, selvakumar s here's working sample based on another question in stackoverflow: using dotnetopenauth.oauth2; using google.apis.authentication.oauth2; using google.apis.authentication.oauth2.dotnetopenauth; using google.apis.bigquery.v2; using google.apis.bigquery.v2.data; using google.apis.util; using system; using system.diagnostics; using system.collections.generic; namespace bigqueryconsole { public class bigqueryconsole { // put client id , secret here (from https://developers.google.com/console) // use installed app flow here. // client id l...

x86 - Assembly code to print a new line string -

i have assembly code print (display) string. problem i'm not able how print 2 string different line! .model small .stack 100h .data msg1 db 'fun $' msg2 db 'day!$' .code main proc mov ax, @data mov ds, ax lea dx,msg1 mov ah,9 lea dx,msg2 mov ah,9 int 21h mov ah,4ch int 21h main endp end main the output should like: fun day! but in result: day! help me! you missing int 21h call first part, that's why second printed. 2 lines, append cr lf string. can print whole thing @ once, such as: .model small .stack 100h .data msg db 'fun', 10, 13, 'day!$' .code main proc mov ax, @data mov ds, ax lea dx,msg mov ah,9 int 21h mov ah,4ch int 21h main endp end main

php - How can I extract the value of a variable and re-use that value until it is overwritten -

i have website acts blog / photo gallery. comprises php , mysql. objective able set image on homeimage dynamically. have set form posts variable (which contains relevent image filename) homepage file. pick using $_post method. works fine, until refresh homepage @ point variable no longer there , so, understandably, image no longer called. can explain how can store variable value i.e. image filename, can used until such time overwritten new image. have tried setting function returns value, can't seem hold on it!! guidance appreciated. well, can multiple things : store using mysql. create table named "configuration" example, 1 field named "homepageimage" example. when want modify image on homepage, update field. when want image, query table , fetch field. store in file on server. have overwrite file new filename inside when want change image. fetch content of file when want display image create symbolic link (pointing right image), , update link ...

Magento custome option product in search result -

i uploading product , product has different size available, if customer- want buy this, have select size after can buy. how this. knew custom option available in magento. want allow customer search product size also, should perform type of things?. please you shouldn't use custom options different sizes. why have configurable products . you make configurable product , link simple products represent sizes. then simple product select visibility: search (to show on search). custom product options not used in search , there nothing can use them in search (apart building complex module). another solution put values custom options inside attribute has use in advanced search , use in quick search yes.

objective c - iOS not able to update the set text in UITextField -

i have uitextfield in uitableviewcell text property not updating. my tableview delegate: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { kapinputtableviewcell *cell = [self.registertableview dequeuereusablecellwithidentifier:kapinputcellidentifier]; if (!cell) { cell = [[kapinputtableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:kapinputcellidentifier]; } switch (indexpath.row) { case 0: cell.inputtextfield.placeholder = kaplocalizedstring(@"email", @"e-mail address"); cell.inputtextfield.text = @"test"; cell.tag = 0; cell.errorlabel.text = self.emailerror; self.emailcell = cell; self.emailtextfield = cell.inputtextfield; break; } cell.inputtextfield.delegate = self; cell.selectionstyle = uitableviewcellselectionstylenone; return cell; }...

scala - How to match exactly 'n' given characters with FastParse -

the fastparse parser-combinator scala library gives .rep(n) 'repeat' method allow create new parser attempts parse givenparser n or more times. what's canonical way if want exactly n matches? in case, want parse 40-character git commit id - if longer 40 characters, that's not commit id, , shouldn't match. the closest example i've found in docs far is: val unicodeescape = p( "u" ~ hexdigit ~ hexdigit ~ hexdigit ~ hexdigit ) ...which matches 4 characters simple repetition (verbose 40-character commit id). these parser-combinators, not regex, answer \p{xdigit}{40} . since issue closed commit , rep supports max keyword argument. supports keyword argument. hexdigit.rep(exactly = 40)

Converting Object Names to Strings in AS2 -

so i've made object called "potato", started loop check if in "_level0" has name of "_level0.potato". think since the things in _level0 objects instead of strings, object name can't recognized string, im guessing need find way convert object name string or vice versa. var potato:movieclip = this.createemptymovieclip("potato", this.getnexthighestdepth()); for(objects in _level0){ trace(_level0[objects]) if(_root[objects] == "_level0.potato"){ trace("omg, found potato on level0") } } your suggestion objects stored string incorrect. if try using typeof before trace(typeof _level0[objects]) you see type movieclip , "_level0.potato" string not equal. can convert object reference string using string(...) construct. and names. you're confusing names , references. movieclip object others in ac2 have property called _name . in property name of object stored string. name, no...

html - Cannot put image inside div -

i trying put profile image next names, won't go next text, instead go below div containing text. i'm not sure if i'm being blind, can't find how fix it. to clarify, i'm attempting put images on page next text (the white next 'main, wolf next 'joe' , kenny next 'kenny'). edit: found stupidly easy solution. flagged deletion! i think can you: <div style="display:inline-block;float:left;"> <img alt="" src="" width="50" /> text here </div> also if want text in center put text in <div> element this: <div style="display:inline-block;float:left;"> <img alt="" src="" width="50"/> </div> <div> text here </div>

java - Colouring for Wearable ListView Items -

Image
is there way change text colour of list items on android wear? i've seen before , hence done phones don't think same code can used wear. activity code public class mainactivity extends activity implements wearablelistview.clicklistener{ private wearablelistview mlistview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mycoloringadapter adapter = new mycoloringadapter(this,listitems); final watchviewstub stub = (watchviewstub) findviewbyid(r.id.watch_view_stub); stub.setonlayoutinflatedlistener(new watchviewstub.onlayoutinflatedlistener() { @override public void onlayoutinflated(watchviewstub stub) { mlistview = (wearablelistview) stub.findviewbyid(r.id.listview1); mlistview.setadapter(new myadapter(mainactivity.this)); mlistview.setclicklistener(mainacti...

javascript - checked checkbox values in angularjs controller -

in application, there multiselect-dropbox. when values of checked items of multiselect dropdown list.it has, scope.names = [1,2,4,5] means have selected 4 names list. during on change selected names other say, scope.names = [3,4]. how angularjs controller? getting following error, typeerror: cannot read property 'indexof' of undefined @ scope.$scope.ischecked (mmmultiselect.js:85) @ $parsefunctioncall (angular.js:12332) @ object.expressioninputwatch (angular.js:12735) @ scope.$get.scope.$digest (angular.js:14217) @ scope.$get.scope.$apply (angular.js:14488) @ htmldivelement.<anonymous> (angular.js:22954) @ htmldivelement.jquery.event.dispatch (jquery.js:4409) @ htmldivelement.jquery.event.add.elemdata.handle (jquery.js:4095) #update scope.names = []; scope.onnamesselected = function() { var names = scope.names //get selected name list in array [1,2,3] scope.onnameschanged(); } scope.onnameschanged = function() { scope.name...

html - Creating links, with categories and filters, ActiveRecord::AssociationTypeMismatch in LinksController#create -

i stuck , need help. trying create links have categories , filters them. when i'm trying create new link categories , filter website show message i've inserted. i inserted of code, if i'm missing please comment , add right away. activerecord::associationtypemismatch in linkscontroller#create level(#70251425229100) expected, got string(#70251404789620) extracted source (around line #27): # post /links.json def create @link = current_user.links.build(link_params) respond_to |format| if @link.save rails.root: /users/victorblomberg/startcode_co activerecord (4.2.1) lib/active_record/associations/association.rb:216:in `raise_on_type_mismatch!' activerecord (4.2.1) lib/active_record/associations/belongs_to_association.rb:12:in `replace' activerecord (4.2.1) lib/active_record/associations/singular_association.rb:17:in `writer' activerecord (4.2.1) lib/active_record/associations/builder/associa...

parse.com - Retrieve objects from Parse and put them in an array -

i have class "object" on parse contains column int values named "score". want put values (using parse query) inside array going used in project. so, how can retrieve int values parse , put them in array? docs in website seem give examples , lessons on retrieving object known id (which useless me). thanks! js sdk var query = new parse.query("object"); // object classname query.limit(1000); query.descending("createdat"); query.exists("score"); query.find().then(function(results) { // results list score exist });

ruby on rails - Syntax error near unexpected token `(' on service unicorn start on amazon EC2 linux -

i trying setup unicorn in amazon ec2. following this blog . but when start unicorn using: sudo service unicorn_firstapp start i getting following error: /home/ec2-user/rails_projects/firstapp/config/unicorn.rb: line 2: syntax error near unexpected token `(' /home/ec2-user/rails_projects/firstapp/config/unicorn.rb: line 2: `app_dir = file.expand_path("../..", __file__)' what mistake? if 1 has idea issue, please share me. unicorn.rb: # set path application app_dir = file.expand_path("../..", __file__) shared_dir = "#{app_dir}/shared" working_directory app_dir # set unicorn options worker_processes 2 preload_app true timeout 30 # set socket location listen "#{shared_dir}/sockets/unicorn.sock", :backlog => 64 # logging stderr_path "#{shared_dir}/log/unicorn.stderr.log" stdout_path "#{shared_dir}/log/unicorn.stdout.log" # set master pid location pid "#{shared_dir}/pids/unicorn.pid" /etc/...

c# - Byte array to struct -

i'm having trouble converting string parts of byte array. my struct looks this: [structlayout(layoutkind.sequential, pack = 1)] struct message { public int id; [marshalas(unmanagedtype.byvaltstr, sizeconst = 10)] public string text; } creation of test byte array: private static byte[] createmessagebytearray() { int id = 69; byte[] intbytes = bitconverter.getbytes(id); string text = "test"; byte[] stringbytes = getbytes(text); ienumerable<byte> rv = intbytes.concat(stringbytes); return rv.toarray(); } method convert bytearray struct: static t bytearraytostructure<t>(byte[] bytes) t : struct { var handle = gchandle.alloc(bytes, gchandletype.pinned); var result = (t)marshal.ptrtostructure(handle.addrofpinnedobject(), typeof(t)); handle.free(); return result; } when call bytearraytostructure result createmessagebytearray() struct id=60 , text="t". why don't whole string e.g...

c# - Configuration error after deploying ASP.NET application -

Image
i using vs2012, website on local machine works fine , when deploy website on remote pc / server , works fine when run on localhost in server computer, problem arises when access remotely having static/live ip. gives following configuration error. deployed in following path inetpub > wwwroot > pse i have deployed website in inetpub > wwwroot > pos works fine here website structure here 1 web.config file in root directory <?xml version="1.0"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=169433 --> <configuration> <system.web> <customerrors mode="off"/> <compilation debug="true" targetframework="4.0"> <assemblies> <add assembly="mysql.data, version=6.9.6.0, culture=neutral, publickeytoken=c5687fc88969c44d"/> </assemblies> </compilation> ...