Posts

Showing posts from September, 2014

ruby on rails - How do I stop circular "followers" in a model? -

basically, have table 2 columns, follower , followed. if user1 follows user2, need make sure user2 cannot follow user1. write in model validate that? i have user model each 1 has id. created new relationship model, there 2 columns. this i'm at. class relationship < activerecord::base attr_accessible :followed_id, :follower_id belongs_to :followed, class_name: "user" belongs_to :follower, class_name: "user" validates :followed_id, presence: true validates :follower_id, presence: true validates :verify_no_circular_requirements private def verify_no_circular_requirements return true end end you write custom validator function: for example(assumption, have followed_users method returns users current user following, , follow method, taking user id , "following user.): class user < activerecord::base has_many :users, inverse_of :user, as: followed_users validates :verify_no_circular_followers def followed

python - PyInstaller error with PySide -

i have been playing pyinstaller on windows 7 (64 bit). using pyinstaller 3.1.1 python 2.7.6. created app creates simple pyside gui , generated dist folder executable command: > c:\python27\scripts\pyinstaller.exe .\hellowidget.spec this spec file looks like: # -*- mode: python -*- block_cipher = none = analysis(['hellowidget.py'], pathex=['c:\\users\\spearsc\\documents\\python_projects\\helloworldgui'], binaries=none, datas=[('.\\mainwindow.ui', '.')], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=false, win_private_assemblies=false, cipher=block_cipher) pyz = pyz(a.pure, a.zipped_data, cipher=block_cipher) exe = exe(pyz, a.scripts, exclude_binaries=true, name='hellowidget', debug=false, strip=false

html - Firefox SVG rect size not drawn for size greater than 300,150 -

the following jsfiddle works correctly in chrome not in firefox(at least in 16 , 21) (look size of rect) http://jsfiddle.net/ej5zk/9/ <svg> <g> <rect y="0" x="0" width="400" height="463" /> </g> </svg> actually works incorrectly in chrome , correctly in firefox. you want set width , height when embedding svg in html per svg specification the ‘width’ attribute on outermost svg element establishes viewport's width, unless following conditions met: the svg content separately stored resource embedded reference (such ‘object’ element in xhtml [xhtml]), or svg content embedded inline within containing document; and referencing element or containing document styled using css [css2] or xsl [xsl]; and there css-compatible positioning properties ([css2], section 9.3) specified on referencing element (e.g., ‘object’ element) or on containing document's outermost svg element sufficient

mailmerge - Simple mail merge for google form -

i trying modify email template given google's simple mail merge. google sheets linked form response set send me emails of results when fills out form. problem when add additional line under email address phone number, results show right after results email. not show on separate line. sorry if doesn't make sense. hoping has used google forms , used mail merge shine light. in advance. the example below. hi ${"first name"} signing up. submitted following data: first name: ${"first name"} last name: ${"last name"} email address: ${"email address"} please verify information , contact if there's mistake. thank you! if add different line below : hi ${"first name"} signing up. submitted following data: first name: ${"first name"} last name: ${"last name"} email address: ${"email address"} phone number: ${"phone number"} please verify information , contact if there'

c - system() keeps returning 127 -

i developing shared-library l used other system service s . in program need call small program p , uses oracle shared libraries. the small program p packaged , installed correctly, , environment variables, such path , ld_library_path , oracle_home set correctly. can run p on command line without problem. but when service s call library l runs small program p via system() , gives me return code 127 . i've googled, people says it's command not found error, path issue, i've tried absolute path following int status = system("/usr/bin/myprog --args"); if (status < 0) { ... } ret = wexitstatus(status); ret still equals 127 . any idea please ? thank you. update turns out service s launched via command daemon , in init.d script, have found following line: daemon /usr/bin/myserv if export explicitly environment variables ( path , oracle_home , ld_library_path ), works. don't know if daemon eliminates environment variables.

rubygems - Ruby on Rails Gem or Bower for CSS and Javascript? -

in ruby on rails, better css , javascript dependencies? to install them gem or bower dependency? such jquery , or bootstrap ? it better install css frameworks bootstrap gem. here favorite bootstrap installation guide: https://launchschool.com/blog/integrating-rails-and-bootstrap-part-1 jquery included in default rails setup.

