Posts

Showing posts from September, 2010

Python - What do these two lines do? -

being new python, i'm having heck of time figuring out these 2 lines do: for in [j j in xrange(0, n) if [k k in xrange(j) if now[k] == now[j]] == []]: j in [k k in xrange(1, k + 1) if [l l in xrange(i) if now[l] == k] == []]: is there way rewrite noobs myself understand it? thanks. i'm positive code equivalent to: for in range(0, n): prefix = set(now[:i]) if now[i] in prefix: continue j in range(1, k + 1): if j in prefix: continue # or (which bit less efficient, nicely reflects idea behind code): for i, j in itertools.product(range(0, n), range(1, k + 1)): prefix = now[:i] if now[i] not in prefix , j not in prefix: # , j but it's written in convulted, inefficient way (especially [...] == [] nasty , pointless). maybe feels pretty clever using complex structures simple ones better suited.

php - Domdocument encoding -

the question domdocument encoding, when open html string contain utf-8 contents, loadhtml method , changes , when want save , variable savehtml , put database, characters changed : روش را امتحا&#1606 and can't read it. characters , suggestion prevent change ? it appears not parsing html properly. read more info http://php.net/manual/en/class.domdocument.php

postgresql - SQL query between current date and previous week -

select sge_job.j_owner "owner" ,sum(sge_job_usage.ju_cpu) "cpu total" sge_job_usage, sge_job group j_owner; here current sql query reads in cpu% , job owner i'm having trouble incorporating sum above if it's between current date 14days(2 weeks) ago. in sge_job_usage table belongs both: ju_start_time , ju_end_time anyone me towards how can check if it's between current date - 14 days before , checks end_time date see if still going then? answer outputs need below: select sge_job.j_owner "owner" ,sum(sge_job_usage.ju_cpu) "cpu total" sge_job_usage, sge_job ju_start_time between localtimestamp - interval '1 week' , localtimestamp group j_owner; adc syntax not valid postgresql. i don't understand condition want applied ju_end_date. should similar 1 on ju_start_time. select sge_job.j_owner "owner" ,sum(sge_job_usage.ju_cpu) "cpu total" sge_job_usage, sge

c# - DockPanel.Dock="Right" is not working for single control on Maximized window? -

Image
i using dockpanel.dock docking controls @ specific place(i.e left/right). problem controls not docking according dockpanel.dock position. below code single control dockpanel.dock="right" <dockpanel> <textblock text ="left1" margin ="5" dockpanel.dock ="left" style ="{staticresource textblockstyle}" /> <textblock text ="left2" margin ="5" dockpanel.dock ="left" style ="{staticresource textblockstyle}" /> <textblock text ="right1" margin ="5" dockpanel.dock ="right" style ="{staticresource textblockstyle}"

Can JQuery or JavaScript be used to manipulate XML/DOM without a browser? -

i starting study web technologies integrate content, markup, layout, styling , behaviors of stuff personal use (not web developing now) , amazed power of jquery selectors , functions. i have heard there ways use javascript "outside" browser, dom selection, manipulation, etc. wonder if jquery used way too. so, is: using programming/scripting language (i use python), access xml file , parse dom; programmatically manipulate , modify dom javascript/jquery selectors , functions; save results (possibly another) xml file. if jquery syntax, check out pyquery : from pyquery import pyquery _ = pyquery('<body><p></p></body>') _("p").text("hello").css({'color': 'red'}) print _.html() >>> <p style="color: red">hello</p>

broadcastreceiver - Using a broadcast reciever to start AlarmManager in Android? -

i writing program fires off intent start service periodically, have decided use alarmmanager, able make wanted in activity im getting error when attempting in receiver im unable figure out. alarmmanager = (alarmmanager)getsystemservice(alarm_service); tells me alarm_service can't resolved variable here complete code reciever: package com.testapp21.second.activities; import android.app.alarmmanager; import android.app.pendingintent; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.os.systemclock; public class phoneonreceiver extends broadcastreceiver { private pendingintent malarmsender; @override public void onreceive(context context, intent intent) { malarmsender = pendingintent.getservice(context, 0, new intent(context, statscheckerservice.class), 0); // want alarm go off 30 seconds now. long firsttime = systemclock.elapsedrealtime(); // schedule alarm!

SEVERE: Error starting static Resources in Tomcat server console -

long time , have deployed dwr webapp example , got net . ran issues , , deleted war file webapps , temp , localhost folders still getting these errrors under tomcat console while starting server info: initialization processed in 795 ms mar 7, 2012 5:31:25 pm org.apache.catalina.core.standardservice start info: starting service catalina mar 7, 2012 5:31:25 pm org.apache.catalina.core.standardengine start info: starting servlet engine: apache tomcat/6.0.33 mar 7, 2012 5:31:25 pm org.apache.catalina.startup.hostconfig deploydescriptor info: deploying configuration descriptor dwr.xml mar 7, 2012 5:31:25 pm org.apache.catalina.core.standardcontext resourcesstart severe: error starting static resources java.lang.illegalargumentexception: document base c:\softwares\apache-tomcat-6.0.33\webapps\dwr not exist or not readable directory @ org.apache.naming.resources.filedircontext.setdocbase(filedircontext.java:142) @ org.apache.catalina.core.standardcontext.resourcesstar

