Posts

Showing posts from August, 2012

ruby on rails - NoMethodError: undefined method `each' for # -

ruby on rails - NoMethodError: undefined method `each' for #<State:0x438a110> - 1. country=country.create(:name=>'australia') 2. country.states #<activerecord::associations::collectionproxy []> 3. first_state=state.new(:name=>'queensland') => #<state id: nil, country_id: nil, name: "queensland", created_at: nil, update d_at: nil> 4. first_state.country => nil 5.country.states=first_state **nomethoderror: undefined method `each' #<state:0x438a110>** in model: class state < activerecord::base belongs_to :country class country < activerecord::base has_many :states i new in rails. trying set country_id it's state, give me error. have done right think, still error occurs. please help me out. it's states (plural); it's expecting array country.states = [first_state] ruby-on-rails ruby-on-rails-4

Not able to connect multiple PostgreSQL database using SPRING +HIbernate -

Not able to connect multiple PostgreSQL database using SPRING +HIbernate - i need connect multiple postgresql database. using properties files database connection properties. when running application throwing error named query not found. when removing configuration sec database,every thing running fine.i have tried using catalog attribute of hibernate mapping. didnt yeild result. <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath:com/*****/config/jdbc.properties</value> <value>classpath:com/*****/config/userlogin.properties</value> </list> </property> <property name="ignoreunresolvableplaceholders" value="false"/> &l

c# - How to remove comma separated duplicated string values and get last two values -

c# - How to remove comma separated duplicated string values and get last two values - i want remove comma separated duplicate string values : string str = "2,4,3,12,25,2,4,3,6,2,2,2"; and want output this: string str1 = "6,2"; please tell how i'll self can't solve this a wild ride linq. there improve way, first 1 think of. string str = "2,4,3,12,25,2,4,3,6,2,2,2"; list<string> uniques = str.split(',').reverse().distinct().take(2).reverse().tolist(); string newstr = string.join(",", uniques); console.writeline(newstr); split string @ comma sequence apply reverse op, 2 2 2 6 .... 4 2 apply distinct, 2,6,3,4,25,12 take first 2 elements (2,6) reverse them 6,2 join in new string comma sep. c# asp.net string

sql - Before Update Trigger Issues -

