Posts

Showing posts from March, 2013

ssl - Unable to Send Email Using PHP -

Image
preview: have been trying send email using moodle long time , decided test sending email using standard php mail() function test if mail working fine. but php not send email!! problem scenario: this code php: $to = "receiver@gmail.com"; $subject = "test mail"; $message = "hello! simple email message."; $from = "username150@gmail.com"; $headers = "from:" . $from; ini_set( "sendmail_from", "username@gmail.com" ); ini_set( "smtp", "smtp.gmail.com" ); ini_set( "smtp_port", "25" ); ini_set("username","username0@gmail.com"); ini_set("password","password"); mail($to,$subject,$message,$headers); echo "mail sent."; the error : warning: mail() [function.mail]: smtp server response: 530 5.7.0 must issue starttls command first. sz6sm10013088pab.5 - gsmtp in c:\program files (x86)\moodle\server\moodle\u...

javascript - How do I load Google Maps JS API in PhoneGap to use it multiple times? -

i'm developing phonegap application multiple pages , of them show map. now i'm trying load google maps api when page loads can access whenever need it. there several options: load script without callback parameter in url ...(url)&callback=functionname when page loads result: google.maps object created it's empty. functions missing. load script with callback parameter in url when page loads result: functions in google.maps available, when create map, empty <div style="overflow-x: hidden; overflow-y: hidden;"></div> inside container element. seems starts create map, rest missing. funny thing here is: works in desktop browsers, not in phonegap application - doesn't matter if android or ios. load script with callback, every time map should displayed result: seems work, error/a warning in console shows up, telling me there may occur unexpected problems if load maps api more once. plus creates unnecessary server requests slow d...

Read items into a file whose name contains some space from a batch script -

i need read items inside files batch script. name of items' file contains spaces. that, use file name parameter, surrounded double quotes in order take account file names spaces. read.bat /f %%a in ("%~1") echo %%a>>result.txt conf file.txt projectid: biew artifactid: sprint1 batch running 'read.bat conf file.txt'. instead having result.txt projectid: biew artifactid: sprint1 i "conf", first part of file name. helping me! you should use "delims=" , session protocol: >type read.bat @for /f "usebackqdelims=" %%a in ("%~1") @echo %%a >type "conf file.txt" 1 2 3 4 5 >read.bat "conf file.txt" 1 2 3 4 5

compilation - Confused about how Intellij compiles things and deals with resources -

i'm quite new intellij visual studio, , i'm quite confused how resource files work in intellij project. i'm read few questions & answers getting resources onto classpath, intellij docs, still confused. have few further questions: some questions mention maven, not. how maven projects differ normal modules in how compile things , deal resources? when run main method within intellij, run from? directly compiled .class files, or generated jar ? both exist in filesystem, , whats difference? if put .xml file somewhere in source tree, intellij default when compiling , running within intellij? how can change puts it? what classpath when running main function within intellij? how arbitary file included in jar file or alongside in compiled output? in maven project ide follows maven rules process resources consistent results between command line maven build , idea build. if maven copies resources classpath, idea same. from classpath of module , dependenc...

Javascript classes, compiler performance and memory allocation on new Klass() -

edit: ======================================================== please see revision 13 of test answers: http://jsperf.com/closure-prototype-static-performance/ ======================================================== i prefer declare klasses this, not big fan of object literal way: first way: private scoping function employees() { var persons = []; // [person, person] this.isemployed = function(_firstname, _lastname) { ( var = 0; < persons.length ; i++ ) { if ( persons[i].equals(_firstname, _lastname) ) { return true; } } return false; } } function person(_firstname, _lastname) { this.equals = function(firstname, lastname) { return _firstname == firstname && _lastname == lastname; } } second way: prototype alternat...

iphone - Coredata Remove and Read Relationship -

is possible remove , read relationship? i cannot post code here since huge project complex process. let's have tablea <-->> tableb tableb gets updated (i.e., tableb objects deleted , new obejcts (re)added). check if objects tablea had relationship tableb, have in array server object id. read data in tableb , readd relationship. relationship gets faulted , cannot accessed. after add or remove object save it. doing wrong? i feel misunderstanding intentions here give try , modify needed. first, entities should start capital letter, using tablea , tableb entities. tablea , tableb terrible names coredata entities. atrociously generic , if ever decide use them outside of tables confuse code. since "huge project complex process." this in essence believe seeking: // defined elsewhere nsmanagedobjectcontext *managedobjectcontext; // saving the object want connect later tablea *relationshiptoa = self.alltablebs.tablearelationship; // remove table...

php - Get div's HTML content via xpath -

