Posts

Showing posts from August, 2011

Converting "myself" from C# to VB.NET -

i c# programmer (hobby), want convert vb.net programmer. have seen many posts written in both c# , vb.net, need links explain basics (like void main void) advanced. note: microsoft blogs (until whatever read) not refer basic core level knowledge/things . aside books/blogs, way learn other side of c#/vb wall write code in c#, compile it, , open dll in reflector , view vb code. allow answer own questions vb.net. for example, suppose want see how generics in vb.net. write simple library in c#: void somemethod() { list<int> list = new list<int>(); } compile this, open in reflector, , show you: sub somemethod dim list list(of integer) = new list(of integer) end sub or that... if know how in c#, can teach how in vb.net way easier looking samples online.

ruby on rails - Is possible to print a line in development logger? -

i have code users_controller.rb, need print line no 30 in development.log line#29 def selectrole line#30 @userrole = rolesuser.find(:all, :conditions =>["p.user_id = ? , p.status = ? ",session[:user_id], params['status']]) line#31 logger.debug print_line(30) line#32 end can see 30th line in development.log this @userrole = roleuser.find(:all, :conditions => ["p.user_id = ? , p.status = ? ", 1234, 'active']) what approach write "print_line" function? here print_line code? def print_line(file_name, line) counter = 1 printline = "-------- no such line --------" file.open(file_name, "r") |infile| while (line_text = infile.gets) if counter == line printline = "#{counter} :: " + line_text break end counter += 1 end end printline end from function getting this @userrole = rolesuser.find(:all, :conditi...

javascript - reject if file name contains non english character -

am trying upload file file name contains in english character symbol or number ,my problem if file name contains english chinese character need validate , need show alert message file name should'nt in non english character can send me code get value of file input, , match against regex \w but should not disallow this. should instead rename file after uploaded. user may upload file name valid in os, invalid on server os. can still store original filename database, if needed.

how to display records in PHP from stored procedure Mysql -

i m creating stored procedure multiple select statement,as shows below: delimiter $$ drop procedure if exists `testsp` $$ create definer=`root`@`localhost` procedure `testsp`( ) begin select area_id,areaname area; select loc_id,locname location; end $$ delimiter ; this shows 2 different results..though want display different in php. php code: $res = $mysqli->query("call testsp()"); while($row = $res->fetch_assoc()) { $arr[] = $row['area_id']; $arr[] = $row['areaname']; $arr1[] = $row['loc_id']; $arr1[] = $row['locname']; } echo '{"users":'.json_encode($arr).'}'; echo '{"users":'.json_encode($arr1).'}'; when try display $arr1,its showing null values...so how display second result sets in php. you have 1 option use union all combine 2 queries. like : select 1 type, area_id id ,areaname name area union select 2 type , loc_id id ,locna...

coldfusion - EntityLoad dates in future -

i have table events. i'm trying display list of events in future. i'm using orm can't figure out life of me how select dates in future. filters accept "=" , not ">". have doesn't work: var events = entityload("tbl_events",{"eventactive" = 1, "eventdate" > now()},"eventdate asc",{maxresults = count}); you have use hql http://help.adobe.com/en_us/coldfusion/9.0/developing/wsf0ed2a6d7fb07688310730d81223d0356fc-7ffe.html var events = ormexecutequery(from tbl_events eventactive = 1 , eventdate > ?, [now()]);

sql - Complex Search with Multiple Models and Geokit using Rails -

i attempting make search complicated (of course, make easier users) i've got app 3 models: campaigns, businesses , locations like so: \\ campaign.rb belongs_to :business has_many :locations, :through => :business acts_as_mappable \\ business.rb has_many :campaigns has_many :locations \\ location.rb belongs_to :business has_many :campaigns, :through => :business acts_as_mappable the way set up, there businesses have multiple locations. don't, geokit info coded campaign database entry. have multiple locations geokit info coded location database entry. i trying search campaigns return results within distance. simple enough when dealing businesses have single address. campaign.find(:all, :conditions => [blahblahblah], :origin => address, :within => distance ) however, want include campaigns belong businesses have multiple locations. want search return result campaign, if business has multiple locati...

Question about integers (php) -

possible duplicate: php: shortest way check if variable contains positive integer? how know, given variable number without residue (and not negative number)? like have numbers (each number variable): 5; 6.416; -76; 254. its better have function, give true or false, like: number "5" true 6.416 false (has residue "416") -76 false 254 true. thanks. this should it: function is_positive_int($n) { return $n && abs(intval($n)) == $n; }

PHP session can't be retrieve after redirection using htaccess -

i have done redirection www.abc.com www.def.com using .htaccess . the redirection successfull have problem whereby cookies , session can accessed when access website using def.com . session missing when checked abc.com. how copy or read session @ def.com ? please me. well can't simply. maybe see this post ?

