Posts

Showing posts from September, 2015

How do .net 4.0 [named] tuples work under the hood? -

i suspect there lot of work done @ low level. when names used tuple elements, auto-properties created? thanks. are talking anonymous types ?

php - Upload Photo To Album with Facebook's Graph API -

i'm trying familiarize myself facebook's new graph api , far can fetch , write data pretty easily. something i'm struggling find decent documentation on uploading images album. according http://developers.facebook.com/docs/api#publishing need supply message argument. i'm not quite sure how construct it. older resources i've read are: http://wiki.auzigog.com/facebook_photo_uploads https://developers.facebook.com/docs/reference/rest/photos.upload/ if has more information or me tackle uploading photos album using facebook graph api please reply! here various ways upload photos using php facebook graph api. examples assume you've instantiated $facebook object , have valid session. 1 - upload default application album of current user this example upload photo default application album of current user. if album not yet exist created. $facebook->setfileuploadsupport(true); $args = array('message' => 'photo caption...

java - I'm really having trouble figuring out how to make my GUI window display the values in the array -

f nudge me in right direction great. or tell me if have redo chunk or something. this program rolling dice. i'm trying make each individual 'roll' display in ediefield. here class: import java.util.random; public class dice { private int times; private int roll; private int side; public int[] each; random roller = new random(); public void settimes(int rolls) { times = rolls; } public void setsides(int die) { side = die; } public int getroll() { int[] each = new int[times]; int total = 0; int c = 0; int = 0; while (c < times) { c = c + 1; roll = roller.nextint(side); roll = roll + 1; each[i] = roll; total = total + roll; system.out.print(each[i] + " "); = + 1; } return total; } public int geteach() { return each[/*each number in array*/]; } } here guiwindow: import javax.swing.*; import java.awt.*; import java.awt.event.*...

linux - Setting up a 'find' command cron/bash script, which emails if there are any results? -

i'd setup cron job checks e.g. every 24 hours see if 'find' command 1 below (which checks malicious shell hacking scripts) has results: find /home/username/public_html -type f -print0 | xargs -0 egrep '(\/tmp\/cmd(temp)?|sniper_sa|(c99|r57|php)shell|milw0rm)' and if there results, receive email @ specified email address exam@ple.com. perhaps cron job calls bash script run once per day, find command run via bash script, , bash script checks number of characters find command returns , sends email if greater 0. not sure if that's best approach it's 1 think of. i don't know enough bash programming implement though (or similar alternative) - implementation of like? the default action of cron email if there output script edit crontab (crontab -e) , add mailto variable @ top. mailto=exam@ple.com 30 1 * * * find /home/username/public_html -type f -print0 | xargs -0 egrep '(\/tmp\/cmd(temp)?|sniper_sa|(c99|r57|php)shell|milw0rm)' ...

objective c - Please help with iPhone Memory & Images, memory usage crashing app -

i have issue memory usage relating images , i've searched docs , watched videos cs193p , iphone dev site on memory mgmt , performance. i've searched online , posted on forums, still can't figure out. the app uses core data , lets user associate text picture , stores list of items in table view lets add , delete items. clicking on row shows image , related text. that's it. everything runs fine on simulator , on device well. ran analyzer , looked good, starting looking @ performance. ran leaks , looked good. issue when running object allocations every time select row , view image shown, live bytes jumps few mb , never goes down , app crashes due memory usage. sorting live bytes column, see 2 2.72mb mallocs (5.45mb total), 14 cfdatas (3.58mb total), 1 2.74mb malloc , else real small. problem related info in instruments technical , problem solving examples i've seen missing release , nothing complicated. instruments shows core data responsible library 1 ...

php - How to build a web site which gives a sub-domain dynamically to every registered user? -

possible duplicate: create subdomain upon user registration suppose have site, , wish give sub-domain each registered users. site, http://site.com/ . and test-user user registered on site, , site wants make sub-domain user. like http://test-user.site.com . like http://test-user1.site.com test-user1. i hope understood requirement. how can create sub-domain using sites back-end or dynamically while registering? make dns record bring * requests site ip. set web server handle * requests (thanks @animuson mentioning) check $_server['http_host'] against database. profit!!!

c# - How can I sort ObservableCollection<T> such that my UI also sees the process of sorting? -

i have listbox item panel set wrappanel. want whenever new item added listbox collection should sorted , process should visible on ui. mean user should able see fancy effect them identify item being sorted. looked @ few posts on stackoverflow , suggest use collectionviewsource. itemsource bound observablecollection in viewmodel. first wrote code. works new collection bound can't see fancy effect items in container move new position original position :- var photolist = photostoupload.tolist<photo>(); photolist.sort(new photosorter()); photostoupload = new observablecollection<photo>(photolist); this class :- public class photosorter : icomparer<photo> { public int compare(photo x, photo y) { return x.photobytearr.length - x.photobytearr.length; } } then wrote simple bubble sorting algorithm. achives desired effect don't know why takes long time. know it's ineffecient algori...

Experience with Coderush XPress and Visual Studio 2010? -

it possible use crx vs 2010: can use coderush xpress in visual studio 2010? refactor key works. (after assigning shortcut) what doesn't work quicknav , quickfilenav . standard shourtcut quickfilenav ctrl+alt+f, conflicted vs view.f#interactive. but removing shortcut or changing shortcuts quicknav , quickfilenav doesn't bring nav-windows. nextreference (tabulator) doesn't work any solutions? other issues? sorry, following features no longer included in coderush xpress vs 2010. microsoft requirement, , (devexpress) can't violate it. tab next reference highlight references quick nav quick file nav declare method declare constructor declare property (auto-implemented) declare class declare enum declare enum element declare interface declare struct declare field it looks if thing can suggest install full coderush pro version if wish use these features, sorry.

printing - Get console text in java -

is there way retrieve output console has been outputted by: system.out.print("blabla"); ? if want able see wrote console, need write own printstream implementation wraps existing printstream , stores whatever supposed write , delegates ( all methods) wrapped (original) printstream actual job. how store messages entirely depends on needs (store last written string, store map of timestamp -> string or whatever). once have this, can replace system.out own implementation (via system.setout() ): public class rememberallwrittentextprintstream extends printstream { private static final string newline = system.getproperty("line.separator"); private final stringbuffer sb = new stringbuffer(); private final printstream original; public rememberallwrittentextprintstream(printstream original) { this.original = original; } public void print(double d) { sb.append(d); original.print(d); } public...

c# - MFC Dll with COM Interface -

i pretty new managed/unmanaged interoperability , com concepts. i received suggestion of using com interop, using existing mfc code in c#. problem me is, have mfc dll not valid com component. how can make mfc dlls have com-accessible interfaces ready use in .net? from thread loading mfc dll in c# windows application to access native code c# have few choices. most directly, can use dllimportattribute describe dll's entry points in c# terms can called via p/invoke. they'll static methods c# program. less directly, can create managed c++ assembly wraps dll in 1 or more managed objects. managed c++ dll can accessed c# via add reference (because managed assembly .dll extension) , should able access mfc dll using #include include mfc dll's header file. a third option turn dll com object c# program can access way.

c# - I need to communicate between 2 pages without refreshing the page, with ajax, when a event is raised on the serverside -

to clearify, i've tried solutions updatepanel / scriptmanager not want use them. want make jquery-ajax posts , nothing else. lets assume scenario. we have global event follows: public static class customglobalevents { public delegate void specialeventraisedeventhandler(object sender, string type, string msg); public static event specialeventraisedeventhandler specialeventraised; public static void specialevent(object sender, string type, string msg) { if (specialeventraised != null) specialeventraised(sender, type, msg); } } we have 2 web-pages, reciever.aspx , sender.aspx. reciever.aspx has following code: protected void page_load(object sender, eventargs e) { if(!ispostback) { customglobalevents.specialeventraised += new customglobalevents.specialeventraisedeventhandler(customglobalevents_specialeventraised); } } void customglobalevents_specialeventraised(object sender, string type, string msg) ...

cocoa - performSelector:onThread: when the target thread is blocked -

yes, i'm being lazy. what happens when call performselector:onthread:... , pass in thread that's blocked (on synchronous i/o, instance)? selector queued executed later? yep. i'm pretty sure gets added thread's runloop performed on next iteration.

How to create a function with vectors and vertical asymptote using MATLAB -

plot function f(x) = 1.5x / x-4 -10 equal or less x equal or less 10. notice function have vertical asymptote @ x = 4. plot function creating 2 vectors domain of x. first vector (call x1) elements -10 3.7, , second vector (calle x2) elements 4.3 10. each of x vector create y vector (call them y1 , y2) corresponding values of y according function. plot function make 2 curves in same plot (y1 vs. x1 , y2 vs. x2). learn how create vectors in matlab. first @ colon(:) operator , creates vectors, if know start, step , end values. @ linspace function, if don't need know how far points in vector are, how many points need. create vectors x1 , x2. then learn how arithmetic calculations in matlab. create vectors y1 , y2. then create plot plot function. may need use hold on, hold off draw 2 curves on same figure.

AJAX HTML PHP question -

this scripts.js function showhint(str) { if (str.length==0) { document.getelementbyid("txthint").innerhtml=""; return; } if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","inputprocess.php?q="+str,true); xmlhttp.send(); } this html <script type="text/javascript" src="scripts.js"></script> <form> type name here : <input type="text" onkeypress="showhint(this.value)" name="name" /> </form> this php file <?php $q = $_get['q']; $dbc=mysql_connect("localhost",...

c# - Querying content of Windows Media Center library -

i'm trying create program in c# lists content of library in windows media center (for instance video library). is possible using windows media center sdk, without having create addin wmc, "external" program, running on same machine wmc? doesn't good, quote msdn: with few exceptions, windows media center object model not accessible windows service or other process other started windows media center. http://msdn.microsoft.com/en-us/library/ms816271.aspx though don't know exceptions are.

data binding - How to delete a Item in a ASP.NET listview and persist the datasource? -

i have collection of objects bind listview this: if (!ispostback) { list<equipment> persons = new list<equipment> {new equipment{itemname = "sworn", itemcount = 7, itemcost = 255}, new equipment{itemname = "civ", itemcount = 3, itemcost = 80}, new equipment{itemname = "civ", itemcount = 5, itemcost = 200}}; lvmain.datasource = persons; bindlist(); } i want add/update/delete object collection , submit final data object collection bl when user saves... rather delete/add/update everytime row changed. so question how maintain state datasource? have tried (delete example) protected void lvmain_itemcommand(object sender, listviewcommandeventargs e) { switch (e.commandname) { case "delete": { listviewdataitem lvdi = (...

javascript - Capturing key event for backspace -

i having difficulty capturing backspace key keyboard event in javascript/jquery. in firefox, safari, opera, chrome, , on iphone/ipad, capture keyup event on text input box this: $(id_input).keyup(function(event) { that.gethints($(this).val().trim(), event, fieldname); }); this event captures user keystrokes, sends them function issue ajax lookup call. my problem comes when user wishes backspace on character he/she typed. in browsers have access except droid phone, when press backspace key, keyup event captures value returned $(this).val().trim() , sends on process in function gethints. on droid, however, neither keyup nor equivalent keydown event fires until user backspaces on every character in $(this). so, example, if type "cu" backspace on "u" leaving "c" in input field, in browsers except droid, keyup event fire , call function gethints("c", event, fieldname) . on droid, keyup event never fires. what missing? how/why backspac...

one-to-many relationships with django -

i intend create teaming system, each team may contain multiple contestants. contestants auth.user . similar to: team: contestant1 contestant2 . . contestantn since contestant user cannot modify have foreignkey team. best way achieve this? the ways though was: create onetoone profile user points team. define manytomany relationship between user , team user has unique. a pause i redesigning structure of application, rephrase question again replies, consider them , see if 1 of them fits. you can this: class team(models.model): contestants = models.manytomanyfield(user, through='contestant') class contestant(models.model): team = models.foreignkey(team) user = models.foreignkey(user) [here go contestant data fields] this allows 1 user take part in different teams, if don't want allow this, can add unique=true contestant.user .

c++ - Drawing continuously in drawing application -

i wondering how drawing applications draw entire time mouse down without having empty gaps. mean is, example if program drew circles @ mouse's x, y coordinate, if mouse went quicly seem bunch of little circles rather nice continuous line. how can done without drawing short straight line between mouse 0.001 seconds ago , mouse is. thanks it can't done without drawing line between current mouse point , previous point, why drawing programs do do. fancier drawing programs fit curvy lines multiple previous points achieve more natural drawing stroke, principle same. update: based on comment, appears have timer involved in drawing code. surely unnecessary, since application generate mousemove event whenever mouse moved @ all, , can use event draw next line.

new operator - C++ new memory allocation fragmentation -

i trying @ behavior of new allocator , why doesn't place data contiguously. my code: struct ci { char c; int i; } template <typename t> void memtest() { t * plast = new t(); for(int = 0; < 20; ++i) { t * pnew = new t(); cout << (pnew - plast) << " "; plast = pnew; } } so ran char, int, ci. allocations fixed length last, there odd jumps 1 available block another. sizeof(char) : 1 average jump: 64 bytes sizeof(int): 4 average jump: 16 sizeof(ci): 8 (int has placed on 4 byte align) average jump: 9 can explain why allocator fragmenting memory this? why jump char larger ints , structure contains both int , char. there 2 issues: most allocators store additional data prior start of block (typically block size , couple of pointers) there alignment requirements, e.g. linux typically allocates @ least 8 byte boundary, os x allocates @ least 16 byte boundary so you'll kind ...

ActiveRecord 'destroy' method returns a boolean value in Ruby on Rails? -

i using ruby on rails 3 , know type of return have following code: @user.destroy i need handle cases on success , fault in someway this: if @user.destroy puts "true" else puts "false" end is possible? if so, how? you should try you're asking before asking. you've got there work fine. if destroy works, return object (which pass true in if statement) , if not, return false or raise exception, depending on why failed.

database - NUnit TestFixture Execution Question -

i trying test legacy database code. have many situations want set database in empty state for group of tests following each group: for group of tests, set db inital test state run tests return db empty state in nunit, when using testfixture guaranteed entire fixture's test run testfixtureteardown before next testfixture gets processed? i've tried using visual studio test stuff , doesn't appear case. the main reason trying this, process of getting db state in step 2 can expensive , don't want have run each of test cases. testfixtureteardown executed once tests testfixture completed. coupling testfixturesetup should provide beahivor seeking on testfixture basis. the unit testing framework in visual studio not have same syntax nunit. while test approach same xunit based frameworks syntax vary.

asp.net mvc - MVC Inner Join via Linq -

Image
i try create product detail (accommodation details) view based on controller action: public actionresult detail(int id) { var detail = cities in _db.cities join properties in _db.properties on cities.cityid equals properties.cityid join proplocations in _db.proplocations on properties.locationid equals proplocations.locationid join proptypes in _db.proptypes on properties.typeid equals proptypes.typeid properties.propid == id select new { cities.cityname, proptypes.proptype1, proplocations.location, properties.propname, properties.propowner, properties.propstars, properties.propaddress, properties.propdescription, propert...

c# - Getting input into a process -

while talking friend on yahoo messenger, told him cool make bot answer generic messages when starts conversation. upon thinking told him, realized quite interesting that. problem don't know win32. so question this: how 'link' process both 1 , windows environment? goal have application running in background makes sort of query see windows opened , when new yahoo messenger conversation window appears should send list of keystroke events window. i use either c# or vc++ programming part , can use help: either specific answers or tips me - e.g.: google for. far google research came apps/dlls/code , scripting stuff , i'm not searching that. want work myself can learn it. http://pinvoke.net/ seems website looking for. site explains how use windows api functions in higher level languages. search on pinvoke of functions i've listed below , gives code necessary able use these functions in application. you'll want use findwindow function find window i...

c# - How to get the Grid.Row Grid.Column from the selected added control? -

how grid.row grid.column added control? basically have 16 grids 4 rows , 4 columns, each grid added round button. how determine rows , columns selected round buttons located respectively in below mouseeventhandler of mouseover? mouseclick, there round button selected, mouseover, there collection of buttons. roundbutton_mouseenter, roundbutton_mouseleave, roundbutton_mousedown, roundbutton_mouseup thanks you can use grid.getcolumn(frameworkelement element) , grid.getrow(frameworkelement element) find out row , column element has been set to. in xaml, grid.row="4" sugar grid.setrow(element, 4)

javascript - Making My Site Noscript-compatible -

i finished building nameplate site myself scratch, both learning experience , formally put presence online. made cool-looking (at least, think so) tabbed site uses ajax , anchor navigation switch between tabs. threw style changing script uses cookies remember style selection. now, sixty-four thousand dollar question: how make site usable people choose turn off javascript? stands currently, user without scripting can see "about me" section , nothing else. put banner @ top directing them "noscript" page, of doesn't exist. best option noscript page shows content @ once? there css method avoid javascript tab switching? or, there method show content on main page users without scripting still have scripting-enhanced version others? my site located @ scolbyme.webs.com . appreciate ideas guys come with! p.s. bonus points person can name background color. i agree jeroen, want build site (w/out ajax) first, add on js layer. if build each tab it's ...

wordpress - How do I dynamically add some piece of php code to an exact position in page before it is returned to the browser? -

i need add piece of code right before wp_head(); call using php because code has execute server side. hooking code wp_head(); not work. need add right before. here php code added. gravity_form_enqueue_scripts(1,true); here code needs inserted: <?php /* add javascript pages comment form * support sites threaded comments (when in use). */ if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /* have wp_head() before closing </head> * tag of theme, or break many plugins, * use hook add elements <head> such * styles, scripts, , meta tags. */ gravity_form_enqueue_scripts(1,true); wp_head(); ?> the code should not show on return browser. how add php snippet exact location dynamically? i needed : add_action('wp', 'gforms_add_before_wp_head'); not add_action('wp_head', 'gforms_add_before_wp_head'); i turns out needed find right hook add_...

flex3 - Setting Busy cursor for the html page with iframes having flex applications -

i have html page 4 iframes out of these 4 1 static html page , other 3 html generated flex. have button , list in 1 of flex applications , list populated on click of button. want have custom busy cursor appear on top of whole html page until list gets populated. please tell me if possible example. thanks in advance prahsant dubey ok, can not have flex control cursor on areas of page not part of flash player. here's can do. call external javascript flex, use js cursor. here's how call js flex: http://www.switchonthecode.com/tutorials/flex-javascript-basics-using-externalinterface and here's how js cursor: http://www.webcodingtech.com/javascript/change-cursor.php

erlang - controlling log output -

if start node slave, log output goes master. however, in setup, don't want have master, , have nodes automatically discover , join cluster @ will. i'd still have cluster's log output go single node, though. there way dynamically make node's logging behave if started slave? otherwise, need alter each installed error_handler redirect output want go? here ideal setup: flip switch , nodes in cluster send that's going of nodes' tty--io:format calls or sasl reports or have you-- instead 1 node both displayed on tty , logged in round robin files. make reality? use group_leader purpose. have checked link ?

apache tika - How to boost a SOLR document when indexing with /solr/update -

to index website, have ruby script in turn generates shell script uploads every file in document root solr. shell script has many lines this: curl -s \ "http://localhost:8983/solr/update/extract?literal.id=/about/core-team/&commit=false" \ -f "myfile=@/extra/www/docroot/about/core-team/index.html" ...and ends with: curl -s http://localhost:8983/solr/update --data-binary \ '<commit/>' -h 'content-type:text/xml; charset=utf-8' this uploads documents in document root solr. use tika , extractingrequesthandler upload documents in various formats (primarily pdf , html) solr. in script generates shell script, boost documents based on whether id field (a/k/a url) matches regular expressions. let's these boosting rules (pseudocode): boost = 2 if url =~ /cool/ boost = 3 if url =~ /verycool/ # otherwise not specify boost what's simplest way add index-time boost http request? i tried: curl -s \ "http://localh...

javascript - How to open multiple browser windows on request? (PHP) -

so have form on php/html page. user submitss same php/html page. php page have $_post data. want when page refreshed opnt popup browser windows url's relative users post request. www.example.com/bal-bla-bla.php? id=$_post['streamid'] if ( isset($_post['submit']) ) { echo '<script>window.open ("'.$_server['php_self'].'myplayer.php?stream_id='.$_post['streamid'].'","myplayer");</script>'; } edited: you can display message before open window advice user accept new window! var flag = confirm(" window not adv! ;-) "); if (flag) window.open("'.$_server['php_self'].'","myplayer");

css - Using image as generic link background -

how can have image background links? want have nice box representing buttons, cannot figure out. i have tried: a { font-size: 40px; background: url('images/shooting-stars/shooting-star-link.png') no-repeat left top; } but not working, image not displaying. "i want have nice box representing buttons, cannot figure out." - don't understand part. anyway, css looks fine here, sure image exists? working example exact same code, image i'm sure exists: http://jsfiddle.net/3k9nm/ if want show image, if text shorter, should set minimum width links. mean they'll have inline-blocks, can't set width on regular link (which inline element). a { display: inline-block; min-width: 25px; } (25px randomly chosen, fill in width of background image..)

Loading and Executing the jquery and javascript scripts using Java or any other language -

we have need parse , extract content html files. thinking of using jquery navigate dom , extract small piece of information. found javascript library written in java mozilla. using libary, tried load file called file.js includes jquery script few lines of jquery script code shown below. var content = $('<html> <body><div id="div1"><span> hello world!</span></div></body></html>').find('div span').html(); print("content = " + content); print("hello"); we got errors related undefined document, navigator etc. in jquery library. can please how run jquery scripts java or c# parse html files. using rhino java fine, have aware of fact javascript not define dom api. it instead role of navigator embeds javascript engine. you need initialize dom yourself, using example script found here: http://ejohn.org/blog/bringing-the-browser-to-the-server/ which allows run jquery, according a...

php - PHP_AUTH_USER only known in certain frames -

getting confused php_auth_user. within web pages have .htaccess files in every directory, controlling can (and cant) see folders. in order further customise pages hoping use php_auth_user within php code, i.e. tailor page contents based on user. this seems work partially. code snippets below demonstrate problems. the main index.php creates framed page menu structure in top left hand corners, irrelvant stuff in top right , tailor made contents in bottom frame. in top left user correctly shown, in bottom frame php_auth_user doesnt seem set anymore (it returns empty , when printing $http_server_vars not listed). script.php in different path, have .htaccess files in them , other contents displayed correctly. why not know php_auth_user there? running version php version 5.2.12 on chrome. index.php <frameset rows="35%, *"> <frameset cols="25%, *"> <frame src="menu.php"> <frame src="something.php"> </frame...

asp.net - javascript on updatepanel -

how run script updatepanel begins. have gridview inside updatepanel , when user clicks sort or change page, i'd run script postback begins. thanks. you can use beginrequest event handler. can see documentatio here . if have more 1 update panel update mode conditional need inspect request see update panel being updated.

security - Sending sensitive information to REST service -

we have soap based web service our in house applications use authenticate users. basically, send soap request username , password. web service authenticates credentials against our data store , returns user information if authentication successful. web service secured using basic authentication , ssl. we need make modifications web service , considering re-writing rest service. rest services have created in past have been simple , had no need security. have never created rest service used sensitive information, have couple of questions / concerns: first, there best practice sending sensitive query parameters (user credentials) rest service securely? can still use basic authentication , ssl. second, if send query rest service using post, still considered restful, or required rest queries? you can use ssl , basic authentication rest web services well. http used data retrieval (queries) can use http post well. useful if can use type of http caching. post usefull...

How to reconcile the C++ idiom of separating header/source with templates? -

i'm wondering bit templating business. in c , c++ common put declarations in header files , definitions in source files, , keep 2 separate. however, doesn't seem possible (in great way) when comes templates, , know, templates great tool. also, boost headers, real issue. separating headers , source still idea in c++, or should not rely heavily on templates? instantiating template costly @ compile time virtualy free @ runtime. basically, everytime use new template type, compiler has generate code new type, that's why code in header, compiler have access code later. putting code in .cpp lets compiler compile code once speeds compilation. in theory write code in headers, work fine, take forever compile large projects. also, change 1 line anywhere, have rebuild everything. now might ask, how comes stl , boost not slow? that's precompiled headers come rescue. pchs let compiler costly work once. works code won't change libraries, effect totally nulli...

iphone development -

i build music bisualiser iphone. have development experience not on iphone platform. can recommend books worth buying started...? you can refer apple's documentation begin with.there lot of forums , blogs refer once have started development , want refer on particular topic. you can use "head first iphone development" first book begin programming in iphone. cheers

mysql - UNIQUE Constraint, only when a field contains a specific value -

i'm trying create unique index constraint 2 columns, when column contains value 1. example, column_1 , column_2 should unique when active = 1 . rows contain active = 0 can share values column_1 , column_2 row, regardless of other row's value active is. rows active = 1 cannot share values of column_1 or column_2 row has active = 1 . what mean "share" 2 rows having same value(s) in same column(s). example: row1.a = row2.a , row1.b = row2.b. values shared if both columns in row1 matched other 2 columns in row2. i hope made myself clear. :\ you can try make multi-column unique index column_1, column_2 , active, , set active=null rows uniqueness not required. alternatively, can use triggers (see mysql trigger syntax) , check each inserted/updated row if such values in table - think rather slow.

Appending csv files in SAS -

i have bunch of csv files. each has data different period: filename file1 'jan2011_price.csv'; filename file2 'feb2011_price.csv'; ... do need manually create intermediate datasets , append them together? there better way of doing this? solution from documentation preferable use: data allcsv; length fileloc myinfile $ 300; input fileloc $ ; /* read instream data */ /* infile statement closes current file , opens new 1 if fileloc changes value when infile executes */ infile filevar=fileloc filename=myinfile end=done dlm=','; /* done set 1 when last input record read */ while(not done); /* read input records */ /* opened input file */ input col1 col2 col3 ...; output; end; put 'finished reading ' myinfile=; datalines; path-to-file1 path-to-file2 ... run; to ...

XMLHttpRequest response is null in Javascript -

when trying execute xmlhttprequest, response returned server (as checked in fiddler), xhr.getallresponseheaders() returns null , throws exception. is because of "same origin policy"? can please suggest how resolve issue? code: using datajs.codeplex.com open source code: xhr.onreadystatechange = function () { if (xhr === null || xhr.readystate !== 4) { return; } // workaround xhr behavior on ie. var statustext = xhr.statustext; var statuscode = xhr.status; if (statuscode === 1223) { statuscode = 204; statustext = "no content"; } var headers = []; var responseheaders = xhr.getallresponseheaders().split(/\r?\n/); resource located in different domain. accessing http://odata.netflix.com/v1/catalog/genres to circumvent same-origin po...

Regex PHP to find BBCode tag contents -

i have string such this: land of gray [example]here example[/example] , pink. i'm struggling php/regex code return contents of [example] tag variable... i'm not php expert but... regex work \[example\]([^\[]*)\[ that capture contents in capture group. so example contents should in $matches[1] ??? ex: <?php $subject = "land of gray [example]here example[/example] , pink."; $pattern = '/\[example\]([^\[]*)\[/'; preg_match($pattern, $subject, $matches); print_r($matches[1]); ?> i didn't test code above because don't have php running on machine think work...

.net - 32 and 64 bit assemblies in one windows installer -

i have application written in c# depends on sqlite managed provider. sqlite provider platform dependent (there 2 dlls 32 , 64 bit applications same name). application loads desired 1 @ runtime based on os. the problem while creating installer cannot add 64 bit mode dll setup project getting following error: file '' targeting '' not compatible project's target platform ''. i use other installer have custom action must invoked during setup. so wanted know if there installer let me add 32 , 64 bit dll , execute custom action written in c#. one possible solution have 2 installers avoid if possible. any suggestions? the inno setup installer support feature wich request, installer flexible , reliable, exist many samples of scripts in web make conditional installation depending of architecture of final client. check script located in c:\program files\inno setup 5\examples\64bitthreearch.iss -- 64bitthreearch.iss -- ; demonstrates how in...

python - Cities/Province/Cantons list with coords? -

where can list of that? need coords of distrits , cantons of costa rica, there place those? thanks in advance geonames.org public database of cities/towns population on 1000. data each city includes geo coordinates , administrative division, believe districts, provinces or cantons.

c# - How to get hold of the current NHibernate.Cfg.Configuration instance -

my c# project has repositories instantiated using dependency injection. one of repository methods needs access nhibernate.cfg.configuration instance (to generate database schema) returned when initializing nhibernate. i cannot pass configuration repository however, because break persistence ignorance principle -- don't want expose implementation details through repository interface. so i'm looking way of getting hold of current nhibernate.cfg.configuration instance within repository. have no trouble getting hold of current session, it's configuration cannot hold of. it not possible. sessionfactory not keep references configuration built it. anyway, mauricio said: schema generation not repository concern.

How do I remove this class after the jquery slide is in the up position? -

i have following code set jquery slide. $(document).ready(function () { $('a#slide-up').click(function () { $('.slide-container').slideup(); return false; }); $('a#slide-toggle').click(function () { if ($('.slide-container').is(':visible')) { $('.slide-container').slideup(); $(this).removeclass('active'); } else { $('.slide-container').slidedown(); $(this).addclass('active'); } }); }); and html: <a id="slide-toggle"></a> <div class="slide-container"> <a id="slide-up"></a> >>content<< </div> when click on #slide-toggle, class 'active' gets applied , div.slide-container slides down revealing content , link slide container (i.e a#slide-up). when click on a#slide-up, container slides a#slide-toggle remains ...

file - How to organize a large number of objects -

we have large number of documents , metadata (xml files) associated these documents. best way organize them? currently have created directory hierarchy: /repository/category/date(when loaded our db)/document_number.pdf , .xml we use path unique identifier document in our system. having flat structure doesn't seem option. using path id helps keep our data independent our database/application logic, can reload them in case of failure, , documents maintain old ids. yet, introduces limitations. example can't move files once they've been placed in structure, takes work put them way. best practice? how websites such scribd deal problem? your approach not seem unreasonable, might suffer if more few thousand documents added within single day (file systems tend not cope large numbers of files in directory). storing .xml document beside .pdf seems bit odd - if it's metadata document, should not in database (which sounds have) can queries , indexed etc? when...

ajax - Inconsistent data corruption in a store loaded through a proxy reader -

we're experiencing inconsistent data corruption in store loaded through proxy reader. it's browser dependant. works fine in chrome , safari on desktop time. on our 2 testing iphones intermittently breaks depending on data store has loaded, larger data volume seems cause more breaks. can't see errors or patterns in json data breaks. symptoms: data loads, of data belonging last few items missing a read listener attached store doesn't fire when data loss occurs, fire on desktop browser experience not data loss the piece of data seems lost start_time. we've been trying debug 1 while , stumped. thank ideas might have why occurring. our regmodel ext.regmodel('booking', { fields: ['id', 'start', 'end', 'title', 'service', 'service_id', 'client_note', 'stylist_note', 'utc_start','day_date', 'start_time', 'end_time', "home_p...

android - How can I prevent the current tab view from being lost when rotating the screen? -

i have tabhost 4 tabs. if (for example) open tab #3, start simple alert dialog, , rotate phone few times, loses focus on tab open before, when press back, tab #1 shows instead of tab #3. i very grateful solution or hints solve problem. protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); savestate(); } protected void onpause() { super.onpause(); savestate(); } protected void onresume() { super.onresume(); gettabhost().setcurrenttab(currenttab); } private void savestate(){ currenttab=gettabhost().getcurrenttab(); } did try save state of tabhost? if not - check reto meier answer in this discussion . you can save current position of tabhost using getcurrenttab @ onsaveinstancestate, , restore @ onrestoreinstancestate using setcurrenttab.

unicode - number of digits in a hex escape code in C/C++ -

i'm having dispute colleague of mine. says following: char* = "\x000aaxz"; will/can seen compiler "\x000aa". not agree her, think can have maximum number of 4 hex characters after \x . can have more 4 hex chars? who right here? §2.13.2/4: the escape \xhhh consists of backslash followed x followed 1 or more hexadecimal digits taken specify value of desired character. there no limit number of digits in hexadecimal sequence. sequence of octal or hexadecimal digits terminated first character not octal digit or hexadecimal digit, respectively. she right. however, can terminate eager catenation: sequence of literals "\x000a" "axz" specifies single four-character string literal. (2.13.4/3) also note unicode uses 21-bit code points ; doesn't stop @ 16 bits.

How to communicate between ASP.net custom controls -

i'm using 2 custom controls. 1 gathers criteria search, , other displays list. these 2 controls need remain seperate time being. what best method of transfering data search control, list control? i'm thinking of viewstate, session or wrapping both within updatepanel , using custom events?? maybe can create delegate , event pass list of searchvalues? way can add or multiple display controls in case ever becomes necessary. note quick sample code should optimized/improved. public class searchcontrol { public delegate void searcheventhandler(object sender, dictionary<string, string> searchvalues); public event searcheventhandler onsearch; public searchcontrol() { btnsearch.click += new eventhandler(search); } protected void search(object sender, eventargs e) { if (onsearch != null) { dictionary<string, string> searchvalues = new dictionary<string, string>(); searchva...

iphone - Getting EXC_BAD_ACCESS when loading view (MBProgressHUD+ASIHTTPRequest) -

greetz, i having issues managing "loading" screen on mainviewcontroller (the first view user accesses.) first view downloads image , puts on uiimageview. while happens mbprogresshud displayed. then, user goes secondview own controller. user uploads image , goes back. when user goes mainview, mainview gets reloaded same image before not displayed. logically, "loading" mbprogresshud should display aswell. nonetheless crashes before can let display, crashes while making transition. the thing error exc_bad_access comes if have mbprogresshud implemented (must problem memory management don't seem it...) these segments code in question: mainviewcontroller.m - (void)viewdidload { hud = [[mbprogresshud alloc] initwithview:self.view]; [self.view addsubview:hud]; hud.delegate = self; hud.labeltext = @"please wait"; [hud showwhileexecuting:@selector(loadingofimageandinformation) ontarget:self withobject:nil animated:yes]; [s...

sql - CakePHP: how to get recently created auto-incremented field -

i have user submit field database, validates, , makes entry. primary key of new row auto-incremented. the user gets form newly created field required. can shed light on problem? thanks in advance! check out model::getinsertid();

WPF Label vs TextBlock in Border? -

if know have show tens of texts border , decide label (which complex , resources consuming) or textblock in border ? . the performance aspect 1 interesting me now. thank ! refer answer given here: what difference between wpf textblock element , label control?

spring - How should we integrate PayPal adaptive (and IPN) API in a Java webserver environment? -

as i'm integrating paypal layer in spring based server (that should usable multiple clients asking me implement webstore): and there's surprisingly few info find on spring/paypal topic, find article: http://blog.mushiengine.com/2010/08/25/paypal-adaptive-api-and-spring-3-rest-template-%e2%80%94-part-2/ i wondering if there perhaps guidelines or best practices concerning topic? any comments on topic more welcome! jochen since having problems finding information that's java-specific can grail's paypal plugin (http://www.grails.org/plugin/paypal-pro) reference.