Posts

Showing posts from May, 2010

string - How to get a specific field from delimited text -

i have string of delimited text ie: value1:value2:value3:value4:value5:value6 how extract, example, specific value ie: label.caption := getvaluefromdelimitedtext(2); value2 thanks in advance paul this should it: function getvaluefromdelimitedtext( const s: string; const separator: char; const index: integer ): string; var i, itemindex, start: integer; begin itemindex := 1; start := 1; := 1 length(s) begin if s[i]=separator begin if itemindex=index begin result := copy(s, start, i-start); exit; end; inc(itemindex); start := i+1; end; end; if itemindex=index begin result := copy(s, start, length(s)-start+1); end else begin result := ''; end; end; this version allows specify separator, pass ':' . if ask item beyond end function return empty string. change exception if preferred. finally, have arranged uses 1-based indexing per example, choose 0-based indexing. ...

python - Finding index of the same elements in a list -

suppose have find each index of letter 'e' in word "internet": letter = 'e' word = 'internet' idx = word.index(letter) but code gives first index. how can find rest of them? mark's answer better single letter. i'm adding in case real substring longer single character. if want use str.index() , can take optional start position , raise valueerror if desired substring not found: >>> letter = 'e' >>> word = 'internet' >>> last_index = -1 >>> while true: ... try: ... last_index = word.index(letter, last_index + 1) ... print last_index ... except valueerror: ... break ... 3 6

mysql - PHP : How can I synchronize one online sql database with another offline database? -

currently working on bus ticket booking site here want run site offline when online server not working due internet problem or server error occurs. problem when run site offline through xammp server how can find last insert bus id online server , how online server know last offline bus_id . anyone can book ticket online 1 pc handle offline site. you have insert communication between servers if both online. or use different ids both servers (largs ids offlie / small ids online).

logging - microSD card FAT module -

i have been using ualfat microsd board ghi electronics data logging, have been having problems reliability; of function calls, @ times, take far longer can handle. using msp430 microcontroller talk ualfat. what similar boards out there possibly use instead of ualfat more reliable? or what favorable oem solution if needed design own interface board work msp430? i think bit differently. flash based storage device have variable timing on writes. 1 file system , wear leveling , features that. tends nature of flash since have erase whole blocks , move things around. if can't live variable timing, i've done in past move piece out of time critical portion of code. typically add queue time critical code writes to, , in background pull queue , write sd card. in rtos, lower priority task. in polling loop, function called when system idle. this changes constraint being worst case timing function call being able meet average throughput requirements logging. worst ca...

c# - How to add Assembly-References on a per-configuration-basis -

i'm looking add debug code windows phone project. debug code drag in debug class library references (nunit helpers) , wcf service client references, , i'd not have these referenced in release build. can suggest way can add assembly-reference debug, not have appear in release? i've seen on connect - https://connect.microsoft.com/visualstudio/feedback/details/106011/allow-adding-assembly-references-on-a-per-configuration-basis-debug-release - it's marked "postponed" there's request on visual studio's uservoice marked closed won't fix here: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2062487-allow-assembly-references-to-switch-based-on-confi both cases using msbuild condition , you've once configure csproj , forget this. first: using condition create new project debugonlyhelpers reference debug-specific helpers in project specify condition in csproj file need filter references: ...

android - how to change the color of the list items in list view -

i using listview in activity class. i'm not using xml code listview. unable change color of text item in listview. i changed background color of listview unable change color of list items. got links internet not able figure out. can me code? my activity class looks this: listview listview; // create array of strings, put our listactivity string[] names = new string[] { "india", "malaysia" }; textview tv = new textview(getapplicationcontext()); tv.settext("select country"); tv.settextcolor(012); listview = getlistview(); listview.addheaderview(tv); listview.setcachecolorhint(color.rgb(36, 33, 32)); listview.setbackgroundcolor(color.rgb(225, 243, 253)); this.setlistadapter(new arrayadapter<string>(this,android.r.layout.simple_expandable_list_item_1,names)); } above, tv.settextcolor set heading of list items. , not working asking me pass integer value...

iis 7 - Classic ASP .CopyFile "Permission Denied" error on Windows Server 2008, IIS 7 -

we upgrading our intranet web server windows server 2000, iis 4 environment windows server 2008, iis 7 environment. part of upgrade, i'm modifying classic asp application make work in new environment. one of pages attempts create new word file copying template file (.dot) word file (.doc) in same directory on web server, using command: fs.copyfile docroot & templatefile,docroot & docname, true note - docroot absolute path, not virtual path. the destination folder set have full permissions for: everyone administrators iusr iwam accounts i still following error: microsoft vbscript runtime error '800a0046' permission denied just wondering if had seen this, , if there workaround available. (i attempted set default application user use permissions, didn't work, either...) the problem in windows 2008 /2008 r2 uac service born in vista era. secures in inetpub directory ... workarround try put file in users/public/ directory, mod...

python - Automating capture of Extent from multiple mxds with multiple dataframes -

i want create single shape file multiple mxd's have multiple frame sets different extents in them. have found/started python script (code below) can't figure out how write captured x&y max/min shape file created this. see output below - attribute error generated. i want write scale , title of frame file name of mxd in extents shape file. would appreciate in completing script. thanks, george --- code start import arcpy, os, glob path = 'p:\\2011\\job_031_townplanning_seriesproduction\\working\\mxd\\1' os.chdir(path) mxds_list = glob.glob('*.mxd') mxd2 = glob.glob('*.shp') count_mapdocs = len(mxds_list) print 'processing ' + str(count_mapdocs) + 'map documents...' #create polygon shapefile arcpy.createfeatureclass_management(path, 'extents.shp', "polygon") arcpy.createfeatureclass_management(path, 'mxds.shp', "polygon") #start loop mxd2 in mxds_list: mapdoc = arcpy.mapping.mapd...