flash - Getting friend's information from Facebook Graph API -

ok, i'm asking question because can find examples , answers php version. need flash version. i'm trying friends information, think i'm doing wrong because if trace it, it'll give me either [object object] or undefined. i did facebook.api("me/friends", handleapiget); private function handlegetapi(success:object, fail:object):void { if (success) { externalinterface.call("doalert", success); } else { trace("nope"); } } externalinterface.call("doalert", success) returns me [object object], [object object]. did externalinterface.call("doalert", success.name), returns me undefined. any appreciated! i haven't used flash facebook bindigs yet, according outputs , graph api, result array, containing friends list. check manual: https://graph.facebook.com/me/friends?access_token=youraccesstoken&format=json according first result ( [object object], [o...

android - Calling an extrenal application -

how can call external application application? e.g: need call shazam (application) app. can see package name of application in logcat . will useful purpose? you can call third party application's activity in following way. final intent shazamintent = new intent("com.shazam.android"); shazamintent .setcomponent(new componentname("com.shazam.android","com.shazam.android.splash")); startactivity(shazamintent ); but, not great way go it. in case package name changes (which remote possibility) or activity name changes ( splash change else) application break. if shazam has intent can invoked start listening song use (not sure if have one). also, necessary check in case shazam not installed call doesn't crash.

asp.net - how to change the label1 text to block n unblock if checkbox in gridview1 is checked? -

Image
i want if checkbox1 in gridview checked label1 text in gridview block if checkbox1 in gridview unchecked label1 text n gridview unblock ... i want because want .... block unblock user in aspnetdb.mdf membership table. .. whatz wrong in code : protected sub gridview1_selectedindexchanged(byval sender object, byval e system.eventargs) handles gridview1.selectedindexchanged dim linkbutton1 linkbutton = me.gridview1.selectedrow.findcontrol("linkbutton1") dim chk checkbox = me.gridview1.selectedrow.findcontrol("checkbox1") if chk.checked = true linkbutton1.text = "block" dim user membershipuser = membership.getuser(gridview1.selectedrow.cells(1).text.tostring) 'to block specific user: user.isapproved = false membership.updateuser(user) else linkbutton1.text = "unblock" dim user membershipuser = membership.getuser(gridview...

Attached propedrties in WPF and event wiring -

i have attached property (e.g. capitalizing text inside textbox). obvoiusly must subscribe textbox's textchanged event capitalize every time text updates. public class capitalize { // enabling/disabling capitalization public static readonly dependencyproperty enabledproperty; private static void onenabledchanged( dependencyobject d, dependencypropertychangedeventargs e) { var tb = d textbox; if ((bool)e.newvalue) { tb.textchanged += new textchangedeventhandler(tb_textchanged); } else { tb.textchanged -= new textchangedeventhandler(tb_textchanged); } } } as see add event handlers textbox (if understand correctly) creates strong reference. mean because of strong ref gc cannot collect textbox? if yes - @ point should unwire event textbox can collected? the reference goes other way around, i.e. text box holds reference event handler. there no possibility...

In Java is there a static version of 'this' -

i know quite minor, @ top of every class end copying , pasting , changing following line of code. private static final string tag = myclass.class.getname(); what not have modify myclass bit every time copy. i.e. write this. private static final string tag = this.class.getname(); but there no @ point. know minor, learn answers, , indeed learnt stuff searching see if there answer already. you can define eclipse template , called tag , example: private static final string tag = ${enclosing_type}.class.getname(); then, type tag followed ctrl+space , insert statement. i use method declare loggers in classes. alternatively, query stack trace of current thread: private static final string tag = thread.currentthread().getstacktrace()[1].getclassname();

ios - UITabBarItem and selection one of the view -

it's possible select uitabbaritem desired in tabbarcontroller 4 uitabbaritem click on button? sure. set tab bar controller's selectedviewcontroller or selectedindex property desired view controller or tab index.

c - What is the meaning of a struct inside another without a tag name? -

i came across code snippet say:- struct { int mem1; char mem2; struct { int inner_mem1; int inner_mem2; }; }; and found code snippet using inner struct's members directly using outer struct's variable name!!! ex: struct *avar; .... avar->inner_mem1 is legal, code compiling , working fine!. purpose use in way? specific scenarios ? please let me know thoughts. this called "anonymous structure": an unnamed member of structure type no tag called anonymous structure; unnamed member of union type no tag called anonymous union. members of anonymous structure or union considered members of containing structure or union. applies recursively if containing structure or union anonymous. this not part of current c standard, c99, foreseen part of upcoming 1 (citation above). also, many compilers support feature extension.

javascript - DOM access to browser autosuggest for inputs -

there way access list of suggestions browser has stored? can see when focus on textinput same name form previous complete? thanks no, not possible - knowledge, in no browser, not in "intranet" or "local" context. massive security problem if could.

