Posts

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 ...