Posts

Showing posts from May, 2014

osx - How to initialize sparkup plugin in Vim for MacOS? -

im new vim , having trouble installing sparkup plugin found @ https://github.com/rstacruz/sparkup . i've copied contents of zip ftplugin folder , have tried expand div tag pressing command e appears. im stumped, assistance appreciated make sure have filetype detection enabled. issue ran a while back on sparkup, similar symptoms. try adding following ~/.vimrc : filetype indent plugin on

android - Links in TextView -

i need put link in textview , have string contains tag <a href="link">text link</a> , other text. problem if run project can see text it's not clickable. tried <b> tag see if works , seems doesn't work too. how can make work without linkify usage? thank all. i have managed make work, after have found examples in android samples. here code: textview.settext(html.fromhtml( "<b>text3:</b> text " + "<a href=\"http://www.google.com\">link</a> " + "created in java source code using html.")); textview.setmovementmethod(linkmovementmethod.getinstance()); hope others...

Sorting a hash in Ruby by its value first then its key -

i trying sort document based on number of times word appears alphabetically words when outputted this. unsorted: 'the', '6' 'we', '7' 'those', '5' 'have', '3' sorted: 'we', '7' 'the', '6' 'those', '5' 'have', '3' try this: assuming: a = { 'the' => '6', 'we' => '7', 'those' => '5', 'have' => '3', 'hav' => '3', 'haven' => '3' } then after doing this: b = a.sort_by { |x, y| [ -integer(y), x ] } b this: [ ["we", "7"], ["the", "6"], ["those", "5"], ["hav", "3"], ["have", "3"], ["haven", "3"] ] edited sort reverse frequencies.

Add up values from matching fields in a linked Sharepoint list -

i have 2 lists, say, fruits & orders . orders has number field fruitid links id field of fruits . orders has number field ordervalue stores value of specific order. i want find out total sale particular fruit. doing calculation in workflow specific fruit. there easy way (read 'no coding')? see list of standard workflow actions here: http://office.microsoft.com/en-us/sharepoint-designer-help/workflow-actions-in-sharepoint-designer-2010-a-quick-reference-guide-ha010376961.aspx there no select, or looping functionality. i suggest writing custom workflow activity, sand boxing should work http://www.wictorwilen.se/post/sandboxed-workflow-activities-in-sharepoint-2010.aspx

ruby on rails - How can I lock a model's associated collection? -

i have class foo has_many :widgets end there's place want pull widgets locked select. so, want equivalent of: @widgets_to_work_with = widget.find_all_by_foo_id(@foo.id, :lock => true) with nicer code, like: @widgets_to_work_with = @foo.widgets(:lock => true) what's best way this? you redefine method widgets in foo activerecord or , safer ,add method a.e. # in foo.rb #... def self.locked_widgets widget.find_all_by_foo_id(self.id, :lock => true) end hope usefull

asp.net - Button event in Gridview Footer template does not fire -

hi gave placed the button in gridview footer template below: i have handled row command event when click on button event not fire did u set command name property button , check in code behind in row command event .. please put sample code fix problem.

.net - C# change mdb filed data type to memo and save it -

i change data type in db "text" "memo". first of all, didnt find "memo" data type in c#. second: got following code execute command in db: public void sqlcommand(string strsql) { oledbconnection objconnection = null; oledbcommand objcmd = null; string strconnection; strconnection = @"provider=microsoft.jet.oledb.4.0;data source=" + path + "\\tasks.mdb"; objconnection = new oledbconnection(strconnection); objconnection.connectionstring = strconnection; objconnection.open(); objcmd = new oledbcommand(strsql, objconnection); objcmd.executenonquery(); objconnection.close(); updatelistview(); } how can change 3rd column's data type , save it? can change data type when form_load function: public void tst() { conn.open(); dataset ds = new dataset(); oledbdataadapter adapter = new oledbdataadapter(...

r - Package TsDyn. SelectSETAR function -

i want apply selectset function list of variables. if this: for(i in 1:ncol(emi)) { print(i) search <- selectsetar(emi[,i], m=3, thdelay=2) set <- setar(emi[,i], m=3, thdelay=2, th=search$th) print(search) summary(set) } the summary instruction overlooked , in fact more important output me. how can this? thanks you use print() did i , search . example: > (i in 1:2) { + print(i) + summary(rnorm(10*i)) + } [1] 1 [1] 2 but > (i in 1:2) { + print(i) + print(summary(rnorm(10*i))) + } [1] 1 min. 1st qu. median mean 3rd qu. max. -0.65260 -0.32320 -0.02333 0.21530 0.82060 1.59900 [1] 2 min. 1st qu. median mean 3rd qu. max. -1.38000 -0.52860 0.04965 0.07786 0.59130 1.76200

Date parse in javascript -

i need parse date in javascript 17dec2010 javascript date. how that? the short answer is: there's no standard means in javascript doing that, you'll have yourself. javascript got any standard string representation dates (as of ecmascript 5th edition, year ago — format simplified version of iso-8601 ), , format doesn't match format. however, there add-on libraries can help, such datejs . your particular format pretty easy parse (see below), if variations, can complex fast. simple example: var months = { en: { "jan": 0, "feb": 1, "mar": 2, "apr": 3, "may": 4, "jun": 5, "jul": 6, "aug": 7, "sep": 8, "oct": 9, "nov": 10, "dec": 11 } }; var datestring = "17dec2010"; var dt = new date( parseint(datestring.substring(5), 10),...