Highcharts how to pass milliseconds to pointStart (really a javascript question) -

what trying pass variable pointstart option of highcharts. here's part of javascript <script type="text/javascript"> var dttemp = '1303401600000'; // dttemp datetime in milliseconds </script> dttemp purpose of question assigned above, comes code-behind using variable opposed entering number directly functional requirement. what use dttemp variable start point highcharts series. appropriate way assign dttemp pointstart . example of pointstart in action can seen in jsfiddle . series: [{ data: [29.9, 71.5, 106.4], pointstart: dttemp, // not work pointinterval: 3600000 }] the code above not work, highcharts not accept dttemp is. pretty new of assume problem dttemp string wants number (double?). however, replacing above following not work: pointstart: number(dttemp), // not work either so bit @ loss problem is. insight may able provide appreciated. in advance! edit: solution per mvchr reply: pointsta...

Is there any free simple SCORM 2004 Javascript player? -

is there free, open source lightweight scorm 2004 player in javascript? looking not bound technology (php, .net, java), implementing basic scorm 2004 lms api functions, handling error codes , maybe parsing scorm manifest. thanks. update: have made very simple javasript scorm 2004 api (but still looking more mature code). update2: have found nice project tinylms . it's scorm 1.2 only, have negotiated client scorm 1.2 sufficient. gonna make solution based on tinylms. slowly growing - https://github.com/cybercussion/scobot . focused more content implementation of scorm 2004/1.2 protocols. there local_api_1484_11.js meant mimc of lms runtime. light weight , not robust full implementation, start @ rate. based work on claude ostyn , countless other resources online (adl, scorm.com etc ..) if affiliated non-profit/non-commercial project in contact me. have more complete version of this. i have bookmarklet checking status of content running on lms located @ http...

Visual Studio 2010 - cannot find color setting for identifier-matching -

i looking option set background/highlight color identifier-matches on visual studio. for example, if have identifier: int mynumber=0 now, put cursor on middle of mynumber. visual studio highlights other occurrances of mynumber on page. i cannot, life of me, find color settings highlighting. @ moment in color scheme looks color selected text. so, confusing , affects productivity. if can track down, hero. it's few months late, setting you're looking highlighted reference .

ruby - The tcp client can not receive data from eventmachine -

there code, client: require 'rubygems' require 'benchmark' require 'socket' i=0 tcpsocket.open "127.0.0.1", 8080 |s| s.send "#{i}th sending", 0 if line = s.gets puts line end end the server: require 'rubygems' require 'benchmark' require 'eventmachine' class handler < eventmachine::connection def receive_data(data) sleep 2 # simulate long running request send_data "send_response" puts data end end eventmachine::run { eventmachine::start_server("0.0.0.0", 8080, handler) puts "listening..." } the client can not print anything it's interaction between s.gets in client , send_data "send_response" in server. your small test works fine me when change: send_data "send_response" to send_data "send_response\n" the s.gets waiting newline remote client. none comes.

cordova - Weird bug with phonegap ios -

i writing iphone application using phonegap , ios. have weird problem. have nsstring holds json string in objective c plugin class. , call callback function provided running phonegap.exec , callback neither success or failure gets called. here code: pluginresult* pluginresult = [pluginresult resultwithstatus: pgcommandstatus_ok messageasstring: jsonstring ]; [self writejavascript:[pluginresult tosuccesscallbackstring:self.callbackid]]; my success callback alerts argument passed. weird thing that, if pass in non jsonstring example replacing jsonstring regular message, @"hello-word" works, , success callback gets called , argument gets alerted. have idea going on? the problem had literal quote in jsonstring, jsonstring hardcoded. instead of doing this, used messageasdictionary appropriate mapped values, , still interpret data recieved javascript json object.

c# - Visual Web Developer Session problem on debugging -

may know there option or setting maintain session variable of c# web application everytime changed code , "start debugging" web application? i tend lose session , need relogin everytime in order recreate session , "member/admin area" working. has slowed down progress heavily :(

security - Dynamically load JavaScript with JavaScript -

after on hour of trying work i'm thinking it's because of cross domain policies, thought work. can't find lot of info on either. but, here issue. have site called http://mysite.com , include 3rd party script (what im writing) , @ http://supercoolsite.com/api/script.js , script needs dynamically load google maps api at: http://maps.google.com/maps/api/js?sensor=false before runs. well, figured code work: function loadscript(filename,callback){ var fileref=document.createelement('script'); fileref.setattribute("type","text/javascript"); fileref.setattribute("src", filename); fileref.onload = callback(); if (typeof fileref!="undefined"){ document.getelementsbytagname("head")[0].appendchild(fileref) } } loadscript('http://maps.google.com/maps/api/js?sensor=false',function(){ console.log('done loading'); init(); }); but response in console is: api.js:408 done loading api.j...

objective c - Chat Option for iphone -

i have implement chatting functionality iphone (login basis).i dont have clear cut idea of sample code support macos supported framework you can use xmpp / jabber , irc , silc protocol chat functionality application.

iphone - uitableviewcell background -

