Posts

Showing posts from April, 2012

c# - Dynamically creating objects at runtime that inherit from a base class -

i writing game editor, , have lot of different "tool" objects. inherit btool , have same constructor. i dynamically populate toolbox @ runtime buttons correspond these tools, , when clicked have them create instance of tool , set current tool. is possible, , if better/easier creating buttons hand? yes. to find tools, can call assembly.gettypes : var tooltypes = typeof(tool).assembly.gettypes() .where(t => typeof(tool).isassignablefrom(t)) .toarray(); to create tools, can call activator.createinstance : obj = activator.createinstance(type, arg1, arg2);

c++ - Only static and const variables can be assign to a class? -

i learning c++. curious, can static , constant varibles assigned value within class declaration? why when assign values normal members, have special way doing void myclass::init() : member1(0), member2(1) { } this looks supposed constructor; if is, should have no return type, , needs have same name class, e.g., myclass::myclass() : member1(0), member2(1) { } only constructor can have initializer list; can't delegate type of initialization init function. any nonstatic members can initialized in constructor initializer list. const , reference members must initialized in constructor initializer list. all things being equal, you should prefer initialize members in constructor initializer list , rather in body of constructor (sometimes isn't possible or it's clumsy use initializer list, in case, shouldn't use it, obviously).

Sample Application - Amazon S3 / Indy / Delphi -

i looking example application store objects amazon s3 using indy components. any appreciated. phillip here's demo synapse, should easy use indy instead: http://www.itwriting.com/s3example_21dec06.zip

list - What's the formal name for this Syntax? -

sometimes in scheme, have functions take arguments this add 3 4 what call kind of "list" it's elements a1 a2 a3 ? don't think can call list because lists contained in parenthesis , elements comma-seperated. lisp uses prefix or polish notation syntax . polish notation, known prefix notation, form of notation logic, arithmetic, , algebra. distinguishing feature places operators left of operands. if arity of operators fixed, result syntax lacking parentheses or other brackets, can still parsed without ambiguity. add operator , right part operands. the arity of operators isn't fixed lisp uses parens in it's syntax group expressions.

algorithm - Why does list length reduce to sqrt(n) after each comparison in interpolation search? -

according book i'm reading, interpolation search takes o(loglogn) in average case. book assumes each compare reduce length of list n sqrt(n) . well, isn't difficult work out o(loglogn) given assumption. however, book didn't talk more assumption except says correct. question: can give explanation on why true? it depends on input being uniformly distributed (without such assumption, o(log n) best can theoretically, ie binary search optimal). uniform distribution, variance around sqrt(n), , in expected case each iteration hits within variance of target. thus, say, search space goes n -> sqrt(n) on each iteration.

cocoa - How to create a specific date in the distant past, the BC era -

i’m trying create date in bc era, failing pretty hard. following returns ‘4713’ year, instead of ‘-4712’: nscalendar *calendar = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *components = [nsdatecomponents new]; [components setyear: -4712]; nsdate *date = [calendar datefromcomponents:components]; nslog(@"%d", [[calendar components:nsyearcalendarunit fromdate: date] year]); any idea i’m doing wrong? update: working code nscalendar *calendar = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *components = [nsdatecomponents new]; [components setyear: -4712]; nsdate *date = [calendar datefromcomponents:components]; nsdatecomponents *newcomponents = [calendar components:nseracalendarunit|nsyearcalendarunit fromdate:date]; nslog(@"era: %d, year %d", [newcomponents era], [newcomponents year]); this prints 0 era, ben explained. your code wor...

iphone - What is faster? Drawing or Compositing? -