sql - Before Update Trigger Issues - i'm trying create trigger accomplishes following examines value of field action_type in row having update requested if row (prior update) has action_type that's null, want insert value/string "change". if row (prior update) has action_type contains string 'add', want maintain value in-tact. if row (prior update) has action_type contains string 'change', want maintain value in-tact. create trigger tbl8_change on holiday_date_table before update begin if ((select action_type holiday_date_table inserted.hid = holiday_date_table.hid) == null) insert holiday_date_table (action_type) values ('changed') inserted.hid = holiday_date_table.hid; if ((select action_type holiday_date_table inserted.hid = holiday_date_table.hid) == 'changed') insert holiday_date_table (action_type) values ('changed') inserted.hid = holiday_date_table.hid; if ((select action_type holiday_date_ta

jsf - Prevent selectBooleanCheckbox from changing value -

jsf - Prevent selectBooleanCheckbox from changing value - i have h:selectbooleancheckbox i'd validate within managed bean before allowing alter it's value. <h:selectbooleancheckbox id="attr" value="#{handler.attribute}" onclick="submit()" immediate="true" valuechangelistener="#{handler.changeattributevalue}" /> public string changeattributevalue(valuechangeevent event) { if(condition) attribute=false; homecoming "home"; } so i'd prevent attribute becoming true if status true. happens attribute set false @ first after method exits becomes true again. be careful immediate="true" . submitted value won't taken attribute remain in component model of selectbooleancheckbox - component, box checked 1 time again next time. seek immediate=false . sure, managed bean @sessionscoped , otherwise forget attribute reload/redirect page. even more handsome: <h

Output a "advanced-custom-fields"-field programmatically in wordpress backend -

Output a "advanced-custom-fields"-field programmatically in wordpress backend - i created custom field "advanced-custom-fields"-plugin. want , output custom field programmatically in template file (backend, edit page), because template called via ajax if user want's add together new part page. is there function returns finish field? found functions gave me values, not field "form". i found solution. duplicated plugin folder theme root directory , set next code functions.php: function relationshipfield() { $newfield = new acf_field_relationship(); $field = array( 'post_type' => array('post'), 'max' => '', 'taxonomy' => array('all'), 'filters' => array('search'), 'res

railscasts - rack::offline in rails 4.1 Issue -

railscasts - rack::offline in rails 4.1 Issue - can give me quick solution please? have done this: routes: offline = rack::offline.configure cache actioncontroller::base.helpers.asset_path("application.css") cache actioncontroller::base.helpers.asset_path("application.js") cache actioncontroller::base.helpers.asset_path("jquery.min.css") cache actioncontroller::base.helpers.asset_path("jquery.tmpl.min.css") cache actioncontroller::base.helpers.asset_path("style.js") # cache actioncontroller::base.helpers.asset_path("custom.css") network "/" end "/application.manifest" => offline in application.html.erb: <html manifest="/application.manifest"> in gemfile: # gem 'rack-offline' # gem 'rack-offline', :github => 'pascalw/rack-offline' gem 'rack-offline', :git => 'https://github.com/wycats/rack-off

Phonegap Filetransfer works on iOS nothing happens on Android -

Phonegap Filetransfer works on iOS nothing happens on Android - now, have problem uploading images on server. code works on ios devices, when i'm trying upload on android, doesn't anything. before filetransfer, i'm trying alert imageuri, it's not happening well. i'm using phonegap build phonegap version 3.4.0 , sencha touch 2.3. in config.xml utilize core phonegap photographic camera plugin: <gap:plugin name="org.apache.cordova.camera" />. my fileupload script looks this: ext.define('my_app.controller.fileupload', { extend: 'ext.app.controller', requires: [ 'ext.messagebox' ], config: { refs: { fileupload: '#fileupload', getlibraryimage: 'button[action=getlibraryimage]', getcameraimage: 'button[action=getcameraimage]' }, control: { getlibraryimage: { tap: 'getlibraryimage&#

windows - Jenkins / Vagrant / VirtualBox - Virtualbox is running as the system user? -

windows - Jenkins / Vagrant / VirtualBox - Virtualbox is running as the system user? - i'm pretty new both virtualbox , vagrant, not jenkins. have jenkins build beingness run on windows slave running "vagrant up" in specific directory. there problem vm- went directory , tried manually run vagrant , started recloning box. investigating, virtualbox vms folder beingness stored in /windows/system32... have looked , jenkins process , virtualbox process definately beingness run user business relationship running jenkins slave. if log business relationship , launch virtualbox, looks vms in business relationship home directory though! i prepare pointing both accounts 3rd location, understand why happening. takers? according docs, since virtualbox 4.0, default location virtual machines saved current scheme user's home directory. so: c:\documents , settings\<username> on windows /users/<username> on mac os x /home/<username> o

jquery - PhantomJS - pause/resume javascript execution -

jquery - PhantomJS - pause/resume javascript execution - i have phantomjs script i'm trying utilize in order generate video of particular website. var page = require('webpage').create(); page.viewportsize = { width: 1280, height: 720 }; page.open('http://my-awesome-site.whatever', function() { var fps = 30; var seconds = 10; var elapsed = 0; var current = 0; takescreenshot(); function takescreenshot() { if (elapsed < seconds * 1000) { page.render('screenshot_' + (current++) + '.png'); elapsed += 1000 / fps; settimeout(takescreenshot, 1000 / fps); } else { phantom.exit(); } } }); the above script effort take 30 screenshots per sec 10 seconds, combine mp4 using ffmpeg. the problem page.render() function not instantaneous, , not halt scripts running on page. when i'm pointing @ page using jquery animations, believe

java - NullPointerException when trying to print a mail message -

java - NullPointerException when trying to print a mail message - i have programme uses javamail retrieve messages exchange server using imap protocol process each messages has been unseen. recently have come across problem of programme throwing nullpointerexception know unitialized object invoking method, in case not create sense me. the stacktrace of exception follows: java.lang.nullpointerexception @ com.sun.mail.imap.imapfolder.handleresponse(imapfolder.java:1905) @ com.sun.mail.iap.protocol.notifyresponsehandlers(protocol.java:135 @ com.sun.mail.imap.protocol.imapprotocol.fetchbodystructure(imapprotocol.java:617) @ com.sun.mail.imap.imapmessage.loadbodystructure(imapmessage.java:1027) @ com.sun.mail.imap.imapmessage.getcontenttype(imapmessage.java:321) @ javax.mail.internet.mimebodypart.ismimetype(mimebodypart.java:802) @ javax.mail.internet.mimemessage.ismimetype(mimemessage.java:851) @ ctt.mail.filehandler.putfilesfrommail(filehandler.java:75) @ ctt.mail.filehandl

java - System.getenv() only works properly when debugging IntelliJ plugin -

java - System.getenv() only works properly when debugging IntelliJ plugin - i'm running intellij 13 (on os x yosemite) , trying go thought plugin working. when debugged application seek find problem is, found reason slave thought that's ran gets environment fine. normally when trying run involving go utility, exception thrown. plugin execute commands executing go <args> environment vars: runtime rt = runtime.getruntime(); process proc = rt.exec(command, goenv, new file(projectdir)); if alter go command total path of go binary, works fine. when debugging however, don't have alter path , still succeeds. the plugin has action prints out environment calls system.getenv() gotoolwindow toolwindow = this.getgotoolwindow(project); toolwindow.showandcreate(project); toolwindow.clearconsoleview(); string[] sysenv = gosdkutil.convertenvmaptoarray(system.getenv()); toolwindow.printnormalmessage(string.format("%s -> %s%n", "project

javascript - What is the best practice for loading multiple textures in three.js? -

javascript - What is the best practice for loading multiple textures in three.js? - having switched three.js renderer, wanting set scheme mapping textures. however, i'm not sure on best practice is. here utilize case i have levels made of lot of box geometries i need able map wide variety of textures each face of each box geometry (grass, water, stone, stone etc.,) i in efficient, performance conscious way possible, offloading gpu best if possible i using web gl renderer i have textures set in sprite sheet; each texture 64x64 pixel square, each different texture offset 64 pixels depending on position. is necessary, or should have directory total of many different textures, loop through , create new instance of three.imageutils.loadtexture( "textures/sometexture.png" ); each one? or there more efficient way of doing this? since textures lightweight, on-demand approach mention in comment separate files right method because gives explicit command

onclick - Preview Mouse Click - Windows Forms -

onclick - Preview Mouse Click - Windows Forms - i have form controls - image boxes. form has event mouse click. event not work when click on image box. there way observe click on form no matter if there image box or not. give thanks you onclick windows-forms-designer

arrays - Java Interface Testing and Coding Issues -

arrays - Java Interface Testing and Coding Issues - i have been working on assignment past few hours , i'm stuck on lastly method histogram required assignment, have problems testing , code (i'm using netbeans). the method should > histogram: takes positive number n indicating number of divisions in span of info divided, , returns array of integers of length n, each element of array contains count of elements fall division. example, if info (0.5, 1.2, 2.4, 9.8, 5.1, 10.5), span 10.0 (from 0.5 10.5). histogram(4) split range 4 segments: 0.5—3.0, 3.0—5.5, 5.5—8.0, , 8.0—10.5. inspecting data, see 3 values fall in first segment, 1 value in second, 0 values in third, , 2 values in fourth. therefore, returned value array of length 4 containing values (3, 1, 0, 2) in order. note sum of elements in returned array equal number of elements in info array. here code: @override public int[] histogram(int divisions) { int[] wide = new int[divisions

javascript - jQuery accSendReq is not defined even when it is -

javascript - jQuery accSendReq is not defined even when it is - why accsendreq not defined when below? the function accsendreq() console.log('works'); function. i phone call function below. code below in html that's generated, , not in .js file that's included in page. jquery loads before this, still error. no other errors generated. //there's html above <script type="text/javascript"> $(document).ready(function() { accsendreq(); }); </script> function accsendreq() function that's in include.js file include in head of page. it's this: function accsendreq() { console.log('workd'); } javascript jquery

php - Struggling with checking if logged in -

php - Struggling with checking if logged in - hi there i'm trying figure out how check if user logged in , if allow them come in page if not homecoming 'index.php'. what i've done create duplicate pages of such 'index.php', 'index2.php', 'service.php' , 'service2.php' on , forth minor adjustments such no 'search bar'. is still possible so? i'd 'check see if logged in' on pages '2' in them. such 'service2.php' or 'about2.php' i've tried code (keep in mind code not whole entire page) if(check_login()) { echo 'you in!'; } else { header('location: login.php'); exit; } function check_login () { if(isset($_session['login'] && $_session['login'] != '') { homecoming true; } else { false; } } only used code on pages want displayed thanks in advance ! :) update edit: <?php include ('

java - How to call object from other class to another class and add it? -

java - How to call object from other class to another class and add it? - i'm new android java coding. i'm seek menu list have tick box, , 1 time tick items, n press next, should go view layout , show items , total of item selected, press next should open details page user must set details n press send button send via email. don't know how phone call items menu cart , confirmation class. this menu.java . class="snippet-code-js lang-js prettyprint-override"> import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.toast; public class menuactivity extends activity { button btnorder; button btnback; button btnlinkcart; protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.menu); btnlinkcart = (button)

ruby - How to execute a rails action when html button is clicked? -

ruby - How to execute a rails action when html button is clicked? - i trying clean array when html button clicked. have controller: class infocontroller < applicationcontroller $names = {} def show render :print end def @name = params[:myinfo][:name] @number = params[:myinfo][:number] $names[@name] = @number render :test end def clean $names = {} end def add together end end how go executing clean action when button within form clicked? <h1>info print</h1> <%= form_for :myinfo |a| %> <%= a.label :name %> <%= a.text_field :name %><br> <%= a.label :number%> <%= a.text_field :number%><br> <%= a.submit %> <%end%> <form> <input type="button" onclick=""> </form> <%= $names.each |key, val|%> <%=key%> &nbsp <%=val%> <%end%> you can write this: <form> <%=

ios - Circular Progress Bar help, Swift Programming Language -

ios - Circular Progress Bar help, Swift Programming Language - i'm trying create little circular progress bar in swift, this have far private var timer:cgfloat = 100; override func update(currenttime: cftimeinterval) { /* called before each frame rendered */ var startangle:cgfloat! var endangle:cgfloat! var circletimer:uibezierpath! startangle = cgfloat(m_pi * 1.5) endangle = startangle + cgfloat((m_pi * 2)) var progress:cgfloat = (endangle - startangle) * (timer / 100) + startangle circletimer.addarcwithcenter(cgpointmake(200, 200), radius: cgfloat(130), startangle: startangle, endangle: progress, clockwise: true) timer--; } i error when run app "bad_instruction (code=exc_i386_invop, subcode=0x0)" on line "circletimer.addarcwithcenter(cgpointmake(200, 200), radius: cgfloat(130), startangle: startangle, endangle: progress, clockwise: true)" i'm new swift (programmed in other languages) , ca

php - Store time in database -

php - Store time in database - which best way store info come entire world? thinking, instance, store time() without timezone , convert every time. could right? there method observe timezone of request? for can save unix timestamp in database. http://php.net/manual/en/function.time.php http://dev.mysql.com/doc/refman/5.5/en/datetime.html returns current time measured in number of seconds since unix epoch (january 1 1970 00:00:00 gmt). so every people have same timestamp format without timezone. otherwise have store datetime field , timezone , calculate right value. php timezone

javascript - ng-repeat not updating after change in nestled data -

javascript - ng-repeat not updating after change in nestled data - i have directive draws using d3.js , if draw depends on info in scope. problem can't redraw things after change, i've tried variants $scope.$apply , haven't had success far. html: <body ng-app="app" ng-controller="mainctrl"> <div ng-repeat="val in data"> <div draw="" value="{{val.avg}}">{{val.avg}}</div> </div> </body> js: var app = angular.module('app', []); app.controller('mainctrl', function ($scope, $timeout) { $scope.data = [{avg: 0}, {avg: 1}]; $timeout(function (){ var = 1; (key in $scope.data){ $scope.data[key].avg = i++; }; } ,3000) }); app.directive('draw', function() { homecoming { scope: { value: "@" }, link: function (scope, element, attrs){ if (attrs.value != 0) {

html - Vertical Button using CSS -

html - Vertical Button using CSS - i'm trying build vertical button not able set text in 1 line. until have: css: #hp-ctn-howitworks { position:fixed; top:300px; right: 0px; padding:0px; margin:0px; width: 40px; height:160px; background:#ff931e; z-index:15; border-radius: 3px 0px 0px 3px; } #hp-ctn-howitworks img { margin: 15px 0px 0px 13px; } #hp-ctn-howitworks p { color: #fff; -moz-transform:rotate(-90deg); -ms-transform:rotate(-90deg); -o-transform:rotate(-90deg); -webkit-transform:rotate(-90deg); } html: <!-- how works button --> <div id="hp-ctn-howitworks"> <img src="~/content/images/ui-symb-arrow-left-white-15x15.png" width="15" height="15" /> <p>como funciona</p> </div> any thought how can force downwards text , set in 1 line? you can using html non breaking space &nbsp; here <p>com

java - Unable to map request from jqgrid to Spring MVC Controller -

java - Unable to map request from jqgrid to Spring MVC Controller - i trying send form info jqgrid spring mvc controller getting error http status 404-the requested resource not available. . below code. 1)overviewcontroller.java @controller @requestmapping(value="overview") public class overviewcontroller { @autowired overviewservice service; @requestmapping(value="order.spring",method=requestmethod.get) public modelandview getorderview(modelmap map,httpsession session) { modelandview modelandview=new modelandview("vieworders"); modelandview.addobject("vieworders", new orderoverviewform()); homecoming modelandview; } @requestmapping(value="order.spring",method=requestmethod.post,produces="application/json") public @responsebody orderoverviewresponse getorderoverview(@requestparam("accid") integer accid ,@requestparam("fromdate&

ruby - rails: upvoted pin by user (exists? relation) -

ruby - rails: upvoted pin by user (exists? relation) - so have pretty simple upvote scheme in rails app, allows users upvote pin: pins_controller.rb def upvote @pin = pin.friendly.find(params[:id]) if @pin.votes.create(user_id: current_user.id) flash[:notice] = "thanks recommendation." redirect_to(pin_path) else redirect_to(pin_path) end end and in view can upvote clicking on button (represented icon): in app/views/pins/index.html.erb <%= link_to upvote_pin_path(pin), method: :post %> <span class="text-decoration: none;"><i class="fa fa-chevron-up"></i> <% end %> <%= pluralize(pin.votes.count, "") %></span> i render icon in different color if user has upvoted pins: thought using exists?: <%= link_to upvote_pin_path(pin), method: :post %> <% if pin.votes.where(user_id: current_user.id).exists? %> <i class="fa fa-chevro

jdbc - Unable to import data from Vertica to Cassandra using Sqoop -

jdbc - Unable to import data from Vertica to Cassandra using Sqoop - i trying utilize sqoop import table vertica datastax enterprise 4.5. no error nor exception has been reported, no info in target table. here did: create keyspace , table in cqlsh: create keyspace if not exists npa_nxx replication = { 'class': 'simplestrategy', 'replication_factor': '1' }; create table npa_nxx.npa_nxx_data ( part varchar, market varchar, primary key(market)); create alternative table: cql-import --table dim_location --cassandra-keyspace npa_nxx --cassandra-table npa_nxx_data --cassandra-column-mapping region:region,market:market --connect jdbc:vertica://xx.xxx.xx.xxx:5433/schema --driver com.vertica.jdbc.driver --username xxxxx --password xxx --cassandra-host xx.xxx.xx.xxx then execute sqoop command: dse sqoop --options-file /usr/share/dse/demos/sqoop/import.options and here total output: 14/10/30 09:28:53 warn tool.basesqoo

linked list tutorial in java -

linked list tutorial in java - i learning linked list in java , wrote sample code practise. singe linked list. code works fine reverses output. prints out cory, joe , tom , want output tom, joe , cory. tom beingness first node. how go or way single linked list works. reverses output? public class linkedlist { public string name; public linkedlist next; public linkedlist(string name) { this.name = name; this.next = null; } public string tostring() { homecoming name; } public static void main(string[] args) { // todo auto-generated method stub linked l = new linked(); l.insert("tom"); l.insert("joe"); l.insert("cory"); l.print(); } } class linked { linkedlist first; public linked()//initialize { this.first = null; } public void insert(string name) { linkedlist g = new linkedlist(name); g.next = first; first = g; } //checks if list empty public boolean isempty() { homecomin

C# Making a Football Game Console Application -

C# Making a Football Game Console Application - i have c# console application write using code have tried couple of things , seem run block. trying create timer on game @ top way me print console , sort of maintain eliminating console.clear code. there way can maintain countdown timer @ top while console.clear active timer not in console window? additionally, know how convert number format timeclock so: 00:05:00? using system; using system.timers; namespace timerexample { class programme { static timer timer = new timer(1000); static int = 10; static void main(string[] args) { timer.elapsed+=timer_elapsed; timer.start(); console.read(); } private static void timer_elapsed(object sender, elapsedeventargs e) { i--; console.clear();//here disable , prints out timer in widow // if leave console window wipes out