Posts

Showing posts from July, 2013

Is it possible to pass a php variable inside javascript? -

i trying pass php variable inside javascript bt not working. <a href="javascript:wait1();getpass('<?php echo $current?>');">comment</a> is possible or may incorrect somewhere... thanks response in advance! :) you're dynamically generating javascript. save headaches if when need you, keep simple. transfer data php javascript in simplest way possible @ top of page: <script type="text/javascript" > var $current = '<%? echo $current; %>'; </script> as others have pointed out, want encode , quote php variable, using json_encode (in case won't need quotes), or simpler escape function if know possible values. now, inline code can simpler: <a href="javascript:wait1();getpass($current);">comment</a> a final recommendation pull out own function, , use "onclick" attribute.

r - Ordering Merged data frames -

as new r programmer seem have run strange problem - inexperience r after reading , merging successive files single data frame, find order not sort data expected. i have multiple references in each file each file refers measurement data obtained @ different time. here's code library(reshape) # enter file name read & save data filename=readline("enter file name:\n") # find first occurance of file ( round1 in 1 : 6) { readfile=paste(round1,"c_",filename,"_stats.csv", sep="") if (file.exists(readfile)) break } x = data.frame(read.csv(readfile, header=true),rnd=round1) ( round2 in (round1+1) : 6) { # readfile=paste(round2,"c_",filename,"_stats.csv", sep="") if (file.exists(readfile)) { y = data.frame(read.csv(readfile, header=true),rnd = round2) if (round2 == (round1 +1)) z=data.frame(merge(x,y,all=true)) z=data.frame(merge(y,z,all=true)) } } ordered = order(z$lab_id) results = z[ordered,...

MySQL error USING BTREE -

i have mysql database have downloaded online server , trying import on local mysql not working showing syntax error. cannot find errors in query this error: 1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near 'using btree, key idx_p_id ( p_id ) using btree, key ' @ line 27 and query: primary key (`a_id`), unique key `idx_a_id` (`a_id`) using btree, key `idx_p_id` (`p_id`) using btree, key `idx_m_id` (`m_id`) ) engine=innodb auto_increment=1 default charset=latin1; your mysql server version older , not compatible 1 dump created. try upgrade mysql server or export dump using --compatible option of mysqldump. you need this: mysqldump --compatible=mysql40 ... you have option import dump newer server can create locally , re-export there using comopatible option. i have seen people search , replacing stuff in mysql dump files ugly approach, might work if have incompatibility. also fo...

svn - Using Subversion TortoiseSVN Merge Algorithm in a .NET Project -

i have whole bunch of pairs of files have subtle differences. use subversion source control, , merge/diff utility comes tortoisesvn windows. , can use utility manually compare/merge 2 files together. question this: how can programmatically merge 2 files same way utility (and ignore , flag files have conflicts)? this may help: automating tortoisemerge

c# - How to show hours and minutes on the DateTimePicker -

i'm using c# .net , have windows form datetimepicker. my question is: how can display hours , minutes (for user change) along year, month, , day? check out customformat property: http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.customformat.aspx it allows set format you'd like. also, make apply, you'll have set datetimepicker.format custom. edit: if provide better idea/example of format want displayed, can actual format string.

arrays - Property based searches in Javascript -