blocking - How to get around an ISP block on port 25 for SMTP -

yes, question has been answered in variety of ways, none of which, answered in way fit needs. so, therefore i'm asking mine specific situation. i've tried, 5 or 6 different ways setting mail (smtp) server on spare computer @ home i've set run website. isp blocks several ports 80 , 25 allow hosting web servers, mail servers, ftp servers. etc. luckily, domain registrar had way forward traffic specific port used options in router port translation , redirect traffic 1 port specified in account settings on registrar's site go port 80 on web server computer, worked fine, , website up. however, i've come find out default, when setting mx record can set mail server, system default sends traffic port 25. (so rather web server pointer can specify: 012.345.678.910:8080, mx record has mail.mydomain.com or mydomain.com. there no way in options (currently) specify port can website. so, guess 2 part question. 1. did happen choose crappy domain registrar; or specif

css - Hovering <a> elements in one column causes other columns' <a> elements to blink -

hovering on <a> elements on 1 column may trigger blinking on other <a> elements in column. .cvtitle { font-weight: 400; text-transform: uppercase } #cvpress { -webkit-columns: 4 250px; -moz-columns: 4 250px; columns: 4 250px; -webkit-column-gap: 20px; /* chrome, safari, opera */ -moz-column-gap: 20px; /* firefox */ column-gap: 20px; } #cvexhibitions { -webkit-columns: 2 400px; -moz-columns: 2 400px; columns: 2 400px; -webkit-column-gap: 20px; /* chrome, safari, opera */ -moz-column-gap: 20px; /* firefox */ column-gap: 20px; } .twocolumns { -webkit-columns: 2 400px; -moz-columns: 2 400px; columns: 2 400px; -webkit-column-gap: 20px; /* chrome, safari, opera */ -moz-column-gap: 20px; /* firefox */ column-gap: 20px; } #cvpress { display: inline-block; transform: translatex(0px); transition: 0.3s ease-in-out; } #cv

ruby - Accessing and checking a value within a hash -

looked around , not find proper answer problem facing. want access , check value within hash. code below... class bank class accountmaker attr_accessor :account_number, :name, :balance, :pin def initialize(account_number, name, balance, pin) @account_number = account_number @name = name @balance = balance @pin = pin end end attr_accessor :int_account_number, :int_account_pin def initialize @accounts = {} @int_account_number = int_account_number @int_account_pin = int_account_pin end def add_account(account_number, name, balance, pin) @accounts[account_number] = accountmaker.new(account_number, name, balance, pin) end def login_screen def account_number_login puts "please enter 7 digit account number." account_number = gets.chomp int_account_number = account_number.to_i if @

c# - .Net SMTPClient leaves connection in WAIT_CLOSE -

i have issue plaguing me. every 2 3 days, end getting connections our smtp provider don't finish closing. running netstat on server shows connection status of close_wait. researching thought had narrowed down object not being disposed of properly. specifically .net smtpclient class in previous version of framework did not implement idisposable. when moved 4.0 framework never needed go , update this, meaning we've been along time without these errors. few weeks ago started having problem. started when our provider had outage on servers. in theory still having intermittent issues not broadcasting. in either case code needs able recover , keep going. i've been through every piece of code sends emails, , they've been fixed. every mailmessage object , every smtpclient object in using statement. still issue randomly. when happen seems happen multiple times close together, doesn't happen days. the worst of problem once end 2 connections same server s

tensorflow - tenser flow in android only for prediction use -

i want make model using tensorflow in gpu server , want use in android user service. full tensorflow framework size huge run in android. want use prediction functionality in android. how can come work easily? it looks needs done through jni tensorflow c++ interface. though there seem java shim layer available. haven't tried yet, here decent discussion of it: https://medium.com/google-cloud/how-to-invoke-a-trained-tensorflow-model-from-java-programs-27ed5f4f502d#.mcaz69nvf

laravel - WAMP - php artisan command becomes slow in WAMP 3.0 -

