Posts

Showing posts from March, 2011

tsql - How do you turn off a specific bit in a bit mask? -

in tsql, how turn off specific bit in bitmask without having check see if bit set or not? found it! use & ~ this... update mytable set mybitmask = mybitmask & ~128 -- 8th bit myid = 123 the ~ operator flips bits (1s become 0s , 0s become 1s). set value flip 1 want turn off , use & safely turn off 1 specific bit without having check see if bit set.

regex - Get Div Content with Regular Expressions in C# -

i have html code: <div id="top" style="something dont know"> text </div> and want string "text". script looks this: regex search_string = new regex("<div id=\"top\".*?>([^<]+)</div>"); match match = search_string.match(code); string section = match.groups[0].value; messagebox.show(section); is possible c#? use xpath easier http://www.codeproject.com/kb/cpp/myxpath.aspx use xpath selector //div[@id='top'] then u can inner value

forms - SiteFinity 4.0: Trouble Accessing Postback Data in Custom User Control -

i'm trying highly customized hand built form sitefinity 4.0 , problem no matter can't access form's postback data in code behind. form user control , i've added in way described here: http://www.sitefinity.com/40/help/developer-manual/controls-adding-a-new-control.html after struggling several hours, created basic test form , i'm still not able access postback data. i've tried adding enableviewstate="true" on place form data still empty on postback. exact same user control runs , posts data outside of sitefinity. tried other methods of accessing postback data , discovered request.form contain data need. i'd still love access form elements in usual way though, don't have request.form every control on page , loop way, seems hokey. here's code basic form: "basicusercontrol.ascx" <%@ control language="c#" autoeventwireup="true" codebehind="basicusercontrol.ascx.cs" inherits="sitefinity...

Regex to validate dates in this format d/m/yyyy -

i found regex works wonders,but forces leading 0's on month , day , need accept dates have month and/or day in single digit format i tested regex tester: ^(((0?[1-9]|[12]\d|3[01])\/(0?[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0?[1-9]|[12]\d|30)\/(0?[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0?[1-9]|1\d|2[0-8])\/0?2\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0?[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$ this same @ant18 linked, added ? every leading 0 . edit: sry misread asker's name, corrected

iPhone/iPad WebApps don't allow cookies? -

when use <meta name="apple-mobile-web-app-capable" content="yes"> , page doesn't set, load, or retrieve cookies. there way around this? can't find useful in google. uiwebviews don't store cookies. use html5 local storage instead.

Connecting to MySQL database from PHP -

everything find on net tells me provide database user , password connect database. being paranoid usual, don't because means has php source can log database , screw data. way access database? context: http://www.cyberciti.biz/tips/facebook-source-code.html since php parsed interpreter , html output, need not fear there no way hold of php source (guessing have set appropriate measures php source cannot downloaded). block traffic mysql server outside. allow localhost use it.

c# - Running PsExec From IIS: PsExecSVC hanging on remote host -

i trying run .bat file on remote host web page. psexecsvc (on host) hang , not close after execution of batch causing server wait indefinitely. when running exact same code (see @ bottom) in console application service closes , fine... the weird part when batch file consists of 1 liner echo: @echo off echo ------ start ----- exit psexecsvc close , "------ start -----" shown on page. (this want..) on other hand, @echo off echo ------ start ----- echo echo2 exit psexecsvc hang @ end of execution... when manually killing psexecsvc, "------ start -----" shows , stderr prints: psexec v1.98 - execute processes remotely copyright (c) 2001-2010 mark russinovich sysinternals - www.sysinternals.com the handle invalid. connecting novi2... starting psexec service on novi2... connecting psexec service on novi2... starting c:/dbinfo.bat on novi2... error communicating psexec service on novi2: ...

java - Miffed... Simple Code, but ... org.jasypt.exceptions.EncryptionOperationNotPossibleException -