using jquery to find radiobutton groups with no answers -

i've been racking brain find better solution following situation. imagine page lot of radiobuttons on it, , having custom validation highlighting groups of radiobuttons haven't been answered. example html (with answers preselected): <input type='radio' name='a' value='1' /> <input type='radio' name='a' value='2' /> <input type='radio' name='a' value='3' /> <input type='radio' name='b' value='1' checked="checked"//> <input type='radio' name='b' value='2' /> <input type='radio' name='b' value='3' /> <input type='radio' name='c' value='1' /> <input type='radio' name='c' value='2' checked="checked"/> <input type='radio' name='c' value='3' /> <input type='radio' name='d...

class design - Objective-C call private methods -

the following example of private method in objective-c: myclass.m #import "myclass.h" @interface myclass (private) -(void) privatemethod:(nsstring *)arg1 and: (nsstring*)arg2; @end @implementation myclass -(void) publicmethod { nslog(@"public method\n"); /*call privatemethod arg1, , arg2 ??? */ } -(void) privatemethod:(nsstring *)arg1 and: (nsstring*)arg2{ nslog(@"arg1 %@ , arg2 %@", arg1, arg2); } @end i've read private interface / methods declaration. how invoke them other public method ? i've tried [self privatemethod:@"foo" and: @"bar"] doesn't looks right. yes, [self privatemethod:@"foo" and:@"bar"] correct. looks wrong it? , why didn't try it? (btw, it's not private method, it's hidden interface. outside object knows message signature can still call it. "real" private methods don't exist in objective-c.) ...

wpf - How to enumerate all dependency properties of control? -

i have wpf control. example, textbox. how enumerate dependency properties of control (like xaml editor does)? public ilist<dependencyproperty> getattachedproperties(dependencyobject obj) { list<dependencyproperty> result = new list<dependencyproperty>(); foreach (propertydescriptor pd in typedescriptor.getproperties(obj, new attribute[] { new propertyfilterattribute(propertyfilteroptions.all) })) { dependencypropertydescriptor dpd = dependencypropertydescriptor.fromproperty(pd); if (dpd != null) { result.add(dpd.dependencyproperty); } } return result; } found here: http://social.msdn.microsoft.com/forums/en/wpf/thread/580234cb-e870-4af1-9a91-3e3ba118c89c

php - Zend Framework & PHPunit path issues? -

when extend zf class, path errors. here test: <?php require_once ('zend/acl.php'); // gives error w/o require_once ('../application/models/acl.php'); class model_acltest extends controllertestcase { /** * @var model_acl */ protected $acl; public function setup() { parent::setup(); $this->acl = new model_acl(2, 'sims'); } public function testhasusername() { echo $this->acl->username; $this->assert($this->acl->username); } } here model_acl class: class model_acl extends zend_acl { private $username; private $userid; private $userroles; private $allroles; public function __construct($userid, $username) { if (method_exists(parent, '__construct')) parent::__construct(); $this->username = $username; $this->userid = $userid; $this->setroles(); $this->setresources(); ...

c# - Box and UnBox what does it means? -

possible duplicates: why need boxing , unboxing in c#? what boxing , unboxing , trade offs? in c# doe sit means: "box , unbox"? here extract msdn founded text. but convenience comes @ cost. reference or value type added arraylist implicitly upcast object. if items value types, must boxed when added list, , unboxed when retrieved. both casting , boxing , unboxing operations decrease performance; effect of boxing , unboxing can significant in scenarios must iterate on large collections. thanks! here more detailed explanation looks @ internal of common language runtime. first, let's make difference between value types , reference types : a value type held on stack , copy of passed called methods a reference value held in managed heap , stack holds pointer (reference) location. location, , not object, passed called methods if don't know stack (don't offended), it's memory area holds local v...

java - Create custom properties for JMS Queue -

i using jboss.x , ejb3.0. i have 2 jms queues. "a" queue , "error" que. a que has retry mechanism, after 3 retries, msg deliver error queue automatically, , there mdb listen. i want add msg delivered error que, property define. (ofcourse cant add body line, since have rollbacks, , each time rollback being executed, body rollback also) so read little in net, , got can use header purpose(roll backs wont affect it). in order user header custom property must create jmspropertytype , add header. didn't find info how it, mybe show me, or maybe there way of doing this? thanks, ray. transactional retry limits , poison message queues (your error queue) vendor-specific features. they're not in jms spec. should read vendor documentation (jboss, apparently) details. i'm skeptical failing receiver add property message ask. vendor might implicitly add properties itself. think i've seen case (bea jms?) add vendor-specific property fail...

android - Exception when calling setDataSource(FileDescriptor) method (failed.: status=0x80000000) -