i used wamp 3.0 local environment (windows 7). didn't change on environment, , "php artisan" command became slow. command not return display within minutes. i switched , forth on php, 5.6.16 , 7.0.0, both supported in wamp 3.0. , same. how can solve problem? thanks! there number of reasons why wamp running slow. please refer page on things try correct that: https://www.devside.net/wamp-server/wamp-is-running-very-slow for me, helped disabling cgi_module in apache. can done by: click green "w" -> apache -> apache modules -> uncheck: cgi_module.

c# - Protected Internal method not allowing Internal Class as parameter -

this code not compile: internal class foo {} public abstract class somebaseclass { protected internal void processfoo(foo value) { // doing something... } } the compile fails stating: inconsistent accessibility: parameter type foo less accessible method somebaseclass.processfoo apparently, protected internal means protected or internal , not protected , internal had believed. credit michael liu

c# - How to query customer list detailed with sales rep and price level in Quickbook SDK -

my goal basic: try customers details, including sales rep , price level. i create new customer class this. public class customer { public string name { get; set; } public string fullname { get; set; } public bool isactive { get; set; } public string salesrep { get; set; } public string pricelevel { get; set; } } and main code https://gist.github.com/anonymous/3968904d2d0fc492ed176c40465313b6#file-gistfile1-txt private void button1_click(object sender, eventargs e) { qbsessionmanager sessionmanager = null; try { sessionmanager = new qbsessionmanager(); imsgsetrequest requestmsgset = sessionmanager.createmsgsetrequest("us", 13, 0); requestmsgset.attributes.onerror = enrqonerror.roecontinue; sessionmanager.openconnection("", "quickbooks sdk demo test"); sessionmanager.beginsession("", enopenmode.omdontcare); icusto

php - a syntax error shows on hosting and the same code works just fine on the local -

this question exact duplicate of: error appears on online server doesn't appear on local host [closed] i using http://www.000webhost.com/ web server. code works on localhost online getting error parse error: syntax error, unexpected t_string in /home/a1582910/public_html/setcore/create.php on line 1 and cannot fix because not understand problem because know code in 1 line of in line 1 :d after searching found names of variables case sensitive made in small letters , still having same error. can 1 help? i using wampserver (32 bits & php 5.4) create.php contains following <html> <head> </head> <body> <?php class invoice { function addninvoice ($i) { require_once 'phpexcel_1.7.9_doc/classes/phpexcel.php'; /** phpexcel */require_once 'phpexcel_1.7.9_doc/classes/phpexcel/iofactory.php'; $excel2 = phpexcel_iofactory::createreader('excel200

r - Split Data Frame into Rows of Fixed Size -

i have bunch of data frames varying degrees of length, ranging approx. 15,000 500,000. each of these data frames, split them smaller data frames each 300 rows further processing on. how can this? this ( split dataframe number of rows ) provides partial answer, doesn't work because not data frames have length multiples of 300. would appreciate if plyr , non-plyr solution can both provided. thank you! i don't understand why plyr solution needed. split works , hadley himself didn't suggest plyr/reshape2 solution when looked @ earlier question: split(dfrm, (0:nrow(dfrm) %/% 300) # modulo division does produce warning since expecting non-evenly divisible result should ignore it.

java - Constructor or Setters? -

Image
well of may simple question i'm asking ensure class design isn't violating design concepts when comes proper use of constructor access modifier. in class i'm working on didn't use setters because thought correct initialize subject object using constructor instead of setting each field using setter methods. hence, require other teammates supply attributes of class subject when instantiated before calling add() method. my question why i'm getting warning on netbeans? should make instance variables private final ? should remove constructor parameters , create setter methods initialize fields/variables? here's code. public class subject { private string subjectname; private string subjectcode; private int subjectunits; private string subjectdescription; private string subjectyearlevel; private int schoolyearstart; private int schoolyearend; public subject(string name, string code, int units, string description,

javascript - Is there a better solution than using an if/then statement for this? -

i have extension detection function, relies heavily on numerous lines of if/then statements. there different method use same results? (all of variables defined @ higher level). want deal less code, , increase performance speeds. if (extt == 'app') { doctype = 'app'; docdesc = 'application'; } else if (extt == 'exe') { doctype = 'exe'; docdesc = 'executable file'; } else if (extt == 'vwx') { doctype = 'vwx'; docdesc = 'vectorworks file'; } else if (extt == 'torrent') { doctype = 'torrent'; docdesc = 'bittorrent document'; } else if (extt == 'ipsw') { doctype = 'ipsw'; docdesc = 'apple device software update file'; } else if (extt == 'mpkg') { doctype = 'mpkg'; docdesc = 'installer package'; } else if (extt == 'prefpane') { doctype = 'prefpane'; docdesc = 'mac os x preferen

C# - WPF - ColumnGroups Footer? (telerik) -

can tell me whether it's possible set footer each columngroups of radgridview in wpf using code behind ? i able on normal gridviewdatacolumn setting footer attribute true how columngroups? possible? no, don't think possible. telerik documentation has no such feature. you can set xaml code behind normal columns, not column groups... by default though column footers hidden, in order make them visible have set showcolumnfooters property true, per example: <telerikgrid:radgridview x:name="radgridview" showcolumnfooters="true"> ... </telerik:grid:radgridview>

ios - How to set a Mapkit Overlay object's "zPosition"? (i.e. how to access it's view layer?) -

how can access & set layer.zposition property of mapkit overlay? for example how this: func mapview(mapview: mkmapview, rendererforoverlay overlay: mkoverlay) -> mkoverlayrenderer { let layer = overlay.layer // ??? how layer.zposition = 1 } or there way? background: want approach group mapkitview overlays have have determine types of objects displays on top of other types of objects ?

excel - How can I link two checkboxes to one cell so that IFF two checkboxes are false, the cell is changed -

my first question! i have created tool allows selection (via checkboxes) of services offered @ hospital , redistributes nominated bed total across services selected. example, 1000 beds distributed among 34 services according demand projection , deselecting services adjusts distribution bed counts services changing every click of checkbox. have reached pretty point tool , macros far - select , deselect button services , collapsing lists , hiding checkboxes when collapsed. there 2 bed numbers each service, medical , surgical. besides complete deselection (unselection?) of services, have '% service' column user puts in number between 0 , 100 depending on how of demand hospital should serve. have both these functions (checkboxes , %) working separately affect bed number columns. if % value > zero, 2 checkboxes must true. conversely, if both checkboxes false, % value should zero. so, % 0 100 , affects both columns per service. and, each column has checkbox per service.

python - How to select the following specific XML nodes using XPath? -

i have xml doc following: <objects> <object distname="a/b"> </object> <object distname="a/b/c1"> </object> <object distname="a/b/c4/d/e"> </object> <object distname="a/b/c2"> </object> <object distname="a/b/c6/d"> </object> </objects> and need select nodes has path ends "c" + number . like: " a/b/c1 " , " a/b/c2 " not " a/b/c6/d ", nor " a/b/c4/d/e ". if try following: `cnodes = xmldoc.xpath("//object[contains(@path, `a/b/c`)]")` then include "a/b/c6/d" , "a/b/c4/d/e" not require. so there way job in 1 or maybe 2 lines of code . mean can loop , stuff that, don't want to. that's because real xml doc thousands of nodes. ps: python 2.7, lxml unfortuantely it's not simple express condition matches patterns using xpath 1.0. if can m

Nativescript App keeps crashing with the following error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) -

this app keeps crashing after 10 minutes of non-use , app remaining open. i'm new nativescript , don't have idea start this. --------- beginning of crash 05-24 20:08:19.316 17271 17271 f libc : fatal signal 11 (sigsegv), code 1, fault addr 0xdeadcab1 in tid 17271 (ivescript.ppmns) 05-24 20:08:19.428 274 274 debug : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 05-24 20:08:19.428 274 274 debug : build fingerprint: 'lge/g2_tmo_us/g2:5.0.2/lrx22g/1507914346dda:user/release-keys' 05-24 20:08:19.428 274 274 debug : revision: '10' 05-24 20:08:19.428 274 274 debug : abi: 'arm' 05-24 20:08:19.428 274 274 debug : pid: 17271, tid: 17271, name: ivescript.ppmns >>> org.nativescript.ppmns <<< 05-24 20:08:19.428 274 274 debug : signal 11 (sigsegv), code 1 (segv_maperr), fault addr 0xdeadcab1 05-24 20:08:19.527 274 274 debug : r0 a2dd9855 r1 a2dd9855 r2 00000000 r3 deadcab1

ios - Trouble setting UIImageView.image on custom class from another class -

i have custom class subclass of uiview manages uiscrollview fits size of view , contains uiimageview fills scrollview. i having trouble setting imageview.image of custom class: here's class #import "backgroundpickerview.h" @implementation backgroundpickerview @synthesize scrollview; @synthesize imageview; @synthesize actionbutton; -(id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; return self; } -(void)layoutsubviews { [super layoutsubviews]; //[[nsnotificationcenter defaultcenter] addobserver:self // selector:@selector(changeimage) // name:@"imagechangenotification" // object:nil]; //here's add custom subviews scrollview = [[uiscrollview alloc] init]; imageview = [[uiimageview alloc] init]; actionbutton = [[uibutton alloc] init]; [scrollview setf

c# - Finding count of a keyword in an XML -

xml can have format <root> <child1> value1 </child1> <child2> <child3> value2 </child3> <child4> <child5> value1 </child5> </child4> </child2> <child6> value1 </child6> </root> here value1 written 3times, count should 3. or xml can have format this: <root> <child1 value="value1" /> <child2 value="value2"/> <child3 value="value1" /> <child4 value="value1"/> <child5 value="value3" /> <child6 value="value4"/> </root> here value1 has count 3. so xml can have format, want count particular keyword count in xml. please guide ! edit: question not possible duplicate of link have mentioned, h

powershell - Service to Service Calls Using Client Credentials -

i tried create alias group in office 365 using below code shows error.how solve this. tried use service service calls method. got token generated. how check valid or not? possible create alias using api group without powershell option? if no kindly advice me other options.. string clientid = "************"; string clientsecret = "******"; string tenantid = "********"; //string resourceuri = "http://office.microsoft.com/outlook/"; string redirecturi = "https://login.live.com/oauth20_desktop.srf"; var authuri = "https://login.windows.net/" + tenantid + "/oauth2/authorize/"; var resource_url = "https://graph.windows.net"; httpclient client = new httpclient(); var authcontext = new authenticationcontext(authuri); var credential = new clientcredential(clientid: clientid, clientsecret: clientsecret); var result = authcontext.acquiretokenasync(resource_url, credential).result; client.defaultrequestheaders.

lucene - RCA needs more information, using Hibernate Search -

one of our customers, whom did custom development facing weird issue. though still in pre-uat, see not conforming known lucene behavior. we using hibernate search 5.5.2, apache lucene 5.3.x; using filesystem index. running inside weblogic 12c container, oracle 12c database. we have 2 different virtual machines host 2 different weblogic 12c instances (thereby application) point same database (thereby same data); @ start of application, index data on filesystem on each of nodes. same query, yields different results on each of nodes! has faced similar issue? indexing mechanism in way tied hardware or specific machine? cannot fathom reason behavior. also, next question if there non-replicated (no form of replication) clustered nodes (weblogic 12c) - ok index on each of nodes separately,the same data? or necessary use master-slave replication? not need answer maintainability point of view, rather view of correctness of results? see original question on official hibernate searc

maven - Execute test suites in a specific order -

i'm using maven-failsafe plugin trigger testng suites configuration similar <suitexmlfiles> <file>src/test/resources/suites/somesuite.xml</file> <file>src/test/resources/suites/anothersuite.xml</file> <file>src/test/resources/suites/yetanothersuite.xml</file> </suitexmlfiles> but suites or tests within them not getting executed in correct order. there way specifiy suites should executed in below order somesuite.xml anothersuite.xml yet suite.xml i don't care order in tests within suite executed, execute 1 suite after previous 1 has completed. there configuration use achieve same? create seperate testng.xml file , add below: <?xml version="1.0" encoding="utf-8"?> <!doctype suite system "http://testng.org/testng-1.0.dtd"> <suite name="suite"> <suite-files> <suite-file path="path-to\suite1.xml" />

java - Method must be called from the UI thread, currently inferred thread is worker -

i trying draw circles in canvas. can on button click, need same when fragment loaded. below fragment code. public class steptwentyonefragment extends fragment { private canvasview customcanvas; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.step21_fragment, container, false); customcanvas=(canvasview)v.findviewbyid(r.id.signature_canvas); final button button1=(button)v.findviewbyid(r.id.step18button1); float radius=(customcanvas.getcanvaswidth()/2) - ((customcanvas.getcanvaswidth()/2)/100)*60; new myasynctask(customcanvas).execute(); button1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(v.getid()==r.id.step18button1){ float radius=(customcanvas.getcanvaswidth()/2) - ((customcanvas.getcanvaswidth()/2)/100)*60;

Matlab - setting up a nested parfor loop -

i got trouble setting parfor loop in matlab. know rather easy bit stuck here thats why appreciate help. i have tried following valuesform = zeros(901,100); valuesforopratio = zeros(100,1); counter=1; x = xlsread ('gtc.xlsx', 'a2:a10000'); y = xlsread ('gtc.xlsx','c2:c10000'); z = xlsread ('gtc.xlsx','b2:b10000'); parfor m = 100:1000; counter=counter+1 opratio = 1:100; npvtotal = cut_off_optimisation(m,opratio,x,y,z); valuesforopratio(opratio)=npvtotal; end valuesform(m-99,:) = valuesforopratio; end and following error: error using senitivity_script_10000_steps (line 10) error: variable valuesforopratio in parfor cannot classified. how can fix ? lot. edit following commments advice tried following: valuesform = zeros(901,100); x = xlsread ('gtc.xlsx', 'a2:a10000'); y = xlsread ('gtc.xlsx','c2:c10000'); z = xlsread ('gtc.xlsx','c2:c10000'); parfor m = 100:1000; npvtotal

jquery - I couldn't select tr's with ng-repeat inside tbody of the table? -

i trying write directive table angularjs , selecting table > tr resulting first row of table. tr's inside tbody not included in result.when remove ng-repeat="header in headers" statement <table> <thead> <tr> <th ng-repeat="header in headers">{{header}}</th> </tr> </thead> <tbody> <tr ng-repeat="header in headers"> // removed ng-repeat select rows <td ng-repeat="header in headers">{{header}}</td> </tr> </tbody> </table> all rows of table selected .i can see 4 tr objects console.log. how can select rows inside table in directive linking function? time. here plnk: http://plnkr.co/edit/fvvc85 compile : function($element, $attrs){ return function(scope,element,attrs){ settimeout(function() { console.log(element.find('tbody').children());

Magento theme integration -

Image
hi i'm trying figure out theme implementation in magento. it's first magento community edition installation , first theme try. problem i'm ecnoutering footer.phtml in not showing in front-end showing default footer .and 1 more thing, in screensort u'll see default content coming want disable " cms homepage content goes here " here file structure: /var/www/projects/magento_mag/app/design/frontend/mypackage/mag/magento_theme/templates/html here have created html files in template. header , content part showing in front-end footer part not showing here screensort , footer html <?php /** * copyright © 2015 magento. rights reserved. * see copying.txt license details. */ // @codingstandardsignorefile ?> <!-- footer container --> <div class="footer-container"> <div class="footer"> <div class="footercol"> </div> <!-- footer botom bar

asp.net - vb.net gridview row highlight and image change onmouseover -

i can find different ways highlight rows of gridview onmouseover, can't figure out how change imageurl property of imagebutton inside row. have gridview alternate row background , 2 imagebutton in cell 0. images red, highlight color must red, when row highlighted want change images alternative ones white. how achieve so? 1 example found row highlight, can please add image changing thing? also, how trigger delete command confirmation dialog on highlighted row when imagebutton pressed? thank you protected sub gvhremploye_rowdatabound(sender object, e gridviewroweventargs) if e.row.rowtype = system.web.ui.webcontrols.datacontrolrowtype.datarow ' when mouse on row, save original color new attribute, , change highlight color e.row.attributes.add("onmouseover", "this.originalstyle=this.style.backgroundcolor;this.style.backgroundcolor='#eeffaa'") ' when mouse leaves row, change bg color original value e.