Posts

Showing posts from February, 2010

php - jQuery currency spinner - "normalization" -

i want use jquery spinner currency value (i.e. money), value of might in dollars, euros, or supported spinner. the data should saved mysql database, in 1 col save currency, in value. the problem not sure on how this. better save data in format provided spinner (therefore saving varchar), or should take step of normalizing values in , reconverting according currency when out db? note perform calculations (simple algebra) on data, values of same currency. if want calculations inserted data, it's better store without , . / $ . , wherever want show data, change currency format.

c# - Dotless fails silently when parsing Bootstrap 2.3.1 to CSS -

here's lesstransform class use parse .less files .css files: public class lesstransform : ibundletransform { public void process(bundlecontext context, bundleresponse response) { response.content = dotless.core.less.parse(response.content); response.contenttype = "text/css"; } } i'm trying parse downloaded bootstrap.css file using lesstransform class. when method running, response.content has contents of bootstrap. after call dotless.core.less.parse() , response.content blank. parser failing silently. why? your less parsing doesn't have error handling, errors being silently ignored. if handling errors, you'd see following: expected '}' on line 577 in file '../bootstrap/mixins.less': [576]: [577]: .spanx (@index) when (@index > 0) { --------------------^ [578]: .span@{index} { .span(@index); } it looks bootstrap uses less syntax dotless not yet support. try older boo

javascript - .addClass to only the bullet being clicked on in unordered list -

i have short unordered list 2 bullets. i added javascript, when bullet clicked on, adds class it. the problem is, adds class existing li's, not 1 clicked on. here jsfiddle: http://jsfiddle.net/4sa8t/ javascript: $("#items li a").click(function(){ $("#items li").addclass("newclass"); }); html: <div id="content"> <ul id="items"> <li><a href="#">hello</a></li> <li><a href="#">bye</a></li> </ul> </div> $("#items li a").click(function(){ $("#items li").addclass("newclass"); }); should be $("#items li a").click(function(){ $(this).parent().addclass("newclass"); }); $(this).parent() refer specific li element, , $('#items li') refers all li s under #items

java - How to implement database search in JTable if I'm using VOs and DAOs? -

everyone. decided contribute topic after racking brains exhaustively. most part of filtering code got from: search jtable repeatedly using jtextfield text http://swingdepot.blogspot.com.br/2010/08/text-search-in-jtable.html software used: mysql 14.14 jdk 7 netbeans 7.1.2 suppose have following example table called " table ": +-----------+-------------+------+-----+---------+----------------+ | field | type | null | key | default | | +-----------+-------------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | | name | varchar(50) | yes | | null | | | phone | varchar(20) | yes | | null | | | birthdate | datetime | yes | | null | | | status | int(1) | yes | | null | | +-----------+-------------+------+-----+---------+----------------+ creating view called " vtab

php - Outputting data from flat file in XML String -

i have sms api script i'm modifying in order import flat files containing list of phone nos, arranged line line. have problem trying declare data in array such each phone no on separate line tags enclosed between them. this code below works outputting data (numbers.txt) flat file. $lines = file("path/to/file/numbers.txt"); foreach($lines $line) { echo "<gsm>".$line."</gsm> \n" ; } however when tried embed array output in xml code below using $xmlstring function, doesn't work. wrong , i'm stuck. $xmlstring=' <sms> <authentication> <username>'.$user.'</username> <password>'.$pass.'</password> </authentication> <message> <sender>'.$sender.'</sender> <text>'.$message.'</text>

Write a program that uses the FOR loop to sum all even integers less than N (MATLAB) -

what did n = input ('n='); x = 1:n x= (1:n) if mod(x,2) == 0 t = x; b = sum(t) end end is correct? why keep giving me error message? "??? index exceeds matrix dimensions. error in ==> exampractise1 @ 7 b = sum(t)" n = input ('n='); b=0; x= (1:n-1) if (mod(x,2) == 0) b=b+x; end end disp(b); a few points: clear b @ start of program or else previous calculation effect current matlab vector system, when did 1:n made vector such [1 2 3 4] , when made for loop 1:(1:n) confusing @ best. should 1:n . not sure why need variable called t sum should replaced standard + operation. don't forget x go last number specific, , hence should avoid adding n

spring and DWR mapping problems -

i have problem spring mvc mapping when integrated dwr. problem that, can't them worked together. want use dwr service in jsp, when dwr mapping works spring doesn't , opposite. web.xml <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>spring mvc application</display-name> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>

internet explorer - Firefox/IE play streamed MP3 (Served with PHP) -

i'm having trouble playing locally created mp3 through firefox , ie, although work fine in chrome. the file this: header('content-type: application/octet-stream'); header('x-pad: avoid browser bug'); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); header('content-type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3'); header('content-disposition: inline; filename="'.$file_name.'.mp3"'); header('content-length: ' . filesize('files/'.$file_name.'.mp3')); ob_clean(); flush(); readfile('files/'.$file_name.'.mp3'); exit(); i don't type of error in ie, in firefox i'm met with: http "content-type" of "audio/mpeg3" not supported. load of media resource [url here] i tried audio/mpeg content-type had same pr

java - How to search a node in outline view in swing -

i have implemented outline view in application consist of 200 node. how can search specific node , expand ? i have looked breadthfirstenumeration() , depthfirstenumeration() method of defaultmutabletreenode not find equivalent method in outline. the approach depends on treemodel used construct outlinemodel . in filetreemodel cited, getroot() returns arbitrary file representing root of subtree in hierarchical file system. subtree can searched recursively shown here . instead of printing results, accumulate file instances representing path array. array used construct treepath . given such treepath , can reveal corresponding node in manner analogous shown here . outline.expandpath(treepath); outline.scrollrecttovisible(getpathbounds(treepath));

mocking - is it better to name the subclass's mocked class same with subclass but in different .h in c++? -

i have parent class: baseclass; and it's sub class subclass , when need 1 mocked subclass subclass, how name it? i check someone's code sample, subclass's mock class , use same name, in different .h file, 1 subclass.h.the other's mocksubclass.h, so in case, there need name mock subclass use 1 different name such : mocksubclass ? thanks. depends on needs. approach mention reasonable, i.e. cmyclass->cmockmyclass. have mock class per subclass, , there times when need mock base class well. using 'interface' classes can when creating mock classes, per so mocking framework using? true mocks or stubs?

compare - look up for master data in R -

i have a problem following topic. after using excel, workload of doing high. want r in automatic way. i have different models of washing machines: for every model, have data.frame required components. 1 model example component = c("a","b","c","d","e","f","g","h","i","j") number = c(1,1,1,2,4,1,1,1,2,3) model.a= data.frame(component,quantity) as second information, have data.frame components, used models , in addition actual stock of these components. component = c("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z") stock = c(100,102,103,105,1800,500,600,400,50,80,7

jquery - Javascript Best Practice for finding all differing Nested Array Elements -

with 2 large, potentially large nested javascript arrays. 1 current , other previous iteration of array. function need find differing elements , act upon changed. i know how make function this, wondering best practices doing such thing. advice appreciated. looking @ using either native javascript jquery handling responses differing elements. this question deals several things. what most efficient way compare objects . in javascript checking, via if, if object equals or not equal object, not, if equal. objects need broken down , compared. what best way return results? make array of differences? while going though first array clear out objects same in first, or make entirely new array return? function comparearrays(arr1, arr2){ for(var key in arr1){ if( arr1[key] !== arr2[key]){ // traverse nested array if(typeof(arr1[key]) == 'object' || typeof(arr2[key]) == 'object'){

c# - Convert string into MongoDB BsonDocument -

i have long string in json format, , want convert bsondocument insertion mongodb database. how do conversion? i'm using official c# driver. the answer is: string json = "{ 'foo' : 'bar' }"; mongodb.bson.bsondocument document = mongodb.bson.serialization.bsonserializer.deserialize<bsondocument>(json);

razor - ASP.NET MVC ViewModel is null on Post Back - sometimes -

depending on input in html form (6 or 6.5 - or in general, integer vs float) or don't following exception (it works int , doesn't work float): the model item passed dictionary null, dictionary requires non-null model item of type 'system.boolean'. the viewmodel of view null , problem gets visible in custom template expects bool value, gets null instead. use asp.net mvc 4 .net 4.0, c# , razor templates. after several hours debugging came following conclusion(s): post form-data identical (except 1 property different, still correct) the execution order somehow weirdly different: for int application_beginrequest->filter runs through attributes->action->view rendering or redirect (everything normal) for float application_beginrequest->filter runs through attributes->view rendering-> end exception , empty viewmodel i have checked dozen times -> if pass float view somehow gets rendered without action (which have seen) executed (

c++ - Why should operator< be defined as non-member? -

i test on hash_map, using struct key. define struct: struct st { bool operator<(const st &rfs) { return this->sk < rfs.sk; } int sk; }; and: size_t hash_value(const st& _keyval) { // hash _keyval size_t value one-to-one return ((size_t)_keyval.sk ^ _hash_seed); } then: stdext::hash_map<st, int> map; st st; map.insert(std::make_pair<st, int>(st, 3)); it gives me compiler error:binary '<' : no operator found takes left-hand operand of type 'const st' (or there no acceptable conversion) so change operator non-member: bool operator<(const st& lfs, const st& rfs) { return lfs.sk < rfs.sk; } it's ok.so want know why? you missing const : bool operator<(const st &rfs) const { return this->sk < rfs.sk; }

mysql - Selecting every row in a table without using limit? -

i'm using jdbc mysql. need iterate on every row in table (60,000 rows, table = innodb), , perform processing on each. will mysql accept query without limit that? in simplest implementation, select entire table, , keep iterating results while cursor gives me more results: preparedstatement stmt = conn.preparestatement("select * foo"); resultset rs = stmt.getresultset(); while (rs.next()) { .. stuff on each row .. } i can implement paging query of course in batches, it'd simpler stated in first approach. wonder if mysql internally, or tries load entire query result set memory first? thanks mysql gonna run , try best sure, or @ least try use our memory until runs out. it's interesting highlight in few other points: even using limit, mysql parser still gonna fullscan in table. limit runs in 1 level after process; mysql gonna try use memory , if not enough, parser swaps filesystem, more slower , expensive in terms of performance; try use i

a singly linked list, output includes spaces - Java -

so, console, input this. (the app class working fine, that's not issue) j [[1, 2, 3] [4, 5] [6, 7]] and output this: [1, 2, 3, , 4, 5, , 6, 7] essentially, it's picking whitespaces or something. here's code: public static <e> sllist<e> joinallcopy(list<sllist<e>> lists) { sllist<e> result = new sllist<e>(); for(int = 1; < lists.size(); i++){ sllist <e> temp = lists.get(i); result = lists.get(0); node<e> curr = temp.first; while(curr != null){ result.addlast(curr.item); curr = curr.next; } } return result; } what doing, taking in arraylist of singlylinked lists, , iterating through them each element, , adding them result. anyway can including whitespaces without altering given tostring method? all work needs done inside method, nothing outside of needs altered. have been killing myself on 24 hours now, can't seem find way. d: edit: think it's because curr.ne

jquery - how can I have hover style by default? -

i have list , each has css hover state. default every item black , hovering turns blue. my problem: want first item blue before hovering loading page. once user hovers other item first 1 not blue anymore , other normal items turns blue hovering. here jsfiddle . html: <ul> <li>one</li> <li>two</li> <li>three</li> </ul> css: ul li:hover { color:blue; } <ul> <li class="active">one</li> <li>two</li> <li>three</li> </ul> <style> ul li:hover, ui li.active { color:blue; } </style> <script> $('ul').hover(function(){ $('ul li').removeclass('active'); } , function(){}); </script>

objective c - Xcode Preprocessed File Troubleshooting Circular Import Loop -

Image
i using xcode 4.6.2 , believe facing circular import issue in project unable troubleshoot. due not able access few methods class using class method. see earlier question here . although using @class instead of #import in header files, still unable fine problem is. members of stackoverflow have suggested me use xcode's built in functionality found under product > generate output > preprocessed file. i have used functionality , generated file long follow , don't know it. i have tried searching how use troubleshoot issue couldn't find help. can me point out how use "preprocessed file" troubleshoot issue. thanks! i went through earlier question have mentioned inside question. have said using @class instead of #import in header files, methods trying access declared in header files , there no typos of kind. in such cases, no body points issue going anyway because have faced such issues many times. have created many copies of project work on ea

Robust Download Function in PHP? -

i'm trying download image file programatically within php , treat locally. edited: previous function replace 1 suggested below. i have function: function downloadfile ($url, $path) { $result = false; $useragent = 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; .net clr 1.1.4322)'; $ch = curl_init($url); curl_setopt($ch, curlopt_useragent, $useragent); curl_setopt($ch, curlopt_connecttimeout, 60); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_nobody, true); curl_setopt($ch, curlopt_header, true); curl_exec( $ch ) ; if(!curl_errno($ch)) { $type = curl_getinfo($ch, curlinfo_content_type); if ( stripos($type, 'image') !== false ) { // image curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_nobod

javascript - How to make rectangle visible until another rectangle draw -

i'm trying draw rectangle on google map. bound values after draw rectangle successful.but rectangle not visible problem. please me visible rectangle until rectangle draw. in on 'click' event listener rectangle removing setting setmap(null), , setting bounds minimal values. should remove these lines , on 'mousemove' event check 'state' variable instead of using getmap if (state==1) { rect.setbounds(tobounds(pt1, event.latlng)); } see updated jsfiddle

Android Application Compatibility -

what should have write in manifest android application screen compatibility multiple android devices? tried compatible , support screen taking normal layout. i think looking this <supports-screens android:resizeable=["true"| "false"] android:smallscreens=["true" | "false"] android:normalscreens=["true" | "false"] android:largescreens=["true" | "false"] android:xlargescreens=["true" | "false"] android:anydensity=["true" | "false"] android:requiressmallestwidthdp="integer" android:compatiblewidthlimitdp="integer" android:largestwidthlimitdp="integer"/> but giving can not achieve looking for read this developer site also example

Out-of-box membership provider for asp.net -

is there out-of-box membership provider asp.net? or there tutorial creating one? my problem can't change asp.net membership , need change on it. is there out-of-box membership provider asp.net? yes, there's default membership provider uses sql database. if want write custom 1 inherit membershipprovider class , implement abstract methods intend use. for example: public class myprovider: membershipprovider { ... implement abstract methods here } and in web.config replace default provider own: <membership defaultprovider="myprovider"> <providers> <clear /> <add name="myprovider" type="mynamespace.myprovider, myassembly" /> </providers> </membership> here's article on msdn explains different methods of membership provider need implement , used for.

define macro in makefile for visual studio C++ build -

i have 2 exe use same .dll through explicit linking, both specific work, differentiated through macros. have created make file build dll, how define macro in makefile, can generate respective dll use. while build on windows, , using visual studio compiler, input appreciable. when run make , can set macros on command-line. these macros become read-only during make run (in other words, override assignments may attempt inside makefile). so, create make-based visualstudio project. debug configuration ensure runs make target=debug and release configuration make target=release

php - URL Rewriting not working on Zend Server Community Edition 5.3.9 -

to @all, nobody here answer question? i have tried below problem following question zend server community edition .htaccess issue not success. that's why posting details question here follows: i having serious issue zend community server edition (zendserver-ce-php-5.3.9-5.6.0-sp1-windows_x86) . everything working fine not url rewrtiting . i have following things set in httpd.conf file of apache folder on windows 7 i have enabled mod_rewrite module in httpd.conf file like loadmodule rewrite_module modules/mod_rewrite.so below document root projects documentroot "d:/projects/" and related <directory> settings like <directory /> options followsymlinks allowoverride order allow,deny allow #order deny,allow #deny </directory> <directory d:/projects> options indexes +followsymlinks allowoverride #order deny,allow #deny order allow,deny allow </directory> i have

Relation in Py2neo with Neo4j -

how can end node of relation. example: rels = graph_db.match(start_node=user, rel_type="is_post_owner") so how can end nodes of start node user. regards, samuel like this: rels = graph_db.match(start_node=user, rel_type="is_post_owner") end_nodes = [rel.end_node rel in rels] each relationship returned match method standard relationship object , can used such.

Android Theme Background applies also to title bar -

i designing andriod theme in want change background of activities. using following code: <style name="mycustomtheme" parent="android:theme.holo"> <item name="android:windowbackground">@drawable/background_gradient</item> </style> the problem background applies title bar. how can apply background content please? i think can create base activity set background in activity, activities can inherit base activity. all can override titlebarbackground in theme: <item name="android:windowtitlebackgroundstyle">@color/yourtitlebarcolor</item>

OpenERP Home Action & Menu Action -

i'm trying customize users home page without success far. i have tried few values in both "home action" , "menu action" fields messaging feed on startup. how can customize ??? thanks in advance the home action , menu action functionalities doesn't work web client. can see why here . can change sequence number in menu item. smallest sequence number calling first.

c# - Select multiple elements with Linq to XML -

i have c# application , need extract multiple elements linq xml collection. i have following extract xml file <sns> <uniquesystem><system>49</system><label>engines</label> <uniquesubsystem><subsystem>30</subsystem><label>apu</label> <uniqueunit><unit>00</unit><label>starter</label> </uniqueunit> </uniquesubsystem> </uniquesystem> <uniquesystem><system>50</system><label>hydraulics</label> <uniquesubsystem><subsystem>30</subsystem><label>reservoir</label> <uniqueunit><unit>00</unit><label>pump</label> </uniqueunit> </uniquesubsystem> </uniquesystem></sns> i need extract values within each 'uniquesystem' element. in example above, under 'sns' element there 2 'uniqu

wcf - Why do I need MEX? -

i understand metadata exchange endpoint helps client interact server properly. don't understand difference between using , not using client wise. mean, possible establish client-server connection without mex what's difference if decide not use it? the metadata exchange endpoint (mex) endpoint in wcf exposes metadata used describe service. without it, not able automatically generate proxy class (using svcutil). in many cases can disabled on production environment. see msdn comprehensive explanation.

sql - Query timeout expired - ASP Classic (VB). Timeout happens in client browser, not on server -

i'm having troubles timeouts on website. has rather large newsletter receiverlist (approx. 100k recievers). deliver tool sending out newsletters, , based on query newsletter (segmentation fx), make show total number recievers of newsletter. if run query through sql server management studio result in 2 seconds. if querye run through client browser same timeout evert time: " [microsoft][odbc sql server driver]query timeout expired ". i have tried adjusting server.scripttimeout parameter no luck. seems there's problem data connection, that's stuck. i'm hoping of brilliant people know answer 1 :-) thanks! have tried setting connection timeout property of connection string? -- edit -- ps: know i've given vb.net page, connection strings pretty similar.

python - Twython - How to update status with media url -

in app, let users post twitter. let them update status media. in twython.py see method update_status_with_media reads image filesystem , uploads twitter. images not in filesystem on s3 bucket. how make work s3 bucket urls? passing url in file_ variable, fails on io error, no such file or directory. passing stringio fails on unicodedecode error. passing urllib.urlopen(url).read() gives file() argument 1 must encoded string without null bytes, not str . i tried using post method , got 403 forbidden twitter api, error creating status. just solved it bah, got work, finally! maybe else save few hours cost me. twitter = twython( app_key=settings.twitter_consumer_key, app_secret=settings.twitter_consumer_secret, oauth_token=token.token, oauth_token_secret=token.secret ) img = requests.get(url=image_obj.url).content tweet = twitter.post('statuses/update_with_media', params={'status': msg},

android - AsyncTask textview redrawing -

i little bit beginner android, , cannot explain 1 things code. i have textview , button on activity. on button click start asynctask child class giving activity instance constructor. long running asynctask updates textview in progress update, during textview not cleared , redrawn, instead numbers written on top of each other. it not important why solved async now, part of test, interesting question me right why happens this. have forget important property setting textview or what? <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="60dip" android:layout_marginbottom="20dip" android:text="large text" android:gravity="center_horizontal" android:textsize="50sp"/> and code: public class asynctask1 extends activit

node.js - How to configure timeout for nodejs on Heroku -

how configure timeout nodejs on heroku. heroku timesout @ 30seconds. timeout @ 25th second. how configure ? at moment there method directly on request object: request.settimeout(timeout, [callback]); this shortcut method binds socket event , creates timeout. reference: node.js timers manual & documentation

mysql decimal(10,2) extract java -

i have database decimal(10,2) value. i need extract database , add quantity java, don't it. from database query, value 5.50 system.out.println(rsmax.getlong(1)); long cost = rsmax.getlong(1) + 2; this prints 5 , cost = 7, should print 5.50 , cost = 7.50 how should it? long integer. need bigdecimal type.

python - Non-flicker interactive Image sequence display with wxpython -

i've created interactive image sequence viewer. viewer work if there no flickering. read bit double buffering , find bit confusing. need straight on explanation/code should remove flickering in program. in of examples there explanation resizing. in other hand not need that, window size-fixed. approach should take fix flickering? code: import wx class main_frame(wx.frame): def __init__(self): wx.frame.__init__(self, none, wx.id_any, 'main window', size=(1300, 750)) self.panel = wx.panel(self, -1) self.centre() #------------------------------------------------------------------------------ self.frames = [] l=1 while l < 365: self.frames.append(wx.image('images/{0}.png'.format(l), wx.bitmap_type_any)) print l l+=1 self.slider = wx.slider(self.panel, wx.id_any, size = (500,-1)) self.slider.setmax(356) l = self.slider.getvalue() self.image

php - Form made in Yii returns error, Property is not defined -

i have controller ecommercecontroller.php , looks this: public function actionlegalisation() { $model = new product(); $this->render('legalisation', array('model'=>$model, 'documents'=>$documents, 'countriesissued'=>$countriesissued, 'countries'=>$countries, 'flag'=>$flag)); } and in legalisation view have: <?php $form=$this->beginwidget('cactiveform', array( 'id'=>'legalisationform', 'action' => $this->createurl($this->id."/".$this->action->id), 'enableajaxvalidation'=>true, 'clientoptions' => array( 'validateonsubmit'=>true, 'validateonchange'=>true, 'validateontype'=>false, ), )); ?> <table> <tr> <td> <?php echo $form->dropdownlist($model, 'countriesissued', $select = arr

ios - Manage position of a moving object -

i'm making first ios app, have problem... moving objects come top of screen bottom. goal of game kill moving objects (which have random position.y) before come out of screen. if object come out, lose 1 of 3 lives. that: if(movingobject.position.y < 0) _lives--; but when launch app, , object come out of screen, lose 3 lives... what lose maximum 1 life moving object? here code create new movingobject double curtime = cacurrentmediatime(); if (curtime > _nextmovingobjectspawn) { float randsecs = [self randomvaluebetween:3 andvalue:5]; _nextmovingobjectspawn = randsecs + curtime; float randx = [self randomvaluebetween:25 andvalue:winsize.width/2-20]; float randduration = [self randomvaluebetween:4 andvalue:6]; ccsprite *movingobject = [_movingobjects objectatindex:_nextmovingobject]; _nextmovingobject++; if (_nextmovingobject >= _movingobjects.count) _nextmovingobject = 0; [movingobject stopallactions]; movingobject.posi

ruby on rails - How to update attributes -

i have problem update attributs. try update via cron. sheduler.rb every 3.minutes runner "update_from_feed_continuously(feed_url)" end feed_entry.rb class feedentry < activerecord::base attr_accessible :guid, :name, :url, :feed_url after_create { |feed| feedentry.update_from_feed(feed.feed_url) } def self.update_from_feed(feed_url) feed = feedzirra::feed.fetch_and_parse(feed_url) add_entries(feed.entries) end def self.update_from_feed_continuously(feed_url) feed = feedzirra::feed.update(feed) add_entries(feed.new_entries) if feed.updated? end private def self.add_entries(entries) entries.each |entry| unless exists? :guid => entry.id create!( :name => entry.title, :url => entry.url, :guid => entry.id ) end end end end i use gem feedzirra , gem whenever loading development environment (rails 3.2.13) 1.9.3p392 :001 > feedentry.update_from_fe

sql - How do I match against multiple conditions on a table join? -

i have 2 tables: users attributes id|name id|name|user_id ------- --------------- 1 |foo 1 |bla | 1 2 |bar 1 |blub| 1 1 |bla | 2 how create query gives users both "bla" , "blub" attributes? in case should return user "foo". i know data not normalized. select u.*, a.id, b.id, a.name, b.name users u join attributes on a.user_id = u.user_id , a.name = 'bla' join attributes b on u.user_id = b.user_id , b.name = 'blub'

playframework - Query string lost from a submit button -

i new both web application , play framework, , problem asking might naive. however, googled around little while , couldn't find answer it, please bear me. first, platform play-2.1.1 + java 1.6 + os x 10.8.3. a short version of problem: have form of submit button action="hello?id=100". however, when click button, request being sent seems hello? rather hello?id=100 . action request expects parameter id , error hello? . here full setup. conf/routes: get / controllers.application.index() /hello controllers.application.hello(id: long) app/controllers/application.java: package controllers; import play.*; import play.mvc.*; import views.html.*; public class application extends controller { public static result index() { return ok(index.render()); } public static result hello(long id) { return ok("hello, no. " + id); } } app/views/index.scala.html this ind

qt - Detect hiDPI mode -

working qt 4.8.4 on os x -- desktop application development . need able detect, @ paint time, if on hidpi display ("retina") or not. know how achieve this? you can use qscreen in qt 5, , in qt 4 can use qsystemdisplayinfo class qt mobility. for qt 4 there qsystemdisplayinfo - http://doc.qt.digia.com/qtmobility/qsystemdisplayinfo.html the relevant methods getdpiheight , getdpiwidth . you use qdesktopwidget 's physicaldpix , physicaldpiy methods. for qt 5 use qscreen - http://qt-project.org/doc/qt-5.0/qtgui/qscreen.html#physicaldotsperinch-prop ((qguiapplication*)qcoreapplication::instance()) ->primaryscreen()->physicaldotsperinch() there physicaldotsperinchx , physicaldotsperinchy .

drawing - Windows Phone - Serialize/Save InkPresenter control -

i have inkpresenter , add strokes onto using inkpresenter.strokes.add(stroke) . after that, want serialize/save inkpresenter file system or database. ink.strokes type of strokecollection , msdn says there save(stream) method issue. on windows phone, there seems lack of functionality. maybe, there's way serialize , deserialize inkpresenter control. as in jeff's post, on windows phone way have own type stores strokes , can save isolated storage can load , "replay" strokes. or can save strokecollection formatted string. basically, each stroke consists of color , bunch of points. way can example store strokecollection collection of strings in simple format this: color|x1,y1$x2,y2$x3,y3 -- represents single stroke with can write function accepts stroke collection , file name , can save strokecollection public void savestrokes(string filename, strokecollection strokecollection) { var isf = isolatedstoragefile.getuserstoreforapplication(); var

uitableview - IOS Custom Table Cell does not Automatically Resize Width for Orientation Change -

have custom table cell it's own .xib , .h , .m. nothing fancy. when device rotates, cell width not change. tables cell index path called, width not changes (say portrait landscape). preventing this? don't want hand set frame size. will post code if need to, maybe can answer out code on one. even if starting app in landscape not set larger width cell. [addition] also not work non-custom cells. self.tableviewselection.autoresizessubviews = true; self.tableviewselection.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; self.view.autoresizessubviews = true; xib table has resizing seemed setup correctly (non-ios6 support). if overriding layoutsubviews or method, don't forget call it's super: override func layoutsubviews() { //... super.layoutsubviews() } not doing result in problem facing.

Coldfusion 8: identify repeating values in a column and counting number of times it appears -

i need query table in sql db using cf 8, @ specific column repeating values, , count how many times occurs. i new cf , life of me can't figure out how this. can query db , specify results referenced column, rest frustrating! so, if had following results query specific column: apple apple grape pear apple pear apple i know query of query, have know values (fruits in case) before hand. or believe. basically, need able run cfm , have spit out: apple: 4 pear: 2 grape: 1 not knowing values might beforehand. can please help? <cfquery name="qmyfruits"> select fruitname, count(fruitname) instances fruits group fruitname </cfquery> <cfoutput query="qmyfruits"> <p>#qmyfruits.fruitname# : #qmyfruits.instances#</p> </cfoutput>

c++ - exchange data with socket.io server from embedded system websockets cpp client -

i'm unable exchange data socket.io server native c++ websocket (www.websocket.org) client. note not want solution based on boost i'm running websocket client embedded system (it has light-weight). i've tried both lws_write_text , lws_write_http (no padding) modes. i'm not using secure sockets (i.e., not using wss or ssl certs). myserver.js: var io = require('socket.io').listen(80); io.configure('production', function(){ io.enable('browser client etag'); io.set('log level', 3); io.set('transports', ['websocket']); }); io.configure('development', function(){ io.set('log level', 3); io.set('transports', ['websocket']); }); io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); i've enhanced libwebsockets-test-echo.cpp s

Magento redirecting base url -

i have installed demo site of original site, redirecting http://demo.example.de/demo.example.de/ instant of http://demo.example.de/ can solution, thanks using phpmyadmin navigate database , find table core_config_data , see values of these 2 fields web/unsecure/base_url web/secure/base_url they should be web/unsecure/base_url http://demo.example.de/ web/secure/base_url https://demo.example.de/

c - gdb backtrace shows malloc -

i debugging process crash ,& backtrace looks kind of below. process crashing @ different points in code time backtrace comes down malloc. i tried increasing heap 128 m 256 m, didn't either. size of core dump around 164 m, & while running process uses same virt memory. can guys please point me in right direction. appreciate help. #0 #1 #2 #5 0xb7fc7966 in malloc (size=141858520) . . . #16 0x0805ef69 in main (argc=1, argv=0xbffffa64) . bt 2: 2nd backtrace got. same process crashed @ different point in code. #0 #1 #2 #5 0xb7fc7677 in realloc (p=0xe01fd8, size=139629112) . . . #18 0x0805ef69 in main (argc=1, argv=0xbffffa64) any crash inside malloc guaranteed sign of heap corruption. on linux, the tools finding such heap corruption valgrind , address sanitizer . see this page understand differences between two.

Can I grant append-only permission to a google drive file? -

i developing ios app manage data company. maintain data files in single google drive , grant full access dba, view access users, , append-only access some. different access permissions granted based on different passwords used log google drive, doesn't seem way google drives setup. creating 1 dba-level username-password google drive "owner" access files , 1 user-level username-password google drive shares "view-only" access 1 folder in dba google drive , "edit" access folder in dba google drive. however, "edit" access limited "append" only, doubt option available (yet). want non-dba users able add data not able delete data. how can make work using chrome-google-drive , ios app functionality. don't want implement server running mysql (e.g.) each company uses app. want create 1 or 2 unique google drives each company. app maintains list of company employees individual passwords can used hold access permissions, since a

Change jquery code for mobile users -

i launched new website - mollycampbelldesign.com while doesn't adapt mobile users yet, decided site , continue forward go. problem far, phone icon in top left - right can toggle phone number clicking on phone icon. did mobile users can click on phone # without making box slide out. when you're viewing on desktop, nice able click entire number box make disappear. there way make mobile users 1 set of code, , desktop users another? html code: <div class="call-button"><p>call now: <a href="tel:8013827471">801-382-7471</a></p> <img src="/wp-content/themes/boilerplate/images/phone.gif" alt="call now"/></div> js code: $(document).ready(function() { $(".call-button img").toggle( function() { $(".call-button").animate({ left: "0" }, 1000 );}, function() { $(".call-button").animate({ left: "-225px" }, 1000 ); }); });

ruby on rails 3 - Better way fo filter boolean value from model -

what's difference between these 2 methods? class model < activerecord::base def self.approved self.where("approved = 1") end def self.approved approved: true end end so..some code again 1.9.3p374 :001 > 1 == true => false 1.9.3p374 :002 > 0 == false => false 1 not true, , 0 not false. means, first used when type of approved column integer, , second - boolean

c# - Create a list of objects by grouping on multiple properties -

i have list<t> t custom object cow . right use following code split list based on color . cowgroups = x in cows group x x.color y select y.tolist().tolist(); then take cowgroups , run foreach on set of actions each cow . list comes out ienumerable<list<cow>> what i'm trying do double grouping on initial list<cow> can group base on color , size. result should still ienumerable<list<cow>> , each list<cow> made based on combined pair of color , size. a co-worker recommended tolookup approach, returns list of key/value pairs, , can't seem value part of pair. i guess i'm looking either way go straight collection of lists, or turn result of tolookup approach collection of lists. you can group class contains both attributes: group x new { x.color, x.size } y