i make extensive use of -drawrect: nice animations. timer tries fire 30 times per second -setneedsdisplay, feels 20 times. can't use -setneedsdisplayinrect: because animation covers entire thing. would take of drawing operations out of -drawrect: , move them subview? -drawrect has less then, instead os have more work compositing views. is there rule of thumb 1 more worse? remember apple text claimed core animation doesn't redraw during animation. secret of speed? using subviews in animations? much of similar my answer your other question : compositing faster, far. on iphone, content drawn calayer (or uiview's backing calayer) using quartz drawing calls or bitmapped image. layer rasterized , cached opengl texture on gpu. this drawing , caching operation expensive, once layer on gpu, can moved around, scaled, rotated, etc. in hardware-accelerated manner. gpu has while layer animating composite other onscreen layers every frame. why core animation ca...

asp.net - Permission issue when webservice deployed as virtual directory.Works in VS IDE -

i have asp.net web service create text file in path being passed parameter method. private void createfile(string path) { string strfilename = path; streamwriter sw = new streamwriter(strfilename, true); sw.writeline(""); sw.write("created @ " + datetime.now.tostring()); sw.close(); } now passing folder in network parameter , calling method createfile(@"\\192.168.0.40\\labels\\test.txt"); when running code visual studio ide,the file getting created in path.but when published , deployed virtual directoty,its throwing me error like "system.unauthorizedaccessexception: access path '\\192.168.0.40\labels\test.txt' denied. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.filestream.init(string path, filemode mode, fileaccess access, int32 rights, boolean userights, fileshare share, int32 buffersize, fileoptions options, security_attributes secattrs,...

c# - Creating Uninstaller Using Visual Studio 2008 -

i know how create installer application want know how add uninstaller applications work group. there anyway add visual studio 2008 deployment project. or have create separate application altogether? as other answers stated, there uninstaller feature provided installer project. besides that, this link explains how create short cut uninstaller feature, users expect present somewhere in start menu. as alternative batch file described in blog post, create short cut file ( .lnk file) launches command batch file ( msiexec /x [productcode] ). assign nice icon , include file setup project. as last step, let installer copy link file directly creted start menu folder. hope helps.

c# - Add item to Generic List / Collection using reflection -

i want add item generic list using reflection. in method "dosomething", trying finish following line, pi.propertytype.getmethod("add").invoke(??????) but getting different kinds of error. below complete code public class mybaseclass { public int vechicleid { get; set; } } public class car:mybaseclass { public string make { get; set; } } public class bike : mybaseclass { public int cc { get; set; } } public class main { public string agencyname { get; set; } public mybasecollection<car> lstcar {get;set;} public void dosomething() { propertyinfo[] p =this.gettype().getproperties(); foreach (propertyinfo pi in p) { if (pi.propertytype.name.contains("mybasecollection")) { //cln contains list<car> ienumerable<mybaseclass> cln = pi.getvalue(this, null) ienumerable<mybaseclass>; ...

installation - Local install of sqlite3-ruby -

on current system dont have root-access , want install sqlite3-ruby. can compile , know how set custom install-folder, how ruby-installation can recognize/find installed gem usage? i tried prefix of custom rubylib-folder didnt work either. any suggestions? thanks skully by default, if don't have root access, rubygems tries install gem in home directory, within ~/.gem directory. type $ gem install sqlite3-ruby

jquery - Opening links within tabs -

at present have jquery tabs , these tabs contain links. unfortunately on following 1 of links, new page opens if following normal link i.e. not within tab want want happen. have tried following section no avail: http://jqueryui.com/demos/tabs/#...open_links_in_the_current_tab_instead_of_leaving_the_page any ideas might going wrong here? <html> <head> <script src="jquery-1.4.2.min.js"></script> <script src="jquery-ui-1.8rc3.custom.min.js"></script> <link href="redmond/jquery-ui-1.8rc3.custom.css" rel="stylesheet" type="text/css"></link> <script type="text/javascript"> $(function() { $("#tabs").tabs({ load: function(event, ui) { $("a", ui.panel).click(function() { $(ui.panel).load(this.href); return false; }); } }); }); </script> </head> <body> <div id="tabs"> <ul...

python - Django: How can I show a list of values in a text input field? -

i have defined model manytomanyfield, , want field show values joined spaces, example: <input type="text" name="foo" value="val1 val2 val3"/> i have defined form use charfield represent multiple values: class myform(modelform): foo = charfield(label='foo') class meta: model = mymodel instead of showing values separated spaces, value shows instead: [u'val1', u'val2', u'val3'] how can override behavior? you have basic misunderstanding, fields aren't responsible how they're rendered. that's widgets do.

serialization - How do I serialise Lambdas and Event delegates when Tombstoning on the Windows Phone 7? -

i've been using game state management sample has worked far. i've hit snag though: when tombstoning, screens serialised; trouble is, messageboxscreen has event handlers accepted , cancelled. what's best way serialise these? did bit of research on using expression trees seemed overly complex wanted do. how serialise these? or... alternative approach use save state of screen contains delegates? i'd steer clear of attempting serialize remotely resembling lambda, or matter, named methods. remember: you're storing state , , nothing else. depending on how far , wide various assignments these delegates are, might able away maintaining dictionary<string, whateverdelagatetype> , serializing keys , looking callbacks after deserialization. another thing consider--i'm no expert, reading between lines sounds if you're working towards tombstoning temporary modal dialog. want that? might better off bringing user right high scores table, or w...

Move cursor x lines from current position in vi/vim -

is there way move cursor relative amount of lines in vi/vim? have cursor 10 lines under block of code want remove. if have line numbers shown in relative order, nice have "jump 10 lines command" take there. or perhaps it's better have absolute line numbers shown , go xgg x line number? yep, of course there's way. j , k move down , 1 line, 10j , 10k move down , ten lines. can repeat motion putting number before it. you might want set relativenumber if lot of - it'll save counting printing line numbers relative current line, instead of absolute numbers.

c# - Editing raw data of a FAT drive -

i trying edit raw data of fat drive (i think found solution ntfs, didn't work fat. don't have fat, devices using it) c# (the result should drive in different format - own format). able read raw data (was nice seeing fat inside) using createfile , opening stream using intptr got, couldn't write it. tried several computers, usb flash drives, sd cards, floppy disks - nothing. if isn't possible c#, can language , later call function using dllimport. thanks. if edit/modify drive on sector level no longer compatible. the standard way make big file fill al space , operate on sectors. since goal space fat not efficient. if control both ends ( read/write) can cange sector 0 is not recogninzed existing file system , can wirte own sectors. windows nag @ insertion drive not formatted.

mysql - Checking if any of a list of values falls within a table of ranges -

i'm looking check whether of list of integers fall in list of ranges. ranges defined in table defined like: # type field default null key 0 int(11) rangeid 0 no pri 1 int(11) max 0 no mul 2 int(11) min 0 no mul using mysql 5.1 , perl 5.10. i can check whether single value, 7, in of ranges statement like select 1 range 7 between min , max if 7 in of ranges, single row back. if isn't, no rows returned. now have list of, say, 50 of these values, not stored in table @ present. assemble them using map : my $value_list = '(' . ( join ', ', map { int $_ } @values ) . ')' ; i want see if of items in list fall inside of of ranges, not particularly concerned number nor range. i'd use syntax such as: select 1 range (1, 2, 3, 4, 5, 6, 7, 42, 309, 10000) between min , max mysql kindly chastises me such syntax: operand ...

c - Using ptrace to generate a stack dump -

i compiling c++ on *nix , generate stack dump a) @ arbitrary point in program, b) during signal, particularly during sigsegv. google tells me ptrace tool job, can't find comprehensible examples of walking stack. getting return address, yeah, next return address? , extracting symbolic name of function @ point? dwarf? many if can tell me go here. if using glibc, gnu functions backtrace() , backtrace_symbols() best way this. walking stack going environment-specific anyway, there's no downside using non-portable native functions on each platform it.

mapreduce - Emit a DateTime in the Map function of MongoDb -

my map function looks this: map = function() { day = date.utc(this.timestamp.getfullyear(), this.timestamp.getmonth(), this.timestamp.getdate()); emit({day : day, store_id : this.store_id}, {count : 1}); } timestamp stored date in database, this: { "timestamp" : "mon mar 01 2010 11:58:09 gmt+0000 (bst)", ...} i need "day" in result collection stored date type well, it's stored long (epoch ticks) this: { "_id" : { "day" : 1265414400000, "store_id" : 10}, "value" : { "count" : 7 } } i tried changing emit didn't help: emit({day : {"$date" : day},...) any ideas how that? date.utc going return miliseconds epoch. when put data db, can use example: new date(dateaslong) and stored bson date format. earlier mongo 1.7 show in hash as: "mon mar 01 2010 11:58:09 gmt+0000 (bst)" 1.7+ appear as: isodate("2010-03-01t11:58:09z") ...

sql server 2005 - How to avoid chaotic ASP.NET web application deployment? -

ok, here's thing. i'm developing existing (it started being asp classic app, can imagine :p) web application under asp.net 4.0 , sqlserver 2005. 4 developers using local instances of sql server 2005 express, having source-code , visual studio database project this webapp has several "universes" (that's how call it). every universe has own database (currently on same server) share same schema (tables, sprocs, etc) , same source/site code. so manually deploying annoying, because have deploy source code , run sql scripts manually on each database. know manual deploying can cause problems, i'm looking way of automating it. we've created visual studio database project manage schema , generate diff-schema scripts different targets. i don't have idea how put pieces together i to: have way make "sync" deploy target server (thanksfully have full rdc access servers can install things if required). "sync" deploy mean don...

actionscript 3 - How to get/obtain Variables from URL in Flash AS3 -

so have url need flash movie extract variables from: example link: http://www.example.com/example_xml.php?aid=1234&bid=5678 i need aid , bid numbers. i'm able full url string via externalinterface var url:string = externalinterface.call("window.location.href.tostring"); if (url) testfield.text = url; just unsure how manipulate string 1234 , 5678 numbers. appreciate tips, links or this! create new instance of urlvariables . // given search: aid=1234&bid=5678 var search:string = externalinterface.call("window.location.search"); var vars:urlvariables = new urlvariables(search); trace(vars.aid); // 1234 trace(vars.bid); // 5678

c++ - Reading text file in Qt -

i want read huge text file in dividing strings according comma (,) , store strings in array. how this. there class action stringtokenizer in badaos. have tried qfile not able read whole file. qtextstream lets read line line qfile file(hugefile); qstringlist strings; if (file.open(qiodevice::readonly | qiodevice::text)) { qtextstream in(&file); while (!in.atend()) { strings += in.readline().split(";"); } }

c++ - iMX31 dependencies? -

i beginner in silverlight application. @ first looked on demo application provided wince 6.0 r3 @ location wince600\public\common\oak\demos\xamlperf - this contains c++ code , wince600\public\common\oak\files\xamlperf - this contains xaml file images now before running application in emulator. @ first proceeded following: i have first taken workspace went catalog item , added "silverlight windows embedded" drop down menu of catalog item then right clicked on solution explorer , choosed on properties , under configuration in drop down menu have selected environment variables have added new variable called "sysgen_samplexamlperf" , assigned value 1 variable. now after rebuiding application, have dumped image emulator , found @ desktop of device emulator can see exe file run , can see application working fine 3d effects. now same thing proceeded in imx31 hardware , not able see application running in proper manner performing in emulator. feel ...

opengl es - GL_COLOR_MATERIAL with lighting on Android -

Image
it appears glcolormaterial() absent opengl es . according this post (for iphone), may still enable gl_color_material in opengl es 1.x, you're stuck default settings of gl_front_and_back , gl_ambient_and_diffuse otherwise set glcolormaterial() . ok this, diffuse lighting not working correctly. i set scene , tested 1 light, setting glmaterialfv() gl_ambient , gl_diffuse once in initialization. normals have been set correctly, , lighting works way it's supposed to. see gouraud shading. with gl_lighting disabled, flat colors have set glcolor4f() appear on various objects in scene. functions expected. however, when glenable(gl_color_material) called, flat colors remain. expect see lighting effects. glcolormaterial() mentioned on anddev.org , i'm not sure if information there accurate. i'm testing on android 2.1 handset (motorola droid). edit : works on 1.6 handset (adp1). i've filed issue 8015 . not work emulator android 1.6 or 2.1. here mi...

php - How to include excerpt in ul from different pages with the same parent - Wordpress -

i wish title, excerpt , meta 3 different pages have same parent. i not wish specify wich 3 pages show rather show 3 last edited/published. i aim display content 3 blocks on horizontal line. as unable code work: <ul id=""> <?php query_posts("posts_per_page=1&post_type=page&post_parent=4"); the_post(); ?> <li> <img src="<?php echo get_post_meta($post->id, "image", true); ?>" alt="<?php the_title(); ?>" /> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> </li> </ul> thank dan, still not work though. excrept of first page not show (the title shows , meta also). tried code below same result except second time content displayed, excerpt of first page shows. <?php get_header(); the_post(); ?> <div id="main-content"> <?php $categoriescf = get_post_meta($post->id, "categories", true); $allcategories = e...

How to get password of active directory by ldap in php? -

i have problem password in active directory. want password "username" of user tried function "ldap_search", not find correctly attribute password tried as: password, userpassword, userpassword, unicodepwd, unicodepwd, not correct. i forward helping of :d trankinhly passwords in active directory not retrievable. nor in directories. (edirectory has password policy, if bind specified user, can retrieve passwords via ldap extensions) some directories might let recover hashed versions, not great either. to cross platform, better try , bind values provided , either succeed or fail. additionally, ldap says bind blank password anonymous bind, succeed, need filter case. once bound user, @ group memberships (since can see own) or @ other attribute, if can read it, means have level of rights. (i.e. implement authorization authentication).

asp.net mvc - form name in mvc url.action -

i having following <form action="<%=url.action("passworddetails",new{controller = "user"}) %>" method="post" name="passwordform" id="passwordform" enctype="multipart/form-data"> however, $("#passwordform").submit(function() { if (validate()) return true; else return false; }); isn`t being passed through. what wrong? <% using (html.beginform("passworddetails", "user", formmethod.post, new { id = "passwordform" })) { %>

scroll - edittext inside tablerow android -

i have textview , edittext inside tablerow.. problem when try write many chars in edittext cant see writing..it seems problem in width..any way make multiline row or scolling edittext while writting? <tablelayout android:id="@+id/table" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingtop="30dip" android:paddingleft="10dip" android:paddingright="10dip" android:layout_below="@id/banner" > <tablerow> <textview android:id="@+id/username_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textcolor="#fff" android:textsize="18dip" android:text="username" /> <edittext android:id="@+id/entry1" androi...

c# - Is there a subtle error in this type? -

found in our codebase , took while figure out (and had use debugger). class 1 thing not quite intended. thought i'd share! edit got rid of syntax error, sorry! public class recordnotfoundexception : applicationexception { readonly string _entityname; public string entityname { { return _entityname; } } readonly string _details; public override string message { { return string.format("can't find record {0}.", _entityname) + _details != null ? string.format(" details: {0}", _details) : ""; } } public recordnotfoundexception(string entityname) { _entityname = entityname; } public recordnotfoundexception(string entityname, string details) : this(entityname) { _details = details; } } although question vague, problem, change message property this: public override string message { ...

jquery - How to load and show data Asynchronously -

i using asp.net , sql server. load data database asynchronously , show data partially loaded immediately. suppose there tons of records in query result. after 3 sec,it loads 20% have process , show 20% data immediately, not waiting complete response. know $.ajax in jquery load data async. possible process partial response, not wait complete response , show immediately. is there way this? suppose there tons of records in query result you have aks yourself: end user see ton of records @ once? you don't specify , how showing data, i'm going assume showing data in grid. what days on such commun scenario load data using pages , fire when user scrolls grid down, can see in mobile devices , on facebook, twitter, etc... it load first page (for example set page 20 records), load first 20 records ( page 0 ), reach bottom, automatically load 20 more records ( page 1 ). this technique called infinite scroll

Any possiblity to get autocompletion / type-ahead / intellisense in Android XML Files (Eclipse) -

is there way make eclipse + android sdk + adt plugin offer sort of auto-complete in xml files if hit ctrl+space when cursor in spot such ones marked * below. <linearlayout id* ... lay*> the thing think above working directly after initial install - though of course never worked within style files. <style name="actionbarwrapper" parent="fill_parent.vertical"> <item name="android:layout_height">36dp</item> <item name="a*" </style> thanks lot kind of lead in right direction. there icon in eclispe toolbar directly access "new android xml file" wizard.

java - How to update JTree elements -

i use jtree treenode extending defaultmutabletreenode.when add new node,i cant update jtree.any appreciated adding node not enough, tree needs notified. correct way let model take care of adding/removing nodes, notify correctly tree on way. in case of defaulttreemodel (which should 1 used in jtree if haven't made own treemodel), have method insertnodeinto(mutabletreenode newchild, mutabletreenode parent, int index) , can use.

performance - Wordpress: Your favorite permalinks structure - efficient / seo friendly -

i using wordpress permalink format: /year/month/postname in wordpress blog . of blog posts write tutorials / how-tos. doesn't make sense organize on based of date. i know comments / suggestions on how organize urls in wordpress. know wordpress not recommended permalink based on category name: /category/postname, organize urls based on categories without affecting blob performance. /year/month/postname -> good /postid/postname -> good /category/postname -> bad /author/postname -> bad please give feedback on favorite permalink structure keeping both performance , seo in mind. thanks it depends on blog content. by default 90% go simple /postname/ only if year or month important blog (which isn't case), add year or month it. never add date unless it's important google search (maybe news blogs etc.). it's important keep url short. , important have keywords in url. what's needed, , rid of not. that's general point...

asp.net mvc - How to select the Telerik MVC TabStrip programatically? -

does know how programatically switch tabs in telerik tabstrip? in view call html.telerik().tabstrip().selectedindex(). check client-side api on website info on how on client.

visual studio 2008 - auto update asp.net website bin folder -

is there way vs2008 automatically fill website bin folder necessary dependencies required website? at moment contains assemblies solution not third party assemblies using. thanks, aj you should set copy local true in reference properties. http://msdn.microsoft.com/en-us/library/t1zz5y8c.aspx

javascript - Can i add extra fields? -

i'm using full calendar. possible add field besides title in events property ? look @ last paragraph on page: http://arshaw.com/fullcalendar/docs/event_data/event_object/ in addition fields above, may include own non-standard fields in each event object. fullcalendar will not modify or delete these fields. example, developers include description field use in callbacks such eventrender.

c# - Invoking another URL -

string url = "http://foo.com/bar?id=" + id + "&more=" + more; httpwebrequest request = (httpwebrequest)webrequest.create(url); httpwebresponse response = (httpwebresponse)request.getresponse(); i m trying make call server, , getting following: |fatal|the remote server returned error: (406) not acceptable. (ref #1) system.net.webexception: remote server returned error: (406) not acceptable. why getting error? , how fix this? according rfc 10.4.7 406 not acceptable the resource identified request capable of generating response entities have content characteristics not acceptable according accept headers sent in request. review accept headers request sending , , content server in url ; ) bonus to see accept headers: browse url , use firebug (html tab). to set accept headers request use httpwebrequest members .

java - Allow user to resize html image in jeditorpane -

i'm creating application that, amongst other things, allows users insert images on document. document jeditorpane , going use html insert image because way able add print functionality. don't see why should need change component because under understanding jeditorpane powerful component of type... but anyway, inserting image alright, need allow user change alignment , size atleast, , @ minute, i'm not sure how can , that's i'm asking for. i'd of thought there type of html code that, like, online wysiwyg editors use - couldn't find anything! know how tackle little problem, prefabably i've got? thanks in advance andy i think need add javascript project. check out http://tinymce.moxiecode.com/ wysiwyg editor in javascript, can linkt css file.

java - Converting double[][] in to float[][] -

i wondering if there way of converting double [][] in float[][] in java? have loop in code , looking better , cleaner way. any ideas appreciated, thanks, there's no quicker way. note not every double value convert float - range of float smaller.

PHP CURL Google Calendar using Private URL -

i'm trying array of events google calendar using private url. read google api document want try doing without using zend library since have no idea eventual server file structure , avoid having other people edit codes. i did search before posting , ran same condition php curl_exec returns false url json file if url open using web browser. since i'm using private url, need authenticate against google server using zend? i'm trying have php clean array before encoding flash. $url = <string of private url google calendar> $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, 1); $data = curl_exec($ch); curl_close($ch); $result = json_decode($data); print '<pre>'.var_export($data,1).'</pre>'; screen output >>> false you can "roll own" authsub or oauth implementation: the following summarized from: http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#auth to acquir...

mysql - what is the problem if we got ER_UNKNOWN_COM_ERROR -

i've got mysql error: 1047 sqlstate: 08s01 er_unknown_com_error error mysql. i've try search in google. didn't find solution. maybe can me.... thanks, if describe little more situation, maybe can find something... http://dev.mysql.com/doc/refman/5.0/es/error-handling.html

apache - .htaccess redirect if URL contains an email address -

i want allow clean urls in form of domain.com/me@msn.com should redirect domain.com/?profile=me@msn.com (url encoded or not). what rewriterule achieve this? should detect email address in url redirect. it's painful match mail addresses regular expressions. rfc-2822 compliant regex 2 pages long. matching @ should, however, suffice in scenario. rewriteengine on rewriterule ^((?<!results=).*@.*)$ ?profile=%1 [l] edit: make sure manually navigating ?profile=... still works asserting case.

c - Arrays scoping in threads -

how arrays scoped in c? when ever destroyed? (note, talk if can passed in p_threads) they're scoped normal variables: // in function int arraya[300]; { float arrayb[100]; // arraya , arrayb available here } // arrayb out of scope, inaccessible. // arraya still available. if pass array function, valid long array still in scope @ calling site.

language agnostic - CPU or GPU bound? profiling OpenGL application -

i've got opengl application i'm afraid gpu bound. how can sure that's case? , if is, how can profile code run gpu? if using windows, linux or mac, (well, computer!) give try gdebugger .

java - Bidirectional OneToMany/ManyToOne mapping in OpenJPA JPQL problem -

i have 2 classes bidrectional relationship: @entity @access(accesstype.field) @table(name="room") public class room { @id @generatedvalue @column(name="room_id_pk", updatable=false, nullable=false) private int id; @column(name="name", nullable=false, unique=true) private string name; @onetomany(mappedby="room", cascade={cascadetype.all}) private final set<wall> walls; ... } @entity @access(accesstype.field) @table(name="walls") public class wall { @id @generatedvalue @column(name="wall_id_pk", updatable=false, nullable=false) private int id; @column(name="name", nullable=false, unique=true) private string name; @manytoone @joincolumn(name="room_id_fk", referencedcolumnname="room_id_pk") private room room; ... } i'm running mysql -- looks sane set of tables generated: rooms: int room_id_pk, varchar name...

UML enumeration as a return type -

<< enumeration>> e1 | .red .green .blue | i have above enumeration class in uml diagram. associate class house . need method on house +getcolor() returns color above enumeration. how depict in uml? : +getcolor(): e1 ? yes, suggestion right , depending on level of detail, add dependency house e1.

powershell - How to to copy all the files available in my TFS source server to a folder in a directory? -

i want copy files available in tfs source server folder in directory. tried below code error coming while achieving same. can suggest solution? ps> c:\windows\system32> get-tfsitemproperty $/myfirsttfsproj -r ` -server xyzc011b| {$_.checkindate -gt (get-date).adddays(-150)} | copy-item d:\john\application1 -destination c:\test -whatif copy-item : input object cannot bound parameters command either because command not take pipeline input or input , pr operties not match of parameters take pipeline input. @ line:2 char:14 + copy-item <<<< d:\deepu\silverlightapplication5 -destination c:\test -w hatif i create workspace/workfolder mapping , use tf.exe tool files @ date interested in e.g.: ps\> cd <root_of_workfolder_on_local_harddrive> ps\> tf . /r "/v:d$((get-date).adddays(-150))" if isn't final destination copy dir contents destination. if don't need workspace longer, delete it. btw use powertool cmd...

jquery - javascript Truncate string after comma -

i'm looking way remove comma , comes after in string, example: important, not important i'd remove ",not important" any ideas? in advance! you can substring , indexof : str = str.substring(0, str.indexof(',')); but you'd have sure comma in there (test before). another possibility use split() : str = str.split(',')[0]; this works without testing beforehand might perform unnecessary string operations (which negligible on small strings).

c# - Generate number sequences with LINQ -

i try write linq statement returns me possible combinations of numbers (i need test , inspired article of eric lippert ). method's prototype call looks like: ienumerable<collection<int>> allsequences( int start, int end, int size ); the rules are: all returned collections have length of size number values within collection have increase every number between start , end should used so calling allsequences( 1, 5, 3 ) should result in 10 collections, each of size 3: 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5 now, somehow i'd see pure linq solution. able write non linq solution on own, please put no effort solution without linq. tries far ended @ point have join number result of recursive call of method - like: return in enumerable.range( start, end - size + 1 ) select buildcollection(i, allsequences( i, end, size -1)); but can't manage implement buildcollection() on linq base - or skip method call. can me her...

How do I share data between kernel C programs and user level C programs? -

i using ubuntu 9.04 kernel 2.8.32. created simple system call counts number of clone , execve calls. when user/shell calls system call, pass user these 2 values. of using: #include <linux/sched.h> #include <linux/asmlinkage> /* these 2 variables extern longs defined in sched.h , initialized in process_32.c */ total_execve; total_clones; long mycall* (int i){ int array[2]; array[0] = total_execve; array[1] = total_clones; return array; } i not able compile undefined reference. regarding returning array: new call able access array, won't array located in kernel memory? answering last question first: array indeed in "kernel" memory, it's stack allocated means "go away" when mycall() function exits. function may appear work, may fail in cases memory gets re-used quickly. to return multiple values, common pattern caller pass in pointers user-space memory, , have kernel routine fill them in. example, pass i...

How do I get the position of an element after css3 translation in JavaScript? -

i saw posted in 2 different forms on stackoverflow, solutions don't work me. essentially, have item translate. when obj.style.left or obj.offsetleft, after element has been translated, 0. there anyway can coordinates/position of element after has been translated css3? i can't use jquery (because can't , because want understand solution, not use library without understanding happening underneath) any ideas? thanks much! ok, hold tight because not nice: window.addeventlistener('load', function(){ var node = document.getelementbyid("yourid"); var curtransform = new webkitcssmatrix(window.getcomputedstyle(node).webkittransform); console.log(node.offsetleft + curtransform.m41); //real offset left console.log(node.offsettop + curtransform.m42); //real offset top }); you can play here: http://jsfiddle.net/duopixel/wzz5r/

actionscript 3 - Try Catch With Sound Element into Flash CS5-as3 -

hi all—anyone has idea why code doesn’t work? with other load [example image] work perfect sound...no :( mysoundurl = new urlrequest(var+".mp3"); mysoundurldefault = new urlrequest("default.mp3"); try{ sound.load(mysoundurl); }catch(e:ioerrorevent){ trace("can't load sound: "+e); sound.load(mysoundurldefault); } this error i’m getting: error #2044: unhandled ioerrorevent:. text=error #2032: stream error thanks , day! you not use try/catch loaders. here's instead: sound.addeventlistener(ioerrorevent.io_error, onioerrorevent); sound.load(mysoundurl); private function onioerrorevent(e:ioerrorevent):void{ trace(e); trace(e.message); // ^ show file tried load , failed @ e.currenttarget.removeeventlistener(ioerrorevent.ioerror, onioerrorevent); e.currenttarget.removeeventlistener(event.complete, oncomplete; // ^ don't forget clean listeners! } the reason is, you've seen, uncaught e...

c++ - boost asio ssl stream socket compilation issue -

using boost 1.4.2 asio in c++ app , getting linux compiler warnings don't grok. still here? app i'm working on needs "socket" might ssl socket or regular tcp socket hide specifics behind template "socket" class takes either ssl socket class or tcp socket class template parameter - below ssl class code. app runs without optimization turned on; issue when compile under linux g++ 4.4.1 , turn on optimization @ -02 or higher, -fstrict-aliasing flag turned on. compiling results in strict aliasing warnings along lines of: "warning: dereferencing type-punned pointer break strict-aliasing rules" everywhere dereference _psock (eg _psock->handshake) i'd know why warning being issued, , indicate design problem... class socket_ssl_cli { public: typedef ba::ssl::stream<ba::ip::tcp::socket> socket_type; socket_ssl_cli(ba::io_service& io_svc, socketconfig & sockcfg) : _io_svc(io_svc) , _ctxt(_io_svc, ba:...

sql - LLBLGen: Copy table from one database to another -

i have 2 databases (sql server 2005) same table schemes. need copy data source table destination modification of data along way. and if destination table contains data, rows source table should not override, added destination table. in our project use llblgen , linq llblgen orm solution. example: database 1 database 2 database 1 table 1: table 1: table 1: key value key value key value 1 1 1 t2_one result=> 1 1 2 2 2 t2_two 2 2 3 3 3 3 4 t2_one 5 t2_two i create view of table 2 in db1 (you can create view of table db), generate code llbl getpro , make query select values view not present in table 1. can save retrieved values in table 1.

.net - Are there any string comparison alogrithms out there that are "better" than Levenshtein Distance? -

i have been using project working on, of results aren't choose. example: when "date" compared to "state" has lev distance of 2 "today's date" has lev distance of 9 this expect algorithm of course, i'm curious if knows of out there give closer match compared strings have exact match of source string (date)? meaning "today's date" have higher ranking because has "date" in it. bonus points if can find .net library implements this. i think it's meant tokenize word before employing levenshtein. alternative there jaro-winker distance too. there's .net library simmetrics seems cover a few alternatives .

iphone - Can I cancel touch programmatically? -

uiscrollview has canceling mechanism, cancels touch of subviews when detects 'scrolling'. i wonder if can cancel touch event (which has begun) programmatically. i have draggable view inside scroll view. can let draggable view receive touches, i'm wondering how stop receiving touch events when want , give touch events scroll view. you might want have @ uitapgesturerecogniser class's cancelstouchesinview method

javascript inherance? with Private vars and methods too -

hy need inherent class another. parent has private var "_data" , private method "_test" , public method "add" child have public method "add", uses private method parent "_test" , private var "_data". how do this? var parent = function(){ var _data = {}; var _test = function(){alert('test')}; this.add = function(){alert('add parent')} } var child = function(){ this.add = function(){// here uses _data , _test parent class alert('add child') } } // inherent child parent // instance child , use add method and think im miss prototype concept ( javascript inheritance ) a simple inheritance: function createchild(){ child.prototype=new parent() return new child() } this way fresh initialization of parent every child.

java - JPA @TableGenerator shared between multiple entities -

i have 'dog' entitiy @id , @tablegenerator ... @tablegenerator(table = "seq", name = "dog_gen", pkcolumnname = "seq_name", valuecolumnname="seq_val") @id @generatedvalue(strategy = generationtype.table, generator = "dog_gen") private long id; ... is there way reuse same table generator (dog_gen) in other entity? want keep same id sequence in 2 independent entities, say dog=1, dog=2, dog=3, cat=4, cat=5, dog=6 , on... both entities don't share common superclass implement kind of inheritance id property. if add @generatedvalue( generator="dog_gen") on cat entity, omitting @tablegenerator declaration throws exception saying can't find generator when starting context. caused by: org.hibernate.annotationexception: unknown id.generator: dog_gen @ org.hibernate.cfg.binderhelper.makeidgenerator(binderhelper.java:413) @ org.hibernate.cfg.annotationbinder.bindid(annotationbinder.java:1795) @ org.hibernat...

javascript - Regex Lookaheads -

need capture content of root <pubdate> element, in document can either within <item> element or within <channel> element. <item> child of <channel> i'll bring example <channel> ... <pubdate>10/2/2010</pubdate> ... <item> ... <pubdate>13/2/2029</pubdate> ... </item> ... </channel> need capture 10/2/2010 with <item> no problem, can capture it, along <pubdate> . i don't know javascript, can't dom. agree 100% it's bad idea try , parse xml regex. there might quick, dirty, , brittle workaround, though: if indentation consistent throughout file, , <channel> elements @ same level of indentation, use fact guide regex. in example /^ {2}<pubdate>([^<]*)<\/pubdate>/m (= 2 spaces after start-of-line) might work. use @ own risk. here dragons etc.

.net - How to get started with the mono profiler 2.8? -

Image
i download profile mono 2.8 http://hurlman.com/greghurlman_com/attachments/monoprofile2_8.zip add in c:\program files\reference assemblies\microsoft\framework.netframework\v4.0\profile\mono create new project winforms (framework 4.0) in visual studio 2010. in project change "target framework" mono 2.8 profiler. end press "startin debuging". in case error occurs how work? from greg hurlman's blog . "markus" posted : i had same problem, error dialog telling me should download “.netframework,version=v4.0,profile=mono” in order run application. the trick create registry key. me, running windows 7 x64, was: hkey_local_machine\software\wow6432node\microsoft\.netframework\v4.0.30319\skus\.netframework,version=v4.0,profile=mono i suppose x86 it’s hkey_local_machine\software\microsoft\.netframework\v4.0.30319\skus\.netframework,version=v4.0,profile=mono (where v4.0.30319 version of current 4.0 fra...

sql server - Group by sql query on comma joined column -

my table structure below, "mail" column can contain multiple email joined comma data(int) mail(varchar(200)) [data] [mail] 1          m1@gmail.com,m2@hotmail.com 2          m2@hotmail.com,m3@test.com & need generate report below, counting each row per each email [mail]                   [count] m1@gmail.com          1 m2@hotmail.com       2 m3@test.com            1 so sql(server) query generate above? can't change table structure. string splitting faster using charindex without xml or cte. sample table create table #tmp ([data] int, [mail] varchar(200)) insert #tmp select 1,'m1@gmail.com,m2@hotmail.com,oth...

How to read empty string in C -

i have problem reading empty string in c. want read string following - ass ball (empty) cat but when use gets() not treat (empty) string[2]. reads 'cat' string[2]. how can solve problem? char str1[15002][12]; char str2[15002][12]; char s[25]; map<string,int> map; int main() { int ncase, i, j, n1, n2, count, case; freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); scanf("%d",&ncase); case = 1; while(ncase > 0) { map.clear(); //this necessery part scanf("%d %d\n",&n1,&n2); count = 0; printf("n1=%d n2=%d\n",n1,n2); for(i = 0; < n1; i++) { gets(str1[i]); } for(i = 0; < n2; i++) { gets(str2[i]); } //end of reading input for(i = 0; < n1; i++) { for(j = 0; j < n2; j++) ...

c# - Server.TransferRequest() and the http status code -

i had implement custom httpmodule handle 404 error in sharepoint. it listens presendrequestcontent event, , looks 404 status code. if 1 found transferrequest. void app_presendrequestcontent(object sender, eventargs e) { httpresponse res = app.response; httprequest req = app.request; if (res.statuscode == 404 && !req.url.absolutepath.equals(pagenotfoundurl, stringcomparison.invariantcultureignorecase)) { app.server.transferrequest(pagenotfoundurl); } } this works fine, noticed in fiddler page showing 200 status code, though original request 404. not search engines. is expected behaviour of transferrequest ? can somehow maintain 404 status code? or, have been better off using old fashioned server.transfer? update i tried outside of sharepoint environment, , server.transferrequest request indeed give 200 status code, removing 404. server.transfer doesn't work don't think can given pipeline. update 2 thanks answer below, have...

json - Using Facebook graph to get the fans of a fan page? -

i have fan page located @ http://www.facebook.com/shop4tronix . can access info on page going to: http://graph.facebook.com/shop4tronix however, want list of fans of page returned. figured work: http://graph.facebook.com/shop4tronix/fans but doesn't. there way list of fans returned using method? looks it's not possible. if google bit, you'll find people scraping fan pages (as there seem no api access).

security - php Form to Email sanitizing -

im using following send contact type form, iv looked security , found need protect from: bit of mail function, ive hardcoded mean script spamproof / un-hijackable $tenantname = $_post['tenan']; $tenancyaddress = $_post['tenancy']; $alternativename = $_post['alternativ']; //and few more //then striptags on each variable $to = "hardcoded@email.com"; $subject = "hardcoded subject here"; $message = "$tenantname etc rest of posted data"; $from = "noreply@email.com"; $headers = "from: $from"; mail($to,$subject,$message,$headers); unhijackable? yes. spamproof? wouldn't describe that, form can still used spam target of form.

SQL Server ODBC performance penalty? -

this bizarre, hoping can me out. i have stored procedure call takes 42 seconds run – when called application connected odbc connection. however, if run same call in ssms (sql server management studio), takes 10 or 15 seconds execute….as recorded trace. this not appear network issue. passing 1200 records client – , in case, times gave coming straight trace duration field….so taking sql server 3 or 4 times longer process same call – when done via odbc call. can reproduce on , on again. more interesting, reads , writes (taken trace) little higher odbc call, cpu usage 3 or 4 times ssms call is. there other stored procs called part of same process, , not appear affected in same way...or @ least not same extent. we using sql server 2005 any ideas going on here? could pulling data "warmed" cache in ssms. try running these lines before stored proc call in ssms , see if runs quickly: checkpoint go dbcc dropcleanbuffers go dbcc freeproccache go -- sql begins ...

.net - What happened to Shersoft and the ActiveListBar control? -

i have task of maintaining application started life vb6 app , has been migrated .net 3.5. app contains several third-party com controls, 1 of shersoft activelistbar control. i'm trying couple new programmers set edit project , we're running licensing issue , pop-up telling contact shersoft... company no longer exists. know happened activelistbar product, if purchased , being sold company? (yes, realize proper thing pull control codebase , replace with .net code, there isn't time in release schedule right now...) i found answer: sheriden software -- shersoft -- , protoview merged in 2001 create infragistics . ssactlivelistbar control has since been updated/replaced winlistbar control .

html - Selecting id using jQuery on the fly -

using checkbox styling system here (with few slight modifications): http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/ have following jquery code: if($(this).data("checked") == true) { $("#" + this.id + "l").css("padding", "8px 0px 0px 0px"); $(this).css({backgroundposition:"center -"+(imgheight*3)+"px"}); } and html: <div class="checkbox" id="c2"> <input type="checkbox" id="cbx2" name="num[]" value="2" /> </div> <div class="cbxlabel" id="c2l">opt 2</div> the part i'm having trouble $("#" + this.id + "l") . no matter try, doesn't select id of div "opt 2" properly. i'm trying style part of div can't seem right. var $_this = $(this); $('#'+$_this.attr('id')+'1').css(...

android - Shortcut icon too small from assets directory -

this craziest issue. loading custom icons assets directory use application. application loads custom icon , makes shortcut on desktop. of icons 48x48 png files. on android 2.1 , 2.2 emulator works perfect. on droid x (android 2.2) icons show smaller 48x48. now kicker, if move 1 of icons drawable directory , load there shows correctly. any ideas problem droid x? is there way list of drawables? if there put icons in drawables directory, albeit little ugly dump 100 icons in there. my code loading icons pretty standard: assetmanager assets = context.getassets(); inputstream inputstream = assets.open("icons/"+ name); if (inputstream != null) { bitmap bitmap = bitmapfactory.decodestream(inputstream); if (bitmap != null) { return bitmap; } } one thing mention here when said worked okay on 2.1, 2.2 emulators.. density of emulators used. density has hug...