i'm developing video streaming application , i'm getting stuck when calling set setdatasource filedescriptor. want application play video being downloaded, once minimum number of bytes, move bytes file can played in file while it's being downloaded in original file. so, check if can start media palyer every packet this: if (mediaplayer == null) { // create mediaplayer once have minimum // buffered data if (totalkbread >= intial_kb_buffer) { try { startmediaplayer(); } catch (exception e) { log.e(getclass().getname(), "error copying buffered conent.", e); } } } else if (mediaplayer.getduration() - mediaplayer.getcurrentposition() <= 1000) { transferbuff...

SQL Server Foreign Key "On Delete Set Null " constraint not working -

i using sql server express 2008 mmse. have set foreign key constraint between tables , set on delete constraint "set null". no seem enforce constraint , left id in field of deleted row. here small screen sho t of how have set where going wrong? table 1 table 2 the ddl posted works fine me. declare @id int; insert deliveryareas(description,rate) values ('to delete', 100) set @id=scope_identity() insert customer(fname,deliveryareaid) values ('test',@id) select id,fname,deliveryareaid customer delete deliveryareas id=@id select id,fname,deliveryareaid customer returns id fname deliveryareaid ----------- ------------------------------ -------------- 1 test 3 id fname deliveryareaid ----------- ------------------------------ -------------- 1 test null can double check enabled status end? selec...

using the find_if() function in c++ -

i errors use find_if function. says no matching function. did find others have come through error, couldn't quite understand replies. please can 1 correct & explain mistakes are? appreciated. in advance. //another way split strings #include<iostream> #include<string> #include<algorithm> #include<vector> using std::endl; using std::cout; using std::cin; using std::string; using std::vector; using std::istream; istream& getwords(istream&, vector<string>&); string& removedelimeters(string&); bool space(char); bool not_space(char); void display(const vector<string>&); int main() { vector<string> words; getwords(cin,words); display(words); return 0; } void display(const vector<string>& vec) { cout<<endl; for(vector<string>::const_iterator iter = vec.begin();iter != vec.end();iter++) { cout<<*iter<<endl; } } bool space(char c) { ...

html - Clear/Overwrite css for a input element -

Image
i have problem styling form. works fine except checkboxes. strange. have @ small rectangle, how looks when place checkbox in html: <input id="check" type="checkbox" name="test" value="test"/> the strange thing is, if remove css not change. there basic css configuration checkbox make standart checkbox? tried things like #check{background: white !important} but not work. any other advice? is default styling browser or have like * { margin: 0; padding: 0 } in css code? if so... that's what's causing default behavior removed , hard put back.

php - codeigniter, uri routing and subcontrollers -