this question has answer here: how innerhtml of domnode? 6 answers i need support on following issue, have website want product descriptions via xpath. below example html of content: <div id="description"> <span>some test</span> <img src="some src"> <p> content etc. </p> </div> and use below code: $result = $xpath->query('//div[@id="description"]'); but when i'm outputting result below line: echo "<pre>".$result->item( 0 )->nodevalue."</pre>"; // there 1 element what unformatted: "some testsome content etc." no spaces , other tags. know because xpath treats other tags nodes but... i there way div's content html ? hey did similar while , post helped me: php domdocument / xpath: html-text , surrounded...

perl - How to compare two hashes -

i have 2 files have read 2 seperate hashes. first file has 2 columns , looks like: 123456789 11111 234567891 22222 345678912 33333 the second file has 1 column, looks like: 123456789 010124561 100324531 i want compare 2 hashes , whenever there match between first columns of 2 files, should print new file results of first column. have far... #!/usr/bin/perl use sys::hostname; use lib "$env{home}/common/lib/perl"; use strict; use warnings; %oid; %oid2; %atom; %newline; $oid; $atom; @line = (); @line2 = (); @oid = (); @oid2 = (); $input = 'file.txt'; $input2 = 'file2.txt'; $output = 'outputfile.txt'; open (in, "<$input"); open (in2, "<$input2"); open (out, "+>$output"); $line (<in>) { chomp $line; @line = split /\t/, $line; push( @oid, $line[0] ); $oid{ $line[0] } = $line[0]; $atom{ $line[0] } = $line[1]; } $line2 (<in2>) { chomp $line2; @line2 = split...

magento - MultiStore with different products -