while looking best way search array of objects in javascript (there doesn't seem iterate + compare function that) came across post seems elegant way of doing this. however have questions: javascript doesn't have associative arrays. these seems one. gives? this seems elegant solution how stack against competition? "pass array , comparison function" - means several specific comparison functions various searches. "optimised findbyx functions" - means optimised searches each type needed. " scalalala method" - suspect slowest elegant. also how go taking reponse ajax , creating array similar structure this? tutorials hand-pick , roll examples demonstrate associativity of arrays not how used practically. is there pitfalls using method? decent links ( beyond this ) appreciated. thanks. update: having trouble with. if have data coming server similar this: $.getjson("map.php?jsoncallback=?", function(data) { (var ...

c# - Excel through OleDb shows numbers differently...depending on whether spreadsheet is open? -

i'm opening excel worksheet datatable using oledb this: string select = string.format("select * [{0}$]", worksheetname); using (var con = new oledbconnection(connectionstring)) using (var adapter = new oledbdataadapter(select, con)) { con.open(); var dt = new datatable(); adapter.fill(dt); con.close(); return dt; } then loop through rows of datatable reading various bits of data this: decimal charge; bool ischargereadable = decimal.tryparse(row["charge"].tostring(), out charge); i discovered code choking on cells dollar amounts such "$1100.00", can't parse decimal. not surprising...except code working before now. further investigation revealed if run code while workbook open , sees 1 of cells "1100". if run while workbook closed, sees "$1100.00". why happening? i'll have rework code function while workbook closed, why make difference? would've thought reading saved workbook. ...

php - Log out everywhere, where else I am logged in -

i use php sessions basis of user login system, successful login setting $_session['userid']. allows user log in same account multiple machines. however, i'd implement following features: log out everywhere, similar stack overflow has. see else 1 logged in. both require more session variable, , i'm willing put more information database accomplish these. standard way above? create new database table store sessions, , instead of storing information directly in $_session , store id referring row in new session table. table can contain information ip address, username, , time of last activity. your application should check sessions table against has in $_session , when remove rows in table particular user, every session invalidated, wherever is. can query rows belonging particular user, can show have active sessions. you'll have start thinking handling user leaves session without explicitly logging out - possibly scheduled job runs every hour or...

git - How can I fork my own GitHub repository? -

so, total newbie git. been reading through guides , think have basics having difficulties accomplishing 1 goal. i have repo created generic markup source code. stuff reuse every breakout. it's called markupdna.git i have different directories in mac sites dir ~/sites/project-n . build upon generic stuff , breakout of site. these tied main git repo forks, cannot fork own repo? i wish this: git clone <url> name git add . # make changes git commit -m 'whatever' git push but don't want push origin. want push fork of markupdna repo whence cloned. seems pushes changes right origin master. idea keep markupdna clean , have lot of forks different projects, each of have own cloned dir on hard drive. any ideas? it lot easier use branches , rather using separate forks. can still have separate checkouts each branch; clone repo multiple times, , use git checkout in each 1 switch appropriate branch (or git checkout -b create branch , check out @ onc...

High-level Java filesystem content manipulation : old style vs. jcr? -

what best way choose managing text/binary content on filesystem? typically when building web applications lot of multimedia binaries , other various text based content stored on filesystem, jdk 6 java.io still low level. it change java 7 can see here new java.nio.file.* package but until java 7 out , implemented ides etc., don't know use this, except of org.apache.commons.io. tried few samples jackrabbit, i'm not sure if idea purpose mentioned @ beginning. possible manage filesystem binary/text content jackrabbit ? put nodes , properties instead of directories. bring advantages ? it's not clear you're looking for, google's guava libraries have io package, , in particular, files class full of static methods file manipulation. it's not content repository system, may provide enough functionality you're trying do.

php - gd text and lines show up as grey in gif from Illustrator -

i'm using gd in php add text gif image illustrator. i've added text , drawn figures, , no matter how specify color, show gray (i'm guessing 50% gray). i opened image in ms paint , re-saved gif. when did that, gave warning of color loss. however, colors show correctly when add things using gd on new image. what's deal? have palette illustrator uses when saving original? i'm using php version 5.2.6-1+lenny9. here's gd info: gd support enabled gd version 2.0 or higher freetype support enabled freetype linkage freetype freetype version 2.3.7 t1lib support enabled gif read support enabled gif create support enabled jpg support enabled png support enabled wbmp support enabled gif indexed colour format - means image has limited palette of colours choose (up 256, if recall correctly, gif). when process image gd, have make sure you're correctly choosing kind of image resource copy things, alter or whatever. if ...

java - How to extract the value from a resulset of two statments that are union -

i have method in dao class called "getdetails" . in method, union 2 select statments 2 tables same field called "main shop" & "sub shops" , put queries preparedstatement. put preparedstatement resultset. this "getdetials" method return "details" , i'll use method in mediator called "writefile" in order print values in microsoft word "writefile(details)" . in "writefile" method, there strings of values , put values of "details" respective string. , append "outputstring" each value. on input screen, user may check "sub shops" check box , fill details of "sub shops" after checking it. if don't check, need fill "main details" , not "sub shops" . if check "main shop" , need print 1 letter. if check "sub shops" , fill "quantity of sub shops" , need print letters letter number equal "quanti...

vb.net - Form is not updating, after custom class event is fired -

i'm having issue main form isn't updating though see event fire off. let me explain situation , share of code i'm sure horrible since i'm amateur. i created class take in settings running process in background. add custom events in class use in form instead of timer. i put break on 2 subs handle events , see them kicked off install starts. i @ data , it's coming across , no exceptions thrown. at first thought because datagridview had latency issues. set double buffered through tricks found didn't matter. there still 10 second delay before data showed in datagrid. i thought , decided didn't need datagridview , replaced control multiline textbox, didn't make difference. it's still taking 10 seconds or longer show updates form/textbox. i've included of code below. public shared withevents np newprocess private sub form1_load(byval sender object, byval e system.eventargs) handles me.load try np = new new...

Grails - Determine if an artefact class is in a given subdirectory of grails-app -

i'm implementing artefacthandler , want able create artefacts script s (to support legacy format). don't want make scripts artefacts, in particular subdirectory of grails-app, grails-app/foo/ . i'm stuck @ trying figure out path of artefact artefacthandler 's isartefactclass method. there way path original source of class, or otherwise determine if it's contained in grails-app/foo ? grails doesn't care on filesystem classes are. that's smoke , mirrors. such, there no support location based artefacts, there ticket it: http://jira.codehaus.org/browse/grails-2174 in meantime, simplest solution force scripts have naming convention or possibly introduce kind of marker annotation. unsure how introspect script classes though looking annotations.

java - JScrollPane setViewPosition After "Zoom" -

the code have here using mouseadapter listen user "draw" box around area of image zoom in on , calculate ratio of box image. resizes image calculated ratio. part works. the issue having making jscrollpane view appear if still @ same top left position after image has been resized. have tried several methods seem have gotten close result want not exactly. this listener finds scale ratio , sets position: import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import java.awt.graphics; import java.awt.point; import javax.swing.jscrollpane; import javax.swing.jviewport; import javax.swing.jcomponent; public class dynamiczoom extends mouseadapter { private point start; private point end; private double zoom = 1.0; private jscrollpane pane; private jviewport port; public void mousepressed(mouseevent e) { if(e.getbutton() == mouseevent.button1) { this.pane = (jscrollpane)e.getsource(); this.port = pane.getviewport(); start = e....

bash - have to determine all users home directories - tilde scripting problem -

assume someuser has home directory /home/someuser name=someuser in bash - expression use combining tilde (~) , $name return users home directory? homedirectory=~someuser echo $homedirectory /home/someuser name=someuser echo ~$name ~someuser any suggestions? safer : eval homedirectory="$(printf "~%q" "$name")" here %q option printf quotes , escapes dangerous characters. if $name joe, you'd /home/joe . root, might /root . "abc;rm something" you'd "~abc;rm something" instead of having removed.

c# - WPF: Binding a ItemsSource to a Directory -

i'm trying first wpf project, , i've started this sample project image display. part of xaml binds listbox array of images: <listbox.itemssource> <x:array type="{x:type imagesource}"> <imagesource>http://static.flickr.com/34/70703587_b35cf6d9eb.jpg</imagesource> <imagesource>http://static.flickr.com/20/70703557_494d721b23.jpg</imagesource> <imagesource>http://static.flickr.com/35/70703504_3ebf8f0150.jpg</imagesource> <imagesource>http://static.flickr.com/35/70703474_18ef30450f.jpg</imagesource> </x:array> </listbox.itemssource> now nice, bind images in subfolder , it's subfolders match pattern. directory structure this: archive 1994-01 index.jpg page1.jpg ... pagen.jpg 1994-02 index.jpg page1.jpg ... pagen.jpg i want bind listbox various index.jpg images. my normal app...

java - are the new objects assigned from eden space or eden + fromSurvivor space? -

are new objets assigned eden space or eden + fromsurvivor space ? can free space in survivor space used allocation new objects? edit : consider scenario: suppose eden space full , survivor space occupancy less, in case if new object created (new object small enough fit survivor space) minor collection occur or space new object allocated fromsurvivor space? i believe eden space used small objects, , large objects allocated directly in old space. if new objects allocated in survivor space, kinda defeat point of having separate spaces. see this pdf more details, including: most objects allocated in eden. (as mentioned, few large objects may allocated directly in old generation.)

Get last key-value pair in PHP array -

i have array structured this: [33] => array ( [time] => 1285571561 [user] => test0 ) [34] => array ( [time] => 1285571659 [user] => test1 ) [35] => array ( [time] => 1285571682 [user] => test2 ) how can last value in array, maintaining index [35]? the outcome looking this: [35] => array ( [time] => 1285571682 [user] => test2 ) try use end($array);

What are the different ways of performing sorting in java -

this question asked in interview . except collections.sort() other methods . sorting interfaces comparable<t> , comparator<t> standard interfaces used standard java sorting options (all except on primitive arrays, is). in java-speak, class implements comparable has "natural order". (technically, must implement comparable<? super e> e matches itself, have natural order). classes don't have natural order can sorted using external comparator. comparator can used implement sort order runs against natural order (e.g. sort strings in descending alphabetic order). these principles applied both in sortedset<e> , sortedmap<k,v> implementations, sort elements / keys automatically using either natural order or supplied comparator. these same principles can found in static utility methods arrays.sort(arr) , arrays.sort(arr, comparator) arrays collections.sort(list) , collections.sort(list, comparator) lists that can u...

Keypad decimal separator on a Wpf TextBox, how to? -

i have wpf application textbox decimal input. i when press "dot" key (.) on numeric keypad of pc keyboard send correct decimal separator. for example, on italian language decimal separator "comma" (,)...is possible set "dot" key send "comma" character when pressed? for need gloablize application. see these links: http://msdn.microsoft.com/en-us/library/ms788718.aspx http://www.codeproject.com/kb/wpf/globalizelocalizeawpfpro.aspx

javascript - How to disable Cross Domain Restriction -

i providing web service return data json object. problem ajax, ajax can't call cross domain url. possible disable it? you can't disable it, can solve problem accepting jsonp -requests.

vba - XML Schema for customizing Office 2010 Ribbon -

i've seen plenty of examples around internet on how add button or group etc. ribbon, no reference xml schema document explain options writing xml own custom ribbon tabs , groups. have link this? cheers, dave --trindaz on fedang #office-2010-customization the schema here , control identifiers here .

Insert/Select with Linq-To-SQL -

is there way insert/select linq translates sql: insert tablea (...) select ... tableb ... yes @bzlm covered first, if prefer bit more verbose: // dc = datacontext, assumes tablea contains items of type var toinsert = b in tableb ... select new { ... }; tablea.insertallonsubmit(toinsert); dc.submitchanges(); i kind of prefer review/maintenance point of view think bit more obvious what's going on in select. in response observation @jfbeaulac : please note will not generate sql shown - far i'm aware it's not possible generate directly using linq (to sql), you'd have bypass linq , go straight database. functionally should achieve same result in perform select , insert data - round-trip data server client , may not optimal large volumes of data.

linq to sql - TextBox value not updated -

i fetching data database textbox using linq.when try update same textbox value,it not work. dal.tournamentsdatacontext tdc = new schoolsports.dal.tournamentsdatacontext(); var tournamenttable = tdc.gettable<dal.tournament>(); var tournamentrecord = (from rec in tournamenttable rec.tournamentid == tournamentid select rec).single(); tournamentrecord.tournament_type = tournament_type; tournamentrecord.tournament_name = tournament_name; ; tournamentrecord.tournament_level = tournament_level; tournamentrecord.tournament_for = tournament_for; tournamentrecord.country_code = country_code; tournamentrecord.tournament_status = tournament_status; tournamentrecord.tournament_begin_date = tournament_begin_date; tournamentrecord.tournament_end_date = tournament_end_date; tournamentrecord.sponsored_by = sponsored_by; t...

vb.net - ASP.NET membership check if a user is in a role in custom class -

in vs solution, have 2 projects.one web interface, other dataacess , businesslogic. know can check if logged-on user employee in web interface project code behind: dim isemployee = user.isinrole("employee") the problem have class call usermanagement in da , bl project want check logged-on user role also. can't use dim isemployee = user.isinrole("employee") because doesn't have aspx page. what need check user role in custom class? thank you. you need reference system.web in business project. following: dim context system.web.httpcontext = system.web.httpcontext.current dim isrole boolean = context.user.isinrole("admin") or c# system.web.httpcontext context = system.web.httpcontext.current; bool isrole = context.user.isinrole("admin");

Why does new T-SQL of SQL Server 2008 work on database in compatability mode 80? -

experimenting new features of t-sql, i've run puzzle. here new syntax supported sql 2008 , i'd expect work on databases set compatibility mode 100 (i.e. 2008) , not work compat mode 80 (i.e. 2000). yet works database set sql server 2000 compatibility mode on sql 2008 instance of standard edition: use mds -- db compat mode 80 go create table dbo.employees ( name varchar(50) null, email varchar(50) null, salary money null ) insert dbo.employees(name, email, salary) values('scott', 'scott@example.com', 50000.00), ('jisun', 'jisun@example.com', 225000.00), ('alice', 'al@example.com', 75000.00), ('sam', 'sam@example.com', 45000.00) select * dbo.employees drop table dbo.employees the compatibility mode setting used control relatively obscure (imho) aspects of databae engine behavior. not block or prevent use of extensions t-sql language being used on databases migrated prior versions--for exam...

flex - difference between <s:Line> and graphics.lineTo() -

if skin button , use as3 graphice.clear() , graphics.lineto , beginfill create shape, button overlaps other items in container. when use , mxml create same shape, button neatly positioned inside container. why that? because line object doing bunch of checks , work aren't doing when use graphics object. @ code spark.primitives.line see doing aren't.

google app engine - in gql (appengine), how do i check if an entity exists matching 2 filters before inserting a new one? -

the 2 filtered fields unique index in sql want see if entity exists based on these 2 fields before inserting new one. currently have: t2get = db.gqlquery("select __key__ talk2 ccc = :1 , ms = :2", c, theday) x in t2get: thekey = x[0] if thekey: t2 = talk2.get(thekey) else: t2 = talk2() which errors with: unboundlocalerror: local variable 'thekey' referenced before assignment if entity doens't exist. any ideas? if 2 fields unique index, maybe should instead use them key_name. faster , can use transaction, if needed. def txn(): key_name = "%d.%d." % (c, theday) t2 = talk2.get_by_key_name(key_name) if not t2: t2 = talk2(key_name=key_name) t2.put() db.run_in_transaction(txn)

php - Are databases always the solution in web data storage? -

i haven't got experience databases, intends learn , use on web project i'm planning. though, i've got advice pal of mine use of databases should quite more extensive planned. believes in keeping of data in databases, find databases convenient regarding perhaps user data (just tiny pieces of data), , page content data , (everything that's not tiny pieces of data) in static files - without having knowledge build assumption upon. what better solution? minimum data in databases, or as can find ways store in them effectively? is there performance difference between use of static files , databases? would best solution depend on general site traffic? i intend use combination of php , mysql. if want able search specific data based on several parameters, need use database. sql language namely offers where clause this. whenever data created , updated, database best choice, because provides constraints ensure uniqueness of data degree. relations between...

iphone - How can i highlight a specific rows on UITableView -

hi have uitableview x rows , cell data loaded plist file , wanna implement uitextfield user inserts cell number , after done button cell going highlight , show cell row , example enter 104 , show me row 104 . there anyway ? thank . -[uitableview selectrowatindexpath:animated:scrollposition: ]

Prevent ASP.NET GET request timeout? -

i've got asp.net application serves mp3 content, content generated during request , can delay sending of response's first byte several minutes. the client podcatcher (i don't know which), , lowest timeout i've seen 20 seconds. is, these clients (reasonably enough) giving relatively quickly, assuming there's no response coming. how can keep these clients giving up? how can let them know response coming? if you're serving content in binary format, should able format headers , push them out right away before have binary content organized. if you're using handler, can speed process avoiding lot of iis overhead, , @ same time can content-headers started (not completed, started) , use response.flush() them out.

How do I pass data between Activities in Android application? -

i have scenario where, after logging in through login page, there sign-out button on each activity . on clicking sign-out, passing session id of signed in user sign-out. can guide me on how keep session id available activities ? any alternative case the easiest way pass session id signout activity in intent you're using start activity: intent intent = new intent(getbasecontext(), signoutactivity.class); intent.putextra("extra_session_id", sessionid); startactivity(intent); access intent on next activity string s = getintent().getstringextra("extra_session_id"); the docs intents has more information (look @ section titled "extras").

What does the "rep stos" x86 assembly instruction sequence do? -

i stumbled across following assembly instruction sequence: rep stos dword ptr [edi] for ecx repetitions, stores contents of eax edi points to, incrementing or decrementing edi (depending on direction flag) 4 bytes each time. normally, used memset -type operation. usually, instruction written rep stosd . experienced assembly coders know details mentioned above seeing that. :-) eta completeness (thanks phis): each iteration, ecx decremented 1, , loop stops when reaches zero. stos , thing observe ecx cleared @ end. but, scas or like, repz / repnz prefixes used, ecx can greater 0 if operation stopped before exhausting ecx bytes/words/whatevers. before ask, scas used implementing strchr -type operations. :-p

How do I use Union in linq (vb.net)? -

i know how call union extension method, e.g. dim r = productfirstchars.union(customerfirstchars) however do linq syntax, e.g. from productfirstchars select ???? you can't - not linq operators supported in query expressions, , union 1 of isn't. (vb has language support more query operators c#, happens.) see the documentation list of supported query clauses.

axis2 - How to stream Axis 2 MTOM temp file to HttpServletRequest -

i'm using code below retrieve attachment webserver. client in case web browser. currently, user makes request webserver attachment. webserver makes mtom request server attachment. webserver waits attachment download before begins writing attachment out response. user waiting twice long file. how can tap axis2 code access temp file can stream user being created? know doesn't sound best way this, requirement. i'm working large files 2gb, waiting twice long recieve file isn't working out. options options = new options(); options.setto(new endpointreference(this.endpointurl)); options.settransportinprotocol(constants.transport_http); options.setproperty(constants.configuration.enable_mtom, constants.value_true); options.setproperty(constants.configuration.cache_attachments, constants.value_true); options.setproperty(constants.configuration.attachment_temp_dir, this.tempdirectory); options.setproperty(constants.configuration.file_size_threshold, string.valueof(this.tem...

sql server - Alter column, add default constraint -

i have table , 1 of columns "date" of type datetime. decided add default constraint column alter table tablename alter column dbo.tablename.date default getutcdate() but gives me error: incorrect syntax near '.' does see wrong here, missing (other having better name column) try this alter table tablename add constraint df_constraintname default getutcdate() [date] example create table bla (id int) alter table bla add constraint dt_bla default 1 id insert bla default values select * bla also make sure name default constraint..it pain in neck drop later because have 1 of crazy system generated names...see how name default constraints , how drop default constraint without name in sql server

radio button - ASP.NET Radiobutton list set to autopostback but not posting back if selected item changes -

i have radiobuttonlist have set autopostback, when user clicks button, there no postback. any suggestions? i assume "when user clicks button" mean when user clicks 1 of radio button options. without seeing code, 2 common scenarios be: a script error occurring preventing postback (script errors can detected in ie or via firefox , firebug extension 2 diagnostic options) updatepanels involved, , attempting use autopostback refresh updatepanel if latter scenario , using updatepanels, try putting radiobuttonlist inside own updatepanel, autopostback set true on radiobuttonlist , updatemode on updatepanel set "always" (the default value).

java - What is the use of AtomicReferenceArray? -

when idea use atomicreferencearray ? please explain example. looks it's functionally equivalent atomicreference[] , occupying little less memory though. so it's useful when need more million atomic references - can't think of use case.

windows - What exactly is a PWSTR and why use this naming compared to char*, std::string, or CString in C++? -

in various c++ code see different usage of strings: pwstr, char*, std::string, cstring, etc ... when best time use pwstr compared other string type? a pwstr wchar_t string pointer. unicode (usually ucs2) string each character taking 16 bits. a char* pointer 8 bits per character. ascii, ansi, utf8, or 1 of many hundreds of other encodings. although need worry encodings if need string hold languages other english or special symbols. in general, windows api unicode internally windows programmers use wchar strings. std::string , cstring can both unicode if right symbols #defined , choice between pwstr , std::string , cstring matter of preference or convention of codebase work with.

iphone - Retain counts of IBOutlets -

while coding same questions concerning retain counts of iboutlets came along: retain count after unarchiving object nib? when use @property's iboutlet? retain or assign while setting? differences between mac , iphone? so read the nib object life cycle apple's documentation. test apps on mac , iphone gave me strange results. nevertheless wrote down few rules how handle issue stay happy while coding wanted verify community , listen opinions , experiences: always create iboutlet top-level objects. non-top-level objects if necessary (access needed). always provide property follows iboutlets (and release them necessary!): top-level objects on mac: @property (nonatomic, assign ) iboutlet someobject *someobject; @synthesize someobject; [self.someobject release ]; non-top-level objects on mac ( no release ): @property (nonatomic, assign ) iboutlet nswindow *window; @synthesize someobject; top-level objects on iphone (must retain): @property (nonatomic, retain ...

jQuery custom validation method issue -

i have select list that's default value (for please select) 0. due payment processing system , beyond control. have add.method states if select's value "0" return false, otherwise return true. works ok, except when change select's value else after submitting , getting error, error msg still displayed. how fix this the html: <form action="" method="post" id="singlepmnt"> <td> <select name="technology" class="select" id="singletech"> <option value="0" selected="selected">&nbsp;please select</option> <option value="interactive brokers">&nbsp;interactive brokers</option> <option value="mb trading">&nbsp;mb trading</option> <option value="patsystems">&nbsp;patsystems</option> <option value="pfg">&nbsp;pfg (peregrin...

c# - Screen saver application doesn't read App.Config -

i've written screen saver in c# whenever run on preview mode or let kick in, throws exception. when double click in windows\system32 runs fine. visual studio debugger sussed out doesn't read .config file of application, in windows\system32. i think when rundll32.exe executes screen saver, app.config file being omitted. there way force load? thanks as far remember previous experience, screen savers run "current directory" set %userprofile%. may check if true or not temporarily placing config file directory. , if happens true have add code read config directory in screen saver sits, not current directory.

Streamming a h.264 coded video over UDP -

i don't know h.264, thing i've got video in h.264 in mp4 container stream on udp. my question simple, there tweaks can maybe while coding video comes out tolerant "light" packet loss? i know compressed video has keyframe every n frames , in between sends deltas. can imagine h.264 should lot more complex that, , might not simple. to more precise, i've been making experiments , realized removing 1024 bytes out of stream of video, render "unplayable" point of loss , on. what tolerate light losses that, possible? thanks nelson it depends on data you're losing. data in h264 stream not data can lost. example, if experiment dropped 1024 bytes happened first 1024 bytes sent, dropped sequence parameter set , picture parameter set (sps/pps), information tells decoder how interpret incoming information. can't drop random 1024 bytes out of stream; typically h264 packetized sort of thing wouldn't happen anyway. so h264 contai...

python - How do I subclass QApplication properly? -

i newbie pyqt4 (and qt altogether), , facing problem, i have subclassed qapplication (to have global data , functions global application): class app(qapplication): def __init__(self): qapplication.__init__(self) self.foo = none def bar(self,x): do_something() when try add slot main window like: self.connect(bar, signal('triggered()'), qapp.bar) i error: attributeerror: bar what doing wrong? or should make stuff want global, global stuff instead off attributes , methods of qapplication subclass? (or else, if so, what?) note: worked fine when "global" methods , attributes in qmainwindow -subclass... try adding qtgui.qapp = self __init__ method (or try using qapplication.instance() instead of qapp ). i hope helps.

WCF Client proxy creation strategy with custom endpoint behavior -

i'd centralize creation of wcf proxies in wpf client application. during creation of each proxy i'd define programaticaly specific endpoint behaviors (adding localization headers etc) , define client credential settings (i'm using message level security username client credentials). creation of proxy should this: public class servicechannelfactory { public t createchannel<t, tservice>() t : clientbase<tservice> { var proxy = new t(bindingbuilder.getbinding(), endpointbuilder.getendpointaddress()); //!!! proxy.endpoint.behaviors.add(new localizationendpointbehavior()); proxy.clientcredentials.username.username = applicationcontext; proxy.clientcredentials.username.password = txtpassword.password; return proxy; } } and usage should this: var scp = new servicechannelfactory(); var proxy = scp.createchannel<myserviceclient, icustomerservice>(); proxy.open(); try { proxy.callservice(); } { proxy.close(); } but i'm not able f...

c# - WPF - Good Way to take a list to a Tree -

i have list looks this: base/level1/item1 base/level1/item2 base/level1/sub1/item1 base/level2/item1 base/level3/sub1/item1 i easy way put listview. (ie similar this) base | +->level1 | | | +=item1 | +=item2 | | | +->sub1 | | | +=item1 | +->level2 | | | +=item1 | +->level3 | +->sub1 | +=item1 is there established way make kind of conversion or need roll own parser? (in case may relevant real items in code tfs iteration paths.) this take list of strings , turn tree suitable viewing treeview described: public ilist buildtree(ienumerable<string> strings) { return s in strings let split = s.split("/") group s s.split("/")[0] g // group first component (before /) select new { name = g.key, children = buildtree( // recursively build children s in grp s.length ...

Optimal way to store datetime values in SQLite database (Delphi) -

i storing datetime values in sqlite database (using delphi , disqlite library). nature of db such never need transferred between computers or systems, interoperability not constraint. focus instead on reading speed. datetime field indexed , searching on lot, reading in thousands of datetime values in sequence. since sqlite not have explicit data type datetime values, there several options: use real data type , store delphi's tdatetime values directly: fastest, no conversion string on loading; impossible debug dates using db manager such sqlitespy, since dates not human-readable. cannot use sqlite date functions (?) use simple string format, e.g. yyyymmddhhnnss: conversion required relatively easy on cpu (no need scan separators), data human-readable. still cannot use sqlite date functions. do else. what's recommended thing do? i have read http://www.sqlite.org/lang_datefunc.html there's no mention of data type use, and, not being formally schooled in programm...

c# - Examples for Entity Framework 4: Mapping POCOs to EAV database? -

our customer advertises products product's attributes vastly different 1 another. there many product "classes" there products. originally, created eav database added , removed attributes each "class" of product. whole thing works well, complexity mind numbing. this database #1. we came set of fields common represent products (pocos), moving "extra" fields xml field "catch all". this database #2. now have customers using old , customers use new. didn't want update old until needed so, have changes time time take longer necessary because of eav structure. questions: any examples out there on how code ef persist pocos eav databases (where have table of field names , table of data)? should scrap database , write "normal" tables older customers, given have changes time time? normal of course referring boyce codd normal form. we handled older database bleeding structure software, mapping pocos in repository. ...

With rails, how do I find objects NOT in a Has Many Through collection? -

let's article has many tags through taggings. article has_many :taggings has_many :tags, :though :taggings end @article.tags #gives tags article how find tags article not have? thanks the way can think of using rails finders 2 queries , subtract: class article def unused_tags tag.all - self.tags end end alternately, through sql (which more efficient since you'd getting rows want ): query = <<-eos select * tags t not exists ( select 1 taggings article_id = ? , tag_id = t.id ) eos tag.find_by_sql [query, article.id]

How to apply a function to every element in a list using Linq in C# like the method reduce() in python? -

how apply function every element in list using linq in c# method reduce() in python? assuming you're talking this reduce function , equivalent in c# , linq enumerable.aggregate . quick example: var list = enumerable.range(5, 3); // [5, 6, 7] console.writeline("aggregation: {0}", list.aggregate((a, b) => (a + b))); // result "aggregation: 18"

asp.net - Global 301 redirection from domain to www.domain -

could use begin request of global.asax redirect everything, from mydomain.domain www.mydomain.domain ? if 1 true, how can that? protected void application_prerequesthandlerexecute(object sender, eventargs e) { string currenturl = httpcontext.current.request.path.tolower(); if(currenturl.startswith("http://mydomain")) { response.status = "301 moved permanently"; response.addheader("location", currenturl.replace("http://mydomain", "http://www.mydomain")); response.end(); } }

c# - Code in base class method not executing when using "base" keyword -

i'm seeing strange problem when overriding abstract method , trying call base class's method i'm overriding. //in dll "a" namespace rhino.etl.core.operations { using system; using system.collections; using system.collections.generic; public class row {} public interface ioperation { ienumerable<row> execute(ienumerable<row> rows); } public abstract class abstractoperation : ioperation { public abstract ienumerable<row> execute(ienumerable<row> rows); } public abstract class abstractdatabaseoperation : abstractoperation { } public abstract class sqlbulkinsertoperation : abstractdatabaseoperation { public override ienumerable<row> execute(ienumerable<row> rows) { console.writeline("sqlbulkinsertoperation"); return rows; } } } //in console app "b" namespace mystuff { usi...

regex - Efficiency of lookarounds in C# regular expressions. Should I avoid them if I can? -

everyone! i'm quite new regular expressions, them, lot! call me nitpicky if will, i'd know if should avoid using lookaheads , lookbehinds if have option. for example, 2 commands below same thing, 1 uses lookbehind , other doesn't. the_str = regex.replace(the_str, @"(;|!|\?) \.{3}", "$1..."); the_str = regex.replace(the_str, @"(?<=(;|!|\?)) \.{3}", "..."); which 1 use? more efficient? thanks answers! i tested both locally , method using lookbehind 25% slower. another variation tested using lookahead instead of lookbehind 10% slower: s = regex.replace(s, @"(;|!|\?) (?=\.{3})", "$1"); i don't think there's enough of performance difference advise avoiding lookarounds. if think makes code more readable use them. optimize performance if profiling shows have performance problem , regular expression bottleneck. for information, string tested on "blah; ... foo ...; bar bar ? ....

flex - Tree Show toolTip during drag -

i denying user ability drop tree during conditions, it's going well, want tell user why i'm denying drop. prefer tooltip, doesn't seem work. can not have tooltip during drag operation? how can force one? flex seems treat tooltips property of ui component, component deciding when , if show it. force doing 1 in javascript saying "show now" "stop showing now" does know doing during drag? thanks ~mike what try show tooltip mx.managers.tooltipmanager . create example vbox implements mx.controls.tooltip , displays message want show user. you can see working example @ flexexamples . another idea show programmatic mouse cursor when drop denied. i've read article on inside ria .

php - put multipart data with curl with different content types -

i want ask question because php documentation doesn't mention it how 1 put xml data , binary data together? $imagecontent = @file_get_contents($imagelocation); $xmldata ="<xml></xml>"; $headers = array("mime-version: 1.0"); curl_setopt($ch, curlopt_customrequest, "put"); curl_setopt($ch, curlopt_httpheader, $headers ); curl_setopt($ch, curlopt_postfields,$data); i know if pass $data array, curl automaticly set multipart, how can associate different content types different contentvariables? $xmldata $imagecontent content-type: application/atom+xml content-type: "jpg" i have sample wich done fputs , more inline , uses boundary. don't know if have curl , if how it? can provide samplecode please? thanks, richard i've found answer similar question , can useful you.

latex - How can I add delimiters around the amsmath align environment? -

Image
i have group of equations , i'd show under transformation, system looks else. i'd group ams align environment inside pair of brackets such align environment vertically centered on line , can like: (that uses matrix environment, alignment centered.) i using lyx. \begin{equation} \left\{ \begin{matrix} x = & y \\ y = & -x-\mu(x^4-1)y \end{matrix} \right\} \rightarrow \left\{ \begin{matrix} w = & -x \\ x = & w-\mu f(x) \end{matrix} \right\} \end{equation} produces closely thing shown above.

has many - what is the right way to model status values as an association in Rails? -

i have model called contacts. contacts can have different status "bad, positive, wrong..." these status may need changed on time, across contacts, same options. should model way: contacts.rb belongs_to :status_contact statuscontacts.rb has_many :contacts then manually populate types of status in table? i want use ajax click button corresponding value update value contacts. it looks you're trying ensure values status going restricted set of possible answers of choosing. if that's you're trying do, there's no special need separate table. can use magic of activerecord validations instead here. first, create string database column contact called :status. then can use validation ensure values limited ones want. in rails 3, can this: validate :status, :inclusion => { :in => %w( bad positive wrong ) } (if you're using rails 2, use #validates_inclusion_of instead.) in activerecord, validations check object's values...

c# - How to load an image, then wait a few seconds, then play a mp3 sound? -

after pressing button, show image (using picturebox), wait few seconds , play mp3 sound, dont work. wait few seconds use system.threading.thread.sleep(5000) . problem is, image appears after wait time, want show first, wait, play mp3... tried use waitonload = true doesn't work, shouldn't load image first , continue read next code line? here code i've tried (that doesn't work): private void button1_click(object sender, eventargs e) { picturebox1.waitonload = true; picturebox1.load("image.jpg"); system.threading.thread.sleep(5000); messagebox.show("test");//just test, here should code play mp3 } i tried loading image "loadasync" , put code wait , play mp3 in "loadcompleted" event, doesn't work either... i use loadcompleted event , start timer 5 sec interval once image loaded, ui thread not blocked: private void button1_click(object sender, eventargs e) { picturebox1.waitonl...

c# - What's a good substitute for an enum? -

i'm writing web service returns different types of errors. each method can return 1 of 3 basic types of errors: general , invalidinput , or non . in addition 3 possible values, each method can have it's own errors (e.g. signin method - invalidpassword) - each method can return 1 error. example signin method able return 1 of following error types: general, invalidinput, non, invalidpassword. @ first thought of using enums, think error types should implement inheritance because there basic 3 types, , each new method's error types inherit that.. can't think how. thought of using static class - have 1 string static field - , inheritance irrelevant again... problem enums web service's client meaningless int (through json) so question is: way of conveying idea there 3 basic possible values, , can add make new type of errors? it best if reconsidered interfaces. it far better use exceptions on error codes not because easy forget checking error code, b...