i have uitableview (grouped style). wanted customize appears "stick it" or "post it" yellow background interface. hence added following code - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uiview *backgroundview = [[[uiview alloc] initwithframe:cgrectzero] autorelease]; backgroundview.backgroundcolor = [uicolor yellowcolor]; cell.backgroundview = backgroundview; cell.textlabel.backgroundcolor=[uicolor yellowcolor]; } this worked. able achieve yellow background, separator line missing. can some1 me out ? is best way it? or should create image cell , use backgroundview? outdated. why creating custom background view? if want achieve yellow color can customize color using uicolor colorwithred: green: blue: alpha: create own color , add cell setbackgroundcolor:uicolor . seems seperator being overwritten if add background view in grouped table view. if still want have custom...

perl - Increase limit from 1000? -

when search so my $mesg = $ldap->search( base => "ou=test,dc=example,dc=com", scope => 'one', filter => '(objectclass=organizationalperson)', attrs => ['distinguishedname', 'displayname', 'samaccountname', 'employeeid'], ); i 1000 entries, expect ~20000. is possible increase limit in perl script, or have changed on server? the solution use paged search so use net::ldap; use net::ldap::control::paged; use net::ldap::constant qw( ldap_control_paged ); $page = net::ldap::control::paged->new(size => 999); $cookie; while (1) { $mesg = $ldap->search( base => "ou=test,dc=example,dc=com", scope => 'one', filter => '(objectclass=organizationalperson)', attrs => ['distinguishedname', 'displayname', 'samaccountname', 'employeeid'], control => [$page] ); $mesg->code ...

decode large base64 from xml in java: OutOfMemory -

i need write base64 encoded element of xml file separate file. problem: file reach size of 100 mb. every solution tried ended "java.lang.outofmemoryerror: java heap space". problem not reading xml in general or decoding process, size of base64 block. i used jdom, dom4j , xmlstreamreader access xml file. however, want access base64 content of respective element mentioned error. tried xslt using saxon's base64binary-to-octets function, of course same result. is there way stream base64 encoded part file without getting whole chunk in 1 single piece? thanks hints, andreas try stax api ( tutorial ). large text elements, should several text events need push streaming base64 implementation (like 1 skaffman mentioned).

Is there a way to find out what winform/wpf components a program uses? -

Image
i'm complete novice in gui-programming , i'm looking easy way visualize data structure have. own program similar job , component uses seems fulfill purposes well. instead of testing out different components myself (which undoubtedly force me learn lot), i'm wondering if there's fast way out of it. is there anyway find out specific wpf/winform component program using without asking author/having source code access? edit: looks this, area it's in scrollable horizontally/vertically. objects on selectable, moveable , have actions associated right-click menu. want visualize undirected graph , have possibility interact nodes graphically. here's control i'm talking about: first step, i'd @ assemblies app references. if references dll component vendor (a simple search can figure out), can visit vendor's website , check out offerings. if custom control embedded within application, , wpf app, i'd use snoop . (image ganked http://...

jQuery SlideShow of Reviews if Class Exists -

i have dynamically created reviews inside tables class 'helpfulreviews'. want take these tables , hide 1 of them , automatically slide next table after period of time using jquery here 3 reviews, want 1 display , slide other after around 10 seconds, slide third review, rotate beginning. have simplified example: <table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews"> <tbody> <tr> <td>my first review goes here<br>terrible product</td> </tr> </tbody> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews"> <tbody> <tr> <td>my second review goes here<br>great product have here</td> </tr> </tbody> </table> <table width="100%" border="1...

PHP namespaces does away with requiring files? -

i reading on information on php namespaces released in php 5.3, , seeing looked instead of requiring files code need had use namepace. correct in assumption? no. namespaces give means logically separate code. still need require source files in order use them. (or, more likely, use autoloader you. note however, feature exists prior 5.3.)

Naming php function and php class based on your variable name -

i have php class , php function used , since im making few of edits same files on , off have rename class , function based on file working on , code class myclassname{ function myfunctionname{ } } and later used $myvariable = myclassname::myfunctionname($getwhatineed); so $default_cf_name ="desiredname"; class prefix_$default_cf_name{ function prefix_$default_cf_name{ } } you may want read on object-oriented php beginners .

edit - How to make hidden rows not editable/copiable in VBA? -

the macro hides rows. after rows hidden, users can copy, edit , delete blocks of cells/rows. when users select range contains hidden cells, hidden cells, unfortunately, got selected also, actions performed on hidden cells too. is possible hide rows in such way, not participate in actions performed on visible part of worksheet (behave hidden rows after autofilter)? to hide rows use code: rows(i).entirerow.hidden = true not aware of. need @ protecting worksheet , locking cells don't want modified/copied.

ruby on rails - rake routes fails because of "missing action" -

i started clean rails app, installed , migrated devise gem couple straightforward models of own. devise user controller methods not working (i error page when go localhost:3000/users/new not when got /users/sign_up). when run rake --trace routes, following output: (in /users/tim/coding/rails_projects/libertyhive) ** invoke routes (first_time) ** invoke environment (first_time) ** execute environment rake aborted! missing :action /users/tim/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/actionpack-3.0.4/lib/action_dispatch/routing/mapper.rb:167:in `default_controller_and_action' /users/tim/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/actionpack-3.0.4/lib/action_dispatch/routing/mapper.rb:68:in `normalize_options!' and continues many more lines of /users/tim/.rvm/gem/ruby-1.9.2-p136@rails3tutorial/gems/... i have no idea how debug this. i'm pretty new rails. did rails 3 tutorial michael hartl, helped me through of general setup , configuration of rails. ...

html - Unable to handle Float:left property -

<!doctype html> <html> <body> <table style="float:left;margin-left:20px;width:120px"> <tr><td style="background-color:#ebebf5;">profile info >> </td></tr> <tr><td>entertainment</td></tr> <tr><td>sports & fun</td></tr> <tr><td>add more </td></tr> </table> <table style="width:200px"> <tr><td>info</td><td>education</td><td>work</td></tr> </table> </body> </html> looks these when browser window maximized profile info >> info education work entertainment sports & fun add more then minimized browser window smaller , smaller peak,now looks these profile info >> entertainment sports & fun add more inf...

c++ - Reading from an input file -

#include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { int size = 0; int highnum = 0; int m; string fname; cout << "supply name of input file use." << endl; cin >> fname; ifstream input; input.open(fname.c_str()); input >> size; int numbers[size]; (int n = 0; n < size; n++) input >> numbers[n]; (m = 0 ; m < size ; m++) { if (numbers[m] > highnum) highnum = numbers[m]; } int j; int k; bool values[] = {false, false, false, false, false, false}; (j = highnum; j > 0 ; j--) { (k = size - 1 ; k >= 0 ; k--) { if (j <= numbers[k]) values[k] = true; } if (values[0]) cout << "| xxx"; else cout << "| "; if (values[1]) cout <<...

In java, how can i search String array in another String array? -

i have 2 different string array. string[] str1={(abc),(cde),(def),(fge),(ert)}; string[] str2={(abc),(fge)}; i wanna know str1 have str2's members?how can search str2 in str1? arrays.aslist(str1).containsall(arrays.aslist(str2));

datetimepicker - Is it possible to use time picker only in blackberry -

i want user pick time @ time, system stop sending messages clients. possible enter in editfield still want use built in feature of black berry use time picker. learned datetimepicker class useful this. cant find code anywhere. please me providing hints or code. thank you this code shows time picker. check this: final datetimepicker datepicker = datetimepicker.createinstance( calendar.getinstance(), null, "hh:mm:ss aa"); datepicker.domodal(); further details check link: datetimepicker .

iphone - How to structure data: arrays in array -

i trying come structure data. let's imagine have library. in library, there different books - can add books library , delete them. guess need start nsmututablearray : nsmutablearray *entirelibrary; each book in library has set of features. require array (such different strings headings in each book) , other features, such page length, require integer. set of characteristics stays same each book, so: nsstring *booktitle; nsmutablearray *chapterheadings; nsinteger *pagecount; my question best way store of information in library. right now, have different arrays, strings or integers , can't see how can assign them individual book placed in library -- , how access data when need it. create own custom class called bookclass. keep booktitle, chapterheadings , pagecount properties of class , add bookclass objects entirelibrary nsarray.

Input Data to next available row Excel C# -

hello there anyway next empty row in excel , allow data input row? have looked on internet , found nothing looks this. 1 idea came add row evertime , input row, wondering if there easier way go this. appreciated. thanks one thing careful on .usedrange can select row ghost data on (where data may have been deleted, has left legacy data behind- such formats). here, leave blank rows need deleted. if have column in data cannot empty, pretty easy- use the range("a1").end(xldown).row method. if looking next available empty row (where column can populated/empty), use find function it. like; sub unusedrow() dim lstartrow long dim lunusedrow long lstartrow = 3 'starting row no in case have blank rows @ top lunusedrow = lstartrow - 1 application.screenupdating = false on error resume next while lstartrow = lunusedrow + 1 lunusedrow = lstartrow lstartrow = cells.find("*", cells(lunusedrow, 1), , , xlbyrows, xlnext).row + 1 loop on error...

rubygems - Interaction with shell through Ruby continuously? -

i want capture output shell commands using response = `#{command}` which fine if want run 1 command , not continuous interaction. instance if do response = `cd tmp` # response = '', correct response = `ls` i return ls within tmp, since in previous command had changed directory temp. there way run continuous shell on own thread or gem or effect? the ` starts sub-shell, not affect current ruby shell. can use ruby's dir.chdir or fileutils.cd change working directory of ruby shell. btw, maybe fresh , hybrid between system , ruby shell. can use cd/ls there, while being in ruby shell.

android - Manage the back button with multiple scene -

i followed tutorial http://www.andengine.org/forums/tutorials/multiple-screen-andengine-game-v2-t4755.html create simple application multiple scene , 1 activity. i'd know how can can return previous scene when use button , finish activity when i'm in first scene. i tried in multiscreen class: @override public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_back)) { this.mengine.getscene().back(); } return super.onkeydown(keycode, event); } replacing core.getengine().setscene(scene); in scenemanager this.mengine.getscene().setchildscene(scene); scene work differently how understood, resolve with: @override public void onbackpressed() { scene scene = this.mengine.getscene(); if(scene.haschildscene()){ scene.back(); } else{ this.finish(); } } you can override key in 1 of 2 ways, either overriding onbackpressed() method, or...

sql - how to work with Derived Tables -

i trying understand derived tables kinda have idea still messing it. did code dont think right. don't know if have input wrong or left out. table working distinct company name customers table orders have higher discount than.2.i have been looking on maybe have of names backwards or something. select distinct c.companyname customers c join (select orderid orders o join [order details] od on c.customers = od.orderid od.orderid = '<.2' the last part not working the.2 how columns set in northwind database click on tables , go down see dbo.order details , click on columns find orderid, productid, unitprice, quantity, disounts. have custumers table had customerid, companyname, contactname, contacttitle, address, city, region, postalcode, country, phone, , fax. if go under order table have orderid, customerid, employeeid, orderdate, requireddate, shippeddate,shipvia, frieght, shipname, shipaddress, shipcity, shipregion, shippostalcode, shipcountry. something ...

winapi - User's Preferred poweroff action - Windows -

i have program takes long time run , intended run unattended. in windows, best way determine users preferred poweroff action. what power button does. in windows 7, start menu logoff action (which shut down default). how can determine these values on windows xp, windows vista , windows 7? is there api this? (i.e. shutdown, suspend, or hibernate according users preferences) if using managed code, there powergetactivescheme. there example of how use here: http://www.pinvoke.net/default.aspx/powrprof.powergetactivescheme

nhibernate - One-way inheritance with HNibernate -

i frankly haven't got clue search reagarding question, here goes. i'm trying out different approaches new project i'm starting on. i have postgresql dbms. have single db multiple schemas. idea there "root" schema, works foundation other schemas. i'm trying achieve sort of "one-way" inheritance. i'd queries in root-tables not @ subclassed schemas, haven't found way that. when querying subclasses, i'd join base class, when querying base class, don't want query subclasses. i understand difference between different inheritance approaches, i'm not sure if i'm trying possible. my current setup works subclasses in different schemas, when querying base class, nhibernate goes query each of subclasses see if base class of types. maybe behavior appropriate in situations, in others, i'd query base class "alone". as requirement, base class cannot know subclasses (they're plugins/extensions). hope above...

iphone - UITextField KeyboardType - Xcode and IB? -

i'm using ib design main ui, , it's worked well. however, i'm looking ability have code override ib's value keyboard type. currently, ib keyboardtype set numbers , code trying set default keyboard (at least temporarily, later want option change keyboardtype on fly). here's code: nsinteger uikbtype = uikeyboardtypedefault; […] - (uitextfield *)varafield { varafield.keyboardtype = uikbtype; return varafield; }

java - Passing Swing classes (references) on network? -

i want know possible send major swing classes event/actionlisteners, events, components via rmi. possible scenario : if 1 client press button or move slider every client's button or slider move etc same other swing elements. i expecting answer in context of rmi , swing mvc architecture, want call swing component's models e.g buttonmodel , want send swing actionevent on wire , register propertychangelistener/propertychangesupport remote objects getting updates @ client site. typical examples : server should call method each client, when ever change occur in model public void propertychange(propertychangeevent evt) { (abstractviewpanel view: registeredviews) { view.modelpropertychange(evt); } } in case of event on 1 client, each client actionperformed should called server: @override public void actionperformed(actionevent e) { } is feasible? if not why? face problems, mean classes transferable (serialized) , not... edit: her...

xcode4 - Disabling Word-Wrap in XCode -

i'd disable word-wrap "feature" in xcode. can done? can't find setting or hotkey this. also, before stating "long lines of code bad-- keep them short , format wrapping yourself", please realize 2 things. first, keep multiple code pages open reference, each pretty small. second, using xcode strictly editor existing, embedded systems project. didn't write of code , of 80+ characters wide because of heavy use of code indention. i think searching checkbox under preferences>text editing>indentation>wrap lines editor width .

python - counting a set dictionary of words in a specific html tag -

i trying parse document , if there name associated specific docno, count total number of names. after loop ends docno, want store names[docno]= word count. therefore, if namedict={'henry':'','joe':'') , henry in docno=doc 1 -4 times , joe 6 dictionary store ('doc 1': 10). far, can figure out counting total number of names in entire text file. from xml.dom.minidom import * import re string import punctuation operator import itemgetter def parsetrec1 (atext): fc = open(atext,'r').read() fc = '<docs>\n' + fc + '\n</docs>' dom = parsestring(fc) w_re = re.compile('[a-z]+',re.ignorecase) doc_nodes = dom.getelementsbytagname('doc') namelist={'matt':'', 'earl':'', 'james':''} default=0 indexdict={} n=10 names={} words={} doc_node in doc_nodes: docno = doc_node.getelementsbytagname('docno...

sql server - how to discards the scalar value in stored procedure? -

please 1 tell me how discards scalar value in stored procedure? this sp create procedure testdata begin set nocount on; select c.customername,c.customercode, a.address, a.email,a.phone,a.zipcode customer c join address on c.customercode = a.customercode end go this c# code customerdataentities enty = new customerdataentities(); var productentity = enty.testdata123(); // error foreach statement cannot operate on variables of type int foreach (var prd in productentity) { } return customerlist; thanks. based on you're showing here, i'm assuming stored procedure set imported function. guess not mapping results of function entity type.

c - Copying a pointer for bit operations -

i have function passes in struct , instead of doing bit manipulations on arr want create copy. how can make copy of element of array of unsigned ints bit manipulations on? unsigned int * arr = cs->arr; // cs->arr set unsigned int * arr; unsigned int copy; memcpy(copy,arr[0], sizeof(unsigned int)); // copy copy first element, int = 0; while(copy != 0) { += copy & 1; copy >>= 1; } return i; thank you! you dont need memcopy . simple array access enough: unsigned int copy = cs->arr[0]; int = 0; while(copy != 0) { += copy & 1; copy >>= 1; } return i;

php - Automatically creating next and previous type pages using glob -

trying make glob function displays first 10 results (text files folder) , automatically next 10 next button. currently, used array_slice display first 10, i'm not sure how automate process. foreach(array_slice(glob("*.txt"),0,9) $filename) { include($filename); } oh , while i'm @ it, if possible, display "displaying 1-10" , last/first links. figure out myself after past first obstacle, don't bother unless it's super easy solution. what you're trying accomplish called pagination. example, can dynamically choose ten you're viewing setting variable determines number (file) start at. example: <?php $start = isset( $_get['start']) ? intval( $_get['start']) : 0; $glob_result = glob("*.txt"); $num_results = count( $glob_result); // check make sure $start value makes sense if( $start > $num_results) { $start = 0; } foreach( array_slice( $glob_result, $start, 9) $filename) { inclu...

php - how to display the distance only 4 digits -

how can make php display floating point number 4 digits after decimal point? $value = sprintf('%.04f', $value); or $value = number_format($value, 4);

linux - Some daze about the Pascal output -

platform: linux 2.6.18 x86_64 compiler: free pascal compiler version 2.2.2 [2008/11/05] x86_64 the source code is: program main; var invalue:string; begin (*until eof, loop continue work*) while not eof begin write('please input express: '); flush(stdout); readln(invalue); writeln('the expression is: ',invalue); end; writeln(''); writeln('exit program. bye!'); end. i compiled , run it. ouput like: 123 please input express: expression is: 123 234 please input express: expression is: 234 345 please input express: expression is: 345 exit program. bye! the numbers input. googled it, , thought because of buffer. tried add flush(stdout) or flush(output) after write. still not work well. i hope works as: please input express: 123 expression is: 123 please input express: 234 expression is: 234 please input express: 345 expression i...

asp.net - using linked server or separate connection strings? -

i have 10 databases 3 cities of them located in 1 db server different instances , 1 main database. each city has following databases: 1-db1 2-db2 3-db3 every record inserted in db main has city field.according th city field of inserted record same record must inserted in 3 databases of specified city in inserted record in db main. better use linked server or using separate connection string in c# code? know connection string should changed each database. ideally wouldn't make application responsible keeping databases in sync - many things go wrong - application might crash, network might go down... you might better off using database trigger, way application has update 1 database , trigger rest. here's msdn article explaining how it: create trigger

dictionary - Store map key/values in a persistent file -

i creating structure more or less of form: type filestate struct { lastmodified int64 hash string path string } i want write these values file , read them in on subsequent calls. initial plan read them map , lookup values (hash , lastmodified) using key (path). there slick way of doing in go? if not, file format can recommend? have read , experimented with key/value file stores in previous projects, not using go. right now, requirements simple big database server system overkill. want can write , read quickly, easily, , portably (windows, mac, linux). because have deploy on multiple platforms trying keep non-go dependencies minimum. i've considered xml, csv, json. i've briefly looked @ gob package in go , noticed bson package on go package dashboard, i'm not sure if apply. my primary goal here , running quickly, means least amount of code need write along ease of deployment. as long entiere data fits in memory, should't have pro...

jquery - Difference between $.ajax(); and $.ajaxSetup(); -

what difference between $.ajax(); , $.ajaxsetup(); in jquery in: $.ajax({ cache:false }); and $.ajaxsetup({ cache:true }); also, 1 best option? the following prevent all future ajax requests being cached, regardless of jquery method use ($.get, $.ajax, etc.) $(document).ready(function() { $.ajaxsetup({ cache: false }); }); you should use $.ajax, allow turn caching off for that instance: $.ajax({url: "myurl", success: mycallback, cache: false});

uiview - iPhone Footer like functionality -

i having trouble designing app. having button , label in every page, required functionality when user clicks button, fetch last tweet of application's tweeter account , display in label. know how fetch , display in 1 page. question is, can't create custom control, need place in every page. hope, able explain question. appreciated.. in advance. paresh you create footer view , place in first view (or base view) , add subsequent views below it.. or add directly window..

javascript - How to create an array from .each loop with jQuery -

how can create array inside of '.each loop' , use outside of loop? my .each loop : // loop through button class .apply $('.profile-nav ul li a').not('.apply').each( function() { // if loop through element has .cur class if( $(this).hasclass('cur') ) { //get first class of match element var classestoapply = $(this).prop('class').split(' ')[0]; } //how can create array classestoapply? //var arr = jquery.makearray(classestoapply); // create array, 1 element }); how can create array var = classestoapply ? and how can array? e.g $( allclasses array selectors).dostuff(); if declare variable outside of each , accessible inside each : var yourarray = []; $('.profile-nav ul li a').not('.apply').each(function() { if($(this).hasclass('cur')) { ...

silverlight - WP7 with visual studio -- All my apps are getting the same schema messages -

every time create wp7 app, following 2 messages: "could not find schema information element 'http://schemas.microsoft.com/client/2007/deployment:deployment'. and "could not find schema information element 'http://schemas.microsoft.com/client/2007/deployment:deployment.parts'. as far can tell, apps working ok. messages annoying. how can rid of them? in properties folder, should have file clled appmanifest.xml following contents: <deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <deployment.parts> </deployment.parts> </deployment> you should have reference system.windows[.dll] in app.

php - Switching between HTTP and HTTPS pages with secure session-cookie -

update: note every website switching between unsecure http , encrypted https pages, inevitable prone ssl-strip . please think using https whole site, although neither can prevent ssl-strip, @ least gives user possibility call site safely, if cares. sites need switch, method still best option. it's common scenario, website has pages sensitive data, should accessed https protocoll, , other ones noncritical data. i found solution allows switching between secure , non secure pages, while keeping session , ask hints flaws in concept. whole article can find here: secure session cookie ssl (of course i'm happy hear, safe). the problem https makes sure, nobody between client , server can eavesdrop our communication , prevents man-in-the-middle attack. unfortunately doesn't apply session-cookie, sent unencrypted requests too. php offers function session_set_cookie_params(...) parameter $secure. need, leaves problem loose our session, when switch unsecure page. ...

reporting services - visual c# express reports -

i using visual c# 2010 express edition , sql server 2008 r2 express develop software. need create reports in c# based on data stored in sql database. based on link : sql 2008 r2 express install option i have version "database management tools" installed. is, 1 235 mb. now requirements software, written in c#, must able generate reports based on data found in sql database. my questions are: must install database advanced services version (727 mb) able use ms sql reporting services? considering using express editions both c# , sql server, able make software use reporting services of ms sql server 2008 r2 express? have no experience in have read somewhere report viewer not available in express edition. prevent me using reporting services? if not, guys have recommendations other reporting tools might use? need generate reports containing graphs (free tools long possible, dissertation project). thank you. i wouldn't bother full reporting services: ...

php - CakePHP savefield() with out knowing the record's id -

how can update single field without knowing record's id? have user's username , don't want waste resources doing query id. note: know can achieve updateall() seams on kill, there better way? can how limit updateall() search 1 record , finish, because don't want continue search when there 1 possible match. updateall() way go in case. all other save methods require id known. you use query() method : $this->model->query($sql) however, remember values not automatically escaped in method.

jQuery: how to "declick" a open slideToggle div? -

is possible "declick" active div has been opened slidetoggle? this function opens multiple text divs independently each other, open div's click(function() still clickable, , div bounce closed , open again. it's user experience; i'd users unable click opened div. jsfiddle: http://jsfiddle.net/auuxk/12/ $(".entry-content").hide(); $(".entry-title").click(function() { $(".entry-content").hide(); $(this).parent().children(".entry-content").slidetoggle(500); }); html: <div class="entry-post"> <h2 class="entry-title">post title 1</h2> <div class="entry-content">lorem ipsum lorem ipsum </div></div> <div class="entry-post"> <h2 class="entry-title">post title 2</h2> <div class="entry-content">lorem ipsum lorem ipsum lorem ipsum </div></div> ...

jQuery function source code -

jquery 1.4.2 in ie 8 when call $.isfunction(function() {}) returns true . source code isfunction function: isfunction: function (obj) { return tostring.call(obj) === "[object function]"; }, when write in console tostring.call(function() {}) === "[object function]" throws "object doesn't support property or method" . source code of minified version: isfunction:function(a){return $.call(a)==="[object function]"} when write in console $.call(function() {})==="[object function]" returns false . why code works in different ways? at top of jquery 1.4.2 source ( inside wrapper ), tostring defined object.prototype.tostring . global tostring function different prototyped tostring method, hencethe different results. // save reference core methods tostring = object.prototype.tostring,

c++ - DLL design : the DLL needs to access some of the application functions/data -

i have dll bunch of functions. far, good, that's dll for. but, functions in dll need call functions (or access data) application loaded dll. app.exe : std::vector<someclass> objectslist; bool foo(void) { ... } loadlibrary( "something.dll" ); something.dll : __declspec(dllexport) void somefunction(void) { if ( foo() ) { objectslist[2].someattr = 1; } } for know, dll code in not correct because dll cannot know foo or objectslist @ linking. so, way see : something.dll : typedef bool footype(void); footype* pfoofunc; __declspec(dllexport) void setfoo(footype* fooptr) { pfoofunc = fooptr; } __declspec(dllexport) void somefunction(void) { if ( (*pfoofunc)() ) { ... _same thing objectslist_ } } app.exe : loadlibrary( "something.dll" ); setfoo = getprocaddress(...); setfoo(&foo); am right or there more elegant way kind of stuff ? solutions here : a dll need access symbols of app...

Sed search replace pattern (bash) -

here sample text i'm using sed (in bash, centos). i've broken text lines make easier read. but text below on 1 line. some text (abc_3.7| autodetect |"}{\fldrslt \plain \f2\fs20\cf2 3:7}}\plain \f2\fs20 xyz_3.16| autodetect |"}{\fldrslt \plain \f2\fs20\cf2 16}}\plain \f2\fs20 more text, qr_3.11| autodetect |"}{\fldrslt \plain \f2\fs20\cf2 11}}\plain \f2\fs20 something i want strip each entry: | autodetect |"}{\fldrslt \plain \f2\fs20\cf2 3:7}} the text between \plain , }} vary, need select everything. here's code i'm using now: s/|autodetect|\"}{\\fldrslt \\plain .*}}/ /g; the problem. expect results be: abc_3.7 \plain \f2\fs20 xyz_3.16 \plain \f2\fs20 more text, qr_3.11 \plain \f2\fs20 but actual results are: abc_3.7 \plain \f2\fs20 the .* greedy , matches first data after 'plain' last pair of close braces, including other auto-detects etc. need more refined (less greedy...