java - ClassNotFoundException for TestApp when I start hazelcast/bin/run.bat -

i started exploring hazelcast today downloaded hazelcast-2.0 site, , following screencast provided in site. went bin directory , started run.bat command prompt. i getting classnotfoundexception . can please let me know have went wrong? caused by: java.lang.classnotfoundexception: com.hazelcast.examples.testapp @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) as noted in duffymo's comment, there problem in .bat file adds following classpath ../lib/hazelcast-${project.version}.jar . just replace ${project.version} version number downloaded, or check correct jar name lib directory , should work properly.

newrelic - Heroku Console and New Relic (cedar stack) -

my team continuously getting new relic log messages on our heroku console. highly annoying , causes issues when working on longer command, , batch of new relic log messages prints out on command. anyone else have this? direction on how remedy? check log level setting in newrelic.yml config file. log level can altered same other logging (fatal, warning, debug etc)

postgresql - One-to-Many relationships in (Postgre)SQL -

i have 2 tables: posts: id | ... other stuff ... | tags ----+---------------------+-------------- 1 | ... | <foo><bar> 2 | ... | <foo><baz><blah> 3 | ... | <bar><blah><goo> and tags: tag -------------- <foo> <bar> <baz> <blah> <goo> posts.tags , tags.tag both of type text. want relation tags.tag rows in posts such querying <foo> give me rows corresponding posts 1 , 2, querying <blah> gives me 2 , 3, <bar> gives me 1 , 3, etc. i've looked @ foreign keys, i'm not sure it's want. (and honestly, i'm not sure does). can tell foreign key must equal primary key/unique column of table. want rows such posts.tags ~ '.*<foo>.*' , etc. want able to, say, tags start b, eg: create view startswithb select tag tags tag ~ '<b.*>'; select dist

PHP HTML5 to PDF converter needed -

i know isn't question treads new ground, after few days of searching around , not being able find satisfies needs i've decided ask community @ large advice. i running php5 on apache2.2 server. have able have satisfactory results on both linux , windows xp machine (test server linux, deployment server is, moment, windows xp). having nightmarish problems regarding getting reports company's web app print uniformly across machines , have decided best generate pdf files instead. i've looked around decent converter , promising looking html2pdf, can't seem function (it spits out massive number of depreciation warnings , terminates undefined functions regardless of library try use) don't think it's viable situation. to clarify, want user click on link (or button) on site , have generate pdf download , instant viewing. furthermore, want use current html5 reports , convert them, rather being forced recreate them using native pdf libraries. so, experts,

Heroku SSL on subdomain for staging server -

i have production instance on heroku users go https://secure.myapp.com checkout. used hostname-based ssl because $100 / month isn't feasible client. now, i'm in situation need staging environment ( http://myapp-staging.herokuapp.com ) , ssl / subdomain stuff doesn't work (" secure " replaces " myapp-staging ") when going checkout, , ssl cert purchased won't work since it's keyed myapp.com . can please advise on affordable setup given situation? thank you! if need replicate production environment closely option setup , pay same ssl have in production. an alternative might configure application it's not reliant on 'secure.' , use piggyback ssl addon.

html - Wordpress CSS not displaying navigation correctly -

i created website on wordpress , second tier menus (display if click 'clothing' or 'bags') starts underneath parent page i in line first level menu regardless on whether click 'clothing' or 'bags' http://www.dawaf.co.uk/showroom/bags /*main navigation ------------------------------------------------------------ */ #access { background: none; -webkit-box-shadow: none; text-align:center; box-shadow: none; margin: -10px auto 6px; text-transform: uppercase; font-weight: bold; } #access div { margin: 0 0.5%; } #access { color: #eeeeee; line-height: 2.2; padding: 0 8px; font-size: 12px; } #access ul ul { width: 800px; } #access ul ul { width: auto; background: transparent !important; font-weight: bold; font-size: 12px; } #access ul ul li:hover { color: #666666; } #access li.current_page_item ul { display: block; } #access li:hover > { background: transparent

Trying to set up sublime text 2 to open files in unix terminal but getting an error -

i'm trying set sublime text 2 open file in cygwin terminal using command 'subl [file]'. run below command in terminal instructed in number of sites ln -s "/applications/sublime text 2.app/contents/sharedsupport/bin/subl" /bin/subl however, error: ln: failed create symbolic link `/bin/subl': file exists how work around that? perhaps try using 'alias', instead? add line .bashrc file similar to: alias subl='/cygdrive/c/applications/sublime\ text\ 2.app/contents/sharedsupport/bin/subl' then 'source .bashrc' command load new alias.

facebook graph api - lack of Secure Tab URL error -

i keep getting error below though have secure tab url, , updated in page settings.. (i have installed ssl today, , when try entering website via https works) please update secure tab url make sure users can view app on secure browser connection (https), please visit developer console update secure tab url. you need use real ssl cert (costs money) rather self-signed cert (free) in compliance.

jquery - Sliding doesn't flow with floated elements -