i have used code or similar time , again within server code on web apps, trying make command line utility work maintenance backend. keep on getting encryptionoperationnotpossibleexception , can't see i'm doing wrong in code. test snippet i've used real encrypted string make sure it's not test input. anybody out there see in code exception come from? import org.jasypt.exceptions.encryptionoperationnotpossibleexception; import org.jasypt.util.text.basictextencryptor; public class decipher { /** * @param args */ public static void main(string[] args) { if (args[0] != null) { string encstr = args[0]; string decstr = ""; if (encstr != null && !encstr.equals("")) { try { basictextencryptor textencryptor = new basictextencryptor(); textencryptor.setpassword("1234566789"); decstr = textencryp...

setting proper cocos2d orientation -

in cocos2d application, inside applicationdidfinishlaunching method app delegate, set orientation via [director setdeviceorientation:kccdeviceorientationportrait] because want portrait. however, apple rejected app saying must support upside down portrait well. i'm not how detect this, though. reading currentdevice orientation seems return unknown orientation, questions twofold: 1) how supposed detect orientation can set either portrait or upsidedown portrait (where stay good). 2) suspect i'll have issue splash screen because it's loaded before reach point in delegate. how can detect orientation can set right splash screen? i can edit codes fix first question.. hope using .99.5.. in rootviewcontroller.h, in function -(bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation look line: #elif game_autorotation == kgameautorotationuiviewcontroller { return ( uiinterfaceorientationislandscape( interfaceorientation ) ); }...

makefile - How do I compile this plugin? -

i'm following foo dissector example know how compile it. the foo dissector example shown in link: http://www.wireshark.org/docs/wsdg_html_chunked/chdissectadd.html you'll notice mentions interlink directory contains examples of support files can use , need modify makefile.am & makefile.common etc. i've modified reflect foo module. however, i'd know how build it. tried running automake complains there there no configure.in. sorry i'm not familar gnu build environment yet. also, possible build module standalone? or need other wireshark sources available? have of course installed wireshark-dev under ubuntu. i went through readme.plugins procedure , here i've got: 1) under plugins directory, rename custom.m4.example custom.m4 custom.make.example custom.make custom.nmake.example custom.nmake 2) rename of foo occurrences in files protocol name 3) go top-level wireshark directory , run autogen , configure root ./autogen.sh ./co...

Is there a static way to throw exception in php -

is there "static" way of throwing exception in php? i need throw exception when mysql query fails. i tried this: $re=@mysql_query( $query ) or throw new exception(' query failed '); but it's not working. and i'm using function based on throwexception() function comment @ php: exceptions manual , know if there static way doing without making class. you won't able directly or throw new exception(); because throw statement, not expression. since or operator, expects operands expressions (things evaluate values). you'd have instead: $re = mysql_query($query); if (!$re) { throw new exception('query failed'); } if you're trying use throwexception() function proposed php manual comment, webbiedave points out comment saying need call function instead of throw statement directly, this: $re = mysql_query($query) or throwexception('query failed'); there's no rule in php says need throw exceptions...

php - Large HTML Form - User Experience and Accessibility -

i have large form lot of fields. used fieldset on it. how create better experience user/accessibility large form? think split it. think it? don't re-invent wheel , confuse user. keep simple. break form down separate parts, either separate steps or pages , progress indicator keep user informed of are. form design patterns: http://patterntap.com/tap/collection/forms

ruby - net-ssh and ActiveRecord 3: bringing it all together -

i'm working on small ruby program connect remote mysql bugzilla database, perform query of records, , email details of records group on daily basis. so far, i've been able ssh db server , execute command using net-ssh. here's example: require 'net/ssh' net::ssh.start("db.example.com", "sroach", :password => "secret") |ssh| result = ssh.exec!("ls -l") puts result end that outputs fine. using activerecord 3.0.3, wanted test establish_connection method established connection local mysql database , able execute commands using activerecord. example: require 'active_record' activerecord::base.establish_connection( :adapter => "mysql2", :host => "localhost", :database => "list_tool_development", :username => "my_username", :password => "secretpassword" ) class mailinglist < activerecord::base end mailinglist.fi...

ASP.NET Dates Deployment Issue -

i bought webspace dailyrazor.com. have deployed application have been working on server , trying workout bugs can't seem solve one. i have set database in visual studio use 1 have create dailyrazor same db deployed version use. i using british dates , on localhost datetime displayed: 27/05/2010 09:00 on dailyrazor host displayed: 5/27/2010 9:00 am short dates e.g. 27/04/2010 display same on both servers. this causing issues when entering data errors occur on date fields. any appreciated. thanks, jon have u tried setting globalization in web.config file: <configuration> <system.web> <globalization culture="en-gb" uiculture="en-gb" /> </system.web> </configuration>

Are jQuery and GWT comparable frameworks? -

at work there's bit of discussion around client side framework should use our front end web applications. it's showdown between gwt , jquery , i'm kind of on fence leaning towards jquery. from can tell, gwt , jquery trying solve different problems compared each other because both end existing in web applications space. i suspect if case, comparing 2 may fruitless i'm trying head around if comparing jquery gwt apples apples comparison in same way jquery , extjs can compared, or more beneficial our team ask questions of our application , use answers determine framework better fit us? in addition craig mentions, there another, hardly-ever-discussed reason. building web-site or web-app? a website traditional way of doing things. user clicks on link, browser goes server , downloads new html. @ times, put in ajax calls populate lists or save data, of times transition 1 page happens on server side. a web-app different. think gmail, google calendar, google ...

iphone - iTunesConnect primary language not found -

i want develop iphone app. , paid apple developer's license $99/year , logged in itunesconnect. but when portal ask me select language (language application description) (primary language) cannot find language! how can add language required in application? sorry.. because first time use itunesconnect think primary language description application see primary languge determine languge pages apper i.e pages next steps appear in language specify list. :)

localization - WPF, localisation: reevaluating control values -

i'm doing small research on localisation methods in wpf. heard idea markup extension: <label content="{local:translate {-- label id here --}}" /> i solution much: it's extremely easy implement , seems nicely flexible. i've got 1 concern, however. let's suppose, user changes locale in runtime. how ensure, localized properties reevaluated match new language? you need call dependencyobject.invalidateproperty . keep in mind if binding object implementing inotifypropertychanged reevaluate way of underlying data changing. dependencyobject.invalidateproperty can called on given dependencyproperty such label.content . label label = new label(); label.invalidateproperty(contentproperty); this have done varying properties need re-evaluation. there in depth article on msdn around localization within wpf varying alternatives should investigated.

Having trouble using 'AND' in CONTAINSTABLE SQL SERVER FULL TEXT SEARCH -

i've been using full-text awhile cannot seem relevant results sometimes. if have field an overview of pain medicine 5/12/2006 , user types an overview 5/12/2006 so create search like: "an" , "overview" , "5/12/2006" - 0 results (bad) "overview" , "5/12/2006" - 1 result (good) the containstable portion of query: from ce_activity inner join containstable(view_activities,(searchable), @search) keytbl on a.activityid = keytbl.[key] "searchable" field contains activity title, , start date(converted string) in 1 field it's search friendly. why happen? [update] okay tested noise word theory. used "pain" , "overview" , "5/12/2006" , works fine. but if add "of" fails. 'of' , 'an' must noise words. now question is, how make ignore words, instead of removing result if noise word exists? any tips? perhaps your current w...

c# - How can I make a read only version of a class? -

i have class various public properties allow users edit through property grid. persistence class serialized/deserialized to/from xml file through datacontractserializer. sometimes want user able save (serialize) changes they've made instance of class. yet @ other times don't want allow user save changes, , should instead see properties in property grid read only. don't want allow users make changes they'll never able save later. similar how ms word allow users open documents opened else read only. my class has boolean property determines if class should read-only, possible use property somehow dynamically add read-only attributes class properties @ run-time? if not alternative solution? should wrap class in read-only wrapper class? immutability area c# still has room improve. while creating simple immutable types readonly properties possible, once need more sophisticated control on when type mutable start running obstacles. there 3 choices have, dep...

mercurial - What are the hook parameters passed to external hook program/script? -

the title says it: looking variable names (hg_*) can make use of them in hook script.. oben has best answer, specific cases or poorly documented options can test specific hooks using hook prints variables: hg --config hooks.pre-commit="export| grep hg_" commit where pre-commit can hook want test , commit can command want test. for example 1 showed: export hg_args='commit' export hg_opts='{'"'"'exclude'"'"': [], '"'"'message'"'"': '"''"', '"'"'addremove'"'"': none, '"'"'include'"'"': [], '"'"'close_branch'"'"': none, '"'"'user'"'"': '"''"', '"'"'date'"'"': '"''"',...

php - How do I divide words with certain criteria? -

i have list of 100k names. example: hp dell google microsoft techcrunch stcakoverflow want search database find similar names. looking if name hp no trim if dell trim last 1 called del , if google became goo trim last 3 , if microsoft micro trim rest. , if techcrunch should techcr , if stackoverflow should stackov that. want achieve want find similar names name going search. this answer may possibly you, alternative or something... implementation of levenshtein distance mysql/fuzzy search? or link http://www.artfulsoftware.com/infotree/queries.php#552

javascript - InnerHTML while alerting it alerts with double quotes in firefox but not in IE -

i make innerhtml data , store in database. when tried in firefox coming proper quotes(" or ') attributes. in ie not getting quotes(" or ') attributes. browser issue? answer this. thanks yes, browser issue, in that's how ie it. note quotes aren't mandatory attributes in html, doesn't make ie's output invalid. if want xhtml you'll have create walking dom.

utf 8 - remove utf-8 figure spaces with php -

i have xml files figure spaces in it, need remove php. utf-8 code these e2 80 a9. if i'm not mistaken php not seem 6 byte utf-8 chars, far @ least i'm unable find way delete figure spaces functions preg_replace. anybody tips or better solution problem? have tried preg_replace('/\x{2007}/u', '', $stringwithfigurespaces); ? u+2007 unicode codepoint figure space . please see my answer on similar unicode-regex topic php includes information \x{ffff} -syntax. regarding comment non-working - following works on machine: $ php -a interactive shell php > $str = "a\xe2\x80\x87b"; // \xe2\x80\x87 figure space php > echo preg_replace('/\x{2007}/u', '_', $str); // \x{2007} pcre unicode codepoint notation u+2007 codepoint a_b what's php version? sure character figure space @ all? can run following snippet on string? for ($i = 0; $i < strlen($str); $i++) { printf('%x ', ord($str[$i])); } on te...

com - Is there any way to set a Type's GUID at runtime? -

how can set type's guid dynamically? silly question, have interface exact same across several third-party com objects, has different guid in each. i have c# interface looks so. [guid("1f13d3d8-3071-4125-8011-900d2eac9a7f")] [interfacetype(2)] [typelibtype(4240)] public interface uictrl { //stuff } i want able change guid dynamically @ run time depending on com object user chooses load. can't change meta data, , type.guid has no set property. ideas? i can't use remit.emit because calling assembly doesn't use it. i'm stuck! so ended fixing using part of @slaks's answer , own. took parent interface , generated child interface had guid wanted. assemblyname aname = new assemblyname("multicasterassembly"); assemblybuilder ab = appdomain.currentdomain.definedynamicassembly(aname, assemblybuilderaccess.run); modulebuilder mb = ab.definedynamicmodule("multicastermodule"); typebui...

Delphi 2010 Search Wrap Around -

is there way switch off 'wrapped around' functionality of delphi 2010's search? i understand lots of developers have issues new search function works me except when search wraps around , goes first result again. i know can flag search selection box not work me. miss part of search functionality let search cursor or scope , tell when there no more results. an example of messing me around. have tree view lots of nodes being accessed level indexes (i.e. item.level = 1) , need add new node @ level 0 , of indexes needs shift level + 1. have wasted plenty of time reassigning these indexes second , third time because search function wraps (i cannot use replace doing). it's pain watch code scroll bar every time change , .level = 0 has become .level = 1, .level = 2 etc. thanks in advance. the default behavior in delphi xe dialog box asks restart search beginning of file , including (unchecked) checkbox wrap around without asking . this behavior config...

ruby on rails - What would be a good way to separate different types of user account? -

supposing various type of users, 'normal', 'medium' , 'premium' each 1 different permissions. a kind of permission on permission. for example: only registered users can post a normal user can post 1 post per month a medium user can post 5 posts per month a premium user can post unlimited posts per month and other attributes. what suggest? i suggest @ can can .

scala - trait implementation -

if have traits like: trait {...} trait b extends a{...} trait c1 extends b{...} trait c2 extends a{...} i can write class in 2 ways (c1 , c2 add same functionality) class concrete1 extends b c1 class concrete2 extends b c2 what variant better(efficient)? they identical in terms of performance. if write test this: object traits { trait { def = "apple" } trait b extends { def b = "blueberry" } trait c1 extends b { def c = "cherry" } trait c2 extends { def c = "chard" } class dessert extends b c1 { } class salad extends b c2 { } } and @ bytecode dessert , salad see public traits$dessert(); code: 0: aload_0 1: invokespecial #29; //method java/lang/object."<init>":()v 4: aload_0 5: invokestatic #33; //method traits$a$class.$init$:(ltraits$a;)v 8: aload_0 9: invokestatic #36; //method traits$b$class.$init$:(ltraits$b;)v 12: aload_0 13: invokestatic...

Qt/C++ event loop exception handling -

i having application heavily based on qt , on lot of third party libs. these happen throw exceptions in several cases. in native qt app causes application abort or terminate. main data model still intact keeping in pure qt no external data. so thinking recover telling user there has occurred error in process , should save or decide continue working on main model. currently program silently exits without telling story. as stated in qt documentation here , qt not exception safe. "recovering exceptions" section on page describes thing can in qt application when exception thrown - clean , exit app. given using third party libraries throw exceptions, need catch these @ boundary between external library , qt code, , handle them there - stated in caleb's comment. if error must propagated qt application, must done either returning error code (if possible), or posting event.

using Windows intergrated authentication with SqlRoleProvider in silverlight application -

i working on web application requires users put roles , given different permissions based on roles. can done using forms authentication , sqlroleprovider. but, application used internally within corporate intranet, , forms authentication forces users manually login every time want use application, using windows integrated autenthification looks more elegant, since users logged on corporate domain. there problem roles here, integrated authentication default uses roles built in users windows accounts (group membership , on..). application requires put users custom made roles. far roles concerned having database control more favorable solution. there way use windows integrated authentification (for authentification) sqlroleprovider (for roles , user management)? we've done in our application, have create own roleprovider , specify in web.config. can load roles whatever source like. <rolemanager enabled="true" defaultprovider="myroleprovider"> ...

android - How to use Parcelable and onClickListeners? -

i've been reading on parcelables , more read more i'm getting confused it. what i'm trying following hook external api json data (currently working). i'm parsing json objects fine strings place in hashmap. i'm using listview display data scrollable (currently working) i've setup onclicklistener sets new intent (currently working) here's i'm getting confused - goal allow user click on item in listview take them new screen more detail information item clicked. questions point number 4: do use parcelable class pass in json object intent? best option in case? if parcelable right choice, create new class implements parcelables json object passed in? guess i'm not sure how proceed. examples i've seen have few strings pass writetoparcel() method. not sure how translates objects multiple properties. thank taking time read. there number of ways pass data next activity, way best depends on how complicated data is. optio...

c# - I'm looking for a SPARQL query program -

i have various sparql queries i'd test. there website or simple programm allows me test these queries? i dont want validator one , i'd execute query , result. as pointed above might see if provider has given web interface on sparql endpoint. normaly e.g. dbpedia , bbc backstage etc. for tool allows enter arbitrary endpoint can query might want check twinkle . it's program know this.

tsql - SharePoint SLK and T-SQL xp_cmdshell safety -

i looking tsql command called "xp_cmdshell" use monitor change slk (sharepoint learning kit) database , execute batch or powershell script trigger events need. (it bad practice modify sharepoint's database directly, using api) i have been reading on various blogs , msdn there security concerns approach. sites suggest limit security command can executed specific user role. what other tips/suggestions recommend using "xp_cmdshell"? or should go way , create script or console application checks if change has been made? i running server 2008 sql 2008. why don't create clr sp using c# , have take care of calls api , other external processes within it. safer , easier manage because need grant execute access clr sp.

javascript - Firebug hits my debugger statement. What does 'continue' do and what does 'disable' do? -

if hit continue, code execute after debugger statement? if hit disable, debugger statement vanishes. how code execute? nothing? execute after debugger statement? or start beginning (i.e., refresh)? clicking "continue" resumes normal execution after debugger statement. clicking "disable" both resumes normal execution and disables break point, next time block of code executed, debugger statement ignored. in other words, "disable" same "continue", prevents being prompted next time.

sorting - How to sort an array in php based on contained associated array? -

i have array of associative arrays: a[0] = array("value" => "fred", "score" => 10); a[1] = array("value" => "john", "score" => 50); a[2] = array("value" => "paul", "score" => 5); i sort "a" array based on "score" value of associated arrays it become: a[0] = array("value" => "paul", "score" => 5); a[1] = array("value" => "fred", "score" => 10); a[2] = array("value" => "john", "score" => 50); can please me? you need use usort , comparison function. something like: function cmp($a, $b) { if ($a['score'] == $b['score']) { return 0; } return ($a['score'] < $b['score']) ? -1 : 1; }

javascript - IE Display Bug, jQuery bug -

so built complex ajaxy jquery module on homepage, of "scrollable" flowplayer.org . it works fine me on chrome, opera, firefox ... of course ie not playing friendly (regardless of version, testing). objects not displaying should, overlaying each other, , when click button divs disappear. however, if resize ie browser window , down, display fixes itself. if click on 1 of buttons made, messes again. until resize window again , looks fine. to see problem: go makemeheal.com visit couple of product pages (you need product browsing history see module) go to: http://www.makemeheal.com/mmh/home.do?forceshowie=1 look @ "your recent history" module. (note forceshowie=1, because default hide ie people) i thinking maybe there way force ie redraw entire module sometimes? or maybe has better idea on how fix underlying problem? source code available here: http://www.makemeheal.com/mmh/scripts/recenthistory.js http://www.makemeheal.com/mmh/styles/recenth...

wmi - Obtaining %appdata% from windows service [C++] -

as in topic - there way logged user appdata environment variable? in application there no problem shgetfolderpath() or getenv("appdata") in service these methods doesn't work. runs "system" account. i think should way obtain %appdata% using wmi i'm not sure that. %userprofile% second point of interest handle when %appdata%. from service viewpoint, there's no such thing "the" logged-on user. there might zero, 1 or more. furthermore, indicates design error if service needs it. real problem you're trying solve?

iphone tcp/ip via accessory port? -

i'd love able mod iphone tcp/ip stack route packets on accessory port either serial or better yet usb or firewire... the applications i'm researching wouldn't able use wifi, 3g or bluetooth... custom apps written use serial port available via accessory port, nice support generic apps need network access. i haven't tracked down info relating this, have thoughts?? about way work jailbreak device, , quite low level hacking. os x supports nkes (network kernel extensions) allow introduce new network interface. don't know if iphone os has these (as there's not information on - it's supposed black box). if did, you'd have make ke lie , claim e.g. wifi device, many applications probe network availability searching wifi interface. basically, think untenable idea. can use external accessory apis allow custom apps use dongle network service provider, can't use provide new network interface. if want kind of open, extensible platform, iphone no...

Regex in URL Rewriting to match Querystring Parameter Values in any order? -

many url rewriting utilities allow regex matching. need urls matched against couple of main querystring parmeter values no matter order appear in. example let's consider url having 2 key parameters id= , lang= in no specific order, , maybe other non-key params interspersed. an example url matched key params in order: http://www.example.com/surveycontroller.aspx ? id=500&lang=4 or http://www.example.com/surveycontroller.aspx ? lang=4&id=500 maybe interspersed non-key params: http://www.example.com/surveycontroller.aspx ? lang=3&id=1 &misc=3&misc=4 or http://www.example.com/surveycontroller.aspx ? id=1 &misc=4& lang=3 or http://www.example.com/surveycontroller.aspx?misc=4& lang=3&id=1 or etc is there regex pattern match against querystring param value in order, or best duplicate rules, or in general should other means? note : main querystring values captured using brackets i.e. id=(3)&lang=(500) , substituted destin...

file io - In Java, when I call OutputStream.close() do I always need to call OutputStream.flush() before? -

if call close() in output stream, output guaranteed, or need call flush() always? close() flushes no need call. edit: answer based on common sense , outputstream encountered. going implement close() buffered stream without flushing buffer first? there no harm call flush right before close(). however, there consequences if flush() called excessively. may defeat underneath buffering mechanism.

objective c - Selecting random numbers iphone sdk -

i want select 10 random numbers 1 35. i trying following, repeated numbers int totalnumbercnt = 1; while (totalnumbercnt < 11) { int randomnumber1 = 1 + arc4random() % 35; nsstring *numberstring = [nsstring stringwithformat: @"%d",randomnumber1]; nslog(numberstring); [firstnumber addobject:numberstring]; [secondnumber addobject:numberstring]; totalnumbercnt++; } thank help. repeated numbers expected; random after all, , random sample contain repeats.

android - AlerDialog is not created - java.lang.IllegalArgumentException: Activity#onCreateDialog did not create a dialog for id X -

i want create normal alertdialog. used example provided android dev docs. changed dialog_paused_id dialog_deletedb. if execute code , press button in return should create dialog, following error log: 04-29 01:01:20.973: warn/dalvikvm(1168): threadid=3: thread exiting uncaught exception (group=0x4001b188) 04-29 01:01:20.973: error/androidruntime(1168): uncaught handler: thread main exiting due uncaught exception 04-29 01:01:20.993: error/androidruntime(1168): java.lang.illegalargumentexception: activity#oncreatedialog did not create dialog id 4 04-29 01:01:20.993: error/androidruntime(1168): @ android.app.activity.createdialog(activity.java:871) 04-29 01:01:20.993: error/androidruntime(1168): @ android.app.activity.showdialog(activity.java:2483) 04-29 01:01:20.993: error/androidruntime(1168): @ mjb.project.avv.favs.onmenuitemselected(favs.java:111) 04-29 01:01:20.993: error/androidruntime(1168): @ com.android.internal.policy.impl.phonewindow.onmenuitemselected(phon...

xcode4 - "Run > Stop on Objective-C exception" in Xcode 4? -

maybe knows "run > stop on objective-c exception" menu in xcode 4? i've used in xcode 3, disappeared in new ide. in left side column of xcode 4: tap on breakpoint tab (the 6th tab over) tap on + button in bottom left of window tap 'add exception breakpoint' tap 'done' on popup

iphone - jQTouch and PhoneGap -

hey guys, isn't question as wanted post people might have been running similar frustrations/issues using jqtouch , phonegap together. i started developing iphone app jqtouch , phonegap , running lot of different little glitches, ui anomalies, etc. , after ton of digging, saw jonathan stark posted new version of jqtouch (revision 161) @ https://github.com/senchalabs/jqtouch , version alot more stable , straight forward. don't know if anyone, thought i'd post because pulling hair out trying components work (like functionality, etc.) hope helps. i have had best successes beedesk fork of jqtouch. seems have features , bugfixes :) https://github.com/beedesk/jqtouch

c# - How to get the row and column of button clicked, in the grid event handler? -

once added button in grid(window control grid, not gridview or datagrid) clicked, how find row , column button located in grid event handler, click event or other events? not button click event handler #region grid event handler setup mygrid.mouseenter += new mouseeventhandler(mygrid_mouseenter); mygrid.mouseleave += new mouseeventhandler(mygrid_mouseleave); mygrid.mousedown += new mousebuttoneventhandler(mygrid_mousedown); mygrid.mouseup += new mousebuttoneventhandler(mygrid_mouseup); #endregion thanks i notice boyan has solution button click event handler case in wpf, how can determine column/row in grid control in? in click event handler button say: int row; button btn = sender button; if (btn != null) { row = grid.getrow(btn); // , have row number... } else { // nasty error occurred... } see inputhittest() : uielement element = (uielement) grid.inputhittest(e.getposition(grid)); row= grid.ge...

casting - How to initialize static const char array for ASCII codes [C++] -

i want initialize static const char array ascii codes in constructor, here's code: class card { public: suit(void) { static const char *suit[4] = {0x03, 0x04, 0x05, 0x06}; // here's problem static const string *rank[ 13 ] = {'a', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'j', 'q', 'k'}; // , here. } however got whole lot of errors stating 'initializing' : cannot convert 'char' 'const std::string *' 'initializing' : cannot convert 'int' 'const std::string *' please me! thank much. you initializing 1 array of characters, want: static const char suit[] = {0x03, 0x04, 0x05, 0x06}; static const char rank[] = {'a', '2', ...}; the forms using declaring arrays of strings , initializing them single strings. if want rank array of strings, initializers need in ...

Setting up proper testing for Django for TDD -

i've been ignoring need test project far long. so spent more day looking ways implement tests current apps , trying tdd going new apps. i found lot of "tutorials" steps: "1. install 2. install 3. install thisnthat 4. done!", noone seems talk how structure tests, both file , code wise. and noone ever talks how set ci server, or integrate testing deployment of project. lot of people mention fabric, virtualenv , nose - noone describes how work them whole. what keep finding detailed information how set proper rails environment testing , ci etc... does else feel django community lacks in area, or me? :) oh, , else have suggestions on how it? as see it, there several parts problem. one thing need unit tests. primary characteristic of unit tests fast, can test combinatorial possibilities of function inputs , branch coverage. speed, , maintain isolation between tests, if running in parallel, unit tests should not touch database or netwo...

LISP: Keyword parameters, supplied-p -

at moment i'm working through "practical common lisp" peter seibel. in chapter "practical: simple database" ( http://www.gigamonkeys.com/book/practical-a-simple-database.html ) seibel explains keyword parameters , usage of supplied-parameter following example: (defun foo (&key (b 20) (c 30 c-p)) (list b c c-p)) results: (foo :a 1 :b 2 :c 3) ==> (1 2 3 t) (foo :c 3 :b 2 :a 1) ==> (1 2 3 t) (foo :a 1 :c 3) ==> (1 20 3 t) (foo) ==> (nil 20 30 nil) so if use &key @ beginning of parameter list, have possibility use list of 3 parameters name, default value , third if parameter been supplied or not. ok. looking @ code in above example: (list b c c-p) how lisp interpreter know c-p "supplied parameter"? let's reindent function foo : (defun foo (&key (b 20) (c 30 c-p)) (list b c c-p)) if indent see function has 3 keyword parameters: a, b , c....

cpu architecture - Does evolution of microprocessors warrants evolution of compilers and language standards? -

as chip makers add new functions, instructions etc new chips, need newer versions of compilers accordingly use new instructions , features of chip? mean programming language needs new opcodes,syntax etc use new features of chip? yes, new hardware features reflected in language extensions , in new languages. example, see various vector extensions c , c++ reflects availability of simd instructions, , new derived data-parallel languages cuda , opencl. if hardware different others, require own, different programming language, see late transputers , occam language.

java - How to pass an object from one activity to another on Android -

i trying work on sending object of customer class 1 activity , display in activity . the code customer class: public class customer { private string firstname, lastname, address; int age; public customer(string fname, string lname, int age, string address) { firstname = fname; lastname = lname; age = age; address = address; } public string printvalues() { string data = null; data = "first name :" + firstname + " last name :" + lastname + " age : " + age + " address : " + address; return data; } } i want send object 1 activity , display data on other activity . how can achieve that? one option letting custom class implement serializable interface , can pass object instances in intent using putextra(serializable..) variant of intent#putextra() method. pseudocode : //to pass: intent.putextra("myclass", obj); // ret...

serial port - Hyper-V: Connecting VMs through named pipe loses data -

we trying connect 2 hyper-v vms through serial port. hyper-v exposes serial port named pipe host system, , implements server end of named pipe. consequentially, connect them, need write named-pipe client connects both vms, , copies data , forth. we have written such application . unfortunately, this application loses data . if connect 2 hyperterms, , have them exchange data, transmission succeeds, in many cases, receiving end reports errors, or transmission deadlocks. likewise, if use link run kernel debugger, seems hang often. what cause of data loss? precautions must taken when connecting named pipes in such manner? edit : have worked around problem, using kdsrv.exe . com port of debuggee continues exposed through named pipe, however, debugger end talks kdserv via tcp. the data loss not due named pipes. infact com ports (emulated , physical) may lose data since operate small buffer in uart. the named pipe receives data written com port. program reads data nam...

c# - Asp.Net MVC EditorTemplate Model is lost after Post -

i have controller 2 simple methods: usercontroller methods: [acceptverbs(httpverbs.get)] public actionresult details(string id) { user user = userrepo.userbyid(id); return view(user); } [acceptverbs(httpverbs.post)] public actionresult details(user user) { return view(user); } then there 1 simple view displaying details: <% using (html.beginform("details", "user", formmethod.post)) {%> <fieldset> <legend>userinfo</legend> <%= html.editorfor(m => m.name, "labeltextboxvalidation")%> <%= html.editorfor(m => m.email, "labeltextboxvalidation")%> <%= html.editorfor(m => m.telephone, "labeltextboxvalidation")%> </fieldset> <input type="submit" id="btnchange" value="change" /> <% } %> as can see, use editor template "labeltextboxvalidation": <%@ control language="c#" inherits="system....

Ruby on Rails - Unable to add "".jpg" file -

i new ruby on rails. i want add ".jpg" file under /public/images folder. can me? when navigate add new page, don't see picture format in menu. please asap. if working rails3.1 or next of that, there app/assets/images folder in application directory. , there default image rails.png available. add images on there , use them follows: <%= image_tag "/assets/rails.png"%>

java - Calculating LCOM3? -

are there opensource/free libraries can use calculate lcom3 or lcom4 class cohesion metric? want write tool reads in java files , calculate metric. this metric is available in sonar .

javascript - Display dynamically created php image after POSTing data -

i have php script outputs image, how can post data , display resulting image without refreshing rest of screen, far have got code below returns png. function go(){ $.post("test_image.php", $("frm").serialize(), function(data){ //alert(data);//proves png image returned. //how display returned image (preferably '$("#modified")') }); } i can't display returned image. you take resulting data , put data: uri (more info here ) won't work in ie, slow, not cachable in way , uses 33% more memory necessary due base64 encoding. the elegant way script write image data file, , return url of new image. your ajax callback simple $("#myimage").src = data;

System.Runtime.InteropServices.COMException error occur in vs2010 c# -

Image
when execute vs2005 project on vs2010 break point appear , message appear on line chartpage.export(@"c:\excel_chart_export.jpg", "jpg", misvalue); give me solution can use without error in vs2010? there's wrong project itself, has dependency on com object. grab crash dump , see stack trace. http://blogs.msdn.com/b/tess/archive/2009/03/20/debugging-a-net-crash-with-rules-in-debug-diag.aspx

.net - How to make TabPages draggable? -

i'd enable user rearrange tabpages order dragging , dropping. it'd cool enable user drag tabpages 1 tabcontrol another. both way in firefox , total commander. how achieve this? reordering tabpages drag , drop - by ludwig b. inspired http://dotnetrix.co.uk/tabcontrol.htm#tip7 private void tc_mousedown(object sender, mouseeventargs e) { // store clicked tab tabcontrol tc = (tabcontrol)sender; int hover_index = this.gethovertabindex(tc); if (hover_index >= 0) { tc.tag = tc.tabpages[hover_index]; } } private void tc_mouseup(object sender, mouseeventargs e) { // clear stored tab tabcontrol tc = (tabcontrol)sender; tc.tag = null; } private void tc_mousemove(object sender, mouseeventargs e) { // mouse button down? tab clicked? tabcontrol tc = (tabcontrol)sender; if ((e.bu...

c - Making pascal's triangle with mpz_t's -

hey, i'm trying convert function wrote generate array of longs respresents pascal's triangles function returns array of mpz_t's. following code: mpz_t* make_triangle(int rows, int* count) { //compute triangle size using 1 + 2 + 3 + ... n = n(n + 1) / 2 *count = (rows * (rows + 1)) / 2; mpz_t* triangle = malloc((*count) * sizeof(mpz_t)); //fill in first 2 rows mpz_t one; mpz_init(one); mpz_set_si(one, 1); triangle[0] = one; triangle[1] = one; triangle[2] = one; int nums_to_fill = 1; int position = 3; int last_row_pos; int r, i; for(r = 3; r <= rows; r++) { //left side triangle[position] = one; position++; //inner numbers mpz_t new_num; mpz_init(new_num); last_row_pos = ((r - 1) * (r - 2)) / 2; for(i = 0; < nums_to_fill; i++) { mpz_add(new_num, triangle[last_row_pos + i], triangle[last_row_pos + + 1]); triangle[position] = new_num; mpz_clear(new_num); position++; } nums_to_fill++; //ri...

scripting - Python repl in python application -

hello learning python(so can use qt python not c++) , i'm curios if possible embed python interpreter in application repl. give users possibility script app using python either loading file (and file act plugin app) or evaluating code entered in text box or that. can embed interpreter in c or c++ , script app using python can done if application written in python(and made stand-alone binary using py2exe or similar)? anders did c# repl or miguel mono. thanks. well, possible, not beginner stuff :p python offers read-eval loop module, you'd still have create console in qt can type in input , display results. same goes plugin system. it's easy import script plugin , plugin has import application access it's state. that's hardly real plugin system, you'd want create proper api plugins don't break whenever in app changes.

c - How to format a function pointer? -

is there way print pointer function in ansi c? of course means have cast function pointer void pointer, appears that's not possible?? #include <stdio.h> int main() { int (*funcptr)() = main; printf("%p\n", (void* )funcptr); printf("%p\n", (void* )main); return 0; } $ gcc -ansi -pedantic -wall test.c -o test test.c: in function 'main': test.c:6: warning: iso c forbids conversion of function pointer object pointer type test.c:7: warning: iso c forbids conversion of function pointer object pointer type $ ./test 0x400518 0x400518 it's "working", non-standard... the legal way access bytes making pointer using character type. this: #include <stdio.h> int main() { int (*funcptr)() = main; unsigned char *p = (unsigned char *)&funcptr; size_t i; (i = 0; < sizeof funcptr; i++) { printf("%02x ", p[i]); } putchar('\n...

c# - WPF: Add controls from code -

i'm used windows forms not wpf. think wpf has great advantages i'm trying use in new projects. my problem next: have xml file witch tells me controls have add form xml change need to: read xml file (solved, no problem) create custom wpf form data have read. is possible? or should use windows forms? yes possible. wpf offers several ways of creating controls either in xaml or in code. for case if need dynamically create controls, you'll have create them in code. can either create control directly using constructors in: // create button. button mybutton= new button(); // set properties. mybutton.content = "click me!"; // add created button created container. mystackpanel.children.add(mybutton); or create controls string containing xaml , use xamlreader parse string , create desired control: // create stringbuilder stringbuilder sb = new stringbuilder(); // use xa...

http - Android: HTTPClient -

i trying http-cleint tutorials svn.apache.org. while running application getting following error in console. [2010-04-30 09:26:36 - halloandroid] activitymanager: java.lang.securityexception: permission denial: starting intent { act=android.intent.action.main cat=[android.intent.category.launcher] flg=0x10000000 cmp=com.org.example/.halloandroid } null (pid=-1, uid=-1) requires android.permission.internet i have added android.permission.internet in androidmanifest.xml. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.org.example" android:versioncode="1" android:versionname="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".halloandroid" android:label="@string/app_name" android:permi...

Plain Html and javascript execution offline -

can html , javascript run offline application? i'm looking running webpage offline silverlight oob applications. if browser closes, want way run webpage again without going online. possible? the html 5 draft introduces mechanisms webpage used offline application although, obviously, recent draft spec isn't supported browsers. you can file > save as , save html file , associated js locally.

html - Display: table-cell, contents and padding -

Image
i have straightforward html page displays content in 2 columns. format columns i'm using <div> outer container (display: table-row) , 2 inner <div> actual columns (display: table-cell). 1 of these columns has padding @ top. markup looks following - markup , styles omitted clarity: <style> .row { display: table-row } .cell { display: table-cell; border: 1px solid black; width: 150px } .content { background-color: yellow } </style> <div class="row"> <div class="cell"> <div class="content">some content; not padded.</div> </div> <div class="cell"> <div class="content">more content; padded @ top.</div> </div> </div> i'm getting this: but expected this: the behavior same whether padding-top applied cell or content. missing anything? thanks. you can achieve 2 desired results using padding ...

c# - Looking for a good implementation that will access multiple databases simultaneously -

i want find out if there's implementation (in c#/asp.net) on how access records different databases simultaneously. have simple application suppose search on these databases, then, display record if keyword matched. i have 5 databases (currently using mysql) in , expanding on future (might changing sql server). aware on how search on single database, while i'm still learning how in multiple databases. any tips, comments or suggestions? i can't mysql, in sql server can select multiple databases (so long user connecting has correct permissions). if tables similar across databases perhaps in 1 query unioning results together. so, if had 3 databases (called db1 , db2 , db3 ) , each had table called records this: select * db1.dbo.records name '%searchterm%' union select * db2.dbo.records name '%searchterm%' union select * db3.dbo.records name '%searchterm%'