apache - Modrewrite Makes Scripts/CSS not appear due to their path location -

i'm having issues modrewrite rule i'm applying. it works intended, when viewing page, it's expecting absolute path scripts/css/images. won't display unless go through each 1 individually , prepend "../" them (i.e. 'icons/book.gif' => '../icons/book.gif') is there way fix modrewrite itself? here rule i'm applying: <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^category/([a-za-z\+]+)/?$ fact.php?category=$1 </ifmodule> edit: function determine absolute path, recommended use links on site. // determines , returns absolute url path function absolute_url ($page = "index.php") { $url = "http://" . $_server['http_host'] . dirname($_server['php_self']); // remove trailing slashes $url = rtrim($url, '/\\'); // add page $url .= "/" . $page; return $url; } have rules this: options +followsymlinks -multiviews rewriteengine ...

php - preg_match or operator -

my code below produces error, unknown modified "|"... i'm trying use or operator. correct way run code without error? $p = "(\w+)|(\()|(\))|(\,)"; $s = "sum(blue,paper,green(yellow,4,toast)))"; preg_match($p,$s, $matches); print_r($matches); edit okay changed bit... ~(\w+|\(|\)|,)~ now... here's problem: need take string , split array this: array("sum","(","blue","paper","green","(" ... etc ); can me that? when run above expression outputs empty array.... thanks you're missing delimiter @crayon correctly mentioned, pattern same thing: $p = '~(\w+|[(]|[)]|,)~'; as (new) problem, try this : $p = '~([(),])~'; $str = 'sum(blue,paper,green(yellow,4,toast)))'; $res = preg_split($p, $str, -1, preg_split_no_empty | preg_split_delim_capture); print_r($res); output: array ( [0] => sum [1] => ( [2] => blue [...