.htaccess - I'd like to remove a constant from a URL with htaccess -

i have site url's this: http://website.com/browse/wedding-service-providers/bridal-wear-and-accessories/ i'd remove /browse/wedding-service-providers from url each time resulting url is http://website.com/bridal-wear-and-accessories/ thanks :) rewriteengine on rewritebase / rewriterule ^(.*)-c-(.*)$ index\.php?main_page=index&cpath=$2&%{query_string} [l] url http://website.com/bridal-wear-and-accessories-c-3/ in url 3 id of category

android - How can I make my Cursor survive an orientation change? -

i trying make app rotation friendly, having problems saving cursor. the cursor holds 13k+ rows of data displayed in listview , , take quite while if requery every time configuration changes. in onretainnonconfigurationinstance() , returning cursor , retrieving through getlastnonconfigurationinstance() . however, retrieved cursor seems closed already, , adapter cannot render list anymore. understand, cursor closed since ondestroy() automatically closes cursors. i save cursor this: @override public object onretainnonconfigurationinstance() { return mycursor; } and retrieve this: mycursor = (cursor)getlastnonconfigurationinstance(); if (mycursor == null) { // stuff here (access db, etc) } else { // returning configuration change // feed cursor adapter } i pasting stack trace if wants @ it: 01-25 16:57:45.637: error/androidruntime(12976): android.database.staledataexception: access closed cursor 01-25 16:57:45.637: error/androidruntime(12976): @...

how to add in uiview for images to button programmaticaly in iphone -

im new iphone development.here added images button in uiview programmaticaly in iphone. here problem want add more images in uiview. added next , previous buttons in view .if click nextbutton more displayed in next view. tried dont no how displayed programmaticaly more images when click nextbutton in iphone. can 1 plz me problem. thank in advance. add uiimageview view , do: myuiimageview.image = [uiimage imagenamed:@"animageinmybundle"]; now, if want have bunch of images , go through them systematically, have few options. going depend on app does. if you're displaying local images in bundle, can create nsarray (mutable or immutable - per situation) , add uiimages @ run time. if app downloads data web, you're going start making network calls in secondary thread downloads , sets next image. give better idea of app does, , might able provide more specific code/examples.

C++ constructor format -

possible duplicate: what weird colon-member syntax in constructor? hi, in sams teach c++ in 21 days book, day 12: implementing inheritance , code snippet: mammal(): itsage(2) , itsweight(5) {} is equivalent saying? mammal() { itsage(2); itsweight(5); } what advantage first form have? usage in book? thanks. the first initialization list syntax, not function calls second snippet. http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6

text parsing - Where should I store a list of stop words? -

my function parses texts , removes short words, such "a", "the", "in", "on", "at", etc. the list of these words might modified in future. also, switching between different lists (i.e., different languages) might option. so, should store such list? about 50-200 words many reads every minute almost no writes (modifications) - example, once in few months i have these options in mind: a list inside code (fastest, doesn't sound practise) a seperate file "stop_words.txt" (how fast reading file? should read same data same file every few seconds call same function?) a database table. efficient, when list of words supposed static? i using ruby on rails (if makes difference). if it's 50-200 words, i'd store in memory in data structure supports fast lookup, such hash map (i don't know such structure called in ruby). you use option 2 or 3 (persist data in file or database table, depending...

php - Some issue with the country, state and city dropdown in cakephp -

there 3 tables 1 country, 2nd 1 state , last 1 city. in table named address have city_id only. need when add new address want state dropdown dynamically populated when select country , same city. there no relation between address table , country table. how can link address country , state. wanna show them in dropdowns. problem how use country , state controller object in address controller. if understand question correctly, have set relations between models: address belongsto city, city belongsto state, state belongsto country. when retrieve address database, automatically retrieve state , country, unless specify otherwise. here info on model associations: http://book.cakephp.org/view/1039/associations-linking-models-together (you didn't version of cakephp you're using linked latest one).

linq - Why my DataContext doesn't see the changes to an object(Unit Of Work)? -

i'm trying set project use unitofwork , repository pattern. now can't use ioc , ef4, i'm trying linq , datacontext bit of dependency :(. don't hide i'm bit confused integration of these concepts. noticed debugging code datacontext doesn't see updates made object, every time adds new entity database. i have read lot about, can't find problem, maybe it's simple step. before proceed, here's have: for example have object called foo...i have foo controller in constructor creates new instance of foorepository. in foorepository add reference unitofwork wraps datacontext...is right? here's code public class listacontroller : controller { ilistarepository _listarepository; public listacontroller() : this(new listarepository()) { } public listacontroller(ilistarepository repository) { _listarepository = repository; } [httppost] public actionresult edit(int id, lista lista) { ...

c++ - TinyXML #include problem... Using libraries -

hey, i'm trying tinyxml @ least read file says "main.cpp:8: error: ‘tixmldocument’ not declared in scope" this code im using: tixmldocument("demo.xml"); ideally want read able read files , output xml tried code found online in tutorial #include <iostream> #include "tinyxml.h" #include "tinystr.h" void dump_to_stdout(const char* pfilename) { tixmldocument doc(pfilename); bool loadokay = doc.loadfile(); if (loadokay) { printf("\n%s:\n", pfilename); dump_to_stdout( &doc ); // defined later in tutorial } else { printf("failed load file \"%s\"\n", pfilename); } } int main(void) { dump_to_stdout("demo.xml"); return 0; } and errors i'm getting are: main.cpp: in function ‘void dump_to_stdout(const char*)’: main.cpp:13: error: cannot convert ‘tixmldocument*’ ‘const char*’ argument ‘1’ ‘void dump_to_stdout(const char*...

flex - How to use the htmlWrapper in Flex4? -

how use htmlwrapper in flex4? how code flex applications? if use flex builder, it's automatically generated. otherwise, there ant task , flexmojos goal. if want create manually scratch, @ official documentation : http://help.adobe.com/en_us/flex/using/ws2db454920e96a9e51e63e3d11c0bf69084-7ba8.html

.net - nonstandard namespace in corba idl -

i'm using iiop.net connect corba servers. servers enterprise level machines , deployed world renowned vendors, implement standard corba idl files. more specifically, of them conform 3gpp standards. in 3gpp standard idl files pragma prefix defined 3pggsa5.org . i've used idl cls compiler, comes along iiop.net, generate dll. gets generated same namespace i.e. 3pggsa5.org . dll unusable in .net because namespace starts integer. if try , put underscore before 3, .net recognized can't connect corba server interface or idl has changed now. i've read somewhere namespaces generated java classes corba idls same corba/idl namespaces. should problem there well. 3gpp standards industry level standards, , not possible don't work. missing something? kindly help. thanks. you need proper idl compiler prefixes bad namespaces (3gpp) proper char. then, code work ;) or change namespace in idl files yourself.

java - Lucene Indexing and searching with Map/Reduce -

possible duplicate: instant searching in petabyte of data… how use hadoop's map/reduce in lucene indexing , searching????? the closest thing find katta : katta distributed application running on many commodity hardware servers similar hadoop mapreduce, hadoop dfs, hbase, bigtable or hypertable. (...) katta supports distributed scoring lucene implementation - because not expect term distribution balanced on shards. each search query done in katta ends being 2 network roundtrips: first document frequencies query nodes , on second trip pass value , search query nodes. please note provide simple count method counts documents matching query within 1 network roundtrip.

Django: parametrizing db_table for inheritance -

i want set db_table meta class attribute in base class inherited classes have names in it, similar how django treats related_name model field attribute: class basemodel(models.model): class meta: db_table = 'prefix_%(class)s' so inherited model: class submodel(basemodel): pass will have db table prefix_submodel . is possible? can meta class access inheriting class' model name? no. can't that. not simple have same table store multiple classes. what need djeneralize project. from examples: class fruit(basegeneralizedmodel): name = models.charfield(max_length=30) def __unicode__(self): return self.name class apple(fruit): radius = models.integerfield() class meta: specialization = 'apple' class banana(fruit): curvature = models.decimalfield(max_digits=3, decimal_places=2) class meta: specialization = 'banana' class clementine(fruit): pips = models.booleanfield(de...

php - Add option value to product, then to cart with Magento -

i searched around while , came wit solutions added whole new option sets products in magento store. what i'm trying accomplish way add simple product cart. simple product has predifined custom options (free text fields) has filled php function. so, how can this? let's have product id "111" , 1 custom option. $qty = '1'; $product = mage::getmodel('catalog/product')->load("111"); // set option value in product model? $cart = mage::helper('checkout/cart')->getcart(); $cart->addproduct($product, $qty); // set option value while passing product car? $cart->save(); thanks in advance hinds. btw: setting option values via querystring relativly easy seen here . you don't set custom option on product model, pass in through second argument $cart->addproduct($product, $params) . the set have project, requires external app add magento cart, use $params array of following format: $params = array( ...

Scala map sorting -

how sort map of kind: "01" -> list(34,12,14,23), "11" -> list(22,11,34) by beginning values? one way use scala.collection.immutable.treemap, sorted keys: val t = treemap("01" -> list(34,12,14,23), "11" -> list(22,11,34)) //if have map... val m = map("01" -> list(34,12,14,23), "11" -> list(22,11,34)) //... use val t = treemap(m.toseq:_*) you can convert seq or list , sort it, too: //by specifying element sorting m.toseq.sortby(_._1) //sort comparing keys m.toseq.sortby(_._2) //sort comparing values //by providing sort function m.toseq.sortwith(_._1 < _._1) //sort comparing keys there plenty of possibilities, each more or less convenient in context.

http - How to retrieve a web page needing authentication in Emacs, can't get url.el to authenticate -

i'm using following code: (defvar xyz-user-name "login") (defvar xyz-password "pass") (defvar site "http://www.site.com/") (defvar xyz-block-authorisation nil "flag whether block url.el's usual interactive authorisation procedure") (defadvice url-http-handle-authentication (around xyz-fix) (unless xyz-block-authorisation ad-do-it)) (ad-activate 'url-http-handle-authentication) (defun login-show-posts () (interactive) (let ((xyz-block-authorisation t) (url-request-method "get") (url-request-extra-headers `(("authorization" . ,(concat "basic " (base64-encode-string (concat xyz-user-name ":" xyz-password))))))) (url-retrieve site (lambda (status) (switch-to-buffer (current-buffer)))))) but webpage text without authentication, i.e. did...

php - Instant Server-Client Communication, C#? -

i have been doing research few months on possibility of client-server communication. have experimented many methods such weborb , fluorinefx, both servers designed deal client/server authentication. weborb runs on windows .net version far can tell, , rather use open source system. have tried using fluorinefx, think must simpler way me build own simple system ground up. i have been using dropbox while now, , way client-server communication instant. far can tell (from google searches) client doesn't open port of own, , communicates dropbox server through port 80. example of instant communication may delete file on dropbox on website, , instantly server communicates client telling has happened. don't know how instant communication possible without opening port. i can create system uses fetching client, asking server every 10 seconds or see if there updates, method able push information server client. my server runs linux don't think can use wcf, , ideally looking ...

plpgsql - Making emacs to highlight postgresql syntax by default -

i use emacs editing sql code. work 99% of time on postgresql plpgsql code. files extension .sql contain postgresql. i'm curious there way set sql-highlight-postgres-keywords sql highlighting default instead of ansi sql, because it's pretty annoying switch mode every time open file. usually in emacs, if want change settings every time mode opened, use hook. similar should work: (add-to-list 'auto-mode-alist '("\\.psql$" . (lambda () (sql-mode) (sql-highlight-postgres-keywords))))

iphone - how to copy the music from an app to iPod? -

i recording voice in iphone app , storing .caf file in app. want copy caf file ipod. is possible in iphone ? edit: if jailbreak device, how can ? no because third-party apps have no write access ipod library.

augmented reality - Improving iPhone AR (Tool)Kit by using the Gyroscope -

i'm using iphone ar kit , fork, iphone ar toolkit , i'm trying improve user experience using gyroscope when it's available. for of used kits, have idea on how ? first thought gyroscope yaw more precise azimuth value. so have questions : does used ar kit linked above, , have thoughts on including gyroscope in ? is idea mix gyroscope , compass data more precise value of azimuth ? gyroscopes measure rotational velocity, gyro output in change in yaw per second (e.g rad/s) rather absolute yaw. there various methods trying use gyros "dead reckoning" of orientation, in practice while they're accurate on short term, integrating gyro read-outs determine orientation "drifts" significantly, have keep recalibrating against absolute measure. it trivial use gyro interpolate between compass readings, or calculate bearing based on gyro short fast motions while compass catches up, fusing compass , gyro isn't trivial. there's a ta...

wordpress - list of pages and categories -

i've question. wordpress theme, prints list of pages in <ul> tag. pages name: page1, page2, page3 ok ... can prints categories names inside pages list? example: <ul><li>page1</li><li>page2</li><li>category1<li><li>page3</li></ul> if can, how can? thanks lot ... if user wordpress 3.0, use custom menu under appereance -> menus. it let build menu pages, categories, links !

c# - Bound ListBox SelectedIndex keeps changing -

i have listbox bound list. every-time listbox updates reflect collection, selectedindex changes top item. how can stop behavior , retain current selectedindex? [update] i found better collection use kind of functionality - 'bindinglist': http://msdn.microsoft.com/en-us/library/ms132679(v=vs.90).aspx . wulfgarpro. when [...] updates reflect collection does mean there new collection? if "the same position" mean? when re-binding a(nother) list, have save & restore index position. write code around place update datasource.

.net - SqlDependency with SQL Cluster? -

i have short question sqldependency. have 2 sql 2005 servers configured in failover cluster.. when active node changed stop receiving notifications... have manually restart windows service hosts sqldependency... is correct behavior? how can automatically restart dependency?? thanks in advance!! ps. sorry english sucks! cheers argentina!!! it expected behavior explained here - http://support.microsoft.com/kb/930048 . as states: to resolve issue, add code monitor database mirroring failovers. then, re-execute relevant commands used dependencies. you might find post "how detect database mirroring failovers" useful. shows different ways monitor failovers.

uml - Use Cases: separate or not? -

should make 2 separate use cases if member of website can view own personal profile , of other users? should member - view own profile , member-view others' profile? or member - view profile enough? as per comments, use case can have 1 complete scenario/feature/function of application. hence if talking use-case of member viewing profile, 1 use case if talking test cases verification, 2 test cases. a member viewing own profile not mean can view others profiles too. hence need have 2 test cases verifying both possibilities. on other hand, there few more cases in - should have cases member able edit profile, edit others profile , can go individual fields too. member being able edit details, able edit few details of other particular members below him in hierarchy , should not able edit details of other members above him in hierarchy etc.

php - CodeIgniter Mod_Rewrite Issue - URL's only showing index -

i have ci app after switching servers, doesn't seem route properly. in config have $config['uri_protocol'] = "path_info"; $config['enable_query_strings'] = true; this should allow both query string parameters , url segments. so this, should in theory work (as on old server): http://www.domain.com/register?param=something however, no matter url go shows index. so if go http://www.domain.com/register it shows in address bar, doesn't register controller, it's showing index. if change 'uri_protocol' request_uri, works. query string parameters won't. my .htaccess is directoryindex index.php rewriteengine on rewritecond $1 !^(index\.php|assets|robots\.txt|favicon\.ico|license.txt) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ ./index.php/$1 [l,qsa] rewritecond %{query_string} . rewriterule ^$ /? [l] any ideas issue be? say, it's working on different server. so,...

spring roo - SpringROO+GWT customization -

i want build gwt application doesn't use database. thought use spring roo initial configurations it. spring roo+gwt generated app has: requestfactory based client-server communication mvp pattern applied activities, places, browser history management [1] uibinder-based uis use *.ui.xml files ui definitions [4] lot of generated activities in /client/managed/activity [5] lot of generated uis in /client/managed/ui - of them use uibinder spring integration [2] spring mvc integration [3] hibernate(or other jpa implementation) integration i don't want [1], [2], [3] features it. questions about [1], intend have own uis don't use uibinder. how do that? what if want different logic/layout app? safe remove [4] , [5] , generate own mvp components? how do - don't care keep spring roo support in app, want change scaffold app , build totally different. saw when add field in domain bean, automatically generate uis, , [4],[5] one of selling points roo ...

Android Thread Pool has runnables building up without execution after background state -

my application has thread pool creates 3 simultaneous threads. invoke runnables, added thread pool. my problem happens when application goes background while. eventually, threads stop executing runnables in pool , pool continues grow. if bring application foreground, threads not start running again. my theory when application goes background threads being killed. i'm not sure , i'm not sure of way of determining whether threads killed can start them again. do have suggestions can determine whether or not thread has been killed? you can't use thread pool execute code in background because android activity lifecycle won't consider app active, , kill process (including threads) after lose ui focus. want android service has different lifecycle. things use local service handler , handlerthread can post runnables into. you'll want similar. note: every time feel there must easier way, might worth searching if has simplified pattern.

Saving images to a database or filesystem on iPhone -

what best approach if want of rows in database table have image. should add column type blob, or should keep reference image , add image in documents folder? there both advantages , disadvantages storing image data (or other large chunks of binary data) in database. on upside: all of app's data contained within single file depending on database, may have option of transactional/atomic updates app's data, avoiding problems app data gets unexpected states during error conditions the disadvantages are: the db larger there may optimizations associated working image data filesystem lost (e.g. - memory mapping) the memory footprint working images may increased depending on db granularity during writes, there may increased contention/blocking decreases speed @ db updated if 1 wanted make lot of separate, transactional/atomic changes quickly

iphone - how do I create fresh NSMutableArray? -

i have nsmutablearray lasts during session. create this nsmutablearray *temp = [[nsmutablearray alloc] initwithcapacity:10]; [self setscorearray:temp]; [temp release]; problem when go check each index i'm getting array outofbounds error nsnumber *previousscore = [[self scorearray] objectatindex:[self quiznum]]; if ( previousscore != nil ) { [self clearquizbtns]; nsinteger previousscorevalue = [previousscore integervalue]; [self selectbuttonattag:previousscorevalue]; }else { [self clearquizbtns]; } i've read in other posts initwithcapacity doesn't create array. can populate array initially? in advance. two ways: first : initiate array default values of nsnull class nsmutablearray *temp = [[nsmutablearray alloc] initwithcapacity:10]; (int = 0 ; < 10 ; i++) { [temp insertobject:[nsnull null] atindex:i]; } [self setscorearray:temp]; [temp release]; and check: if object kind of nsnull cl...

.net - Automatically getting all assembly references in T4 -

is possible have t4 template automatically picks assembly references (and dependencies) of parent project? all examples have seen use <#@ assembly #> or <#@ volatileassembly #> manually define references, example end having reference system.core both in project , template. want avoid duplication: want define references in project, not template. this should add reference project itself, allow referencing additional assemblies in template, , shadow copy whenever necessary avoid assembly locking. it seems this possible before vs2010 , possible re-implement/restore behavior? t4 did indeed pick project dependencies before vs2010. deliberately chose separate out design-time references runtime references in order separate concerns , better support using .net 4.0 in templates if being used generate code .net 2.0 project. you similar pre-vs2010 making custom directive processor used host serviceprovider dte , walked solution/projects find references. quite bit o...

php - Friendly url implement wordpress style -

i need guidance friendly url, best way implement since. htaccess, handle php create links if path is: http://www.site.com/index.php?op=notice&id=34 convert http://www.site.com/notice/34/ or http://www.site.com/notice/the-best/ if have it. .htaccess : rewriterule ^ ([a-za-z0-9-]+)/?$ index.php? op = $ 1 [l] from php generate right links. htaccess, enable slug. have wordpress, idea. thank you have make index.php shows right content depending on uri. how solved different case case. wordpress have see if there's corresponding post or page, , if so, display content.

python - Problem solving the max and min from an input file data -

i new python , need little python script named search_max.py. it opens file "xyz" format , search min , max of each coord. problem when same awk script don't same resuts!!! i wonder if there problem type of data or string operation or ... can me solve problem? python script : #!/usr/bin/python # -*- coding: iso-8859-15 -*- inputfile = "peamorphe.xyz" outputfile = "result.txt" # open input file infile = open(inputfile, "r") # read line 1 : number of atoms atomsno = infile.readline().rstrip('\n').split(" ") # read line 2 : name of system systemname = infile.readline().rstrip('\n') # read line 3 : initialisation min , max temp2 = infile.readline().rstrip('\n').split(" ") zmin = temp2[3] zmax = temp2[3] ymax = temp2[2] ymin = temp2[2] xmax = temp2[1] xmin = temp2[1] lineno = 3 print zmax, ymin, xmin # read other lines ligne in infile.readlines(): lineno = lineno + 1 # extraction , st...

css - IE8, transparent PNG and filter:alpha -

Image
i'll cut right point. here's output: (now optional code - read if want ;)) here's markup: <a href="/" id="logo_wrapper"> <span class="logo logo_normal"></span> <span class="logo logo_hover"></span> </a> here's css (shortened relevant stuff, reading pleasure): #logo_wrapper { position:relative; } #logo_wrapper .logo { display:block; width:260px; height:80px; background-image:url(logo.png); position:absolute; } #logo_wrapper .logo_normal { background-position:0 0; } #logo_wrapper .logo_normal:hover { opacity:0; filter:alpha(opacity=0); } #logo_wrapper .logo_hover { background-position:0 -80px; opacity:0; filter:alpha(opacity=0); } #logo_wrapper .logo_hover:hover { opacity:1; filter:alpha(opacity=100); /* offender! */ } just clarify: i'm aware can away single span , switching logo's background-position on hover, full css features cute ...

c# - Find sum of a column after using binding source filter -

i using bindingsource.filter small list of rows. either can find sum sum(mycolumn) or filter using bindingsource.filter="purchaseid = '" + purchaseid + "'" . how find sum of specific column after filtering? i found solution using dataset inventorydatabasedataset.tables["mytable"].compute("sum(mycolumn)", "purchaseid = '" + pid + "'").tostring();

complexity theory - Maximum two-dimensional subset-sum -

i'm given task write algorithm compute maximum 2 dimensional subset, of matrix of integers. - i'm not interested in such algorithm, i'm more interested in knowing complexity best worse-case can possibly solve this. our current algorithm o(n^3). i've been considering, alike divide , conquer, splitting matrix number of sub-matrices, adding elements within matrices; , thereby limiting number of matrices 1 have consider in order find approximate solution. worst case (exhaustive search) no worse o(n^3). there several descriptions of on web. best case can far better: o(1). if of elements non-negative, answer matrix itself. if elements non-positive, answer element has value closest zero. likewise if there entire rows/columns on edges of matrix nothing non-positive integers, can chop these off in search.

indexing - MySQL index question -

i've been reading indexes in mysql recently, , of principles quite straightforward 1 concept still bugging me: basically, if in hypothetical table with, let's say, 10 columns, have 2 single-column indexes (for column01 , column02 respectively), plus primary key column (some other column), going used in simple select query 1 or not: select * table column01 = 'aaa' , column02 = 'bbb' looking @ it, first instinct telling me first index going retrieve set of rows (or primary keys in innodb, if got idea right) satisfy first condition, , second index set. , final result set intersection of these two. in books i've been going through cannot find particular scenario. of course, particular query 1 index on both columns seems best option, struggling understanding real process behind whole thing if try use 2 indexes described above. its going use single index. need create composite index of multiple columns if want able index off of each column testin...

java - UTF-8 characters not getting displayed -

when run junit test case invoke standalone application sends mail characters getting displayed in mail when application runs on different machine through thread displayed ? instead of real characters. program of mine sends uses sendmail of unix , remote machine uses postfix. can think of possible reasons of problem? show code. likely, aren't explicitly specifying character encoding want use, , default on 1 platform works expect, , default on doesn't.

javascript - When you submit a form, does the button that was clicked get posted also? -

when submit form, button clicked posted also? yes does. long set both name , value : <input name="submit" value="submit" type="submit"/> in fact can have multiple submit buttons on same page , can detect 1 clicked on checking pair.

sql - MSDTC - adding a 3rd node to a windows cluster -

have active/active sql cluster (2005) on windows 2003 we're adding 3rd node. need add new node failover site msdtc? can add node possible in cluster administrator or there more it? thanks looking @ batch script wrote (it's old still good), should able set new node possible owner of msdtc group once it's added cluster. script has following: cluster cluster_name group "msdtc group" /setowners:nodea,nodeb,nodec

android - Adding gesture builder to my app? -

building gestures in advance , forcing user use them ok, great if end user define own gestures application. once great example dolphin web browser. does have links or 1 can locate source code gesture builder app comes in emulator? does have links or 1 can locate source code gesture builder app comes in emulator? that sample in sdk folder.

javascript - js: hiding divs -

i pretty new javascript please bear me. $('#biocontent').css('display','none'); $('#skillscontent').css('display','none'); $('#credstab').css('background-color','#fff'); $('#credstab a').css('color','#19d700'); $('#biotab').css('background-color','#ccc'); $('#biotab a').css('color','#444'); $('#skillstab').css('background-color','#ccc'); $('#skillstab a').css('color','#444'); $('#credstab').click(function(){ $('#credscontent').css('display','block'); $('#biocontent').css('display','none'); $('#skillscontent').css('display','none'); $('#credstab').css('background-color','#fff'); $('#credstab a').css('color','#19d700'); $('#biotab').css('bac...

c - Delayed Table Initialization -

using net-snmp api , using mib2c generate skeleton code, possible support delayed initialization of tables? mean is, table not initialized until of it's members queried directly. reason member data obtained server, , i'd able start snmpd daemon without requiring other server online/ready requests. thought of maybe initializing table dummy data gets updated real values when member queried, i'm not sure if best way. the table has 1 row of entries, using mib2c.iterate.conf generate table iterators , dealing of seems unnecessary. thought of maybe implementing sequence defined in mib , not actual table, that's not how it's done in examples i've seen. looked @ /mibgroup/examples/delayed_instance.c, that's not quite i'm looking for. using mib2c mib2c.create-dataset.conf config file closest got getting work easily, config file assumes data static , not external (both of not true in case), won't work. if it's not done, i'll implement sequence ...

asp.net - how to retain viewstate for the dynamic controls created in GRIDVIEW -

i creating dynamic textbox onrowcreated event in gridview control, when try findcontrol null here how dong... protected void gvorg_rowcreated(object sender, gridviewroweventargs e) { if ((e.row.rowstate == (datacontrolrowstate.edit | datacontrolrowstate.alternate)) || (e.row.rowstate == datacontrolrowstate.edit)) { if (e.row.rowtype == datacontrolrowtype.datarow) { txbox txtreg = new textbox(); txtreg.id = "_registration" + e.row.rowindex + rowid.tostring(); txtreg.text = reg.registrationtoken; e.row.cells[7].controls.add(txtreg); } } } protected void gvorg_rowupdating(object sender, gridviewupdateeventargs e) { ..... .... textbox _registration1 = gvorg.rows[e.rowindex].cells[7].findcontrol("_registration" + e.rowindex + rowid) textbox; } have tried find by: gridview gv = (gridview)sender; gridviewr...

php - How Do I Make Sessions More Secure? -

possible duplicate: php session security i using sessions throughout application. want make them more secure. using code $username = $_session['username']; , like. how make sessions more secure? the first thing you'll want watch out session hijacking . quote wikipedia: in computer science, session hijacking refers exploitation of valid computer session—sometimes called session key—to gain unauthorized access information or services in computer system. in particular, used refer theft of magic cookie used authenticate user remote server. has particular relevance web developers, http cookies used maintain session on many web sites can stolen attacker using intermediary computer or access saved cookies on victim's computer (see http cookie theft ). the basic idea is, if visitor website (alice) has session cookie , session id (let's assume it's 12345 ), if malicious user (mallory) able learn alice's session id via either javas...

iis - PHP Session variable not saving (though some are) -

i have been unable figure out problem - doesn't make sense. the server php 5.2.6 running on windows nt pdp-iis 5.2 build 3790. first have confirmed sessions working via test script: <?php session_start(); if (!isset($_session['counter'])) $_session['counter']=0; echo "counter ".$_session['counter']++.".<br><a href=".$_server['php_self'].">reload</a>"; ?> the counter increments - works. my site using custom built mvc framework (i wrote it), , put last code of app function testing purposes: echo session_id(); echo '<pre>'; var_dump($_session); echo '</pre>'; session_write_close(); exit(); the first few lines of file are: <?php error_reporting(e_all); ini_set('display_errors', '1'); session_start(); the session dumps , looks expected. go server , open session file - , result appears depend on browser i'm using. chrome , saf...

How to get the page element initiating a GET request from inside a firefox extension xpcom component? -

i have firefox extension xpcom component listens http-on-modify-request , gets location of page making request: getlocationoforiginatingwindow: function (httpchannel) { try { var notificationcallbacks; if (httpchannel.notificationcallbacks) { notificationcallbacks = httpchannel.notificationcallbacks; } else if (httpchannel.loadgroup && httpchannel.loadgroup.notificationcallbacks) { notificationcallbacks = httpchannel.loadgroup.notificationcallbacks; } else { return null; } return notificationcallbacks.getinterface(components.interfaces.nsidomwindow).top.location; } catch (e) { debug("exception getting window location: " + e + "\nchannel uri: " + httpchannel.uri.spec); return null; } }, i page element made request (img, script etc.). there way httpchannel? there's no specific way tell ma...

xcode4 - New iOS project, free hosted repository: Xcode 4 or Xcode 3.2? -

i wonder whether should start development of new ios project in xcode 4 or 3.2 - on 1 hand, know 3.2 (a little), there lots of info out there, , it's stable , proven. on other hand, xcode 4 brings improvements well. newer previews of xcode 4 ready prime time, or still buggy? i'm interested in issues (and recommendations of) externally hosted repositories, not happy how xcode 3.2 played subversion repository in last project. which 1 choose, , (preferably free , externally hosted) repository match? today (3rd feb 2011) apple released gm-seed of xcode4. it's ready usage , can compile apps , release app-store. if new xcode, suggest using xcode4. why? the new compiler has lot of optimizations done. compiler (as far can see results) generates faster code. it's big fun! the new userinterface more reliable. makes development lot faster! 2a. interface builder integrated. can "drag , drop" userinterface item using "ctrl"-key code , xco...

sql server - INSERT w/subquery INTO another table - overflow error -

i've been trying insert data 1 access table linked sql server table using following sql statement this question, modified purposes - keep getting 'overflow' error message: insert dbo_tblgageactivity(strgageid, strcustjobnum, datdateentered, dattimeentered) select [gage id] gageid, [customer job#] jobnum, [date] dateentered, [time entered] timeentered tblinsttrak; i've tried number of ways, resulting in 'overflow' error. must missing something, life of me, don't know what. >100,000 records 1 insert subquery handle? -- edited 01/25/2011 @ 1540 hours -- the data types , sizes of fields follows: tblinsttrak type:size required dbo_tblgageactivity type:size required ---------------------------------------------------------------------------------------------------- gage id text:50 true strgageid text:50 true customer job# text:50 false strcu...

ruby on rails - Validation Based Upon Associated Record -

i have 2 models: user , lesson. want lessons assigned users admins. what best way ensure this? attempting create custom validator so: class belongstoadminvalidator < activemodel::eachvalidator def validate_each(object, attribute, value) unless value.admin? object.errors[attribute] << (options[:message] || "must belong admin") end end end but leads rspec saying: undefined method `admin?' nil:nilclass which makes sense. is custom validator best way this? or should checking if to-be-assigned user admin in controller? i think easiest way of doing is: # lesson model validate :allow_only_admins private def allow_only_admins errors.add(:user, "must admin user!") if (user.blank? || !user.admin?) end i assumed have association named user , user object responds admin? method.

asp.net - AJAX combobox adding new items without autopostback="true" -

buenos nachos, brief, question is: possible allow users add new items combobox @ runtime without having autopostback property set true? understand needs postback if new item added, not want box postback if user selects different value! the tag have below. without having autopostback="true" , comboxbox doesn't allow user add new items box >_<' thoughts? <ajx:combobox id="cbcompany" runat="server" width="226px" dropdownstyle="dropdown" oniteminserted="addcompany" autocompletemode="suggestappend"> </ajx:combobox> i know add few more controls , easy workaround, wondering if possible way. you don't need round-trip server each single change in designed components, client should able handle situations except when server must validate data immediately. that anti-pattern of needs postback or using .net's lazy version of ajax (when server deals tiny bits like, example, ...

android - How to programmatically scroll an HorizontalScrollView -

i have horizontalscrollview contains relativelayout . layout empty in xml, , populated java in oncreate. i scroll view somewhere in middle of relativelayout , way larger screen. i tried mhorizscrollview.scrollto(offsetx, 0); doesn't work. don't know what's wrong this. i post code, not relevant. matters done programatically (has :s), , initial position of horizontalscrollview has set programmatically. thanks reading. please tell me if need more details or if not clear enough. i found if extend horizontalscrollview , override onlayout , can cleanly scroll, after super call onlayout : myscrollview extends horizontalscrollview { protected void onlayout (boolean changed, int l, int t, int r, int b) { super.onlayout(changed, l, t, r, b); this.scrollto(wherever, 0); } } edit: scrolling start or end can use: this.fullscroll(horizontalscrollview.focus_right/focus_left); instead of this.scrollto(wherever, 0);

c - Symbol table and semantic analysis for compiler -

i'm working on building compiler (without using tools -like lex or bison) c language (a simpler one) , have gotten past lexer , parser. not sure way doing parser correct or not. because, far parsing, ie check if syntax correct or not , haven't used linked lists @ all. basically, parser looks this: suppose syntax - <program> ::= <program_header> <program_body> <program_header>::= program <identifier> <program_body> ::= (<declaration>;)* begin (<statement>;)* end program my program looks this: parser() { char *next_token; next_token = get_token(); check_for_program(next_token); } check_for_program(next_token) { check_for_program_header(next_token); if (header_found) check_for_program_body(); }... i have functions non-terminals , call them @ appropriate times , checking keywords "strcmp". method ok? from point, how go doing semantic analysis? should start building symbol table? any suggestion or pointer thin...

python - Django - decorators and error messages -

this seems simple question can't seem find simple answer. django seems give nifty simple way of limiting access places using permission required or login required decorators can't see django docs how 1 pass error message (maybe using messages framework). if have roll own decorator this, point of django decorators? not show error messages? i'll assume avoided reading this http://docs.djangoproject.com/en/1.2/topics/auth/#the-login-required-decorator login_required() following: if user isn't logged in, redirect settings.login_url , passing current absolute path in query string. example: /accounts/login/?next=/polls/3/ . if user logged in, execute view normally. view code free assume user logged in. there no "error messages". error messages rude. , largely useless. they're sign of bad design. generally, don't need million tiny little explanations. indeed, default login page works fine 80% of use case...

Why the code shown below does not render as hyperlink with asp.net mvc -

@mvchtmlstring.create("<a href=""" + blogcomment .userblogurl + """>" + blogcomment .userblogurl + "</a>" ) why not doing: <a href="@blogcomment.userblogurl">@blogcomment.userblogurl</a> instead?

Bad practices in Ruby on Rails -

i'm looking examples of bad practices in ruby on rails, presentation on not do. my biggest on use update_attribute on model after_save hook. object.update_attribute(:only_one_field, "some value") as open ended question, wait week or 2 , select answer voted answer. have fun! too mass-assignment without using attr_protected use of many plugins - there many gems , rails has sooo many plugins available use in applications. however, when use gem or plugin, understand how code operating (unless @ source, people never do). huge problem. don't know how debug code properly, plugins , gems clash 1 another, security becomes major concern, etc. reason, recommend writing all own code. sure, devise nice authentication, can tell me how works , queries run? have control on optimization? (i'm not picking on devise, showing clear example many ror developers familiar with)/ keeping unwanted pages/actions - many rails developers use scaffolding (because nic...

java - paintComponent is executing twice -

this bothering me, code works , runs when went run it, seems looping loops twice, can me logic? thanks... package pkgcirc; import java.util.random; import javax.swing.jframe; import javax.swing.jpanel; import java.awt.*; /* * notes: * draw 20 circles * radius/location (x/y/r) random * if (circle) between radii pt (step thru loop) of values, if within , * draw cyan if overlaps, else black * */ public class main extends jpanel { int[] radius = new int [3]; int[] xarray = new int [3]; int[] yarray = new int [3]; public main() { random g = new random(); setpreferredsize (new dimension(300, 200)); for(int = 0; < radius.length; i++) { radius[i] = g.nextint(50)+1; xarray[i] = g.nextint(250)+1; yarray[i] = g.nextint(150)+1; } } public void paintcomponent(graphics page) { super.paintcomponent(page); for(int = 0; < radius.length; i++) { ...

javascript - making a mouse over event for a div efficiently -

have made simple mouse on event "maindiv" using javascript, - visible "divsub" and mouse out event - hide "divsub" works fine fine, problem have allow user use control within "divsub" "divsub" dissappears mouse out of "maindiv" note while asking few simple solutions did come mind, appears stupid thing, but am interested in knowing proper way achieve above "mouseover effect on menu (made of labels)" best done in css. perform more efficiently too. #divsub { display: none; } #maindiv:hover #divsub { display: block; }