Posts

Showing posts from September, 2012

PyQt4 - "RuntimeError: underlying C/C object has been deleted" -

i keep getting runtimeerror i'm not sure how fix. here's i'm trying accomplish. want update qtablewidget values dynamically i'm clicking on different items in qtreeview. on part, code works except when click on second item , need update qtablewidgt when run "runtimeerror: underlying c/c object has been deleted". here's snippet of code: def buildtable( self ): ... label in listoflabels : attr = self.refattr[label] self.table.setitem(row, 0, qtgui.qtablewidgetitem( label ) ) tableitem = qtgui.qtablewidgetitem( str(attr.getvalue()) ) self.table.setitem(row, 1, tableitem ) somefunc = functools.partial( self.updatevalues, tableitem, label ) qtcore.qobject.connect(self.table, qtcore.signal('itemchanged(qtablewidgetitem*)'), somefunc) def updatevalues(self, tableitem, label): print '--------------------------------' print 'updating text prope...

sql - MySQL - Combining Records into Fields -

what i'm trying query table holds custom data person , fields, i'm getting each individual field record in return. the current statement i'm using is select s.fname, s.lname, s.email, s.mobile, s.country, cf.name, ca.value standard s inner join people p on (s.pid = p.pid) inner join custom_answers ca on (ca.pid = p.pid) inner join custom_fields cf on (cf.fieldid = ca.fieldid) p.acctid = 'xxxxxxxxxx' this given resultset of 22,000 rows, whereas looking 900 rows. an example of data output is fname | lname | email | mobile | country | name | value tom | smith | t@t | 0412 | au | state | vic tom | smith | t@t | 0412 | au | position | dept head tom | smith | t@t | 0412 | au | guest | john smith mick | jones | m@j | 0411 | au | postnom | aoc mick | jones | m@j | 0411 | au | state | nsw mick | jones | m@j | 0411 | au | postcode | 2000 whereas output is fname | lname | email | mob...

.net - Why is GUID attribute needed in the first place? -

what necessity guid attribute? why don't let compiler handle automatically?! if compiler handled automatically, you'd end 1 of 2 situations. a new guid every time compiled - since guids supposed published, fail. collisions - if guid same every time, based on (say) hash of name, multiple projects end using same guid different purposes. the existing approach - explicit guid gives developers power control these required.

c++ - Calling overloaded operator () from object pointer -

consider following: class myclass { public: int operator ()(int a, int b); }; when have: myclass* m = new myclass(); i want access operator() method, could: (*m)(1,2); but can this? m->(1,2); not syntax, can do m->operator()(1,2);

c# - Strip Html for specific Tags -