i'm having issue toggle function combined slide effect. trying slide out div element, floated, , have neighboring div element (also floated left) slide take it's place. when use jquery ui in example below slide animation correct (just slide left), floated element next waits until animation complete before moving. with jquery ui in example without jquery ui, neighboring element slides on other sliding out, making smooth transition. in case slide has both left , top animation not trying achieve. without jquery ui i'm trying find solution using jquery ui it's embedded in site other features. here have done similar looking for. jsfiddle demo $('#toggle').bind('click',function() { $("#wrapper").toggleclass('collapse'); if ($("#wrapper").hasclass('collapse')) { $('.collapse').animate({'margin-left':'-50px'}); } if (!$("#wrapper").hasclass('

fonts - How to get the height of the emacs mode line? -

actually, want generate xpm-format image , draw on mode line using display attribute of text string. however, height of mode line turns different result of different fontset. that means need know height of emacs mode line , use generate corresponding size of xpm-format image, generated image can fill mode line totally. my question showing title, how can know (finally rendered) height of mode line after applying specific fontset? i have searched emacs documentation via apropos , found is: can use font-info function font height in current frame. guess maybe can want based on this, although unlucky until now. and, cannot find function related mode line height. try (- (elt (window-pixel-edges) 3) (elt (window-inside-pixel-edges) 3))

javascript - Field.length not working on a single checkbox -

i have form contains list of data, added checkbox in of each, when click on uppermost checkbox selects all. if have 1 row of data , click on upper checkboxes dont work. here script below. ////checking checkbox on page function checkall(field) { // alert(field.length); (i = 0; < field.length; i++){ field[i].checked = true ; } } ////unchecking checkbox on page function uncheckall(field) { (i = 0; < field.length; i++){ field[i].checked = false; } } function selectchk(e){ if(e.checked==true){ //alert("yeah"); checkall(document.paginate_list.list); }else{ uncheckall(document.paginate_list.list); } } function applytoselected(){ var selectedval=""; var withselected=document.getelementbyid("withselected"); // if(withselected.value==1){ //if(document.getelementbyid("list")){ // selectedval=document

multithreading - Python thread holds up the rest of the script -

running python 3.2 on windows 7 pro 64 bit. ok have basic code here that's not behaving want to. #!/usr/bin/env python import time import threading def shutdown(sleeptime): time.sleep(sleeptime) print('i have executed') threading.thread(target = shutdown(5)).start() print('i go first') the idea being script runs, starts thread sleeps 5 seconds prints out 'i have executed'. in meantime script keeps going , prints out 'i go first'. what happens script starts thread, waits finish , continues. i'm not doing threading correctly i'm having trouble finding simple examples of threading python 3. your statement: threading.thread(target = shutdown(5)).start() can equivalently written as: x = shutdown(5) threading.thread(target = x).start() i.e. calling shutdown first, passing result thread constructor. you need pass function, without calling it, , argument list, thread separately: threading.thread(target = sh

Running Eclipse with m2eclipse (maven) from flash drive -

hello trying run eclipse + maven flash drive. basically, able load eclipse , jdk flash drive. eclipse using m2eclipse plugin (embedded versions 3.0.2) eclipse , java projects works fine except maven, have set repository path relative eclipse path i.e: ./m2repo and pointed settings.xml relative location ./settings.xml: window -> preferences -> maven -> installations i have working maven projects opened in "portable" eclipse executed flash drive, did errors: execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3 what reason why i'm getting error? it works me use absolute path

Upload Images to Facebook without using the Facebook android-sdk -

i developing app in want share image on facebook. have searched lot , results find using facebook android-sdk. not using facebook android-sdk, can please me post request use along parameters graph api uploading photo on feed?? image not have link, uploading through mobile. in this documentation in publishing section, not able understand method /album_id/photos , arguments. please help. -thanks in advance the url have provided graph api. and if want use graph api, must have access token, , access token going use facebook-android-sdk. remember methods in graph-api needs valid access token agains app.

regex - Twitter queries using regexp? -

i have been seeing posts , questions using regexp search tweets on twitter using java twitter api. now, have been trying last 2 hours reading possible resources on no success. example: trying query twitter once, receive tweets both "guerillacafe" or "guerilla cafe" i have tried (guerillacafe|guerilla cafe), ('guerillacafe'|'guerilla cafe'), (guerillacafe or guerilla cafe), (guerilla?cafe) , many more, said , cant work. please simple regexp trick. the java twitter api not allow regexp searches. or keyword supported (your third example works me).

joomla1.5 - Joomla Datepicker - Hiding Future date -

i need disable future dates end date in joomla. <?php echo jhtml::calendar('','enddate','enddate','%y-%m-%d'); ?> any idea... "need hide future dates" it not possible using calendar field. http://docs.joomla.org/calendar_form_field_type even if possible, users manually type in date in future in field calendar pop-up fills out text field submitted rest of form. if locked people hack using firebug or similar. i think correct implementation validate selected date after entering , throw error if in future , similar in php avoid users manipulating submitted data.

Python Multiplying Integers inside "print()" -

so have code (relevant code): print("you have chosen bet on numbers") valin = input("how bet?: ") print("if lands on number, win", valin*2) what want print value of valin multiplied 2, have no idea how that! how ? convert input string integer int : valin = int(input("how bet?: ")) then proceed before.

python - SQL Alchemy no transaction begun error -

i run following code db = create_engine('sqlite:///tracking_test.db') db.echo= true metadata = metadata(db) session = create_session(bind=db) #define tables, if exist sqlalchemly find them , sycn otherwise created delivered= table('delivered', metadata, column('delivered_id',integer,primary_key=true), column('domain',string(200)), column('path',string(500)), ) class delivered(object): def __init__(self,obj): self.domain=u'%s' % obj.get("dm","") self.path=u'%s' % obj.get("pth","") report1t = table('clicked', metadata, column('clicked_id',integer,primary_key=true), column('domain',string(200)), column('path',string(500)), ) class report1(object): def __init__(self,obj): self.domain=u'%s' % obj.get("dm","") self.path=u'%s' % obj.get("pth

opa - Scaling with the built in database -

if use built in database comes opa , create single executable how possible scale multiple instances? example, compile app , myapp.exe, understand exe contains database. if want run multiple instances of myapp.exe how synchronize multiple instances of database contained in each exe? to run several instances of myapp.exe , start opa-db-server (installed opa package) --db-local dbname option. run instances of myapp.exe --db-remote:dbname host connect it. if need more in term of scalability, can use mongodb backend. for further information, read http://doc.opalang.org/#!/manual/the-database

php - Make one value a link of another -

i passing holidays.xml table in logged_in.php . holidays.xml <?xml version="1.0" encoding="iso-8859-1" ?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <item> <title>luxurious jamaican holidays | 40% discount on accommodation - book now!</title> <link>http://www.numyspace.co.uk/~cgel1/holidays/jamaica.html</link> <description>7 nights @ golden palm, montego bay travelling newcastle fly jamaica</description> <pubdate>sun, 13 feb 2011 11:58:17 gmt</pubdate> <guid>http://www.numyspace.co.uk/~cgel1/holidays/jamaica.html</guid> </item> </channel> </rss> logged_in.php <?php // load xml file simplexml instance variable $holiday = simplexml_load_file('holidays.xml'); // draw table , column headers echo "<table border=\"0\">"; /*

list - JQuery Minus Plugin -

i´m searching jquery plugin shows me values in list , lets me delete list again. already searched lot in google, haven´t found anything. any ideas? append list: $('#yourselectlist').append('<option value="55">a title</option>'); delete value: $('#yourselectlist option[value="55"]').remove(); or did else?

facebook - Invite friends to use app by list of ids, with PHP -

i wish manage friends invitations use facebook app, in php. i saw documentation js and saw request form doc i've saw lot of questions in stackoverflow. but can't find answer, because don't wish display facebook dialog box ! first : possible in php, without displaying facebook dialog box ? i friends list following (user connected/allowed app) include("../config/fb_config.php"); $facebook = new facebook(array( 'appid' => $fbconfig['appid'], 'secret' => $fbconfig['secret'], 'cookie' => true, )); $friends = $facebook->api('me/friends'); foreach($friends['data'] $users) { echo "<input type=\"checkbox\" name=\"".$users['id']."\"/> ".$users['name']."<br/>"; } is there facebook url/method send invite requests, checked ids , message ? or "publish message on user wall&quo

asp.net - How do i Remove mobile jQuery styling from RadioButtonlist Control? -

i need disable styling asp.net radio button list control when page load start. have tried data-role='none' <table border="0" onclick="ischecked();" data-role="none" class="" id="rbtruetype"> <tbody><tr> <td><div class="ui-radio"><input type="radio" value="217,1" name="rbtruetype" id="rbtruetype_0"><label for="rbtruetype_0" data-corners="true" data-shadow="false" data-iconshadow="true" data-inline="false" data-wrapperels="span" data-icon="radio-off" class="ui-btn ui-btn-up-c ui-btn-icon-left ui-btn-corner-all ui-radio-off ui-btn-up-undefined"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">true</span><span class="ui-icon ui-icon-shadow ui-icon-radio-off"></spa

python 3.x - After so many chars in a string, find the nearest space and put it on a new line -

i'm trying make tidy in file i'm having problem. asking details , if more 27 bytes long need find nearest previous space , put on new line. (using python 3.2) i starting this: details = input ("details: ") delen = len(details) if delen >27: #code here else: pass is possible? if give me hand please? cheers str.rfind friend. details = input ("details: ") if len(details) > 27: nearest_space = details.rfind(' ', 0, 27) first, second = details[:nearest_space], details[nearest_space:] else: first, second = details, none note rfind raise exception if no space found in details .

java - Spring MVC custom Class property editor -

what's wrong in code? i have bound class "fornitore fornitore" property way: @initbinder protected void initbinder(webdatabinder binder) { binder.registercustomeditor(fornitore.class, new propertyeditorsupport() { @override public void setastext(string fornitoreid) throws illegalargumentexception { logger.info("fornitore:: setvalue"); setvalue((fornitore) fornitoreservice.getfornitore(fornitoreid)); } @override public string getastext() { logger.info("fornitore:: getvalue"); if (getvalue() == null) { return ""; } else { return ((fornitore) getvalue()).getragionesociale(); } } }); } ends with: caused by: org.hibernate.lazyinitializationexception: not initializ

Something weird with Stock chart in excel -

i have vba code in excel automatically creates agraph , format , paste in chart excel sheet. code seems work fine graphs except stock graph. whenever run macro, can see chart creation when comes formatting , specially pasting, graph becomes invisibel. in other words, cant see graph when code finishes running. i dont know going on stock graph? can explain , tell me solution fix it? lot. here code: sub creategraph() dim myrng range dim lastcell long lastcell = worksheets(1).range("e3").end(xldown).row set myrng = worksheets(1).range("b3:e" & lastcell) activesheet.shapes.addchart.select activechart.setsourcedata source:=myrng activechart.charttype = xlstockhlc activechart.location where:=xllocationasobject, name:="chart1" end sub sub formatchart() let title = sheets("sheet1").cells(2, 1) activesheet.chartobjects("chart 1").activate activechart.seriescollection(1).select activesheet.chartobjects(&q

Encoding that minimizes misreading / mistyping / misspeaking? -

let's have system in long key value can accurately communicated user on-screen, via email or via paper; user needs able communicate key accurately reading on phone, or reading , typing other interface. what "good" way encode key make reading / hearing / typing easy & accurate? this invoice number, document id, transaction id or other abstract value. let's sake of discussion underlying key value big number, 40 digits in base 10. some thoughts: shorter keys better a 40-digit base 10 value may not fit in space given, , easy lost in middle of the same value represented in base 16 in 33-34 digits the same value represented in base 36 in 26 digits the same value represented in base 64 in 22-23 digits characters can't visually confused each other better e.g. encoding includes both o (oh) , 0 (zero), or s (ess) , 5 (five), bad this issue depends on font / face used display key, may able control in cases (like printing on paper) can't cont

Webdriver vs. browser -

on server side, there way distinguish request coming automated script selenium webdriver vs. request made physical user? you have webdriver set specific cookie during request, way know when you're dealing webdriver request.

qt - Prevent Subwindow Resize -

:d i'm qt beginner , have problems. generally, languages , tools have gui builder have window "resizeable" property. well, need same in qt: no window resize, no resize pointer in hover window's border, maximize button (in window's title) disabled. i'm tried find unsuccessfully. if me, i'll grateful. hug. sorry english. i'm brazilian. :) use void qwidget::setwindowflags ( qt::windowflags type ) . see enum qt::windowtype list of flags can play with. for instance, setting qt::dialog | qt::framelesswindowhint should produce windows without resize frame , no max/min button.

fadein - how to fade in newly added div with jquery? -

i have item comes in dom inside div . i trying add item fading in, , took approach. doesn't seem work <div id="messages" class="comm"> <div class="message">00:50:09</div> <div class="message">00:50:04</div> <div class="message">00:49:04</div> </div>​ var out = ''; out += '<div class="curent">testingg</div>'; $('.comm').prepend(out); $('.messages').css({'opacity':'1'}); $('.curent').removeclass('messages').addclass('message');​ .messages{ opacity: 0; }​ u can see code in jsfiddle also. any ideas? thanlks how this: $('.curent').hide().fadein(); setting opacity 1 or value doesn't cause fade because changes old value new value. can use .animate() method fade between old , new opacities, jquery has .fadein() method you. .hide() element

Restriction on collection with disjunction using NHibernate QueryOver -

hi nhibernate gurus ! given these 2 classes : public class user { long id; string name; } public class project { long id; user owner; ilist<user> managers; ... } i query using queryover (not using criteria "magic string" aliases), projects having user1 owner or 1 of managers. i know how separately : get projects having user1 owner : session.queryover<>project>>().where(p=>p.owner == user1) get manager : session.queryover<>().joinalias(p=>p.managers, ()=>manager).where(()=>manager == user1) but i don't know how write disjunction . if had idea, me lot. thanks in advance, chris something like:- user manager = null; var query = session .queryover<project>() .joinalias(j => j.managers, () => manager) .where(w => manager.name == user1 || w.owner == user1) .list<project>(); edit change filter name id (as op pointed out):- .where(w=>ma

multithreading - Must initialize the COM (out-of-proc) within the object created? -

i created windows nt service, exports com interface using atl (out-of-proc com), api calls coinitializeex (0, coinit_multithreaded) in ctor(), couninitialize () in dtor() of class of object? reading fashionable app designers agree: free threading model what's hot fall , give activex-based web pages boost apartment threading model did nothing clarify. my atl project have declaration of : #define _atl_free_threaded for out-of-process atl server that's taken care of catlexemodulet constructor. call initializecom() in constructor. when you've #defined _atl_free_threaded, automatically produce call coinitializeex(null, coinit_multithreaded), you'd expect. code easy find in vc/atlmfc/include/atlbase.h interface method calls made stub rpc thread, actual thread makes call entirely unpredictable. pretty dangerous because rpc recycles threads , calls made same thread. not always, depending on how many concurrent calls being processed. burden of suppo

rust cargo init occur signature verification failed -

i try use cargo init init cargo manage system. but can't see $home/.cargo dir generate. and shell show macmatomacbook-air:rust kula$ cargo init warning: signature verification failed sources.json macmatomacbook-air:rust kula$ cargo sync error: no sources defined. may wish run "cargo init" "cargo sync". what's on cargo manage system? my os mac osx 10.7 the issue don't have gpg installed can't verify signature of cargo-central's source file, , proceeds not work @ all. this situation signature verification fails supposed non-fatal, there bug in cargo caused not complete 'init' command. i've checked in change cargo believe should allow continue when signature verification fails, fwiw cargo use love make more useful , reliable.

Check if each item in an array is identical in javascript -

i need test whether each item in array identical each other. example: var list = ["l","r","b"] should evaluate false, because each item not identical. on other hand this: var list = ["b", "b", "b"] should evaluate true because identical. efficient (in speed/resources) way of achieving this? function identical(array) { for(var = 0; < array.length - 1; i++) { if(array[i] !== array[i+1]) { return false; } } return true; }

java - Get all nodes under YAML path -

i have yaml file looks this: main: topofhouse: x: 276.4375 y: 71.0 z: -60.5 yaw: -290.7768 pitch: 35.400017 2ndfloor: x: 276.5 y: 67.0 z: -60.5 yaw: -8.626648 pitch: 16.199997 home: x: 276.5 y: 63.0 z: -60.5 yaw: -18.976715 pitch: -32.850002 is there way nodes under main ? to node ids contained in main : file.getconfigurationsection("main").getkeys(false); output: set["topofhouse", "2ndfloor", "home"] the configurationsection.getconfigurationsection(string path) method used path on operate. the configurationsection.getkeys(boolean deep) method node ids within current path set<string> . when deep set true , nodes in children , subchildren too, however, relations between them lost.

ruby on rails - simulate timestamp in seeds.rb -

i want populate database sample data, , reason, want simulate created_at . seeds.rb: 9.downto(1) |i| product = product.new(price: 99.99) product.created_at = i.days.ago, product.save! end in database, result of rake db:seed looks like, ---- 2012-03-03 16:50:30.316886000 z- 1 when need 2012-03-03 16:50:30.316886000 z- 1 how avoid these ---- symbols in result? (db: sqlite3) update: found when use product.created_at = i.days.ago , in callback ( before_save ) created_at array : [date_value, 1] . can use before_save { self.created_at = self.created_at[0] } and then, value in database right (without ---- ), using callbacks doesn't seem way. the problem line: product.created_at = i.days.ago, you need rid of trailing comma, that's why you're ending array created_at . fix , can rid of before_save callback. edit: reason getting --- in there because whatever orm using trying serialize array , it's turning yaml.

java - Specific difference between bufferedreader and filereader -

Image
i know specific difference between bufferedreader , filereader . i know bufferedreader more efficient opposed filereader , can please explain why (specifically , in detail)? thanks. in simple manner: a filereader class general tool read in characters file. bufferedreader class can wrap around readers, filereader, buffer input , improve efficiency. wouldn't use 1 on other, both @ same time passing filereader object bufferedreader constructor. very detail filereader used input of character data disk file. input file can ordinary ascii, 1 byte per character text file. reader stream automatically translates characters disk file format internal char format. characters in input file might other alphabets supported utf format, in case there 3 bytes per character. in case, also, characters file translated char format. as output, practice use buffer improve efficiency. use bufferedreader this. same class we've been using keyboard input. these lines should fami

matlab - How to reshape a vector to make a matrix? -

this question has answer here: reshaping of array in matlab 3 answers here have: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] and here want get: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] the number of rows , columns (3 , 4 in example) known. how that? this guide says mat = vec2mat(vec,matcol) converts vector vec matrix matcol columns, creating 1 row @ time. if length of vec not multiple of matcol, zeros placed in last row of mat. matrix mat has ceil(length(vec)/matcol) rows.

How to createan empty list that is associated with the specified comparator (java)? -

my question mysortedlinkedlist constructor...i know head=null; empty list, don't know how include comparator. you need assign field: public class mysortedlinkedlist<t> implements iterable<t> { private mylistnode<t> head; private final comparator<t> comparator; public mysortedlinkedlist(comparator<t> comparator) { head = null; this.comparator = comparator; } } you can't without introducing field - it's part of differentiates 1 instance another.

javascript - Syntax error when accessing property by variable? -

i have json variable stored in $("#budget").data('allocations') i can access it's data this: id = "5"; alert( $("#budget").data('allocations')[id].amount ); but need access this: var id = "5"; var field = "amount"; alert( $("#budget").data('allocations')[id].[field] ); using variable in property name causes fail. missing name after . operator (referring [field]) basically, .xxx can replaced ["xxx"] , there no limit in combining. use same logic used id : $("#budget").data('allocations')[id][field] whenever key in variable, replace .key [variable] . so, obj.key1.key2 becomes obj[variable1][variable2] same logic.

memory management - Invalid Conversion for Mem Allocator Method (C) -

i'm attempting finish writing memory allocator class project, not necessary homework wasn't assigned, chose project myself. i have 2 lines marked #1 , #2, both not work , give different error messages, here details. i'm getting following error message (for #1) : incompatible types when assigning type ‘size_t *[10]’ type ‘int *’ --- or --- (for #2) error: incompatible types when assigning type ‘size_t *[10]’ type ‘size_t **’ i can't understand why creating empty array of same type (#2) still can't "conversion". if both arrays of type size_t*, why second error message when attempting set free_array new array? void expandarray(void) { //size_t* free_array[10]; #this how free_array declared. size_t* oldarray = free_array; int newarray[freearraysize*2]; #1 //size_t* newarray[freearraysize*2]; #2 free_array = newarray; int = 0; (i=0; i<freearraysize; i++) { free_array[i] = oldarray[i]; }

audio - Header for Sound alerts, iOS. I want to make a sound play each time my app game reaches 5 minutes? -

what header file ios sound alert, , sound management. want make itouch game play sound each time player reaches 5 minutes game? is want? #import "audiotoolbox/audiotoolbox.h" don't forget add framework, too.

c++ - Count number of rasterized fragments -

abtract problem: need count fragments given geometry generated while rendered/rasterized regardless if fragments passed depth/stencil test or not. context: i'm trying implement lens flares project i'm working on. i'm using opengl occlusion querying count pixels visible light source rendering screen aligned quad @ position of light source while having query active determine number of visible fragments of light source. quad has given width , height should have width * height pixels @ some distance camera. after want adjust alpha value of actual flare effect account occluded parts of light source. need know total amount of fragments assembled rendered quad. so, know how can determine number of fragments generated given rendering operation? you suggested occlusion query, right tool job. struggle lies withing misconception try doing in 1 pass. split problem multiple sub-tasks. in case should add 1 render pass occlusion query of geometry (without shaders,

ruby - Rails Single Resource as Nested Resource of Two Other Resources -

i have business, catalog , product resource. a business has catalog , number of products. a catalog belong business. a product may or may not under catalog. the products table both has catalog_id , business_id. how form route can allow product without catalog , product belonging catalog, i.e., these urls: businesses/:business_id/catalogs/:catalog_id/products/:id businesses/:business_id/products/:id i have allowed latter using this: resources :businesses resources :catalogs resources :products resources :images end end how modify allow first url? i know i'm missing simple, feel free close , refer duplicate if there one. thanks lot! well, there: resources :businesses resources :catalogs resources :products resources :images end end resources :products resources :images end end the same way did businesses/products can businesses/catalogs/products, there no difference, nest resou

node.js - How do I disabled client-side logging in socket.io -

so know can use code below, set server-side logging minimum. io.set('log level', 0); however still lot of handshake messaging on client, , wondered if knows how disable it, checked documentation , couldn't find setting it. most of messages this: xhr finished loading: "http://...". if use firebug console change option unckeck show xmlhttprequest http://codeclimber.net.nz/archive/2007/08/01/how-to-debug-xmlhttprequest-with-firebug.aspx

jquery - Rebound same function -

i want bind element function via live() method. function excecutes fine first time. think have unbind element events , rebound same function don't know how it! here code: var temp = function() { var htmlex = "lorem ipsum dolor sit amet, consectetur adipiscing elit."; $('#template_loading').fadein(); $('#template_loading').queue(function() { $('#tp_prev').html(htmlex); $('#template_container').removeclass("cur_temp"); $('#template_container').addclass("cur_prev"); $('#template_container').animate({"margin-left" : "0"}, 400, 'easeoutexpo'); $('#template_container').queue(function() { $('#template_loading').fadeout(); $('#tp_cur').empty(); $('#template_container').removeclass("cur_prev"); $('#te

html5 - Animation SVG or Canvas? -

i wondering whether it's better make animation this in canvas or svg (performance wise)? i'm rewriting in jquery read somewhere canvas redrawn every time changes. for these "simple" animations , scene graphs doesn't matter if use svg or canvas performance wise. both should work fine without performance issues. however might easier create animation svg compared canvas. in canvas have redraw whole scene , in svg create ring once , define transformation (rotation) on it. for svg check out d3.js or raphael , canvas can check out processingjs , fabric.js , kinetic.js or paper.js

php - getting url to work with or without a subexpression -

im trying rewrite url like page.php?sort=66&search=s&category=2,3,4&archive=june&page=3 to page-sort-1-search(s)-category-1,2,3-archive(june)-page3 but thing each of subexpressions or may not in url every time page called had put each 1 in "( )?" regex works or without them ^page (-sort-([0-9]*))? (-search\(([a-z]*)\))? (-category-([0-9][,]?*))? ............. idea now problem mode rewrite considering each 1 of subexpression in parenthesis actual variable (-sort-([0-9]*))? how mode rewrite interpret => $1 = -sort-66 , $2 = 66 so each subexpression got 2 capture-group , that's more 10 link 5-6 variable , there 9 match limit in mode rewrite is there replacement "()?" i have admit, i'm bit confused parts of question, apologize in advance if answer totally off-base . . . sounds need non-capturing group. this: (...) matches ... , creates capture-group (what you're calling "variable"

algorithm - spline surface interpolation -

let's have n number of points defining surface on z-axis f(x1,y1) = 10 f(x2,y2) = 12 f(x3,y3) = 5 f(x4,y4) = 2 ... f(xn,yn) = 21 now want able approximate f(x,y). looking algorithm linear , spline approximation. example algorithms or @ least pointers great. this vague description of approach make linear approximation. determine voronoi diagram of points (for every point in plane, find nearest (x_i,y_i) ) take dual of delaunay triangulation : connect (x_i,y_i) , (x_j,y_j) if there line segment of points (x_i,y_i) , (x_j,y_j) equidistant (and closer other pair). on each triangle, find plane through 3 vertices. linear interpolation need. the following implements first 2 steps in python. regularity of grid may allow speed things (it may mess triangulation). import itertools """ based on http://stackoverflow.com/a/1165943/2336725 """ def is_ccw(tri): return ( ( tri[1][0]-tri[0][0] )*( tri[1][1]+tri[0][1] )

php - Facebook SDK logout not working -

i'm using facebook php-sdk sign in users , works fine. i'm having problem logging users out correctly. after clicking logout button , clicking sign in button not redirect user facebook's sign in page, instead logs them site if logout wasn't successful. here code sign in user: function authenticate_user() { $ci = & get_instance(); $ci->config->load("facebook",true); $config = $ci->config->item('facebook'); $ci->load->library('facebook', $config); $user = $ci->facebook->getuser(); if ($user) { try { $user_profile = $ci->facebook->api('/me'); return $user_profile; } catch (facebookapiexception $e) { error_log($e); } } return false; } public function signin() { $user_profile = authenticate_user(); if (!$user_profile) { $loginurl = $this->facebook->ge

c++ - Return array of pointers (CvSeq pointers) -

i have function returns array of pointers, i.e. pointer pointing first element of array of cvseq. however, don't know if possible create array of cvseq. the purpose of cvseq values of different images contours. here code have: cvseq* get_template_contours(string templ[], int size){ iplimage *templ_img; cvseq *contour = null; cvseq *contourpoly = new cvseq[size]; cvmemstorage* storage = cvcreatememstorage(0); for(int = 0; < size; i++){ templ_img = cvloadimage(templ[i].c_str(), 0); cvfindcontours(templ_img, storage, &contour, sizeof(cvcontour), cv_retr_external, cv_chain_approx_simple, cvpoint(0, 0)); contourpoly[i]=cvapproxpoly(contour, sizeof(cvcontour), storage,cv_poly_approx_dp,1,1); } cvreleaseimage(&templ_img); cvclearmemstorage(storage); cvclearseq(contour); return contourpoly; } but error error: no match ‘operator=’ in ‘*(contourpoly + ((long unsigned int)(((long unsigned int)i) * 96ul))) = cvapproxpoly(((const void*)contour)

java - Is changing the value of a Map an atomic operation? -

i wondering if synchronization or using concurrent class necessary, or conversely thread safe use non concurrent class , no synchronization on map in multi threaded environment, if modification map changing values of map. the reason ask hashmap ( , other non concurrent maps documentation ) have comment: note implementation not synchronized. if multiple threads access hash map concurrently, , @ least 1 of threads modifies map structurally, must synchronized externally. (a structural modification operation adds or deletes 1 or more mappings; merely changing value associated key instance contains not structural modification.) typically accomplished synchronizing on object naturally encapsulates map. which makes me believe if modification not structural (i.e. there no added or deleted) should able update (non concurrent) map sans synchronization. am reading correct? i.e. updating of value in map atomic process? updating map value not atomic proces

facebook - Using Fqcebook Stream Table to query friends news feed -

hi trying use stream table access friends news feed "select post_id, created_time, message, comments, source_id, actor_id, target_id, type stream filter_key in (select filter_key stream_filter uid=".$friendid.") , is_hidden = 0" but keep getting error stating can use stream current user logged in . possible query stream table query friends news feeed or there fql method this. many thanks. it's impossible query user's feed using fql, however, can query friends feed using graph api, entry point /feed.

SQL Server 2008: updating and keeping tracking of anuual price increase -

i have project right need update prices list of products. prices 1/1/2007 12/31/2011 given , need increase prices 5% each year, until end of 2015. here have. getting stuck on updating prices (ie 5% increase). keep getting error message duplicate data. in advance help/hints ! error message: msg 2627, level 14, state 1, procedure update_history, line 9 violation of primary key constraint 'pk_ pricecha _207f7de23a81b327'. cannot insert duplicate key in object 'dbo.pricechange_history'. tables: create table pricechange (productid integer not null primary key, startdate date, endingdate date, unitprice money); alter table pricechange add foreign key (productid) references product(productid) create table pricechange_history (history_productid integer not null primary key, history_startdate date, history_endingdate date, history_unitprice money, modified_date datetime, changetype varchar(20) ); alter table pricechange_history add foreign ke

How do I kill a Javascript script? -

i'm trying debug bunch of functions redirect user. want "kill" script while it's running to read output of console.log(). can't use simple return because there many functions work together. set breakpoint @ spot in code want pause. if add debugger statement in code browsers support automatically stop @ point , open debugger (actually think browsers (chrome?) may ignore statement unless have console/dev tools open, can start dev tools open if necessary).

mysql table gets hanged after update sql -

i having mysql myisam table more 2 million records. running shell script updating each row table , job completed. when opening table in mysql gui tool or try run select query on it, mysql server gets hanged. idea, how proceed on this? thanks

c++ - Integer class wrapper performance -

i looking remodel existing library fixed point numbers. library namespaced functions operating on 32-bit signed integers. turn around , create fixed point class wraps integer, don't want pay performance penalty associated classes fine-grained, performance issue use case. since prospective class has such simple data requirements, , no resources, thought might possible make class "value oriented", leveraging non-modifying operations , passing instances value reasonable. simple class if implemented, not part of hierarchy. i wondering if possible write integer wrapper class in such way no real performance penalty incurred compared using raw integers. confident case, don't know enough compilation process jump it. i know it's said stl iterators compiled simple pointer operations, , similar integer operations. the library updated c++11 part of project anyway, i'm hoping @ least constexpr , other new features rvalue references, can push performance of