i have magento store configured use single website 2 stores (and 1 store view each). both stores must have different products. when created them, each store had own root category, expected magento divide products associated category. somehow worked on local test @ first, didn't on production , after changing categories locally didn't work - changing did not fix problem. searching found change status per store view, @ side of product status, says "website" , when change it, both views change. change visibility i'm not sure if won't slow down store. so, 2 questions: is possible separate products each store based on root category? is visibility per store view optimized? (i have 500 products, 400 in 1 store , 100 on other, , don't want slow down store) edit: couldn't find solution this, used workaround instead: i have on cms homepage: {{block type="catalog/product_list_random" name="home_products" template="cat...

linux - how to make switch execute 2 cases -

how make switch execute 2 cases? i tried following code, execute first case #!/bin/sh action="titi" case "$action" in toto|titi) echo "1_$action" ;; tata|titi) echo "2_$action" ;; esac the case statement in bash executes commands in command-list first match only. however, in bash version 4 or later introduced ;& terminator. ;;& operator ;; , except case statement doesn't terminate after executing associated list - bash continues testing next pattern though previous pattern didn't match. using these terminators, case statement can configured test against patterns, or share code between blocks, example. reference: excerpt taken http://wiki.bash-hackers.org/syntax/ccmd/case so if have bash v 4 or later give desired result: #!/bin/sh action="titi" case "$action" in toto|titi) echo "1_$action" ;;& tata|titi) echo "2_$act...

How do we hide sibling div h2 using jquery -

<div> <div> <h2>referral schedules</h2> </div> <div> <script="javascript"> </script> <iframe width="100%" height="100" frameborder="0" src="www.google.com"> </div> </div> i have page in have control on portion of html, ie div have iframe. need way hide h2 tag. $('div > div > h2').hide(); prodably best way it. but why, really. why? use class. if me id'e special this <div> <div> <h2 class="heading-sibling">referral schedules</h2> </div> <div> <script="javascript"> $(function(){ $('.heading-sibling').hide(); }); </script> <iframe width="100%" height="100" frameborder="0" src="www.google.com"></iframe> </div> </div>

content management system - Magnolia author instance does not work -

Image
i have installed magnolia cms 5.0 pretty successfully. author instance works fine. however, public instance throws following error don't know how interpret. idea? lot! couple of idea, if unix system, check open file limit. ulimit -n increase doing ulimit -n 2048 put whatever number want. got lot of random errors when first installing magnolia , got me past bunch of them. wont fix honest. your problem looks installing both instances on same computer. make sure have them seperated defined folder structure , not installing them same folders. otherwise, post more info log files , steps took here. post doesn't provide you.

php - How to manage large initial application data in Symfony 2 -

i working on symfony 2 application requires quite lot of initial data. couple of thousand rows easily. ways of managing dataset? i have been trying docrine migrations it's bit of pain. data loaded once , can't reload. if there bug in data need migration find , correct it, etcetera. i have been reading on doctrine fixtures. looks more need, required me write php code creates data entities. several thousand entries, going major pain. any better options? if data stored in file, can use doctrine data fixtures import data file. you write fixture class parse data file, set data on new entity, , persit entity. for example, if data stored in yaml file, work: // src/acme/demobundle/datafixtures/orm/loadintialdata.php namespace acme\demobundle\datafixtures\orm; use doctrine\common\datafixtures\fixtureinterface; use doctrine\common\persistence\objectmanager; use acme\demobundle\entity\myentity; use symfony\component\yaml\yaml; class loadintialdata implements fi...

Register/Login popup form for WordPress site -

hi i'm building site using wptube4 theme in wordpress. i'd put link i'm creating on localhost using webmatrix. issue can't register/login popup form work. want have button or link in header says login , says register , when click have form popup in "lightbox" lets , user can register using email , password other sites have. then on can login site. complicate bit more set "log in using facebook option" how stackoverflow has. i've been having hard time finding right tutorial or plugin online , i'm hoping newbie question can answered and/or can point me in right direction. , sorry being such simple thing ask. not sure if should using jquery or it, might redirect page form there wanted avoid this, wanted keep users on same page , overlay (lightbox effect) form when they're done return were. regardless of use learn skill use both. thanks.

c# - LINQ to SQL Get Latest Date from Object -

i have read few items on this, including how select records highest date in linq don't know how apply case more complex. i trying adjusterprofilestatusitem select recent s.statusdate . currently, query returns dates records; whereas want recent date records. (from u in db.users join in db.adjusters on u.id equals a.userid join s in db.adminadjusterstatus on a.id equals s.adjusterid u.usertype.tolower() == "adjuster" && s.status.tolower() == "approved" && s.statusdate.max() // causes syntax error... select new adjusterprofilestatusitem { user = u, adjuster = }) edit: i have tried gives me syntax error... (from u in db.users join in db.adjusters on u.id equals a.userid join s in db.adminadjusterstatus on a.id equals s.adjusterid u.usertype.tolower() == "adjuster" && s.status.tolower() == "approved" group new { u, a, s } s.adjusterid x select new adjusterprofilestatusitem { user = u, // u not ...

sql - Can I get the minimum of 2 columns which is greater than a given value using only one scan of a table -

this example data (there no indexes , not want create any): create table tbltest ( int , b int ); insert tbltest ( a, b ) values ( 1 , 2 ), ( 5 , 1 ), ( 1 , 4 ), ( 3 , 2 ) i want minimum value in of both column , column b greater given value. e.g. if given value 3 want 4 returned. this current solution: select min (submin) ( select min (a) submin tbltest > 3 -- returns 5 union select min (b) submin tbltest b > 3 -- returns 4 ) this searches table twice - once min(a) once min(b) . i believe should faster 1 pass. possible? you want use conditional aggregatino this: select min(case when > 3 end) mina, min(case when b > 3 b end) minb tbltest; to minimum of both values, can use sqlite extension, handles multiple values min() : select min(min(case when > 3 end), min(case when b > 3 b end) ) tbltest the issue min return null if either argument null. can fix doing: select coalesce(min(min(case when ...

How to import javascript in rails with asset pipeline -

in app have 1 controller supporting quite complex object has lot of javascript, written in coffescript. i arrange javascript on several separate files have code arranged more nicely, although can't figure out how import these files. for example have file app/assets/javascripts/general_functions.js.coffee containing following: # rounds number roundnumber = (rnum, rlength = 5) -> pow = math.pow( 10, rlength ) newnumber = math.round(rnum*pow)/pow parsefloat(newnumber) # floors number floornumber = (rnum, rlength = 5) -> pow = math.pow( 10, rlength ) newnumber = math.floor(rnum*pow)/pow parsefloat(newnumber) # returns true if str ends suffix endswith = (str, suffix) -> str.indexof(suffix, str.length - suffix.length) != -1 # returns absolute value of number (always >= 0) abs = (num) -> if num < 0 - num else num how import in app/assets/javascripts/projects.js.coffee needs these functions? i've tried adding //= require general...

subprocess - Python sub process call -

what trying accomplish in few words this: change directories , call script shell. so far have managed change directories os.chdir() . however haven't been able understand how syntax second part of given task. specifically, command want invoke 1 /path-to-dir-of-the-script/script<inputfile.txt>outfile.txt , eyes @ least problem input file (and evidently output file not exist generated script) in 2 different directories. so trying following ( ls , print debugging , supervising purposes more or less) along various modifications getting error. either syntaxerror or system cannot find 2 files, etc. import subprocess import os import sys subprocess.call(["ls"]) #read contents of current dir print os.dir('/path-to-dir') subprocess.call(["ls"]) print in_file = open(infile.txt) #i not sure if declaring files necessity. out_file = open (outfile.txt) com = /path-to-dir-of-the-script/script process = subprocess.call([com], stdin=infile.txt, ...

jsf 2 - Authorization in JSF2 components -

in our project have jsf2 pages used in internal network of company. going open pages internet. pages available everybody. fields not rendered if user comes internet. i know possible write rendered attribute each component such "userisinrole". additional "rendered" control doesn't seem efficient , elegant method. plan mark components going rendered online using custom attribute shown below: <h:inputtext context="internet" /> ... in renderer of inputtext or component code: if(user internet && context = "internet") { return true; // or render... whatever } if component not marked internet, means available (rendered) inside of company. is possible implement authorization using jsf2 components according given attribute? there better options? or should design separate pages internet users? we use: primefaces + spring in our project. thank you this ridiculous. what's difference in effort of using ...

html - How to disable specific CSS styles from Firebug/IE developer tool -

i have following html code: <input type="text" value="test value" readonly/> this input element non-editable since has readonly attribute. it's still possible make field editable inspecting element using firebug tool in firefox. there way make attribute non-editable? this not possible. find way around because code executed on client. if secured client (web browser) there still way post , tamper read-only fields using proxy server fiddler . have 2 choices. 1)remove item field list , make text element. valid solution if don't need information in post. 2) keep item read (or hidden) check content has not changed on server side. best security practice anyway. should validate on server if validate on client. reason people can work aound client side validation. there different approaches server side validation according end language. in case, if using php or asp.net, can stick value in session variable before serve page , check...

vba - If TextBox1.Text found in A:A, add TextBox2.Text to later cell in that row -

i have userform entering translations. there textboxes title (txttitle), text translate (txttotranslate) , translated text (txttranslation) , combobox select language (cbolanguage). the code creates new row of data each time user clicks submit. modify functionality follows: 1 clicking submit, check if txttitle exists in a:a 2a if txttitle not exist, create new row (current functionality) 2b if txttitle exists, add txttranslation row txttitle, rather "nextrow" private sub btnsubmit_click() dim findstring string dim rng range findstring = "*" & txttitle if trim(findstring) & "*" <> "" sheets("output").range("a:a") set rng = .find(what:=findstring, _ after:=.cells(.cells.count), _ lookin:=xlvalues, _ lookat:=xlwhole, _ searchorder:=xlbyrows, _ searchdirection:=x...

java - JTree: Missing link between TreeNode and TreePath -

i have problem described here . i have invertexpand method in mytree class works this: public void invertexpand(defaultmutabletreenode node) { treepath path = new treepath(node.getpath()); // no better way treepath treenode :( if (!isexpanded(path)) { expandpath(path); } else { collapsepath(path); } } but problem isexpanded() method uses hashmap store expanded paths. seems isexpanded() never returns true newly created treepath . (but expanded really) does way fix issue? expand/collapse works on non-leaf nodes, sure node in question not leaf: public void invertexpand(defaultmutabletreenode node) { if (node.isleaf()) node = (defaultmutabletreenode) node.getparent(); treepath path = new treepath(node.getpath()); // no better way treepath treenode :( if (isexpanded(path)) { collapsepath(path); } else { expandpath(path); } } edit (as per op's comment) the real reason misbehavio...

r - Can somebody explain me this datetime result -

i puzzled result: a = "2008-03-03 12:30:38" #i convert posixct , set timezone dt = as.posixct(a, format="%y-%m-%d %h:%m:%s", tz='europe/paris') dt [1] "2008-03-03 12:30:38 cet" unclass(dt) [1] 1204543838 attr(,"tzone") [1] "europe/paris" #i want come posixct as.posixct(unclass(dt), origin='1970-01-01', tz='europe/paris') [1] "2008-03-03 11:30:38 cet" i have expected date-time a , wrong here ? as says in ?as.posixct , origin in tz="gmt" . you can use .posixct instead: .posixct(unclass(dt), tz='europe/paris') # [1] "2008-03-03 12:30:38 cet"

dialog - NewDialog with ProgressBar to execute CustomAction on loading -

dialog1: contains 2 radio boxes. - when user selects radiobox1 moves on wixui_minimal workflow - when user selects radiobox2 moves custom ui starts dialog2 dialog2: contains 1 progress bar - want custom action ca1 called when dialog opens i tried following in dialog1: - publish newdialog open dialog2 order 1 - publish doaction ca1 order 2 ca1 not called in case. i tried following in dialog2 - placed custom action outside dialog control , dialog reference. ca1 not called in case. is there way execute ca1 on opening dialog2? "i tried following in dialog1: - publish newdialog open dialog2 order 1 - publish doaction ca1 order 2 ca1 not called in case." i had tried above in dialog2 had used installexecutesequence instead of installuisequence. by using installuisequence follows able results needed: <installuisequence> <custom action="ca1" before="executeaction"/> </installuisequence>

ios - PushSharp ApplePushService giving a Channel Exception -

i able send , receive push notification sucessfully ios device, seeig error: appears after seems connect maximum attempts reached tries connect again , gives error: have used same credentials before , after seeing these errors sends notifications , them on device. seems try connect , reaches maximum attempts , tries connect again , gives error. if credentials work once shouldn't work time? ammethod:serviceexception; channel exception: pushsharp.apple.applepushservice -> system.componentmodel.win32exception (0x80004005): credentials supplied package not recognized @ system.net.sspiwrapper.acquirecredentialshandle(sspiinterface secmodule, string package, credentialuse intent, securecredential scc) @ system.net.security.securechannel.acquirecredentialshandle(credentialuse credusage, securecredential& securecredential) @ system.net.security.securechannel.acquireclientcredentials(byte[]& thumbprint) @ system.net.security.securechan...

c# - Best Practices: Adding properties to a LINQ-to-Entities query result? -

i'm writing asp.net web pages application , in it, have massive linq entities query. query pulls data table in database, filters it, groups data twice, , adds properties result set. loop through table, outputting rows. the query quite big, sorry: accountorders = db.eventorders .where(order => order.eventid == eventid) .orderby(order => order.productcode) .groupby(order => new { order.accountnum, order.exhibitor, order.booth }) .select(orders => new { key = orders.key, productorders = orders .groupby(order => new { order.productcode, order.product, order.price }) .select(productorders => new { key = productorders.key, quantity = productorders.sum(item => item.quantity), htmlid = string.join(",", productorders.select(o => (o.ordernum + "-" + o.orderline))), ...

indentation - how to set 4 space indent in emacs -

every time add new line, indent automatically indents 2 spaces, not 4 spaces. below .emacs snippet. (defun make-vline-xpm (width height color &optional lor) (let* ((w width) (h height) (s1 (concat "\"" (make-string w (string-to-char " ")) "\"")) (s2 (cond ((eq lor 0) (concat "\"." (make-string (1- w) (string-to-char " ")) "\"")) ((eq lor 1) (concat "\"" (make-string (1- w) (string-to-char " ")) ".\"")) ((null lor) (concat "\"" (make-string (- (1- w)(/ (1- w) 2))(string-to-char " ")) "." (make-string (/ (1- w) 2)(string-to-char " ")) "\"")))) (sa (concat s1 ",\n" s2 ",\n"))) (eval `(concat "/* xpm */ static char * dot_vline_xp...

Rspec with Ruby basic output String testing raises an error -

i've tried write basic test rspec, in order test reception of string on standard output. i've stubed standard output same way it's written in rspec book : require './tweetag.rb' module tweetag describe tweet describe "#print" "prints test" output = double('output').as_null_object t = tweetag::tweet.new(output) t.print output.should_receive(:puts).with('test') end end end end the ruby code looks : module tweetag class tweet def initialize(output) @output=output end def print @output.puts('test') end end end as can see, nothing complicated. still, answer receive after running specs following : failures: 1) tweetag::tweet#print prints test failure/error: output.should_receive(:puts).with('test') (double "output").puts("test") expected: 1 time received: 0 times...

In Android what's the best practice to maintain a session through multiple activities? -

i have app has log in screen goes other screens (in other activities), , needs maintain session throughout. i've looked around , found couple methods don't account multiple activities. i've found 1 using httpclient it's old , android saying it's better use httpurlconnection newer devices. so i'm not sure 1 use , how. since other activities stem single activity thinking of making them child activities login page , having them reference session through mainactivity.session (or whatever it's called). any advice? session cookies maintained http stack using. activities not play role. for example, if read the documentation httpurlconnection , "sessions cookies" section shows how establish cookie manager app: cookiemanager cookiemanager = new cookiemanager(); cookiehandler.setdefault(cookiemanager); then, not matter activity http operations done on -- relevant cookies other operations, since process started, included in subseque...

asp.net - Modifying querystring on asp:hyperlink? -

my code looks this: <asp:hyperlink id="hyperlink1" navigateurl="search.aspx?txtgraphicnumber=" target="_blank" runat="server">search related</asp:hyperlink> my querystring starts "txtgraphinumber=". i'd append querystring information in field on screen. field called txtgraphicnumber. can like: <asp:hyperlink id="hyperlink1" navigateurl="search.aspx?txtgraphicnumber=" + txtgraphicnumber + " " target="_blank" runat="server">search related</asp:hyperlink> you have 2 options achieve same: option 1# code behind: //assuming txtgraphicnumber textbox. hyperlink1.navigateurl += txtgraphicnumber.text; option 2# inlinecode: <asp:hyperlink id="hyperlink1" navigateurl='<%="search.aspx?txtgraphicnumber=" + txtgraphicnumber.value %>' target="_blank" runat="server">search related ...

foreach - Why does c++ range based for loop calls destructor at every iteration? -

i using range based loop read (and parse) file using iterator. loop looks this: for (auto record : reader) { if (even) record.reverse_complement(); cout << record.write(); = !even; } i have added outputs constructor , destructors of iterator , looks destructor beign called on iterator returned end() in every iteration of loop. calling fq_iter full constructor calling fq_iter default constructor calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_iter destructor on 0 calling fq_reader destructor on 0 these classes using parse , iterate on file, idea why destructor being called @ every iteration? (other that, produces correct output). according section 6.5.4 of c++ standard, compiler not supposed that. instead, it's supposed cache end iterator in unnameable local. does operator!= ma...

java - NoSuchElementException even after check -

for (final arraylist<smartphone> smartphones : smartphonescluster) { new thread(new runnable() { @override public void run() { (smartphone smartphone : smartphones) { queue<smartphonetask> tasks = smartphone.getsystem() .gettaskque(); smartphonetask task = null; assert tasks != null; try { while (!tasks.isempty()) { task = tasks.poll(); // line throwing exception (globalnetwork.java:118) assert task != null; task.execute(); task.ontaskcomplete(); } } catch (runtimeexception e) { e.printstacktrace(); } } } }).start(); } and log: java.util.nosuchelementexception @ java.util.linkedlist.remove(linkedlist.java...

ruby on rails - Changing Mongoid class name mid-production -

is possible? i have mongoid class named magazine , associations well, re-name publication . problem have bunch of users have made magazines, issues , articles. original magazine model: class magazine # 1. include mongoid stuff include mongoid::document include mongoid::timestamps include mongoid::slug # 2. define fields field :title, type: string field :description, type: string field :live, type: boolean, default: false field :show_walkthrough, type: boolean, default: true # 3. set attributes accesible attr_accessible :title, :description, :live, :show_walkthrough, :cover_image_attributes, :logo_image_attributes # 4. set slug slug :title # 5. set associations belongs_to :user has_many :issues, dependent: :delete, autosave: true has_one :foreword, :as => :articleable, :class_name => 'article', dependent: :delete, autosave: true embeds_one :cover_image, :as => :imageable, :class_name => 'image', cascade_callb...

serversocket - server Socket in Clustered server - Java -

i building application uses quartz scheduler triggered every 30 min. since have clustered servers, if application deployed job twice , don't want happen. therefore decided use socket approach requires port , ip . question , how implement socket approach if 1 instance run in whole clustered environment ? suggestion or , example code highly appreciated. you may use approach of jms or similar, publish task done on queue. nature of queue, 1 consumer can consume message, can sure 1 of instances should pick task , run.

eclipse - Using a git submodule as an android library -

i've seen few similar questions have not found definitive answer , hoping help. have android project subdirectory git submodule want use library (it android library project). problem way i've found eclipse let me add library first import submodule workspace. if have in workspace , subdirectory. what's trick make eclipse "see" subdirectory library , import without first importing workspace separate project.

php - Fatal error: Call to undefined function mysqli_result() -

can please tell me why doesnt work, when tried switch old sql sqli: $query = "select * `product_category`"; $result = mysql_query($query, $connect) or die("could not perform query: " . mysql_error()); $num_rows = mysql_num_rows($result); ($i=0; $i < $num_rows; $i++) { $id = mysql_result($result,$i,"id"); $name = mysql_result($result,$i,"name"); $description = mysql_result($result,$i,"description"); to: $query = ("select * `product_category`"); $result = mysqli_query($connect, $query) or die("could not perform query"); $num_rows = mysqli_num_rows($result); ($i=0; $i < $num_rows; $i++) { $id = mysqli_result($result, "id"); $name = mysqli_result($result,$i,"name"); $description = mysqli_result($result,$i,"description");` it keeps giving me error of: "fatal error: call undefined function mysqli_result()" don't use kind of cod...

html - My CSS fails my javascript dropdown-menu slide effect -

so if want see menu go here . since know you'll want source, here's css: * { margin: 0px; } #menu-container ul, #menu-container li, #menu-container span, #menu-container { margin: 0; padding: 0; position: relative; } #menu-container { text-align:center; height: 49px; border-radius: 0px 0px 0 0; -moz-border-radius: 0px 0px 0 0; -webkit-border-radius: 0px 0px 0 0; background: #141414; background:url(data:image/png;base64,ivborw0kggoaaaansuheugaaaaeaaaaxcaiaaacudvrzaaaaa3ncsvqicajb4u/gaaaaleleqvqimwmwmrji+v//pxmdw3+m//8zopr/qbgdehuxgloeyswhxg8r5gaadvpfoj3db5oaaaaasuvork5cyii=) 100% 100%; background: -moz-linear-gradient(top, #32323a 0%, #141414 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414)); background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%); background: -o-linear-gradient(top, #32323a 0%, #141414 100%); background: -ms-linear-gradient(top, #32323a 0%, ...

Execute SQL command and output result to DataGridView in C# -

i trying execute sql command on access database on oledbconnection using c# , use information fill datagridview on windows form. have opened connection, stated query, , executed it, cannot find how output results datagridview on windows form (named dataoutput). private void query() { string cmdtext = "select * retentiontable " + "where [datetime] between '" + getdatetimefrom("") + "' , '" + getdatetimeto("") + "'"; string connectionpath = "provider=microsoft.jet.oledb.4.0;data source=retentiondb.mdb"; try { oledbconnection cn = new oledbconnection(connectionpath); dataset objdataset = new dataset(); oledbdataadapter objdataadapter = new oledbdataadapter(); if (cn.state.equals(connectionstate.closed)) { cn.open(); } oledbcommand oledbsearch = ...

javascript - Node.js+Handlebars+Express how to reference the handlebars templates? -

i'm relative new node & express, handlebars templates i've never used before , trying reference them in node app.js keep on getting following error property 'engine' of object # not function this code: app.configure(function () { app.set('views', __dirname+ '/views'); app.set('port', 3000); app.set('view engine', 'handlebars'); app.use(handlebarslayout); app.use(express.static(path.join(__dirname, 'public'))); app.use(app.router); }); // routes app.get('/', function (req, res){ var data = { title: "node + handlebars", body: "hello world!" } res.render('index', data); }); http.createserver(app).listen(app.get('port'), function () { console.log("express server listening on port " + app.get('port')); }); any appreciated...

java - Set a variable and print it, without any threads, but it prints the old value? -

i have simple piece of java code: class { static { int x=3; int y‭; int yy=1234; int yyy‮;y‭=1;int z‮y=x; system.out.println("x: "+x); } } i'd expect print "x: 1234". javac a.java && java x: 3 exception in thread "main" java.lang.nosuchmethoderror: main but instead prints "x: 3". why? type of optimization don't know volatile? thought volatile matters if have multiple threads? tried setting variables volatile, , putting locks around them, no luck. told me should set strictfp on class, no luck there either. you have characters make displaying weird. actual code: 1 class { 2 static { 3 int x=3; ...

Can't open google compute engine's console -

i tried visit project in google computing engine console : https://cloud.google.com/console#/c=gce&pid=xxxxxxxxxx&gce=instances and got strange error message : server request failed: invalid value field 'zone': 'rtb-europe-west1-a'. unknown zone. what's wrong ? sorry that, had issue admin console, should fixed now. please let me know if continue have issue.

javascript - Regex pattern search starts with 2 letters OR 2 numbers -

i'm writing javascript function detect correct entry database before sending it. variable must start either 2 digits or 2 letters followed 2 more letters 3 digits. can make each regex work independently want in 1 statement. i've tried /^[a-z]{2}|^[0-9]{2}[a-z]{2}\d{3}$/ no luck. var vall = /^[a-z]{2}[a-z]{2}\d{3}$/;letter var valj = /^[0-9]{2}[a-z]{2}\d{2}$/;digits you need group alternation. /^([a-z]{2}|[0-9]{2})[a-z]{2}\d{3}$/ otherwise match left or right side of alternation.

c# - Dictionary TryGetValue without using value returned -

i'm implementing simple dictionary<string, int> keeps track of picture files download, , renaming of files. string - original filename int - new filename i read on trygetvalue vs containskey , came across this: trygetvalue approach faster containskey approach when want check key in collection , want value associated it. if want check key present or not use containskey only. from here as such, wondering other people's views on following: should use trygetvalue if not plan use returned value , assuming dictonary size grow 1000 entries, , duplicate checks everytime download ie. frequently? in theory, follow documentation. if don't want value use containskey because there's no code go , grab value out of memory. now, in practice, doesn't matter because you're micro-optimizing on dictionary that's small in grand scheme of things. so, in practice, best , readability of code. and idea, would grow 1000 ent...

matlab - Convert a cell of strings to a matrix of numbers -

i'm trying convert cell of numbers of different lengths matrix of numbers. i'm new matlab cells. apologize in advance if question sucks. i've done homework, last resort. x cell of strings. want these strings converted numbers. there way convert cell matrix without brute force iteration? i've tried cell2mat matlab freaks out. i've tried str2num matlab freaks out. i've googled "converting cell of strings matrix of numbers", nothing comes up. here's cell: >>x x = '0' '850' '10483' '16039' '25670' '31242' '37009' '41023' '46798' '51881' '61491' '67181' '72941' '76163' '85759' '96654' '102439' '104615' '114224' >>class(x) ans = cell you want str2double : x = {'1';'12';'3.14'}; y = str2double(x) which returns y = 1.000000000000...

sql - Using Stored Procedure variable in Like statement -

i can't seem use statement using variable stored procedure. want find rows table start variable passed. i using following query @id value passed stored procedure nvarchar(20) . works fine when ids match, not use '%' appended. proper way complete task? select * table id @id + '%' this works me: declare @id nvarchar(20) select @id = '1' select * tab id @id + '%' sql fiddle demo

mysql - Php sort with mysql_fetch_array -

im trying sort names sql while($ddfg = mysql_fetch_array($result_skey002)) { $total = $ddfg['name2']; } sort($total); echo $total; somthing .., im work name in hebrew doesnt working: $query_skey002 = "select * s_keywords order `name2` asc"; i have no idea how work php sort function. helpers don't sort in php. database query doing that. no need sort twice. mysql can sort hebrew text if use correct charset/collation. http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html update: here working example of inserting hebrew mysql table. tested , works: mysql> create table hebrew_table (my_column varchar(128)) charset=hebrew; query ok, 0 rows affected (0.03 sec) mysql> insert hebrew_table (my_column) values ('אחד'); query ok, 1 row affected (0.00 sec) mysql> select * hebrew_table; +-----------+ | my_column | +-----------+ | אחד | +-----------+ 1 row in set (0.01 sec)

ios - UIWebView disable highlight when the user clink on a link tag a -

is possible remove gray highlight when user click on link? tried css doesn't work. found great solution makes alpha transparent -webkit-tap-highlight-color: rgba(0,0,0,0);

ef code first - One-to-many relation in ASP.NET MVC4 and CodeFirst -

i'm having problems relationship on asp.net mvc4 , codefirst, returning values these tables related foreign key. first of all, let's see if i'm doing correctly. here's example of code: person class public class person { public int id { get; set; } public string name { get; set; } public string surname { get; set; } public city city { get; set; } } city class public class city { public int id { get; set; } public string name { get; set; } } so, this, database created nice looking relationship, , seens work well. have after code, tables this: person --id (pk) --name --surname --city_id (fk) city --id (pk) --name i've populated seed, here's example: context.person.addorupdate(p => p.name, new person { name = "me", city = new city { name = "ludlow" } } ); and when need retrieve information view, this... mydatabase.cs public class leilaodb : dbcontext { public dbset<perso...

javascript - Running script with onclick event when only inside a particular div element -

i'm looking @ running script: $(document).ready(function() { $('a').click(function(e) { var urlyep=(this) e.preventdefault(); $("#content").load($(urlyep).attr('href')); }); }); this loads content local html file via menu hyperlink #content div. works great want make more specific works when click made in #menubar div. err… mean $('#menubar a').click(…) ?

php - if condition at cycling number -

while having loop 0 1 2 3 4 5 0 1 2 3 ... there 2 directions instance number 4 forwarding 4 5 0 1 2 3 ... , backward 4 3 2 1 0 5 ... . how if algorithm detecting of forwarding or backward if values actual 2 next 3, or actual 5 next 0. i'm looking simple if check if (actual > next && ?jump last/first?) { forwarding } else { backward } any ideas how detect forward or backward? here's 1 way it: $forward = ($actual < $next); if (abs($actual-$next) != 1) $forward = !$forward; start off assuming forward if actual less next . check difference between actual , next - if it's not one, you're on boundary, result opposite of expect.

php - Undefined index: sUS_UserID -

this question has answer here: reference - error mean in php? 29 answers i need php. error: notice: undefined index: sus_userid in c:\xampp\htdocs\fazebook\inc\class.user.php on line 21 my "error" code: $userloginq = $db->query("select * `users` `userid` = '{$_cookie["sus_userid"]}'"); // line 21 if (intval($db->num($userloginq)) > 0) { $userlogina = $db->arr($userloginq); if ($_cookie["sus_userid"] == $userlogina["userid"]) { if ($_cookie["sus_security"] == md5($userlogina["lastip"])) { if ($_cookie["sus_password"] == md5($userlogina["password"])) { $this->id = (int) $userlogina["userid"]; $this->name = $userlogina["username"]; $this->...