Posts

Showing posts from January, 2013

asp.net mvc 2 - Trouble Figuring Out The routes.Maproute For This URL (C#) -

despite plethora of url routing posts, have yet reach enlightenment on subject. i have mvc app works fine, want fancy , url rewriting make easier on users. the default route slight variation on usual: routes.maproute( "default", "{controller}/{action}/{query}", new{ controller = "somecontroller", action="index", query = "" }); what want re-route url http://mysite.com/12345 details action of somecontroller 12345 query. tried this: routes.maproute( "directtodetails", "{query}", new{ controller = "somecontroller", action="details" query="" }); routes.maproute( "default", "{controller}/{action}/{query}", new{ controller = "somecontroller", action="index", query = "" }); but ends obscuring http://mysite.com/ , goes somecontroller/details instead of somecontroller/index....

regex - Locale sensitive character classes in regexp with validations? -

validates_format_of :first_name, :with => /\a\w+\z/ the validation doesn't pass if there non-english character in first name, mölläinen . changing rails locale doesn't help. how do culture/locale sensitive validation then? if locale en , \w should map [a-za-z0-9_] , if it's fi , should map [a-za-z0-9_äöåÄÖÅ] , on. try /\a[[:alpha:]]+\z/ . should locale aware, @ least in ruby 1.9. but might want allow other characters too. anna-lena common name in germany, example.

objective c - how to find out is a long string contatins a word obj c, iphone -

i have long string has running list of "words entered" in text box. want able check long string against 1 word string see if long string contains word in short string. any ideas? i've tried , few other things, newstring long string , currenttextrightnow short string. textrange =[newstring rangeofstring:currenttextrightnow]; nslog(@"currenttextright %@", currenttextrightnow); if(textrange.location != nsnotfound) { nslog(@"does contatin substring"); } i had same problem did. doing right (if textrange of type nsrange) problem nsnotfound doesn't work expected (might bug). instead can do if (range.length > 0) { //it found } else { // didn't find } hope helps.

c# - dynamic keyword enables "maybe" monad? -

so have in c# lib: public static tout ifnotnull<tin, tout> (this tin instance, func<tin, tout> func) { return instance == null ? default(tout) : func(instance); } used like: datetime? expiration = promo.ifnotnull(p => p.termsandconditions.expiration) .ifnotnull(e => e.date); i keep wracking brain trying figure out how use c# 4 dynamic keyword enable syntax instead: datetime? expiration = promooffer.termsandconditions.maybe() .expiration.maybe() .date; i had couple examples thought worked broke down when start chaining maybe() s. any ideas? (am wasting time? maybe() win on ifnotnull() )? i don't think using dynamic type idea here, because syntax isn't going better , sacrifice type safety (and intellisense) using dynamic typing. however, here example of can do. idea wrap objects dynamicwrapper (your monadic value :-)) can eithe...

tsql - time format in SQL Server -

does know how can format select statement datetime value display time in sql server? example: table cuatomer id name datetime 1 alvin 2010-10-15 15:12:54:00 2 ken 2010-10-08 09:23:56:00 when select table result display below id name time 1 alvin 3:12pm 2 ken 9:23am any way can in mssql? you can use combination of convert, right , trim desired result: select ltrim(right(convert(varchar(25), getdate(), 100), 7)) the 100 see in function specifies date format mon dd yyyy hh:miam (or pm) , , there grab right characters. you can see more converting datetimes here .

using software metrics for measuring productivity of pair programming -

what software metrics can used measuring performance of pair programming ? to clear is there metrics used measure pair programming , not use measure individual programmer ? parameters used measuring ? for example:if want measure cost both individual , pair programming let's assume individual programming cost = x pair cost = 2* x right and same time individual time = t while pair time = 2* t so if use lines of code measuring product size , there different between individual , pair using metric? any idea sorry spoil party, lines of code 1 of worst metrics possible, if people know assessment or bonus in way tied metric. actively encourages cut , paste programming , other attrocities. it's more effort, why don't categorise workload in terms of expected effort 1 person, based on historical data? or, programmers agree few projects redundantly, rotating between pair-programming , individual, can see how same programmers go @ each. 1 programmer can ...

ruby on rails - How to get mongrel working with bundler? -

transitioning bundler existing production setup. naively gemfile , setup like: gem "rails", "2.3.8" gem "mongrel", git: "http://github.com/dynamix/mongrel.git" bundle install --path /mnt/app/shared/bundle starting with bundle exec mongrel_rails start --environment=production ... results in /mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require': no such file load -- /mnt/services/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1/lib/mongrel/init.rb (missingsourcefile) what do? to answer own, since couldn't find correct solution elsewhere on web scenario: the problem seems interaction of bundler , mongrel 's use of gem_plugin . yes, these may on life support unfortunately lots of people's production configs still depend on them. seems mongrel --pre installed git source, it's looking in bundle/ruby/1.9.1/gems/mongrel_ instead of bundle/ru...

sql - Is PARTITION RANGE ALL in your explain plan bad? -

here's explain plan: select statement, goal = all_rows 244492 4525870 235345240 sort order 244492 4525870 235345240 **partition range all** 207633 4525870 235345240 index fast full scan mct mct_planned_ct_pk 207633 4525870 235345240 just wondering if best optimized plan querying huge partitioned tables. using oracle10g partition range all means predicates not used perform partition pruning. more info. or, alternative (scanning table blocks instead of using fast full scan on index) estimated more expensive overall. if can change predicate limit affected rows small subset of partitions, database able skip whole partitions when querying table.

Is it possible to get information about all apps installed on iPhone? -

is possible information (app icon, app name, app location) apps have been installed on iphone/ipod? there way check if application installed or not, however, violate sandbox rules , apple *may reject app using this. has been done before other apps available in app store, feel free try it sometimes may want check if specific app installed on device, in case use custom url schemes require other app installed (you gray out/disable buttons then). unfortunately, apple apparently not have function checks you, whipped 1 up. not enumerate every single app, instead uses mobileinstallation cache up-to-date springboard , holds info dictionaries of apps installed. although you're not "supposed" access cache, it's readable app store apps. here code @ least works fine simulator 2.2.1: code: // declaration bool apcheckifappinstalled(nsstring *bundleidentifier); // bundle identifier (eg. com.apple.mobilesafari) used track apps // implementation bool apcheckifappins...

javascript - Combining two images on one canvas in HTML5 -

i'm working html5 canvas element. let's have 2 imagedata objects want combine able put on 1 canvas. lets assume don't care how these images combine. both imagedata objects have exact same pixel count , shape. what's best way combine 2 images? i figure can write loop , iterate on imagedata array , manually combine , set every rgba value per pixel, i'm wondering if there's better way? need operation happen possible. thanks in advance. if you're looking superimpose 1 image on top of another, want this: ctx.drawimage(image1, x, y); // adjust globalalpha needed, or skip if image has own transparency ctx.globalalpha = 0.5; ctx.drawimage(image2, x, y); or, depending on specific effect you're after: ctx.drawimage(image1, x, y); ctx.globalcompositeoperation = "lighten"; // many other possibilities here ctx.drawimage(image2, x, y); this faster drawing pixel-by-pixel through get/putimagedata methods, though how browser-dependen...

Can I run a new process from a medium-trust ASP.NET application? -

i'm building asp.net mvc site want use openstv conduct polls. run results through openstv, i'd have run executable. is allowed medium-trust asp.net application? you can't instantiate system.diagnostics.process object unless you're running @ fulltrust . if examine attributes decorating class you'll see demand fulltrust : process class (msdn) [permissionsetattribute(securityaction.inheritancedemand, name = "fulltrust")] [hostprotectionattribute(securityaction.linkdemand, sharedstate = true, synchronization = true, externalprocessmgmt = true, selfaffectingprocessmgmt = true)] [permissionsetattribute(securityaction.linkdemand, name = "fulltrust")] public class process : component

Cannot use the "include file" in JSP -

i want ask question jsp page. set project in following structure in order manage project efficiently. when in list folder, main.jsp, set header following <%@ include file="universe/header.jsp" %> when open main.jsp, shows error cannot find "jsp/list/universe/header.jsp" the header.jsp , other classes cannot read. can me solve problem? thank you. class structure webapp | |-- jsp | |-- list | | | |--main.jsp | |-- universe | |-- header.jsp |-- footer.jsp in jsp include directive path can relative including page or absolute (then has start / , belongs webapplication root directory). so in case have set path either ../universe/header.jsp or /jsp/universe/header.jsp .

scheme - GIMP - Scripting a canvas resize -

just started using gimp today. when resize canvas manually in gimp (so it's smaller image size) lets me move image around can "change" viewable area. how replicate in script? in other words, want script pause @ canvas resizing step , let me position image correctly. the reason i'm asking: i've written small script create square thumbnails of images. way i'm doing resizing canvas height , width same. if height , width different change higher of 2 same lower (e.g. 600x500 becomes 500x500). flatten image , scale whatever need. (if (>= width height) (begin (gimp-image-resize image height height 0 0) ) (begin (gimp-image-resize image width width 0 0) ) ) the code i'm using resize canvas above. know last 2 values in gimp-image-resize command refer offsets. want manually modify when script reaches step. appreciated. thanks! does code work? if so, here's better-looking version of same code: (let ((smalle...

c# - Subversion connection with C # in Visual Studio 2010 -

i using connect library subversion sharpsvn error. code follows: svnclient client = new svnclient(); string targetsource = "http://xxxxxxx/svn/xxxx/xxxx/"; string uridest = "c:/documents , settings/user/my documents/jesus/project/test"; client.checkout(new uri(targetsource), uridest, svnrevision.head.revision, true); although lack of authentication, if try run code following error in main () of project: "the mixed-mode assembly compiled version 'v2.0.50727' runtime , can not loaded @ runtime 4.0 without additional configuration information." put in config file: <configuration> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0"/> </startup> </configuration> it seems used library not built target .net 4.0 runtime.

ide - Eclipse helios install new plugin problem -

i'm trying install new plugin when choose update site got error !entry org.eclipse.equinox.p2.core 4 0 2010-10-07 08:57:56.153 !message provisioning exception !stack 1 org.eclipse.equinox.p2.core.provisionexception: bad http request: http://download.eclipse.org/eclipse/updates/3.6/compositecontent.xml @ org.eclipse.equinox.internal.p2.repository.cachemanager.createcache(cachemanager.java:189) @ org.eclipse.equinox.internal.p2.metadata.repository.compositemetadatarepositoryfactory.getlocalfile(compositemetadatarepositoryfactory.java:74) @ org.eclipse.equinox.internal.p2.metadata.repository.compositemetadatarepositoryfactory.load(compositemetadatarepositoryfactory.java:99) @ org.eclipse.equinox.internal.p2.metadata.repository.metadatarepositorymanager.factoryload(metadatarepositorymanager.java:57) @ org.eclipse.equinox.internal.p2.repository.helpers.abstractrepositorymanager.loadrepository(abstractrepositorymanager.java:747) @ o...

php - Session information not maintained while AJAX requests -

i creating session while rendering page. after calling ajax page every 4 seconds. ajax page doesnt gettign session information. what may reason. whether ajax requests dont maintain session information? code: normal html <body onload="timerint(11)"> <div style="display:none;"> <button id="prev"><<</button> <button id="next">>></button> </div> <div class="anyclass"> <ul id="news-ul"> <?php include('render_latest.php'); ?> </ul> </div> </body> render_latest.php <?php session_start(); $con = mysql_connect("localhost","root","root"); mysql_select_db("test_db", $con); $i=1; $lastresult=mysql_query("select max(epoch) latestepoch list_data"); while($row = mysql_fetch_array($lastresult)) { //$_session['lastepoch...

windows vista - Is there a way to get a local timestamp in my IPython prompt? -

is there way local timestamp in ipython prompt? i'm using ipython 0.10 , python 2.6 on 64-bit windows vista. my current default prompt is [c:python26/scripts] |9> ok, tried follow directions exactly. however, experience has been config editing best kept ipy_user_conf.py . quote it: user configuration file ipython (ipy_user_conf.py) more flexible , safe way configure ipython *rc files (ipythonrc, ipythonrc-pysh etc.) file imported on ipython startup. can import ipython extensions need here (see ipython/extensions directory). feel free edit file customize ipython experience. note such file nothing, backwards compatibility. consult e.g. file 'ipy_profile_sh.py' example of things can here. see http://ipython.scipy.org/moin/ipythonextensionapi detailed description on here. so have these lines in main(): # -- prompt # different, more compact set of prompts default ones, # show current location in filesystem: o.prompt_in1 = r'\c_lightblue[\c_lightcy...

session - How to use $this->methodname in PHP session_set_save_handle? -

i have session class has on_session_write, on_session_read etc. methods inside class. in constructor function have initiate session_set_save_handler("on_session_start", "on_session_end", "on_session_read", "on_session_write", "on_session_destroy", "on_session_gc"); and session_start() within problem methods need called using $this-> because within class. how accomplish this? it's simple: array($this,'methodname'); that's callback method. array('classname','methodname'); that's callback static method.

javascript - Checking to see if object is out of canvas (Raphael.js) -

currently using raphael.js drag , drop circle around canvas. however, disallow user drag circle out of canvas. code follows: <script type="text/javascript" src="javascript/raphael.js"></script> <script type="text/javascript"> window.onload = function() { //create canvas matching image's dimensions var paper = new raphael(document.getelementbyid('canvas_container'), <%=width%>, <%=height%>); //put schematic image onto canvas paper.image("<%=path%>",0,0,<%=width%>,<%=height%>); //create marker on canvas var c = paper.circle(<%=markerx%>, <%=markery%>, 5).attr({ fill: "#800517", stroke: "none" }); var start = function () { // storing original coordinates this.ox = this.attr(...

c++ - A problem overloading [] in 2 variations -

this generic class: template<class t, class prnt> class personalvec { public: personalvec(); t &operator[](int index) const; const t &operator[](int index) const; private: std::vector<t> _vec; }; i'm required implement 2 versions of [] operator: 1 return const reference , regular 1 return reference. when compile get: personalvec.hpp:23: error: ‘const t& personalvec<t, prnt>::operator[](int) const’ cannot overloaded personalvec.hpp:22: error: ‘t& personalvec<t, prnt>::operator[](int) const i've put either 1 of them remark , compile, guess colliding somehow. problem , how can fix it? thank you! return type of function not criteria can used overloading of functions. function can overloaded if: 1. different no of arguments 2. differnt sequence of arguments or 3. different types of arguments you trying overload function based on return type , hence gives error. 'const' keyword can ov...

c++ - how to get timezone -

i m new c.i want ftp system , timezone of system.in c++ there no way in ftp standard this. try uploading new (small) file , check date-time reported ftp, compared current local time.

c# - How to Forcefully close SerialPort Connection? -

i have device connect pc via usb serial communication. performing following steps start device (power on) device detected in pc comx name start application on base of com pid/vid, connect device perform communication. (up not facing problem) when switch off device, device disconnected cannot able close connection. when again start(switch on) device, device detected application cannot able connect comx(device). throws ioexception "comx not exist" so think have way close communication port forcefully. any appreciated thanks if communicationg hardware on serial port , using serialeventlistener, think serial.data_break(dont remember exact name) event occurs. catch in serialevent method , close connection program port. hope helps forcibly close connection @ time of disconnection of hardware.

ASP.NET MVC within DotNetNuke? -

is possible build dnn module uses asp.net mvc? granted dnn doesn't support asp.net mvc out of box...but since both dnn , mvc run on top of asp.net pipeline... the reason ask. large legacy website running on dnn: http://blahblahblah.com i'd stick existing asp.net mvc webpage/application here: http://blahblahblah.com/subfolder is better done setting virtual directory etc on server, or there way integrate dnn? dnn quite tightly tied webforms. asp.net mvc difficult, maybe impossible integrate in module. dnn support webforms mvp (model view presenter) allows of structural/testing benefits of mvc in webforms context. new modules developed dotnetnuke corp. using webforms mvp pattern. here link started step step webforms mvp , dotnetnuke – part 1.

python - using function attributes to store results for lazy (potential) processing -

i'm doing collision detection , use same function in 2 different contexts. in 1 context, like def detect_collisions(item, others): return any(collides(item, other) other in others) and in another, be def get_collisions(item, others): return [other other in others if collides(item, other)] i hate idea of writing 2 functions here. keeping names straight 1 turnoff , complicating interface collision detecting another. thinking: def peek(gen): try: first = next(gen) except stopiteration: return false else: return it.chain((first,), gen) def get_collisions(item, others): get_collisions.all = peek(other other in others if collides(item, other)) return get_collisions.all now when want check, can say: if get_collisions(item, others): # aw snap or if not get_collisions(item, others): # w00t and in other context want examine them, can do: if get_collisions(item, others): collision in get_collisions.all:...

javascript - RegExp for clean file and folder names -

i'm building file manager jquery. users can create folders , upload files. need regual expression (javascript) check if entered folder-name or uploaded file-name web-save. (no special chars or spaces allowed) the name should contain alphanumeric values (a-z,a-z,0-9), underscores (_) , dashes(-) this seems quite straightforward: /^[\w.-]+$/ useful tutorial

web services - Lightweight & Fast REST Server library for java? -

i'm looking lightweight rest library. it must small (in kb size) fast (in total execution time). optimal solution single jar without dependencies ever. the application designed run on appengine library should work on gae/j platform. take @ http://www.restlet.org/ have no idea if run on google app engine.

iphone - XCode 3.2.3 running on iOS3 - Wired framework -

i looked around on stack overflow , didn't find solution of strange problem. i started developing project on xcode 3.1 decided upgrade on xcode 3.2.4 , targeting ios3 iphones. followed topics dealing , changed base sdk ios 4.1 , target os 3.0. worked fine until made changes project. indeed added coremedia.framework project. it worked on simulator, crashed @ launch on iphone. here log can get: <notice>: dyld: library not loaded: /system/library/frameworks/coremedia.framework/coremedia referenced from: /var/mobile/applications/72f009b5-82a8-49dc-a5cd-708ee1a4553c/myapp.app/myapp reason: image not found (i had same problem other frameworks corevideo example) i tried on ios4 iphone , worked well, think xcode doesn't link/copy right framework on iphone. when info on framework under xcode, here path get: /developer/platforms/iphoneos.platform/developer/sdks/iphoneos4.1.sdk/system/library/frameworks/mediaplayer.framework but same path when info on framework o...

java - Problem running task using log4j using Ant -

my java application uses log4j logging. using ant project builds successfully, unable run it. error exception in thread "main" java.lang.noclassdeffounderror: org/apache/commons/logging/log ......... caused by: java.lang.classnotfoundexception: org.apache.commons.logging.log my classpath contains log4j jar. [echo] ..../apache-log4j-1.2.15/log4j-1.2.15.jar: ..... my ant version 1.7.1. missing? [edit] application referencing project required commons logging jar. tried creating executable jar of referenced project dependencies carried over. ant task create executable jar follows: <target name="executablejar" depends="compile"> <delete file="${dist}/app.jar" /> <javac debug="true" srcdir="${src}" destdir="${classes}" classpath="${javac.classpath}"/> <copy todir="classes" flatten="true"> <path> ...

iphone - How do I animate through a bunch of "paged" views in a UIScrollView? -

say have bunch of views in uiscrollview , want each 1 appear on screen, 1 @ time, how do so? assuming views screen size, position them next each other , set pagingenabled property true, make sure contentsize of scoll view wide enough of views , user should able swipe through them 1 view @ time. automatically nstimer if don't want user have swipe.

escaping - How to escape "/" in document name in Documentum DFC/DFS -

how escape "/" when want retrieve document "/templates/blank access 97 / 2000 database" object path in documentum using dfs or dfc? i noticed posted on http://developer.emc.com well. not sure if saw response, believe way asking for. alternatively, query using dql , use chronicle or object id dfs/dfc. session.getobjectbyqualification("dm_document folder('/templates') , object_name='blank access 97 / 2000 database'"); it looks object names not have restriction. instance, when query repository following, loads of results: select * nlrb_document title '% / %'

php - Where did I go wrong in my regex lookaround? -

i'm trying pull first paragraph out of markdown formatted documents: this first paragraph. this second paragraph. the answer here gives me solution matches first string ending in double line break. perfect, except of texts begin markdown-style headers: ### h3 header. this first paragraph. so need to: skip line begins 1 or more # symbols. match first string ending in double line break. in other words, return 'this first paragraph' in both of examples above. so far, i've tried many variations on: "/(?s)(?:(?!\#))((?!(\r?\n){2}).)*+/ but can't return proper match. where did go wrong in lookaround? i'm doing in php (preg_match()), if makes difference. thanks! you try "/(?sm)^[^#](?:(?!(?:\r\n|\r|\n){2}).)*/" i enable multiline option using (?sm) instead of (?s) , start each check @ new line, may not starting #. , used \r\n|\r|\n instead of \r?\n because testing environment had f...

MySQL latest records with condition -

Image
i need latest records, repeated more 2 times. structure: create table if not exists `tags` ( `tag_n` int(10) not null auto_increment, `post_n` int(10) not null, `tag` varchar(30) collate utf8_bin default null, primary key (`tag_n`), key `tag` (`tag`), key `post_n` (`post_n`), ) engine=myisam default charset=utf8 collate=utf8_bin; records: select * tags order post_n desc limit 0 , 30 my query: select tag, count(post_n) tags_count tags group tag having tags_count>=2 order post_n desc limit 5 but wrong results, latest must "xpro", can't understand what`s wrong. any ideas? p.s. sorry english. version 1 select tag, count(post_n) tags_count ,max(post_n) max_post_n tags group tag having tags_count>=2 order max_post_n desc limit 5 version 2 faster select slower insert. stats updates online create table if not exists `tags` ( `tag_n` int(10) not null auto_increment, `post_n` int(10) not null, `tag` varchar(30) coll...

opengl - Change color component -

i'm writing graphic shader program. wrote need except color changing. in cycle there passing counter variable shader , have change it's color white orange shade. have change achive this? i'm not sure i've got right, guess need this: uniform float counter; // assumed range 0 .. 1 const vec3 white = vec3(1,1,1); const vec3 orange = vec3(1,0.6,0.2); void main() { vec3 mixedcolor = mix(white,orange,counter); // white counter < 0, // orange counter > 1, // shaded in between }

xpath - how to load multiple xml files with saxon -

i want use saxon xpath queries don't know load multiple xml files. i'm trying use saxon command line windows i read in saxon manual can use command: query.exe -s:mydatafile.xml -q:myqueryfile -o:myoutputfile but don't know how load multiple xml files , not one edit: have many xml files mydatafile1.xml, mydatafile2.xml, mydatafile3.xml ... , want run query alla these files want load all files , query them (i don't want query every single file , concatenate results) use standard xpath 2.0 function collection() . the documentation saxon-specific implementation of collection() here . you can use standard xpath 2.x collection() function, as implemented in saxon 9.x the saxon implementation allows search pattern used in string-uri argument of function, may able specify after path of directory pattern filename starting report_ having 2 other characters, ending .xml . example : this xpath expression: collection('file:///c:/?select=r...

Silverlight 4 DataGrid border around a column -

Image
i haven't been able find anyway dynamically add border around column in silverlight datagrid. here xaml of datagrid: <sdk:datagrid x:name="plannedandbookedmonthlytable" itemssource="{binding}" autogeneratecolumns="false" margin="5,0,5,5"> <sdk:datagrid.columns> <sdk:datagridtextcolumn x:name="monthlyheadername" header="" binding="{binding seriesname}" /> <sdk:datagridtextcolumn x:name="monthlyheaderjan" header="jan" binding="{binding janvalue}" /> <sdk:datagridtextcolumn x:name="monthlyheaderfeb" header="feb" binding="{binding febvalue}" /> <sdk:datagridtextcolumn x:name="monthlyheadermar" header="mar" binding="{binding marvalue}" /> <sdk:datagridtextcolumn x:name="monthlyheaderapr" header="apr" binding="{binding aprvalue}...

css - how do I reset p's and div's style attributes? -

i have dynamic website html editors creating article content, reason p/div tags generated html editor screwy on front pages. i'm assuming because of css declarations overall website. here quick example: <div class="custom_html_block"> <div align="top"> <p> test test test test test test test test test</p> <p> test test test test test test test test test</p> <p> test test test test test test test test test</p> </div> </div> what css need make elements inside look/appear on blank html page? can me out that? thanks! it sounds default styles of <p> tags have styles being inherited existing styles. way avoid specific these tags can control them individually .custom_html_block { padding:15px 15px 0; } .custom_html_block p { padding-bottom:15px; ) i use firebug find out additional styles need specify in order create more "default...

graphics - Calculating the coordinates of the third point of a triangle -

ok, know sounds should asked on math.stackoverflow.com, embarrassingly simple maths i've forgotten high-school, rather advanced post-graduate stuff! i'm doing graphics programming, , have triangle. incidentally, 2 of triangle's sides equal, i'm not sure if that's relevant. have coordinates of 2 of corners (vertices), not third (these coordinates pixels on screen, in case that's relevant). know lengths of 3 sides. how determine coordinates of unknown vertex? for oblique triangles: c^2 = a^2 + b^2 - 2ab * cos(c) where a, b, c lengths of sides (regardless of length) , a, b, c angles opposite side same letter. use above figure out angle 1 of endpoints know, use angle, position of vertex, , angle between adjacent sides determine unknown vertex is. and complexity of problem doesn't determine site should go on, subject matter. should move math.

javascript - Using jQuery in place of document.getElement -

i use $("#fooid") in place of document.getelementbyid("fooid") because i'm getting id with # in front of it. while can remove enough, there fair amount of intermixing between when i'm using jquery selector , when i'm using native dom calls. in particular being called inside chart draw, seems expect native dom object back. giving extended jquery object makes choke , turn purple. is there way can jquery "play nice" , pretend give, or return instead, native object? you can use get method dom object: $("#fooid").get(0); or bit shorter version: $("#fooid")[0];

How to test multi-touch in Android Emulator -

this question has answer here: is there way test multi-touch on android emulator? 6 answers i'm trying use multi-touch in android 2.0 app. how can simulate emulator using eclipse? can seem mouse 1 touch @ time. current version of emulator doesn't support multi-touch. need device it! update: the emulator supports multi-touch input, experimental feature in r17 read more

django - Conditionally required fields across forms? -

i've got 2 forms on 1 page. if user selects option on 1 form, want make option on other form no longer required. how can that? don't think can put logic in clean method because they're separate forms. you can in view, long set required flag false before call is_valid on second form. class myform1(forms.form): other_field_required = forms.booleanfield(required=false) class myform2(forms.form): sometimes_required = forms.charfield(required=true) def myview(request): form1 = myform1(request.post) form2 = myform2(request.post) if form1.is_valid(): if not form1.cleaned_data['other_field_required']: form2.fields['sometimes_required'].required = false ... if form2.is_valid(): # form2 valid if other_field_required false or, add myform2 argument first form's __init__ method, can put logic in clean method. class myform1(forms.form): other_field_required = forms.booleanfield(require...

Possible to deactivate parts of Visual Studio 2010 Ultimate without reinstall? -

i have visual studio 2010 ultimate installed. includes lot of features use, around team explorer , architecture , modeling tools. these things have ton of commands , menus , context menu items clutter display , slow down vs launching etc. is possible deactivate these components without uninstalling ultimate , installing pro instead? use these components on rare occasions , don't want them gone, temporarily disabled. i looked @ installer's "change" options, , has high level options "c#" , "visual basic", nothing modeling tools. these components not show in addins or extensions lists. (i'm fine hacky solution, renaming folder or editing xml file.) adam driscoll rescue. http://csharpening.net/?p=640 he wrote tool called vstweaker this.

PHP Script running on the command line died during echo() -

i have script runs on command line, called crontab. in last 5 attempts run script, has died partway through echo statement - cron output shows part of intended echo output, , nothing after executed. long-running script, being run through php-cli, performs file management tasks. is there might cause script die during echo statement, without generating other output, or way troubleshoot or catch potential errors during echo? i not sure code can post help, rather comprehensive script involving few libraries. echo statements simple - echo('checking file...') might put in log "che" no more output. first, enable error-logging. secondly, since it's php, may initialize variable function inside echo function, function exits fatal error (common php+i/o operations) , whole script dies. turn on error-logging, see line causes headaches. without seeing code best shot.

c++ - std::transform using C++0x lambda expression -

how done in c++0x? std::vector<double> myv1; std::transform(myv1.begin(), myv1.end(), myv1.begin(), std::bind1st(std::multiplies<double>(),3)); original question , solution here . std::transform(myv1.begin(), myv1.end(), myv1.begin(), [](double d) -> double { return d * 3; });

How to send many emails via ASP.NET without delaying response -

following specific action user takes on website, number of messages must sent different emails. possible have separate thread or worker take care of sending multiple emails avoid having response server take while return if there lot of emails send? i avoid using system process or scheduled tasks, email queues. you can spawn off background thread in controller handle emails asynchronously. i know want avoid queues, thing have done in past written windows service pulls email db queue , processes @ intervals. way can separate 2 applications if there lot of email sent.

sms to map location -

does know how extract location data sms? someone's location marked on google maps. basically they'd text google voice number: 'team 1: message'. email server message , pull lat , long sms. all info was, it's done using drupal, mailsave , gmap modules, custom code extract lat/lon data message, , aql's sms email service. there no location data included standard sms. huge privacy problem. might able location number based, not live location.

indexing - Inverse index binary format -

i'm trying figure out kind of binary file can support needs inverse index. let have document can identify unique id , each document can have 360 fixed values in range of 0-65535. this: document0: [1, 10, 123, ...] // 360 values document1: [1, 10, 345, ...] // 360 values now, inverse index easy - can create each possible value list of documents contains, , query can executed fast, e.g.: 1: [document0, document1] 10: [document0, document1] 123: [document0] 345: [document1] but wanna store large number of documents in kind of file (binary) , have ability query fast add new documents without recreating whole structure. now i'm struggling how organize file. if wanna fast access need fixed length document arrays file seek , read. fixed size means have lot of empty spaces document list. idea have kind of bucketing system , each value can belong bucket of specific size, e.g. there buckets size 1, 2, 4, 8, 16, 32, ... (or that) , need kind of header point me bucket...

php - Magento custom order attribute/fields? Shooting myself in the foot? -

i'm building magento store using single catalog on 4 domains: 1 , 3 europe (uk, french, , german). there's 1 fulfillment warehouse in europe, 1 in , sort of unofficial/internal "warehouse" in giveaways , such fulfilled, , not tracking inventory levels in magento. need track particular transaction types plain web sales along internal/admin orders non web sales, giveaways, trade show orders, etc. plan extend core order model , adding kind of "order/transaction type" field , then, upon placement of order, process order data , direct warehouse sent off fulfillment based on store id , 'order type' value. being new magento, want know if kind of setup bad idea reason. shooting myself in foot? there reason single catalog might problematic? there easier or better way of handling flow? there way add custom attributes orders can products? you're heading in right direction, (as things magento), there couple of options. important principle her...

php - How to use form information to auto populate a form on another webpage -

i trying figure out way can populate form fields on webpage users password managers do. problem not owner of second webpage. thought using javascript iframes doesn't work. i've tried using php replace form information adding values saved previous form. need add info on second form after first 1 submitted. after submit first page off page , can't change else. i'm kinda out of ideas , knowledge limited. ideas or input appreciated. thank time , effort. cannot done because of sop (same origin policy) enforced on javascript code. alternative through xss, other via bookmarklet, , last choice trough greasemonkey script. greasemonkey may best choice, if data filled in website. best choice because greasemonkey scripts can perform cross domain ajax requests.

java - Best ivy practice: Split code into multiple projects or use one project with multiple configurations? -

at work have number of projects need share common code. code universal while of code shared subset of our projects. should split common code 2 separate projects or use 2 different ivy configurations single project? option 1 - 2 separate projects. proj 1 - common published default configuration proj 1 - common-xml published default configuration potential issues: requires have 2 separate projects, 2 separate build files , 2 separate ivy files. option 2 - 1 project, multiple ivy configurations different artifacts artifact 1 - common published core artifact 2 - common xml published core-xml potential issues: may have maintain separate source directories in same project. in either case, common xml component may rely on common core component. so, sf, should maintaining common code? issues did miss 2 methods, , other pros/cons or alternative solutions? hmm, comes down how prefer manage source code. first, i'd asking question of whether need split ...

python - Letting users to choose what type of content they want to input -

this first post here, , i'd describe want specific possible. i'd make model 'selectable.' for example, class simplemodel(models.model): property = models.charfield(max_length=255) value = generalfield() generalfield can "charfield", "urlfield", "textfield" user can select appropriate input type specific property. i'm kinda thinking of similar wordpress's custom_field. my initial thought making textfield , tweak input interface depends on user's selection, it's bit tricky , if involves file uploading functionality, it's gonna complicated. of course, googled lot. if have thoughts on this, please give me tip :) thanx in advance how creating separate model each type of field want support, , model consisting of list of (table_name, entry_id) pairs, customized use combination of fields?

jquery - Prototype code not working when jQuyery library is loaded on top -

my prototype code no longer works when load in jquery library, though jquery first library loaded. the html of page looks bit so: <head> ... <script type="text/javascript" src="/js/jquery.min.js"></script> <script type="text/javascript" src="/js/effects.js"></script> <script type="text/javascript" src="/js/prototip.js"></script> <script type="text/javascript" src="/js/dragdrop.js"></script> <script type="text/javascript" src="/js/default.js"></script> <script type="text/javascript" src="/js/limitfocus.js"></script> ... </head> <body> <input type="radio" name="useotheraddress" id="useotheraddress_y" value="y" onclick="selectaddress()"> <input type="radio" name="useotheraddress" id="useo...

iphone - sigabrt error when loading nib files -

i working on project in start have nav controller. load login page first move login success page have few buttons click, when click on of button here error. when tried debug code, hav break point @ button click method, before executes code there this. here log. can 1 please me this. in advance 2010-10-07 23:15:28.868 cattle_try1[14417:207] -[__nscftype onyardmapbtnclick]: unrecognized selector sent instance 0x6149a40 2010-10-07 23:15:28.872 cattle_try1[14417:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscftype onyardmapbtnclick]: unrecognized selector sent instance 0x6149a40' *** call stack @ first throw: ( 0 corefoundation 0x02655b99 __exceptionpreprocess + 185 1 libobjc.a.dylib 0x027a540e objc_exception_throw + 47 2 corefoundation 0x026576ab -[nsobject(nsobject) doesnotrecognizeselector:] + 187 3 corefoundation ...

php - Need To Optimize RegEx For A Template Parser -

greetings all, i need optimize regex using parse template tags in cms. tag can either single tag or matching pair. example of tags: {static:input:title type="input"} {static:image:picture}<img src="{$img.src}" width="{$img.width}" height="{$img.height"} />{/static:image:picture} here regex have selects need ran through regexbuddy debugger , takes tens of thousands of steps 1 match if html page quite large. {static([\w:]*)?\s?(.*?)}(?!"|')(?:((?:(?!{static\1).)*?){/static\1})? when matches tag, group 1 parameters colon separated words. group 2 parameters. , group 3 (if it's tag pair) content between each tag. i'm having problems when stick these tags inside conditional tags well. doesn't match group 2 (group 2 should blank in both matched tags below): {if "{static:image:image1}"!=""} <a href="{static:image:image1}" rel="example_group" title="imag...

iphone - NSMutableArray causing EXC_BAD_ACCESS crash after viewcontroller did disappear and re appears -

still "somewhat" of newbie... have nsmutablearray stores filenames - when user clicks uitableview corresponding selected cell pass filename in array mpmovieplayercontroller play. works, if exit out of viewcontroller , come back, last video played work, if select other table entry, crash "exec_bad_access". i'm assuming array being released when view controller disappears here code: first off: "nsmutablearray *filenamearray;" in .h file (void)viewdidload { [super viewdidload]; //filenamearray = [[[nsmutablearray alloc] initwithcapacity: 500] autorelease]; filenamearray = [[nsmutablearray alloc] initwithcapacity: 500]; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] ...

python - How to display an image next to a menu item? -

i trying image appear next menu item isn't working. in order make simple possible, have created simple example below highlights problem: import pygtk pygtk.require('2.0') import gtk class menuexample: def __init__(self): window = gtk.window() window.set_size_request(200, 100) window.connect("delete_event", lambda w,e: gtk.main_quit()) menu = gtk.menu() menu_item = gtk.imagemenuitem("refresh") img = gtk.image_new_from_stock(gtk.stock_refresh, gtk.icon_size_menu) img.show() menu_item.set_image(img) menu.append(menu_item) menu_item.show() root_menu = gtk.menuitem("file") root_menu.show() root_menu.set_submenu(menu) vbox = gtk.vbox(false, 0) window.add(vbox) vbox.show() menu_bar = gtk.menubar() vbox.pack_start(menu_bar, false, false, 2) menu_bar.show() menu_bar.appen...

java - Mapping entities with composite keys -

Image
i working on converting legacy system use hibernate (version 3.3.x) instead of using hand crafted sql. have run in problems mapping datamodel pertians composite keys. i've created solution think works, not overly fond of it. hence, see how diagram below could/should mapped , see if on "right" track. in diagram stufftypes pretty static table don't change (no inserts or updates). parent table has dao class associated (the others should persisted when parent instance is). stuff has stufftype , number of substuff associated it. finally, substuff many many mapping table between stuff , stufftypes. what best way of mapping these entities java objects using annotations? personally, refer section 3.2 primary keys through -toone relationships of jpa wiki book. , read 3.1 composite primary keys .

javascript - webkit css3 Column text selection -

iam using column layout model of css3 view content in uiwebview (iphone/ipad), programmatically select , copy content of each column , paste in view, there way achieve this? i'm pretty sure not possible. css3 paged media selectors when they're implemented enable page selection when you're using box layout, have extended column selection. now, you're sol. if care ipad, , have box layout , know font, font size, leading , kernings, try calculate column breaks in javascript - large undertaking.

Google Chrome display JSON AJAX response as tree and not as a plain text -

i cannot find answer one: my ajax calls return json data. in google chrome developer tools > resources > xhr when click on resource on left , on content tab see json string string , not tree firebug , firebug lite do. how force chrome diplay tree. there content-type php file must have??? i happy know answer! thank stefanos to see tree view in recent versions of chrome: navigate developer tools > network > given response > preview

wordpress - include function in php -

is correct or not because show error when im done if(is_page('payment-success')) { include("/wp-content/ga-ecommerce-tracking/ga-ecommerce-tracking.php"); } include accepts absolute path, relative path or url stream argument. using wrong absolute path here. try making relative path ( assuming editing file in wordpress root directory, if not change path accordingly) if(is_page('payment-success')) { include("./wp-content/ga-ecommerce-tracking/ga-ecommerce-tracking.php"); }

linux - Environment variables in symbolic links -

can use $home or other environment variable in symbolic links? i know using relative paths ../../.config many ../ :) ~/.config more comfortable, or use of $home. edit: habbie 's answer psmears 's comment answer, sorry question incomplete. while (as other answers show) can use environment variables when creating symbolic links (as shell command!), can't have environment variable (or '~') references in symlink itself symbolic links handled kernel, , kernel not care environment variables. so, no.

windows - WP7 Toggle switch in a Pivot control? -

is there way control threshold of flick action on/off toggle switch doesn't mess pivot control's navigation? sorry, i'm going avoid you're question (i can't answer anyway) , suggest use different approach. (i assume) use checkbox provide option person using application. afterall toggle switch has same functionality checkbox (specify/choose between 2 states) implements interaction differently. the toggle switch has not been designed/built (afaik) support being used on top of supports same gesture. general rule of usability, having controls on top of each other (or next each other) support same gesture cause problems user. if problems through accidentaly triggering wrong gesture or expectations how gesture interpretted. in summary: tricky problem solve; don't think can controls are; , problem goes away entirely if use different control toggling anyway.

javascript - How to implement an "Auto Save" or "Save Draft" feature in ASP.NET? -

i have registration form in asp.net 2.0. want save registration form fields either clicking on submit button or should saved every 5 seconds. for example have 3 fields in registration page: uid pwd name the user has entered uid , pwd , whilst entering name previous values should saved without interruption of user inputs how in asp.net? you snippet of javascript & jquery. have function that's fired timer periodically reads form data want save , posts savedraft.aspx page. in page persists data somewhere (such database). if user logs out or session lost can query data , pre-populate form if data exists. on data entry aspx page: // usual asp.net page directives go here <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script type="text/javascript" src="scripts/jquery-1.4.1.min.js" ></script> </head> <body> <form id="form1...

C# static "this" -

is there way in c# static method refer type method defined in? in instance method can determine type by: public void foo() { type type = this.gettype(); } how in static method? public static void bar() { type type = ....? } update: sorry, clarification needed: know typeof(...) feature. i'm looking keyword or code gives me type without explicitly referencing class name. update: besides developer art's answer, looking for, there simpler way? here go: public static void bar() { type type = system.reflection.methodbase.getcurrentmethod().declaringtype; } edit: updated correct error - declaringtype property.

wpfdatagrid - Code to fetch data from excel in WPF window -

hi want develop c#.net base wpf application ,in want fetch data excel file included in same project manipulate through data in wpf window. the easiest way convert excel file csv within excel , use example http://www.codeproject.com/kb/linq/linqtocsv.aspx . wpf toolkit http://wpf.codeplex.com/ , use datagrid autogeneratecolumns="true" , set itemssource output linqtocsv. if don't want convert csv you'll have use open xml sdk 2.0 or http://www.smartxls.com/ .

jsf 2 - JSF 2.0 timer component -

i'm looking component counts down specific duration on client side (e.g. display remaining time until auction finishes). component not need perform action when timer timed out. should print timer in human readable form, e.g. 1 hour 2 minutes 23 seconds , update timer without server requests. i know can done somehow in javascript. i'm looking ready-made component or easy way realize (without implementation effort). thanks, theo have @ jquery countdown component. this question gives answer on jsf jquery integration.