osx - C: Search and Replace/Delete -

is there function in c lets search particular string , delete/replace it? if not, how do myself? it can dangerous search , replace - unless replacing single chars char (ie change 'a' 'b'). reason being replaced value try , make char array longer. better copy string , replace new char array can hold result. find c function in strstr(). can find string - copy before buffer, add replacement buffer - , repeat.

python - easy_install libmysqld-dev error :'NoneType' object has no attribute 'clone' -

this error : (mysite)zjm1126@zjm1126-g41mt-s2:~/zjm_test/mysite$ ./bin/easy_install libmysqld-dev searching libmysqld-dev reading http://pypi.python.org/simple/libmysqld-dev/ couldn't find index page 'libmysqld-dev' (maybe misspelled?) scanning index of packages (this may take while) reading http://pypi.python.org/simple/ no local packages or download links found libmysqld-dev best match: none traceback (most recent call last): file "./bin/easy_install", line 8, in <module> load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')() file "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 1712, in main file "/home/zjm1126/zjm_test/mysite/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage file "/home/zjm1126/zjm_test/mysite/lib/py...

algorithm - Enumerating all paths in a tree -

i've tried , tried; searched , searched, not find algorithm solve problem. want enumerate paths in tree, (not simple paths) start , end leaf nodes (this easy constraint though). for example, tree; 1 / \ 2 3 / \ / \ 4 5 6 7 i want able generate following paths: 4 4-2-5 4-2-5-2-1-3-6 4-2-5-2-1-3-7 4-2-5-2-1-3-6-3-7 4-2-1-3-6 4-2-1-3-7 4-2-1-3-6-3-7 5 5-2-1-3-6 5-2-1-3-7 5-2-1-3-6-3-7 6 6-3-7 7 i guess that's all. i have tried following solution complexity of finding simple paths using depth first search? . however, finds simple paths, therefore paths such 4-2-5-2-1-3-6 not found. are there ways can guide me, algorithm perhaps ? do paths 4-2-1-2-5 count? if so, think have answer: it looks me want each edge visited "once" . take "dual" of graph , @ paths sequence of edges rather sequence of vertices. way, edges become "vertices" , vertices become "edges" . this should reduce problem...