not sure how this... have controller name admin- , want use controllers in subfolder "sub" controllers i.e when user visits mydomain.com/admin redirected if not logged , if visit mydomain.com/admin/customers redirected actual customers class stored in controllers/admin/customers.php i want admin controller handle check if logged in , add on header template? how can route this? if understand correctly, try extending base controllers <?php class my_controller extends controller { function __construct() { parent::__construct(); if(!$this->auth->logged_in()) { redirect('login'); } } } class customer extends my_controller { // if user isn't logged in redirected } i cite once again phil sturgeon

jQuery in Chrome Console (8.0.552.237) -

Image
it appears jquery selectors not functioning in chrome console. type of selector returns "null". scripts run javascript, however. has else noticed change or know of fix. thanks. i uncovered cause of in my own question . the console injects own function (just shorthand) document.getelementbyid() , aliased $ , which shadows jquery's $ . easy way check this: when you're @ breakpoint, , jquery seems broken, compare following in console: jquery $ window.$ the first , last jquery proper, local $ like: function () { return document.getelementbyid.apply(document, arguments) } this because code run console wrapped in with statement: with (window ? window.console._commandlineapi : {}) { (window) { // actual code typed in here } } and window._commandlineapi.$ function shadows jquery. found bug in chromium this: http://code.google.com/p/chromium/issues/detail?id=70969

jquery - using a <a> to run a function() -

i wondering link call function want? <a href="http://catalog.bitsltd.us/power_strips#replaced" onclick="document.getelementbyid('caship').function caship()" id="caship">some text</a> and function want call... can tell me why not working also? <script type="text/javascript"> $(function caship(){ $('#caship').replacewith('some html (the new html has id of replaced)'); }); </script> when link clicked go href, same page , id, doesn't replace < > new html, < div >? update: working code: js <script type="text/javascript"> $(document).ready(function(){ //hide canadian information $('.locationdiv').hide(); //bind links click events $('.loclink').click(function(){ $('#1').hide(); $('#desc_' + $(this).attr('title')).show(); }); }); </script> html <a href...

language agnostic - Novel or lesser known data structures for network (graph) data? -

what more interesting graph data structures working networks? interested in structures may offer particular advantage in terms of traversing network, finding random nodes, size in memory or insertion/deletion/temporary hiding of nodes example. note: i'm not interested in database designs addressing external memory problems. one of personal favorites link/cut tree , data structure partitioning graph family of directed trees. lets solve network flow problems asymptotically faster more traditional methods , can used more powerful generalization of union/find structure may have heard of before.

flash - How do I select a certain node in a tree in flex? -

i'm trying properties 1 single node such name i've set or something. how can go selecting 1 node? can event e.currenttarget.selecteditem.@name; but need grab without event, how can go doing this? it's better data data provider xmltree, because it's xml/xmllist can use construction myxml.nodename[0].@attribute

.net - 'Specify' Postfix on Properties of Auto-Generated Classes from Web Reference -

i need develop web services in .net 4.0, .net 2.0 clients can call services. when create auto-generated proxy classes in visual studio 2010 using 'add web reference...' feature, there boolean properties 'specified' appended property name. for example: public long id { set; get; } public bool idspecified { set; get; } why these properties added? , there can prevent them being added? or can ignore completely? i think properties being generated wsdl.exe or svcutil.exe. exist in proxy classes, , not service, correct? unless you're concerned them being used, wouldn't be, wouldn't bother doing trying them.

jquery - random position of divs in javascript -

i'm trying make divs appear randomly anywhere on webpage javascript. div appears disappears, div appears somewhere else on page disappears, div appears again in random spot on page disappears, , on. i'm not sure on how generate random units in pixels or technique use generate random positions. how do that? here's code: var currentdivposition = mydiv.offset(), mydivwidth = mydiv.width(), mydivheight = mydiv.height(), var mydiv = $('<div>'), finaldivpositiontop, finaldivpositionleft; mydiv.attr({ id: 'mydivid', class: 'mydivclass' }); // defined position: absolute css file. // set new position finaldivpositiontop = currentdivposition.top + math.floor( math.random() * 100 ); finaldivpositionleft = currentdivposition.left + math.floor( math.random() * 100 ); mydiv.css({ // set div position top: finaldivpositiontop, left: finaldivpositionleft }); $('body').append(mydiv); mydiv.text('my posit...

toggle - Trouble with jQuery animate() on a panel that contains the anythingSlider() -

i'm using jquery anythingslider rotate content. have little tab underneath slider user can click on toggle display of entire slider. i'm using jquery animate() function on div wraps entire slider. when this, disables anythingslider arrows, problem. when remove animate function div wrapper, anythingslider arrows work again. have feeling there's problem putting anythingslider inside div has jquery animate function applied it. can confirm this? if so, what's way can toggle display of anythingslider? here on jsfiddle can see problem i'm having arrows not working: http://jsfiddle.net/brianmcculloh/h2hpq/3/ html: <div id="slider-wrapper"> <div id="slider"> <div class="wrapper"> <ul> <li> content... </li> <li> content... </li> <li> content... </li> <li> content... ...

Embed Word document preview in WinForms app -

how can embed word document in form or usercontrol explorer preview panel does? i found this topic , dsoframer isn't available more, should use now? third party tool acceptable if free. the thing noticed prevhost.exe starts winword.exe process -embedding command switch, can't find information on switch. okay found solution, kinda obvious. created usercontrol accesses ipreviewhandler word windows explorer , host preview in control. clsid use {84f66100-ff7c-4fb4-b0c0-02cd7fb668fe} you can use windows 7 api code pack interface declarations. don't know if offical supported microsoft me did job.

asp.net - DotNetNuke: ObjectDataSource for GridView not being found -

as follow-up previous question gridview , dotnetnuke, i'm having little more trouble getting things act correctly. right have simple gridview in ascx file , bind data gridview in .cs file so: discoverycontroller objdiscoverys = new discoverycontroller(); list<discoveryinfo> lstdiscoveries = objdiscoverys.getdiscoverys(moduleid); grddiscoverys.datasource = lstdiscoveries; grddiscoverys.databind(); this works. however, have seen alternate method in tutorial instead defines <asp:objectdatasource> in controller, , seems allow designer more intelligent things, such add functioning delete buttons through checkbox. later on in tutorial, see inline editing being done well, functionality desire. so decided give shot. wit: <asp:objectdatasource id="objdatasource" runat="server" typename="mycompany.modules.discovery.discoverycontroller" /> as dll file in bin folder named mycompany.modules.discovery (which matches assembly n...

python - ListProperty vs StringListProperty on Google App Engine -

i want store lists of integers (user ids), should make them strings , use stringlistproperty, or use listproperty, i'm wondering more optimized, specific stringlistproperty of heterogeneous listproperty (when used integers). i need add users list until reaches number, , create group instance users (in separate entity group). stringlistproperty thin wrapper around listproperty. there's no meaningful difference other element type. from the code itself : class stringlistproperty(listproperty): def __init__(self, verbose_name=none, default=none, **kwds): super(stringlistproperty, self).__init__(basestring, verbose_name=verbose_name, default=default, **kwds) i'd recommend storing integers in plain listproperty, since can query , sort them correctly, ie numerically, in datastore queries, can't if convert them strings...

android - Cannot use ndk-build on Cygwin -

i have use ndk clien't project. using windows 7. i followed installation instructions. have installed cygwin 1.7.1. in cygwin bash, go android ndk root directory. when see contents of directory, usin $dir command, can see contents including ndk-build, when try use ndk-build, result get: $ndk-build bash: ndk-build: command not found. not sure doing wrong. cygwin emulates gnu/linux environment on windows computer. means you're working "shell" not same windows command-line. if type asdf.exe in windows command-line, tries find asdf.exe in current directory. if can find it, file executed. if can't find it, it'll go through every directory of %path% , try again. however, if type asdf in bash (there multiple kind of shells, bourne again shell 1 of them), not after in current directory. instead it'll try find in 1 of path directories. can't give sources here, afaik it's security reasons. if want run file not in path , must p...

javascript - What are some architectural reasons to use node.js aside from scalability? -

the common theme read why use node.js high scalability due it's evented, non-blocking i/o model. i'm trying understand other non-scalability uses cases (and aside being used general server-side javascript engine). does node.js have other use cases if scalability isn't concern of mine? if yes #1, they? is node.js usage appropriate particular type of application architectures? e.g. similar how key/value (nosql - ugh hate term) databases useful other scalability reasons. i think blog posts sums quite well: http://debuggable.com/posts/understanding-node-js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb in short (pro node.js): speed javascript (especially if know already) efficiency node.js great. give try! :)

iphone - Initialize a NSDate object with a specific time -

i have time in string format example 2:00 . want initialize nsdate present date . tried doing nsdatecomponents *comps = [[nsdatecomponents alloc] init]; [comps sethour:2]; i not able compare date object. please help try nsdatecomponents *comps = [[nsdatecomponents alloc] init]; [comps setday:6]; [comps setmonth:5]; [comps setyear:2004]; nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdate *date = [gregorian datefromcomponents:comps]; you should able compare date after that. maybe mean like. think set using today's date , can create nsdatecomponents , set time values. nsdate *today = [nsdate date]; nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *weekdaycomponents = [gregorian components:(nsdaycalendarunit | nsweekdaycalendarunit) fromdate:today]; [weekdaycomponents sethour:12]; [weekdaycompon...

java - making Quartz scheduler persistent without JDBC -

we're building app around mongodb , , have need run cron-like jobs periodically. i've used quartz before kind of thing when projects based around rdbms jdbc. since we're using mongodb our main datastore in project, i'd prefer not introduce rdbms persist quartz jobs, there doesn't seem kind of jobstore implementatiom mongodb. can recommend either way quartz mongodb, or simple alternative quartz? needs simple (run various java jobs manner of configuration, à la cron). we run quartz spring , it's xml file jobs defined , cron expressions. declare job in spring: <bean name="myjob" class="org.springframework.scheduling.quartz.methodinvokingjobdetailfactorybean"> <property name="concurrent" value="false"/> <property name="targetbeanname" value="mybean"/> <property name="targetmethod" value="myscheduledmethod"/> </bean> ...

Honeywell SDK Documentation -

i've been trying write programs honeywell devices, using c#. parts easy, others, requires use of sdk, giving me headaches, since can't find documentation on sdk. have clues can find documentation (if exists)? , sorry bad english. if install sdk, can find documentation in visual studio. press f1 , select filter-setting "honeywell sdk für windows embedded (99ex)"

service - Software usage analytics in C# -

i have project working on , implement sort of software tracking in code. ideally, stuff how launched. how long runs for, feature tracking, etc. use exceptioneer unhandled exceptions, similar usage tracking. this data should anonymous , ideally run service else. , give users option turn off, if wish to... so, should implement myself, or there third parties out there sort of things? know might sticky area, have seen stats iphone app usage. it, why cant we? (if user agrees, of course) [update] based on comments, should have been more clear. winforms .net 4. application, though thinking of updating later wcf. tracking own application, though want know minor information environment (windows os version, sp, maybe proc , ram...) +1 deskmetrics. there library .net apps. check out: https://github.com/deskmetrics/net i've heard they're investing pretty hard on others platforms (like adobe air , mac/cocoa). worthy keep eyes on them.

user controls - Silverlight WrapPanel not displaying items consistently -

Image
we use wrappanel display varying number of buttons (actually usercontrols behave buttons). inside each wrappanel itemscontrol items. oftentimes wrappanel doesn’t display items—if there 4 see 1 or two. behavior not consistent. is there we’re doing wrong? there known issues using wrappanel this? for xaml, usercontrol in our main window: <usercontrol x:name="uccatalogcontent" grid.row="2"> <local:catalog_categoryview /> this categoryview markup. has itemscontrol. items other usercontrols wrappanel inside them: <usercontrol xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:toolkit="http:...

python - changing from tuple to list and vice versa -

how change [('a', 1), ('c', 3), ('b', 2)] ['a',1,'c',3,'b',2] , vice versa? thanks going in first direction [('a', 1), ('c', 3), ('b', 2)] ['a',1,'c',3,'b',2] flattening list . taking accepted answer there , modifying example: >>> l = [('a', 1), ('c', 3), ('b', 2)] >>> list(itertools.chain(*l)) ['a', 1, 'c', 3, 'b', 2] this uses itertools.chain nice tool itertools flattens sequences quite nicely. going opposite way zipping: >>> l = ['a', 1, 'c', 3, 'b', 2] >>> zip(l[0::2], l[1::2]) [('a', 1), ('c', 3), ('b', 2)] zip takes 2 lists , combines list 1's first element list 2's first element in tuple, , on down lengths of list. in one, take even-indexed elements our first list ( l[0::2] ), , odd-indexed elements our second ( l[1...

ruby coding convention for single or double quoting your strings -

i had around couldn't find convention on how use quotes strings, know difference between two, everywhere see code double quotes singles enough, therefor can't recognize pattern. i'm asking because i'd start contributing opensource (not writing code of course) , i'd habit since beginning. rather use single quotes as possible (also enstrong confidence difference between two). and way addendum on html great... (something <div class='ok'/> ) thanks that i don't think there strong convention within entire community. have seen, there seems bias towards ignoring single quotes altogether , using double quotes. in circles, is convention, localized one, not 1 whole community. personally, whenever have several different ways express same thing, tend use different ways convey different semantics. (for example, use curly braces vs. do / end in blocks distinguish between blocks used side effects , blocks used return value.) so, use double...

unicode - Decode function tries to encode Python -

i trying print unicode string without specific encoding hex in it. i'm grabbing data facebook has encoding type in html headers of utf-8. when print type - says unicode, when try decode unicode-escape says there encoding error. why trying encode when use decode method? code a='really long string of unicode html text wont reprint' print type(a) >>> <type 'unicode'> print a.decode('unicode-escape') >>> traceback (most recent call last): file "scfbp.py", line 203, in myfunctionpage print a.decode('unicode-escape') unicodeencodeerror: 'ascii' codec can't encode character u'\u20ac' in position 1945: ordinal not in range(128) it's not decode that's failing. it's because trying display result console. when use print encodes string using default encoding ascii. don't use print , should work. >>> a=u'really long string containing \\u20ac , other t...

A simple prolog syntax question -

in user mode in swi-prolog define function follows: |: test1(+x,+y) :- x >= 0, x =:= y. and in query mode: ?- test1(1, 1). false. i expecting return "true" since 1 greater 0 , 1 equal 1. so did go wrong? this want instead: test1(x,y) :- x >= 0, x =:= y. and then: ?- test1(1, 1). true. adding +, - , ? in front of predicate arguments not part of prolog. convention documenting how predicates should used. here gnu-prolog documentation has say: the mode specifies whether or not argument must instantiated when built-in predicate called. mode encoded symbol before type. possible modes are: +: argument must instantiated. -: argument must variable (will instantiated if built-in predicate succeeds). ?: argument can instantiated or variable. in actual code, should not prefix arguments +.

api - using unicode in Google translate url from python script -

i'm trying use script automatically using google translate apis russian english. here code. mytext = {some text in russian} url = 'https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='+ mytext +'&langpair=ru%7cen' request = urllib2.request(url, none, {'referer': 'http://www.mysite.org'}) now i've tried using various encodings mytext, including unicode, utf-8, windows-1251 never works. either urllib.request complains of non-ascii characters or google returns error code. idea if need codec? use url = 'https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' \ + urllib2.quote(mytext) + '&langpair=ru%7cen' to quote text

asp.net mvc 3 pre-select Html.DropDownListFor not working in nerd dinner -

learning dropdown lists, im trying add rsvp create page nerddinner in scott gu's blog html.dropdownlistfor listing available dinners. i can dropdown list populated cannot dropdown pre select value ("sample dinner 2") want. im using initilizer seed few dinner objects in db. database sql ce 4 using ef 'code first approach'. sorry know v common problem , hate ask, have spent quite time on cant work: viewmodel public class rsvpviewmodel { public selectlist dinnerslist { get; set; } public rsvp rsvp { get; set; } public string selecteditem { get; set; } } controller // //get: /rsvp/create public actionresult create() { rsvp rsvp = new rsvp(); string selected = "sample dinner 2"; var typelist = new selectlist(dbc.dinners.tolist(), "dinnerid", "title", selected); var viewmodel = new rsvpviewmodel { dinnerslist = typelist, rsvp = rsvp, selecteditem = selected }; ...

qt - Should I use KeyPressEvent or QAction to implement keypresses? -

in qt, either implementing keypressevent or creating qaction , assigning key combination allow me act based on keyboard. which of these methods preferred? you should use qaction whenever same event triggered key sequence want may triggered through other ways menu, toolbar or other buttons. way can use same action on several widgets should same trick. excerpt qaction doc : the qaction class provides abstract user interface action can inserted widgets. in applications many common commands can invoked via menus, toolbar buttons, , keyboard shortcuts. since user expects each command performed in same way, regardless of user interface used, useful represent each command action.

c++ - Adding to middle of std::vector -

is there way add values middle of vector in c++? have: vector <string> a; // gets filled "abcd", "wertyu", "dvcea", "eafdefef", "aeefr", etc and want break 1 of strings , put of pieces vector . how that? strings break can anywhere, index = 0, somewhere in middle, or index = a.size() - 1 . you can insert vector @ position i writing v.insert(v.begin() + i, valuetoinsert); however, isn't efficient; runs in time proportional number of elements after element being inserted. if you're planning on splitting strings , adding them in, better off using std::list , supports o(1) insertion , deletion everywhere.

How do you read from a multidimensional variant array returned from a COM object in PHP? -

i'm working com object returns multidimensional variant array (vt_array), , i'm trying read values array. when use print_r($mdarray) displays variant object . ( variant_get_type($mdarray) returns 8204 .) i tried using foreach ($mdarray $onearray) message: warning: loader::getfields() [loader.getfields]: can handle single dimension variant arrays (this array has 2) in c:\inetpub\wwwroot\root\script\fileloader.php on line 135 fatal error: uncaught exception 'exception' message 'object of type variant did not create iterator' in c:\inetpub\wwwroot\root\script\fileloader.php:135 stack trace: #0 c:\inetpub\wwwroot\root\script\fileloader.php(135): loader::getfields() #1 c:\inetpub\wwwroot\root\testloader.php(21): loader->getfields() #2 {main} thrown in c:\inetpub\wwwroot\root\script\fileloader.php on line 135 (the foreach loop on line 135) the information can array using count($mdarray) returns 8 . if here ha...

javascript - Parse SQLite ALTER, CREATE & UPDATE -

my project involves running ad hoc sql statements against sqlite database. i'm looking javascript regex expression parse out alter, create , update sql statements. here's examples , results i'm looking for. create index create index christy... create index if not exists christy... create unique index christy... create unique index if not exists christy... result a = [..."create", "index", "christy"] create table without table constraint create table vicky (id integer primary key autoincrement,name text,score real default .10 check (weight<=1)); create table if not exists vicky (id integer primary key autoincrement,name text,score real default .10 check (weight<=1)); result a = [..."create", "table", "vicky", "id integer primary key autoincrement","name text","score real default .10 check (weight<=1)"] create table table constraint create table vicky...

sql - Is it possible to sort the results of a SELECT query in 2 different ways based on a conditional? -

the following invalid syntax i'm trying essentially: select * categories order menu_order asc parent = '1' || if parent = '0' order id asc; is possible order results of select query differently based on conditional within query? just in case wasn't clear, trying order categories parent menu order , without parent id. edit so here's how database looks like: id | name | parent | menu_order ================================== 1 | apparel | 0 | 2 2 | sports | 0 | 4 3 | hats | 1 | 5 4 | weights | 1 | 3 5 | lights | 0 | 1 the result set of query should be: apparel sports lights weights hats use case in order by, this: select * categories order case when parent = '1' menu_order else id end;

iphone - a view containing UITableView and UITabBar -

i using uinavigationcontroller push , pop other uiviewcontrollers in app. in 1 of uiviewcontrollers using uitabbar switch between different views. 1 of view has uitableview , having difficulty showing tabbar @ bottom. if shows scrolls , down tablecells. didn't use tabbarcontroller because apple documentation recommends not push tabbarcontroller on navigationcontroller stack. thank you. i guess using uitableviewcontroller. view of uitableviewcontroller tableview itself, when add tab bar view add table view. why scrolls it. you should create regular uiview, , add tableview , tab bar view. shani

dns - Two letter or Three Letter Domains? -

why ma.tt able 2 letter domain, when try za.ch says error (http://screencast.com/t/mbesajy3ra)? different domain registrars, , different tlds (top-level domains, .ch part in case, representing switzerland) free place whatever restrictions valid domains under control. among other things, domain rules .ch state: 3.1.2 grounds refusal switch refuse registration of domain name if: c. domain name or ace string contains fewer 3 or more 63 characters, subject statutory exceptions or exceptions approved ofcom or office of communications; they seem require correspondence address within switzerland.