i have html string : <td style=\"border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0cm; padding-left: 3.5pt; width: 489pt; padding-right: 3.5pt; background: #dfdfdf; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0cm;\" valign=\"top\" colspan=\"4\"> <strong>kan fejlen genskabes?</strong> </td>\r\n and have piece of code aloow specific tags : public string htmlstrip( string input) { string acceptable = "img|n|br|tr|td|table|tbody|th|td style strong"; string stringpattern = @"</?(?(?=" + acceptable + @")notag|[a-za-z0-9]+)(?:\s[a-za-z0-9\-]+=?(?:(["",']?).*?\1?)?)*\s*/?>"; return regex.replace(input, stringpattern,string.empty); } what trying allow "strong" tag if inside "td" or "table" tag. ideas? bonus: how can...

javascript - EXTJS comboBox multiselect -

in extjs 3.3.1, tried make combobox multi select , doesn't work. please help. var marray = new array("all", "aaa", "bbb"); var mcombo = new ext.form.combobox({ id: 'id', fieldlabel: 'id', triggeraction: 'all', height: 100, width: 163, multiselect: true, store: marray }); ext.getcmp('mcombo').setvalue("all"); there isn't config option multiselect in ext.form.combobox . desired functionality either need develop multiselect combobox own or use 1 of existing alternatives, ext.ux.form.checkboxcombo , ext.ux.form.superboxselect , ext.ux.form.lovcombo .

Rails Routes based on condition -

i have 3 roles: instuctor, student, admin , each have controllers "home" view. so works fine, get "instructor/home", :to => "instructor#home" "student/home", :to => "student#home" "admin/home", :to => "admin#home" i want write vanity url below route based on role of user_id correct home page. get "/:user_id/home", :to => "instructor#home" or "student#home" or "admin#home" how accomplish this? you can't routes because routing system not have information required make decision. rails knows @ point of request parameters , not have access in database. what need controller method can load whatever data required, presumably user record, , redirects accordingly using redirect_to . this standard thing do. update: to perform of within single controller action need split logic according role. example is: class homecontroller < applicat...

mysql - SQL query (~5 tables join if possible)? -

i have mysql tables: products id products_content product_id, lang, product_name, product_content products_and_categories product_id, category_id products_categories id, parent_id products_categories_content category_id, lang, category_name, category_content products_and_prices product_id, price_id products_prices id products_prices_content price_id, lang, description, weight, price, currency how select products category id 5 (for example) , prices every single product? possible single query? currently select products category, i'm using (codeigniter): $this->db->select('*') ->from('products') ->join('products_content', 'products_content.product_id = products.id') ->join('products_and_categories', 'products_and_categories.product_id = products.id') ->where(array('category_id' => $category_id, 'lang' => $lang));

C# GUI application that stores an array and displays the highest and lowest numbers by clicking a button -

background: this updated 13 hours ago have been researching , experimenting few. i'm new programming arena i'll short, i'm teaching myself c# and i'm trying learn how have integers user's input textbox calculated button1_click appear on form. yes, class assignment think have handle on of not of it; that's why i'm turning guys. problem: i'm using microsoft visual studio 2010 in c# language, windows forms application , need create gui allows user enter in 10 integer values stored in array called button_click object. these values display highest , lowest values user inputted. thing array must declared above click() method. this have come far: namespace smallandlargegui { public partial class form1 : form { public form1() { initializecomponent(); } public void inputtext_textchanged(object sender, eventargs e) { this.text = inputtext.text; } public void subm...

How to Rotate Map View from the user current position in android -

i pointing user current location bottom center in android map view.so user able see north side map , not able see south side app.if user turns towards south user should see south side map. i getting bearing angle of user using sensor manager.if rotate map current position of the user changes bottom center how can handle this. please me. i recommend using mapview.setrotation(float bearing) . that's use (i have app similar yours). i'm not sure api level introduced in, works me (2.3.4). make sure call mapview.invalidate() after you've rotated map.

Ruby yaml custom domain type does not keep class -

i'm trying dump duration objects (from ruby-duration gem ) yaml custom type, represented in form hh:mm:ss . i've tried modify answer this question , when parsing yaml yaml.load, fixnum returned instead of duration. interestingly, fixnum total number of seconds in duration, parsing seems work, convert fixnum after that. my code far: class duration def to_yaml_type "!example.com,2012-06-28/duration" end def to_yaml(opts = {}) yaml.quick_emit( nil, opts ) { |out| out.scalar( to_yaml_type, to_string_representation, :plain ) } end def to_string_representation format("%h:%m:%s") end def duration.from_string_representation(string_representation) split = string_representation.split(":") duration.new(:hours => split[0], :minutes => split[1], :seconds => split[2]) end end yaml::add_domain_type("example.com,2012-06-28", "duration") |type, val| duration.from_string_represe...

ninject.web.mvc - Ninject MVC3 - how does the type gets resolved -

scenario: i've set ninject mvc3 using link below: https://github.com/ninject/ninject.web.mvc/wiki/setting-up-an-mvc3-application i followed nuget version. and, code looks below: private static void registerservices(ikernel kernel) { kernel.bind<iservice>().<service>(); } could me understand when , code below gets excuted? var test=kernel.get<service>(); basically i'm trying understand resolve concrete type. update : my question more of mvc use kernel.get() resolve given interface concrete type. is done ninject.mvc? kernel.get<service>() shouldn't called anywhere. should request iservice in constructor of controller needs dependency. when mvc requires controller asks ninject create controller instance , ninject inject service controller.

r - list of character vectors of unequal length to data.frame -

i have named list looks this: > head(pathways) $<na> null $`2` [1] "hsa04610" $`9` [1] "hsa00232" "hsa00983" "hsa01100" $`10` [1] "hsa00232" "hsa00983" "hsa01100" $<na> null $<na> null to describe more formerly. name of each list id number, , entries of each element of character vector elements of list id number. can filter out $<na> entries is.na() , want change rest like: id another_id 2 hsa04610 9 hsa00232 9 hsa00983 9 hsa01100 10 hsa00232 10 hsa00983 10 hsa01100 > dput(test) structure(list(`na` = null, `2` = "hsa04610", `9` = c("hsa00232", "hsa00983", "hsa01100"), `10` = c("hsa00232", "hsa00983", "hsa01100" ), `na` = null, `na` = null), .names = c(na, "2", "9", "10", na, na)) any ideas? so found answer seems work. stack(path...

Is possible to create a singleton c++ to authenticate and post in the wall using HTTP request to Facebook API? -

i'm working on linux. i have been looking method post on facebook c++ app (that runs in android , iphone using cocos2d-x). have found code in c++ post on facebook , twitter, not compile on linux. this or this . in theory, think, using http request, easy do, i'm not sure. the same question on cocosd2-x forum . some idea theory? is possible, better use oficial libraries, added in this wiki this possible using curl. here link1 compile on cocos2d-x library, , example2 using cocos2d-x. link1: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/how_to_compile_libcurl example2: http://www.jesusbosch.com/2012/08/internet-communications-with-cocos2d-x.html

c# - Connection manager to accept either of ADO.NET or OLEDB connection types -

please @ following piece of code. accept ado.net connection type , want make work oledb well. in other words, if connectionmanager presented oledb type connection, should not fail. connect using either of ado.net or oledb (i not looking both of them @ same time). using microsoft.sqlserver.dts.runtime.wrapper; private sqlconnection sqlconnection; public override void acquireconnections(object transaction) { if (componentmetadata.runtimeconnectioncollection[0].connectionmanager != null) { connectionmanager cm = microsoft.sqlserver.dts.runtime.dtsconvert.getwrapper(componentmetadata.runtimeconnectioncollection[0].connectionmanager); connectionmanageradonet cmado = cm.innerobject connectionmanageradonet; if (cmado == null) throw new exception("the connectionmanager " + cm.name + " not ado.net connection."); sqlconnection = cmado.acquireconnection(transaction) sqlconnection; sqlconnection.open(); }...

java.util.date - Java date older than 1923 -

so have strange problem, have java swing application has date 10/11/1922 00:00:00 mst when sends date backend glassfish server via rmi date becomes 10/10/1922 23:00:00 mst. somehow losing hour, bug? can't find on google references problem. if date in 1923 works fine don't lose hour. client running 1.6.0 patch 30 , server running 1.6.0 patch 17. i think i've seen question before--essentially there shift in definition of timezones @ point in history, or that, hour never existed. think, in fact, jon skeet 1 locate error (in previous question). can't find right now, have go lunch, think it's out there :d

excel - Using apache poi ant in eclipse -

i have installed "ee developers" software , "xml editors , tools" on eclipse , want use apache poi read data excel files when eclipse compiles code, gives me error. in fact cannot support following imports. why problem? import org.apache.poi.hssf.usermodel.hssfcell; import org.apache.poi.hssf.usermodel.hssfrow; import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook; cheers the ant tutorial explains how external libraries managed ant. <project name="helloworld" basedir="." default="main"> ... <property name="lib.dir" value="lib"/> <path id="classpath"> <fileset dir="${lib.dir}" includes="**/*.jar"/> </path> ... <target name="compile"> <mkdir dir="${classes.dir}"/> <javac srcdir="${src.dir}" destdi...

streaming - Apache Storm compared to Hadoop -

how storm compare hadoop? hadoop seems defacto standard open-source large scale batch processing, storm has advantages on hadoop? or different? why don't tell opinion. http://www.infoq.com/news/2011/09/twitter-storm-real-time-hadoop/ http://engineering.twitter.com/2011/08/storm-is-coming-more-details-and-plans.html twitter storm has been touted real time hadoop. more marketing take easy consumption. they superficially similar since both distributed application solutions. apart typical distributed architectural elements master/slave, zookeeper based coordination, me comparison falls off cliff. twitter more pipline processing data comes. pipe connects various computing nodes receive data, compute , deliver output. (there lingo spouts , bolts) extend analogy complex pipeline wiring can re-engineered when required , twitter storm. in nut shell processes data comes. there no latency. hadoop how ever different in respect due hdfs. solution geared distributed s...

.net - Encoding.Unicode.GetString error when resolving encryption Byte() -

have been trying encrypt xml file string may transfer on service. transmission server server using symetric key compiled code. i have been using aes sample msdn , converting byte arry , string so: ' encrypt string array of bytes. dim encrypted byte() = crypto.encryptstring(original, _key, _iv) dim encrypstr string = encoding.unicode.getstring(encrypted) '''' >>> transmit... dim posttrans byte() = encoding.unicode.getbytes(encrypstr) ' decrypt bytes string. dim roundtrip string = crypto.decryptstring(posttrans, _key, _iv) without middle 2 line encrypt/decrypt works fine, middle 2 lines included either recieve badly formed xml document cannot parsed or "padding invalid , cannot removed" error. is not method string encryption? works without converting byte() string ad back. do not use encoding.getstring(), not work. use tobase64() thanks henk holterman answer.

php - Can't get the encoding right in MySQL -

i have been struggling encoding problems in mysql while. building database contain not latin cyrillic , arabic text well. here example on how create database: create database db1 default character set utf8 collate utf8_unicode_ci; then table: create table temptb1 ( id int primary key, name varchar(100) not null, arabic varchar(100) not null ) default character set utf8 collate utf8_unicode_ci; and when put data , select strange characters. wrote small php script test doesn't work either: <?php header('content-type: text/plain; charset=utf-8'); $a = mysql_connect('localhost','root','') or die('problem connecting database!'); $b = mysql_select_db('db1') or die('problem selecting database'); mysql_set_charset('utf8'); mysql_query("set names 'utf8'"); mysql_query('set character set utf8'); $query = mysql_query("select * tb1;"); while($row = mysql_fetch_assoc($qu...

php - Get contents of BODY without DOCTYPE, HTML, HEAD and BODY tags -

what trying include html file within php system (not problem) html file needs usable on own, various reasons, need know how can strip doctype, html, head , body tags in context of php include, if that's possible. i'm not particularly @ php (doh!) searches of php manual , on web hasn't made me figure out. meaning or reading tips, or both, appreciated. since substr() method seemed swallow, here dom parser method: $d = new domdocument; $mock = new domdocument; $d->loadhtml(file_get_contents('/path/to/my.html')); $body = $d->getelementsbytagname('body')->item(0); foreach ($body->childnodes $child){ $mock->appendchild($mock->importnode($child, true)); } echo $mock->savehtml(); http://codepad.org/mqvq3xqp anybody wish see "other one", see revisions.

Want to use SetNamedSecurityInfo in Powerbuilder for changing the Owner of a file -

i have requirement change ownership of file or revoke ownership of user created file using powerbuilder. i.e. in application user creates file , want remove ownership file within code. user can't edit or modify file. have found c++ samples same ( change file owner in windows ) not replicate in powerbuilder. getting error code 87 below code when calling setnamedsecurityinfow. if can me achieve ownership change using powerbuilder. constant integer se_file_object = 1 constant integer owner_security_information = 1 constant integer name_size = 64 constant integer sid_size = 32 string domain_name integer ret, sid_len, domain_len integer li_ret, newowner n_filesys nvo integer l_nothing setnull(l_nothing) newowner = 100 li_ret = nvo.setnamedsecurityinfow('p:\my documents\test.txt',se_file_object,owner_security_information,newowner,l_nothing,l_nothing,l_nothing) if li_ret <> 0 messagebox("hi","error") end if ---------...

stdout - x86 assembly: printing integer to the console after mul (seg fault) -

i'm trying learn x86 assembly. book i'm using assembly language - step step, programming linux (and i'd have it's pretty good). i've learned lot far, feel though should challenging myself stay ahead in many respects can learn faster through doing (i can follow along, top-down learning, find tediously slow). so, figured cool idea try , multiply 2 registers (32-bit) , output data console. the problem when execute program (i'm using nasm, book - no insight debugger though), receive segmentation fault. i've done fair amount of debugging in gdb little hammer out, whatever reason can't seem figure out issue is. i'd know why i'm receiving segmentation fault, , way reprimand issue. also, if comments i've made in code don't match happening, i'd grateful if correct me on that. here's code far (it's commented) thanks. teh codez section .data ;todo section .bss valuetoprint: resb 4 ;alloc 4 bytes of data i...

android - How to set both lines of a ListView using simple_list_item_2? -

so following create listview rows have "primary" textview filled values array. arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_2, android.r.id.text1, values); changing third parameter android.r.id.text2 sets "secondary" textview. there simple way set both? afaik simple_list_item_2 contains twolinelistitem containing 2 textviews. arrayadapter not going work here,you'll either have create custom adapter or use 1 supports simplecursoradapter. listadapter adapter = new simplecursoradapter( this, android.r.layout.simple_list_item_2, mcursor, // pass in cursor bind to. new string[] {people.name, people.company}, // array of cursor columns bind to. new int[] {android.r.id.text1, android.r.id.text2}); // parallel array of template objects bind columns. // bind our new adapter. set...

wpfdatagrid - getting datagridrow of datagrid in WPF -

i used line in code not give row object, row null. datagridrow row = (datagridrow)dtgsensorreadinglist.itemcontainergenerator.containerfromitem(channelgrid.items[i]); datagrid xaml code: <datagrid visibility="hidden" virtualizingstackpanel.virtualizationmode="standard" canuseraddrows="false" columnheaderheight="32" mincolumnwidth="65" horizontalgridlinesbrush="darkkhaki" verticalgridlinesbrush="darkkhaki" borderbrush="darkkhaki" block.textalignment="center" autogeneratecolumns="true" canuserresizecolumns="false" canuserreordercolumns="false" horizontalalignment="left" margin="63,540,0,0" name="dtgsensorreadinglist" itemssource="{binding}" grid.row="1" height="auto" verticalalignment="top" maxwidth="1920" width="auto"> <dat...

android - How can I get current atmospheric pressure for my latitude and longitude? -

i want current atmospheric pressure given latitude , longitude kind of remote service, can compare pressure sensor's reading , come altitude. unfortunately twc , and world weather online have usage limits, few hundred requests per day per api key, won't work if more handful of users download app , using @ once same api key in code. after 5 minutes no user able data. need way of querying data without usage limits. there service provides without making api key? hey bro have thought looking altimeter comes w phone? remember science class measure pressure of atmosphere same altimeter. maybe make btree , figure out correct indexes along way.

Twitter profile widget -

i'm using twitter profile widget on website.i changed settings want,got code twitter site. https://twitter.com/about/resources/widgets/widget_profile the problem widget ,each time want me refresh page see tweets. i want load tweets out refreshing page. there way,i implement on widget. <script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script> <script> new twtr.widget({ version: 2, type: 'profile', rpp: 4, interval: 30000, width: 250, height: 300, theme: { shell: { background: '#333333', color: '#ffffff' }, tweets: { background: '#000000', color: '#ffffff', links: '#4aed05' } }, features: { scrollbar: false, loop: false, live: false, behavior: 'all' } }).render().setuser('twitter').start(); </script> thanks in advance! you can force widget load new tweets ...

flex, change the button image when mouse over/out -

with following code, have implemented image change when mouse hover button. image name hardcoded, specified in style. how can make parameterized? want reuse small utility image name input parameter. image used(14 images in case) included in flex project. using flex 3 <mx:style> .mycustombutton { upskin: embed(source="jjyxfx.png"); overskin:embed(source="cwgl.png"); downskin: embed(source="cwgl.png"); } </mx:style> <mx:button y="0" width="105" height="107" fillalphas="[1.0, 1.0, 1.0, 1.0]" x="0" fillcolors="[#3aa2d9, #3aa2d9]" stylename="mycustombutton" usehandcursor="true" buttonmode="true"/> i don't believe can't parameterize css styles; you'll have set styles via actionscript: public function setstylesonbutton(upskinvalue:string,overskinvalue:string,downskinstyle:string):void{ ...

emacs - How to switch from shell buffer to another -

i learn use emacs. when enter m-x shell , enter shell mode, don't know how exit shell mode. want fundamental mode continue editing work. search question emacs switching out of terminal , when press c-c o , input treated command, how exit ? the shell running in buffer. can switch buffer doing work using c-x b .

xcode - iOS provisioning get-task-allow AND <Error>: profile not valid: 0xe8008012 -

Image
i have iphone app i've built app store. before there, need test internally. earlier week went out, got distribution provisioning profile , installed on 50 devices around organization. no problem, went super-smooth , happy. cleaned code bit, did refactoring, , added bit of polish. @ same time, had more devices added beta (around 10 additional units). when ready build , run out second beta, went out, got new provisioning profile , archived build ad-hoc on air deployment. tested app on phone (which development device), , failed install. checked device console in organizer , saw error looks this: <error>: entitlement 'get-task-allow' has value not permitted provisioning profile . never mind fact when archived , deployed 3 days ago worked fine without entitlements plist. thought "ok, 1 of quirks." added entitlements.plist , set get-task-allow yes . re-archived distribution provisioning profile, , tried install device , did install properly. trie...

asp.net mvc 3 - Setting a drop downlist to a specific value in MVC 3 Razor -

afternoon all. i have drop down list in view <div class="editor-label"> @html.labelfor(model => model.sitetypeid, "sitetype") </div> <div class="editor-field"> @html.dropdownlist("sitetypeid", (ienumerable<selectlistitem>) viewbag.sitetypeid) @html.validationmessagefor(model => model.sitetypeid) </div> with model looking so: public class sitetype { [key] public int sitetypeid { get; set; } public string sitetypename { get; set; } } currently there 2 items in drop down: 1 (value) - foo (item) 2 (value) - bar (item) which appears via controller la: public actionresult details(guid id) { var model = model(id); viewbag.sitetypeid = new selectlist(db.sitetypes, "sitetypeid", "sitetypename"...

arrays - C++ 2D matrix iterator efficiency compared to nested for-loop -

i have row-major iterator 2d array, derefence operator follows: int& iterator::operator*(){ return matrix_[y_][x_]; } //matrix_ has type int** the (prefix) increment operator follows: iterator& iterator::operator++() { if((++x_ == xs_) && (++y_ != ys_)) //ys_, xs_ dimensions of matrix x_ = 0; return *this; } i can use iterator optimised version of std::transform (doesn't return un-needed result, in order save few instructions) template < class inputiterator, class outputiterator, class unaryoperator > inline void mytransform( inputiterator first1, inputiterator last1, outputiterator result, unaryoperator op ) { (; first1 != last1; ++first1, ++result) *result = op(*first1); } calling thus: mytransform(matrix1.begin(),matrix1.end(),matrix2.begin(), myfunctor()); however, when compare performance classic, nested for-loop: myfunctor() f; (int y=0; y<ysize; y++) (int x=0; x<x...

c++ run .exe file with parameters -

im trying run exe file c++ no luck i tried this: system("c:\\program files (x86)\\counter-strike condition 0 1.2 build 2771\\hl.exe"); how can run hl.exe parameters? thanks update: 'c:\program' not recognized internal or external command, operable program or batch file im getting error. i tried system("c:\\hl.exe"); , works good. think problem in whitespaces you can run executable parameters adding them end of hl.exe on command line. system("c:\\program files (x86)\\counter-strike condition 0 1.2 build 2771\\hl.exe fullscreen"); where fullscreen parameter run hl.exe with. with spaces in path can put quotes around string containing executable path: system("\"c:\\program files (x86)\\counter-strike condition 0 1.2 build 2771\\hl.exe\" fullscreen");

PHP/cURL curl_exec() error? -

this first time using curl might silly error on part following code: $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, 1); $output = curl_exec($ch); curl_close($ch); echo $output; prints "1". understanding curlopt_returntransfer should ensure curl_exec returns either 0 or content here it's behaving if curlopt_returntransfer hasn't been set true. missing obvious? thanks! i'd use guzzle , oop wrapper around curl. (though since you're using request, file_get_contents($url); work fine). there's no real issue code, though. sure url valid? also, check make sure curl_setopt returning true each call it, , try setting curlopt_url using function.

objective c - Copying NSDate objects and releasing -

if this: nsdate *datestart; [datestart alloc]; // initialise date somewhere here.. .. // modify start date. datestart = [chosendate copy]; should doing [datestart release] before assigning datestart pointer? i'm c/c++ background , don't understand whole objectivec/ios garbage collection behaviour (if indeed there any). c background telling me should freeing initial nsdate object datestart pointing to. correct? yes since allocated before should release before line //release before reassign [datestart release]; datestart = [chosendate copy]; also notice preferred allocation , initialization on same line, dont break them multiple lines so this nsdate *datestart; [datestart alloc]; would change to nsdate *datestart = [[datestart alloc] init....];

IOS Facebook singleton and get profile picture -

i trying profile picture uiviewcontroller. my facebook in singleton class. uiviewcontroller [[myfacebook shared requestwithgraphpath:@"me/picture" anddelegate:self]; doesn't work if need login or app fire first time. because authorize being called , didlogin being called. this line not hit. - (void)request:(fbrequest *)request didload:(id)result { how go around these scenario 1.singleton facebook instance class, 2.calling uiviewcontroller 3. need login. i suggest creating protocol called facebooksingletondelegate @class facebooksingleton; @protocol facebooksingletondelegate <nsobject> - (void) facebooksingletondidlogin:(facebooksingleton *) facebooksingleton; - (void) facebooksingletondidnotlogin:(facebooksingleton *) facebooksingleton; - (void) facebooksingletondidlogout:(facebooksingleton *) facebooksingleton; - (void) facebooksingleton:(facebooksingleton *)facebooksingleton request:(fbrequest *) request didload...

version control - Advantages of GitHub over Bitbucket for Git Repositories -

now bitbucket supports git repositories, seams me alternative github , since free plan includes unlimited private repositories, not available on github. yet, github seams more popular. are there major reasons choose github hosting site git repositories instead of bitbucket? (although have no problems making personal projects publicly available in general, idea of being able make switch public private or vice versa time want. if there reasons use github, willing give freedom.) this should community wiki, since it's subjective think of use community. github's greatest strength it's in use, , supported more 3rd parties. example, continuous integration services travis ci or buildhive feature transparent integration github. personally, use github public code because it's pretty used , supported , use codeplane private code, because $9 month unlimited repos pretty good.

programming languages - What's the name for hyphen-separated case? -

this pascalcase: somesymbol this camelcase: somesymbol this snake_case: some_symbol so questions whether there accepted name this: some-symbol ? it's commonly used in url's. there isn't specific standard name case convention, , there disagreement on should called. lisp has used convention decades described in this wikipedia entry . reason, described lisp-case in question on programmers se similar 1 on. seems original coining. and according this wikipedia entry , may called spinal-case or kebab-case (and upper case version called train-case ). of these forms have been contested original coinings. so answer question is: no, there isn't single widely-accepted name case convention analogous snake_case or camelcase , widely-accepted.

php - Download document from sqlite through website -

i have store sample document inside local server named template.doc. store file directory inside sqlite table. manage call out path of file directory how can allow user download it? codes <form id="list" name="list" method="post" action=""> <select name="list" id="list"> <?php if ($choice !="no") { $path = $_server['document_root']."/web/"; $fullpath = $path.$_get['$choice']; echo "<form id=\"form7\" name=\"form7\" method=\"post\" action=\"\">"; echo "<input type=\"submit\" name=\"download\" id=\"download\" value=".$fullpath."/>"; if (file_exists($fullpath)) { ...

asp.net - HTTP Response is corrupting the return string -

Image
i have controller action in web api return string token below.howver, problem whenever there '/' appear in server side response string, @ client side '/' instead '\' addition original string. how can rid of it? public string gettrackprofile() { string token="0q2l7m4daekjct/yixk0txzyzaxjzmyzq6+oaxhpnorrel7hez2vnkle61mf2zll"; return token; } client side response 0q2l7m4daekjct/yixk0txzyzaxjzmyzq6+oaxhpnorrel7hez2vnkle61mf2zll if string part of http header, should aware according rfc 2616 specification / considered separator character , must escaped (which web api prepending \ ): many http/1.1 header field values consist of words separated lws or special characters. these special characters must in quoted string used within parameter value (as defined in section 3.6). token = 1*<any char except ctls or separators> separators = "(" | ")" | "<" | "...

php - Static classes vs class member access on instantiation -

in versions of php prior 5.4 used static classes instantiate object , call required function, example: $result = foo::init()->bar(); in above example, static function init() instantiates class in contained , returns object. provides method chaining functionality , allows me call bar() , in 1 line of code. static function init() looks this: static public function init() { $object = new self(); return $object; } now php 5.4 has added support class member access on instantiation, , instead of using static class can following: $result = (new foo)->bar(); my question: old way of using static classes bad, , if so, why? php supports class member access on instantiation, more correct way of accessing class members after object instantiation? if that's ->init() does, can away (new foo)->bar(); , when go dependancy injection route, want create kind of factory 'inject depedencies' on instantiation. factory may full fledged instantiated o...

magento - magento1.6.2 Invalid package name, allowed: [a-zA-Z0-9_-] chars -

i have installed magento 1.6.2 , trying install paid extension using “direct package file upload”. use magento connect manager 1.5.0 (i installed free extensions extension key, worked.) then tried uploading 1 of paid extensions purchased using “direct package file upload” , got following error connect error: package file invalid invalid package name, allowed: [a-za-z0-9_-] chars invalid version, should like: x.x.x invalid stability invalid date, should yyyy-dd-mm invalid channel url empty authors section empty package contents section with plugin got: file upload problem or connect error: package file invalid invalid channel url appreciate if has resolved issue before. thanks

vba - how to save excel file attached in an email received in a defined sub folder in the inbox of outlook 2007 to a folder on the windows? -

i need save excel attachement received inside outlook messages in specific sub folder (daily final) located in inbox , knowing emails in subflders including excel attached file. had below example excel vba not working kindly advie me sub saveattachmentstofolder() ' outlook macro checks named subfolder in outlook inbox ' (here "daily final" folder) messages attached ' files of specific type (here file "xls" extension) ' , saves them disk. saved files timestamped. user ' can choose view saved files in windows explorer. ' note: make sure specified subfolder , save folder exist ' before running macro. on error goto saveattachmentstofolder_err ' declare variables dim ns namespace dim inbox mapifolder dim subfolder mapifolder dim item object dim atmt attachment dim filename string dim integer dim varresponse vbmsgboxresult set ns = getnamespace("mapi") set inbox = ns.getdefaultfolder(olfolderinbox) set s...

database - Rails calculation model structure -

i trying put model structure performing various calculations, formulas stored within models. currently, have operand model, connected via many-to-many operations model. works fine long can simple calculation (i.e. without intermediate steps). where have problem if need (for example) subtract result of 1 operation result of another. i'm aware use second model perform calculations on operations, run same problem further chain (i.e. if need perform operation on result of calculation). as such, need way nest operations - i.e. operation take operands normal operand operand model, or result of operation. there way operations model self reference this? thanks! this more of object modeling question rails question -- , without understanding domain models in more detail i'm not sure can great deal. but think calculators , how i've seen simple sets of operations/operand programming work, there have been couple patterns i've seen may helpful: do have '...

java - How can I disable Quick Access TextField in Eclipse RCP Application -

today changed eclipse ide 3.7 4.2 , plugin-project has new feature in statusbar of ui called quickaccess. dont need it, how can disable feature, because position of button bar has changed... go --> install new software https://raw.github.com/atlanto/eclipse-4.x-filler/master/pdt_tools.eclipse-4.x-filler.update/ install plugin , restart eclipse. quick access automatically hide. or else have option hide window --> hide quick access.

php - Created a new field in Drupal, trying to assign it to multiple content types -

i've created field called "field_vote" in drupal, , automatically assigned created it, content type called toolkits. i want assign resources, how do that? 1 go admin/structure/types/manage/[your_content_type]/fields 2 under add existing field , choose existing field wanna add. ( field_vote in case) 3 hit save customize field settings, , you're done. hope works... muhammad.

flash - Good AS2 Encryption -

i know flash as2 encrypter best, need 1 can encrypt enough most people not able unencrypt it. doesn't matter how expensive is, money isn't object. need actionscript 2 , not 3. thanks. swfencrypt pretty good, encrypts swf, obfuscates routines in code, , in general makes pretty hard decompile intelligible code. isn't perfect take long , effort intelligible out of swf run through it.

ruby on rails - Why am I getting an uninitialized constant error and how can I fix it? -

when try run signup form web app i'm building in rails, following error: uninitialized constant user::pillhq which references 2 methods in app code, 1 in user model , 1 in user controller. the method in question in user model is def save_with_payment if valid? customer = stripe::customer.create(description: email, plan: pillhq, card: stripe_card_token) self.stripe_customer_token = customer.id save! end and method in question in user controller def create @user = user.new(params[:user]) if @user.save_with_payment sign_in @user flash[:success] = "welcome sample app!" redirect_to edit_user_path(current_user) usermailer.welcome_email(@user).deliver else render 'new' end end i'm not sure how remove error, can give awesome! the word pillhq on line below not valid against "naming conventions", assuming variable... customer = stripe::customer.create(description: email, plan: pillhq, card: stripe_card_token) local variables ...

Rails layout per controller -

i have home controller , news controller. want both of these controller use application.html.erb layout file , in addition that, home, use home layout , news, use news layout. , render specific view. possible in rails? in other words, don't want specify layout per view, per controller, both inheriting application.html.erb layout. what want remove redundancy of adding top navigation bar , including javascript/css in every single layout file. i'd rather include in 1 file, , controller specific layout layout, , render view. thanks i think want nested layout. rather repeat here, i'll direct http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts

android - How to identify a mobile device with JavaScript -

i'm developing website mobile devices. in order log behavior of users want save id cookie of user on client. when user revisits website can read id cookie identify user. on devices works fine because device automatically accepts saving id cookie . devices (eg. iphone) doesn't work. how can uniquely identify mobile device (eg. mac address?). i can run javascript on mobile device. try this, might work in case :) var macaddress = ""; var ipaddress = ""; var computername = ""; var wmi = getobject("winmgmts:{impersonationlevel=impersonate}"); e = new enumerator(wmi.execquery("select * win32_networkadapterconfiguration ipenabled = true")); for(; !e.atend(); e.movenext()) { var s = e.item(); macaddress = s.macaddress; ipaddress = s.ipaddress(0); computername = s.dnshostname; }

html - Yet Another "Why isn't my Favicon showing?" -

Image
update have tried "pinning" site taskbar again (after removing it) when clicked , held down mouse button on 16x16px icon inside address bar (see pic below), can see favicon being dragged around mouse - internet explorer has found , got icon - it's not displaying in right places! updated code below: as title suggests, can't favicon display; in version of browser. there 1 exception, though - isn't enough: ie 9 , ie 10 - as can see in screenshot above, only time see favicon after i've added favorites folder , opened favorites bar. favicon not display in tab (next page title), not display in taskbar area, , not display top-left of browser window if have "pinned" site taskbar. in every other browser, not display @ all. i have tried every possible "solution" find online. here's code have: <link rel="icon" type="image/x-icon" href="http://www.mysite.com/favicon.ico"><!-- major...

NHibernate with IQueryOver - create where-condition with subquery and or condition -

when do acc accountalias = null; var subquery = queryover.of<temp>() .where(x=>x.isaccepted==null) .and(x=>x.account.id==accountalias.id); var results = session.queryover<acc>(()=>accountalias) .where(x=>x.user.id==65) .withsubquery.whereexists(subquery); this create fallowing sql: select * accounts a.user_id=65 , exists ( select t.account_id temporary_accounts t t.isaccepted null , t.account_id=a.account_id) how can add or condition, nhibernate generate fallowing sql: select * accounts a.user_id=65 , (a.amount = 100 or exists ( select t.account_id temporary_accounts t t.isaccepted null , t.account_id=a.account_id)) not tested tihs may trick acc accountalias = null; var subquery = queryover.of<temp>() .where(x => x.isaccepted == null) .and(x => x.account.id == accountalias.id); var results = session.queryover<...

expressionengine - Integrating Eventbrite with Expression Engine -

has has done eventbrite integration expression engine site? we'd set events eventbrite , have them handle ticket management. we'd able display events within expression engine site , enable users click on link redirected eventbrite. i've viewed api , looks can create custom ee pages api. more importantly i'd let users search events our main site. has done type of work , have hints or resources? thanks. todd perkins got started on module time ago, there hasn't been action on since then. starting point though. https://github.com/toddperkins/eventbrite

iphone - Phonegap: get the filesize of captured audio file -

i using phonegap build iphone application. recorded file using following code. navigator.device.capture.captureaudio( capturesuccess, captureerror ); how can file size of captured audio file? the capturesuccess method of navigator.device.capture.captureaudio( capturesuccess, captureerror ) called array of mediafile objects has size parameter. function capturesuccess(audiofiles) { var i, len; (i = 0, len = audiofiles.length; < len; += 1) { console.log("name = " + audiofiles[i].name); console.log("path = " + audiofiles[i].fullpath); console.log("type = " + audiofiles[i].type); console.log("size = " + audiofiles[i].size); } }

php - bootstrap hero-unit height - Leaflet -

i have basic bootstrap layout navbar , sidebar(span 3) + map(span 9). problem when @ code in browser map looks this: http://dl.dropbox.com/u/15923835/bootstr.jpg but want fixed size map (it should cover 80% of page something. have tried set fixed height in every div nothing happens. have suggestions? sorry bad technical explanation (i'm trying learn) here's copy of code: <div class="container-fluid"> <div class="row-fluid"> <div class="span3"> <div class="well sidebar-nav"> <ul class="nav nav-list"> <li class="nav-header">sidebar</li> <li class="active"><a href="#">link</a></li> <li><a href="#">link</a></li> <li><a href="#">link</a></li> <li><a href="#">link</a...

c++ - Why do cin and cout use << and >> -

possible duplicate: why bitwise shifts (<< , >>) used cout , cin? i understand cout , cin overload bitwise operators << , >>. however, of time functions , tools use arguments or parameters pass information. is there reason in grand history of c++ has lead being case? i know rudimentary thing, new c++ , searching , google, asking few folks, has not turned answer. (a) operator precedence and (b) looks nice - form of operators suggests function

How to programatically change selected item in dropdown while javascript onchange applied asp.net -

i have 2 dropdowns , thier hidden field each on codebehind im adding javascript onchange event attribute.add , button perform dynamic actions adding controls @ runtime when click button dropdown reset. in order maintain state have hidden field dropdown selectedvalue hidden field coding ddcity.items.findbyvalue doesnt seems work can help? protected void page_load(object sender, eventargs e) { ddcountry.attributes.add("onchange", "javascript:bufferaddddcountry('" + ddcountry.clientid + "');"); ddcity.attributes.add("onchange", "javascript:bufferaddddcity('" + ddcity.clientid + "');");} if (hiddenddcityvalue.text != "0") { ddcity.items.findbyvalue(hiddenddcityvalue.text).selected = true;// dont work } if (!ispostback) { this.populatecountry();populatecity();} javascript code <script type="text/javascript"...