oop - PHP OO: Best strategy for dealing with form posts? -

we have built custom forms , @ stage built lot of thought. each class has own responsibility , far basic principle of oop concepts have been used i.e. inheritance, polymorphism, encapsulation, etc. each element of form object , objects collected , initiated on fly. now weve got processing part of forms @ loss strategy deal , ask if has pointers please? is there alternative, instance creation of class responsible checking if form has been submit , methods gather post data, validate, etc or people still old way quick conditional in client check if form submit: if(isset($_post["var"]) { //process form } else { //show form } and best use separate action page process? bascially dont want have write awful code thats not reusable or make use of oop concepts. achieve without using frameworks. i try go structure : // public function __construct( validatorinterface $validator ) $form = new form( new validator ); // public function add_field( $name , array $ru...

Calling jQuery function from Button Click event in C# -

i trying load cropped image asp:image without using updatepanel. problem displays image needs load $('.image-cropper').each(linkup); function present in jquery(window).load() start cropping process. using registerclientscriptblock method not fire function. note: $('.image-cropper').each(linkup); should initiated after image has been updated new image. can let me know error is? using system; using system.collections.generic; using system.web; using system.web.ui; using system.web.ui.webcontrols; using imageresizer; using system.text; public partial class advanced : system.web.ui.page { protected void page_load(object sender, eventargs e) { scriptmanager1.registerasyncpostbackcontrol(button1); if(!ispostback) image1.imageurl = "fountain-small.jpg?width=300"; if (page.ispostback && !string.isnullorempty(img1.value)) imagebuilder.current.build("~/"+imageresizer.util.pathutils.removequeryst...