Posts

Showing posts from September, 2013

install - Installing scipy for python 2.7 -

i cannot seem scipy working python 2.7 on 32 bit windows xp platform. i'd rather not build own copy. know find installer it? tried site , didn't work. download here . i'm not sure site referred to, start at: http://www.scipy.org

jQuery scrollLeft -

i looking @ tutorial @ http://jqueryfordesigners.com/jquery-infinite-carousel/ . tried creating similar myself understanding, turned out more complex thought. how use scrollleft? i created simple fiddle test http://jsfiddle.net/sryku/2/ <div id="carousel"> <div class="wrapper"> <ul> <li><a href="#">test link 1</a></li> <li><a href="#">test link 2</a></li> ... css #carousel .wrapper { position: relative; ul { position: absolute; js $wrapper.scrollleft(itemsperpage * itemwidth); but not scrolling you have use animate method that: $wrapper.animate({scrollleft: itemsperpage * itemwidth});

Link to sort table column in PHP MYSQL -

<?php $con = mysql_connect ("localhost", "user", "pass") or die ('error: ' . mysql_error()); mysql_select_db ("members"); if(isset($_get['orderby'])){ $order = $_get['orderby']; $result = "select * persons order ".mysql_real_escape_string($order)." desc"; } else{ $result = mysql_query("select * persons"); } $num_rows = mysql_num_rows($result); $row_counter = 0; echo "<table width=600 border=0 cellspacing=0>\n"; echo "<tr>\n <th>&nbsp;</th>\n <th>first name</th>\n <th>last name</th>\n <th>email address</th>\n <th>city</th>\n <th>state</th>\n <th><a href='index.php?orderby=submitdate'>date</a></th>\n </tr>"; while($row = mysql_fetch_array($result)){ if($row_counter % 2){ $row_color...

xaml - WPF - Defining DataTemplate inside ResourceDictionary without a key -

Image
i have seen many times wpf code samples in form: <window.resources> <datatemplate datatype="{x:type sometype}"> <!-- elements defining datatemplate--> </datatemplate> </window.resources> i understand usage, cant understand why syntax ok: since resourcedictionary implements idictionary, therefore every element add resource property must specify key. know using dictionarykeypropertyattribute, class can provide implicit key value - in case of datatemplate class, provided property "datatemplatekey". know sounds bit petty, motivation question know how use other classes if didnt have privilege see usage samples before (maybe 3rd party...). anyone? as mentioned in question, entries without x:key attribute use datatemplatekey(sometype) key. can specify 1 such instance particular sometype in resources. datatemplatekey derived templatekey derived resourcekey . of course such datatemplate resource definitions c...

eclipse - Checking out a maven project from a git repository -

i have installed m2eclipse , egit, can checkout project git repository , can build maven project, cannot checkout maven project git repository. problem is, scm url field empty (apart egit have svn team providers well...) , when paste url scm provider not available in maven console. tried searching issue , found have install m2eclipse scm integration , scm handler git, aren't on update sites. ideas? maven scm integration in eclipse used good. used import > check out maven projects scm , put in url scm:git:ssh://git@git:project.git in helios or new version of m2eclipse + extras can't anymore. gives error original post talking about. disappointing have check out in egit , add dependency management. isn't great solution because isn't smooth parent / children poms.

In Django using fiter() then get() on queryset? -

can combine use of filter() , get() on querysets return object in django view? have following view; def my_view(request, city, store, item): item = item.objects.filter(store__city=city, city=city).get(item=item) items unique city , store. trying filter queryset based on 2 foreignkey fields , use on charfield getting error message object not exist. approaching incorrectly or syntax off somewhere? thanks if related filter returns 1 result, can use : def my_view(request, city, store, item): item = item.objects.filter(store__city=city, city=city)[0] which filters item records , store them in queryset, has list-lilke structure, take first element... if sure result, can use instead of filter: item = item.objects.get(store__city=city, city=city) but if there exists no record fits filer criteria, error. if not sure whether filtering return result or not, use: item = item.objects.filter(store__city=city, city=city) if item: item = item[0] which ckecks resu...

java - How to prevent the result of Servlets from being cached? -

how can stop caching of pages in browser using servlets? i want session should expire if press button of browser when logged in. to permanently disable cache. // set expire far in past. response.setheader("expires", "sat, 6 may 1995 12:00:00 gmt"); // set standard http/1.1 no-cache headers. response.setheader("cache-control", "no-store, no-cache, must-revalidate"); // set ie extended http/1.1 no-cache headers (use addheader). response.addheader("cache-control", "post-check=0, pre-check=0"); // set standard http/1.0 no-cache header. response.setheader("pragma", "no-cache"); clearing client cache not expire session immediately,but clears session cookies in browser. make session expire immediately, need explicitly specify in server side jsp or servlet. // use session invalidate session.invalidate();

Find all .htaccess files and replace content with PHP script -

i need create script find .htaccess files on server , replace content new content need in order pages seo friendly. so far i've come across few scripts find .htaccess files need able open, replace content new , save proper permissions. can me following code add functionality need? <?php function searchdir($dir) { $dhandle = opendir($dir); if ($dhandle) { // loop through while (false !== ($fname = readdir($dhandle))) { // if element directory, , not start '.' or '..' // call searchdir function recursively passing element parameter if (is_dir( "{$dir}/{$fname}" )) { if (($fname != '.') && ($fname != '..')) { echo "searching files in directory: {$dir}/{$fname} <br />"; searchdir("$dir/$fname"); } // if element .htaccess file replace content } else { if($fname == "....

How to check if a map contain a empty string value in scala? -

i have newbie question. we can use contains check if map contain specified key, as: val map = map("a"->"1", "b"->"") map.contains("a") but now, want check if map contains empty string, there method use? try map.values.exists(_ == "") edit: think above clearest, can't resist showing 2 others. map.exists(_._2 == "") is more compact, have remember _2 value when iterate through map. map.values.exists(""==) is alternative form of original, instead of explicitly comparing argument _ == "" , supply equality function "".equals _ or ""== short. (two ways of looking @ same thing--is empty string supplying equals method testing, or closure testing elements against empty string? think latter (the original) considerably clearer.)

themes - theming in yii framework -

how can create base theme , sub theme in yii framework? take @ this: http://www.yiiframework.com/doc/guide/1.1/en/topics.theming if i'm not wrong, can switch theme @ application, module , controller level if want to. need place files in correct place, explained in link.

New ASP.NET website using DotNetNuke -

currently using dnn 5.2.x , using 1 portal on site. need make mobile version of portal , eliminate of dnn stuff info displayed. decided create seperate asp.net web forms website , utilize dnn providers (membership, roles, etc) logging in. having issues. 1 in particular ("unknown exception trying write log"). we've moved of dnn global.asax (i.e. simplecontainer instructions) file new website , added necessary web.config sections , references error when user logs in. did copy on same web.config machine key new website. connection strings there (app settings , connection string sections , named sitesqlserver). so question is, has created new website around dnn without using dnn except membership? i.e. no modules, no skins, etc. validate user , roles. if have needs done dnn 5.2.x (or later) log user in , return roles, post steps? the default dnn login based on asp.net membership . if want login feature, much easier use asp.net membership directly try rip out...

multithreading - Objective C - performSelectorInBackground V.S detachNewThreadSelector? -

both detachnewthreadselector , performselectorinbackground used call method in background. is there difference between 2 methods? or both work same way? they're both same different paradigms. behind scenes same thing. real difference -[performselectorinbackground:withobject:] follows other performselector style methods in they're defined on nsobject , message defines selector wish perform. in general, should never have call either of these methods. favor using grand central dispatch or nsoperation , nsoperationqueue factor out expensive operations on other threads. both gcd , nsoperation classes give memory management, thread pool management , many other things you'll miss using older style dispatch methods.

parsing - Get all recipients from email To header in PHP (ZF is a bonus) -

is there way parse recipients of email zend framework? i'm asking, because email headers can contain this: to: foo@bar.de, "lastname, firstname" <foo@bar.com> so can't split on comma. didn't find way zend framework mail class. how do this? , there way zend framework? you can try with str_getcsv — parse csv string array example print_r( str_getcsv( substr('to: foo@bar.de, "lastname, firstname" <foo@bar.com>', 3) ) ); output ( demo ) array ( [0] => foo@bar.de [1] => lastname, firstname <foo@bar.com> ) as zend_mail , zendmail::getrecipients() return? or using?

java - Redirect after login (Spring security on GAE) -

i having troubles making login redirect same place always. have done this <http auto-config="true" use-expressions="true" entry-point-ref="gaeentrypoint" > <intercept-url pattern="/_ah/login" access="permitall"/> <intercept-url pattern="/**" access="isauthenticated()"/> <custom-filter position="pre_auth_filter" ref="gaefilter"/> <form-login authentication-success-handler-ref="authsuccesshandler"/> </http> <beans:bean id="authsuccesshandler" class="dk.lindhardt.arbejdsfordeling.server.security.authenticationsuccesshandlerimpl"/> and public class authenticationsuccesshandlerimpl implements authenticationsuccesshandler { public void onauthenticationsuccess(httpservletrequest request, httpservletresponse response, authentication authentication) throws ioexception, servletexception { ...

My application is execute on android emulator but it throws exception when it install on HTC Tattoo -

possible duplicate: why android application not installed on htc tattoo? hi, m new in android, have above problem please me. it's must problem os version (even if description very small...)

Change search engine in mobile safari on iphone to a different provider? -

is there anyway when user lands on our webpage give them option change default search engine in mobile safari our search engine? i on iphone , went yahoo , asked me if wanted change default yahoo. is there anyway program have change else example search engine uses google framework or duck duck go example? or big 3 providers allowed (bing, google , yahoo) thanks safari supports 3 options shown in in settings app.

Android - Including more than one Advertising provider in the same application. Possible? -

i'm newbie android. possible include more 1 advertisement provider in android application? (such admob , graystripe)... you can roll own, take @ adwhirl code opensource well. seems best solution type of thing

android - Third Party Custom Components -

as new android development, did find section custom components. interested in create custom components , make them available other developers. there article or information covers creation & deployment of third party components android? example: company "a" wants use custom component wrote. how go getting them , can use in there application development? thanks in advance! craig android applications not different java programs. in order create own library can create jar out of distribute jar. use it, 1 have include jar in code. using eclipse, can use export function create jar. it's possible create jars out of android projects, in case have careful not include conflicting files (like androidmanifest.xml) when creating jar, or else library useless end user.

Convert date to closest end-of-month date MATLAB -

i need convert datenumber closest end-of-month date. found online link inefficient large matrix (at http://www.mathworks.com/matlabcentral/fileexchange/26374-round-off-dates-and-times ). matlab ( financial toolbox ) has inbuilt function this? couldn't find it. date_in = 734421 ; somefunction(date_in) --> sept 2010 thanks! i had errors in previous version. here's logic incorporated function. checks month , updates accordingly. function out = roundmonth(datenumber) datevector = datevec(datenumber); day = datevector(3); month = datevector(2); year = datevector(1); month = month + sign(day - 15 + double(~(month-2)))... + double(~(day-15 + double(~(month-2)))); datevector(1) = year + double((month-12)==1) - double((1-month)==1); datevector(2) = mod(month,12) + 12*double(~mod(month,12)); out = datestr(datevector,'mmm yyyy'); examples: 1. roundmonth(datenum('10-oct-2010')) ans = sep 2010 2. ...

windows phone 7 - curve movement animation in wp7 -

i use blend 4 (storyboard) create animation movement wisp. required have wisp move in curve path. have found solution in code (from programming windows phone 7 book) part iii chapter 2 xna. wonder if can make curve movement blend 4 or other easier way? animation storyboards easiest way go if you're trying animate along complex path curvy line best way go use pathlistbox class (msdn). pathlistbox class let animate object along path no matter how crazy path may be. here links check out. creating motion path pathlistbox (from microsoft.com) silverlight 4 pathlistbox motion path animation motion path in silverlight 4 using pathlistbox

URI simplification in java -

i have several strings being combined make uri. want ensure resulting uri simple possible. example, given str1 = "/dir1/dir2"; str2 = "./dir3/"; i want end "/dir1/dir2/dir3/" not "/dir1/dir2/./dir3/" . is there java library performs kind of simplification? jdk7 has path.normalize method removes redundant name elements path. contains path.resolve can used join 2 paths. take @ java tutorial | path operations more information.

properties - How to automatically convert property values from String in Java? -

suppose i've bean has many properties of many types int, string, date, etc... primitive types of course. , want fill string representations of values, without writing parsing code... how do that? bean frameworks spring you. if want write need use reflection find type required , use correct conversion code. if have class this: public class mybean { private int count; public void setcount(int count) { this.count = count; } } and application context this: <beans> <bean id="mybean1" class="mybean"> <property name="count" value="3"/> </bean> </beans> then should work fine you. have @ docs more info, examples better docs though.

javascript - Changing Day Names Dynamically -

i know fullcalendar, can change day names when calendar first initialized using: daynames: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] and replacing names new ones. have need change names after calendar has been initialized though. have dropdown menu , change them on fly when changed without reloading entire page. there anyway that? currently not possible, once issue done, possible: http://code.google.com/p/fullcalendar/issues/detail?id=293

.net - How to Monitor C# Threads from another Thread -

i have several threads running in threadpool in wpf app. need monitor them, possibly thread find out if of threads have terminated. how able achieve this. for simplicity, usage scenario is: click button start several threads in threadpool. start thread monitor in threadpool lock ui of wpf app. release lock when thread in step 3 sets global value indicate threads started in (2) have terminated. put threads in threadpool in array. when want wait pool threads exit, use waithandle.waitall wait threads complete.

c# - How can I make this LINQ query of an Enumerable DataTable of GTFS data faster? -

i'm working gtfs data new york city mta subway system. need find stop times each route @ specific stop. that, stop times stoptimes datatable have, specific stop_id. want stop times between , next 2 hours. then, need lookup trip each stop time, using trip_id value. trip, have lookup route, using route_id value, in order route name or number stop time. here counts each datatable: stoptimes(522712), trips(19092), routes(27). right now, takes anywhere 20 seconds 40 seconds execute. how can speed up? , suggestions appreciated. thanks! foreach (var r in stoptimes.orderby(z => z.field<datetime>("departure_time").timeofday) .where(z => z.field<string>("stop_id") == stopid && z["departure_time"].tostring() != "" && z.field<datetime>("departure_time").timeofday >= datetime.utcnow.addhours(-5).ti...

msbuild - Dynamic Metadata Assignment in an ItemGroup -

i have itemgroup defined as: <itemgroup> <protofiles include="protos\*.proto"/> </itemgroup> it yields list of .proto files in directory of project. want each item in group include piece of metadata specifies name of file generated based on .proto file. know can this: <itemgroup> <protofiles include="protos\*.proto"> <outputfile>%(protofiles.filename).cs</outputfile> </protofiles> </itemgroup> but problem is not simple mapping .proto filename output filename. there tricky logic involved need encapsulate somewhere , call when assigning metadata. need like: <itemgroup> <protofiles include="protos\*.proto"> <outputfile><getoutputfilename protofilename="%(protofiles.filename)"/></outputfile> </protofiles> </itemgroup> the idea being custom getoutputfilename task called in order metadata value. is p...

Regarding mark-sweep ( lazy approach ) for garbage collection in C++? -

i know reference counter technique never heard of mark-sweep technique until today, when reading book named "concepts of programming language". according book: the original mark-sweep process of garbage collection operates follow: runtime system allocates storage cells requested , disconnects pointers cells necessary, without regard of storage reclamation ( allowing garbage accumulate), until has allocated available cells. @ point, mark-sweep process begun gather garbage left floating-around in heap. facilitate process, every heap cells has indicator bit or field used collection algorithm. from limited understanding, smart-pointers in c++ libraries use reference counting technique. wonder there library in c++ using kind of implementation smart-pointers? , since book purely theoretical, not visualize how implementation done. example demonstrate idea valuable. please correct me if i'm wrong. thanks, there 1 difficulty using garbage collection in c++,...

Amazon EC2 regions and Windows Azure affinity groups - Security Considerations -

i read regions , affinity groups in amazon ec2 / windows azure. seems used first , foremost assure performance. what concerned security. can these services "switch" region , transfer of data in cloud region if have performance bottle neck? couldn't find information far. for employer it's important data never crosses regions since our clients demand data stays on european data centers. in azure, affinity groups abstraction concept tells fabric controller best ensure groups of related services deployed ensure optimization inter-app communication. groups ensure services, storage, etc placed in close proximity whenever possible. affinity groups bound regions, don't need worry ag switching countries on own, bound region. in azure, explicit geo-location concept of region . if specify region binding datacenter (or virtual concept of dc) in particular geographical region. @ time there no ability move/migrate services among regions on own. the f...

excel - Copying and pasting data using VBA code -

i have button on spreadsheet that, when pressed, should allow user open file, copy columns a-g of spreadsheet "data", paste data columns on current sheet. i have logic error in code; runs, pastes selection in wrong place. i having trouble referencing 2 workbooks. here code: sub button1_click() dim excel excel.application dim wb excel.workbook dim sht excel.worksheet dim f object set f = application.filedialog(3) f.allowmultiselect = false f.show set excel = createobject("excel.application") set wb = excel.workbooks.open(f.selecteditems(1)) set sht = wb.worksheets("data") sht.activate sht.columns("a:g").select selection.copy range("a1").select activesheet.paste wb.close end sub use pastespecial method: sht.columns("a:g").copy range("a1").pastespecial paste:=xlpastevalues but big problem you're changing activesheet "...

java - How to write something in binary and assign it to a variable? -

possible duplicate: in java, can define integer constant in binary format? in python, can like: a = 0b00000010 set 2. is possible in java? know go through , assign varibles number instead of binary, visual. thanks ~aedon in java 7, can do int = 0b00000010; however if you're working older version, i'm afraid you're stuck with int = integer.parseint("00000010", 2);

How to format the axis values in an asp.net mvc 3 chart using C# and razor? -

i'm trying create chart in asp.net mvc 3 using system.web.helpers namespace. however, cannot find way format values of y axis. display 1000,2000,3000,4000 when them $1,000,$2,000,$3,000,$4,000 any ideas? there not seem way this. marking answer.

Javascript include control depending on page -

i'm working client-side developer on web app , found myself having lots of modules, each 1 different pages. wonder idea include depending on route myself (in javascript) or pass responsibility back-end (ruby on rails) guys. i suppose need application.js included in every page, , in this: if (window.location.href == '.../somepage') { loadscript('somepagecontrols.js') } if (window.location.href == '.../anotherpage') { ... } any thoughts? ok, not simple answer @ all, since there , there theese ruby-guys, hope ok beetwen you! ;) although if don't want bother theese guys, ( know not easy work in team ) can ask include 1 ruby file working folder ex. /web-app/ruby-guys/you/ruby-js.rb now can work unique file , load here js file need. using eaxmple switch-case case url-query when x # print out drag-drop.js when y, z # print out mouse-move.js

Push a tag to a remote repository using Git? -

i have cloned remote git repository laptop, wanted add tag ran git tag mytag master when run git tag on laptop tag mytag shown. want push remote repository have tag on clients, run git push got message: everything up-to-date and if go desktop , run git pull , git tag no tags shown. i have tried minor change on file in project, push server. after pull change server desktop computer, there's still no tag when running git tag on desktop computer. how can push tag remote repository client computers can see it? to push single tag: git push origin <tag_name> and following command should push all tags (not recommended): git push --tags

memory - Who takes care of freeing MIB_TCPROW_OWNER_PID structure when calling GetExtendedTcpTable via ctypes in Python? -

i'm calling getextendedtcptable via ctypes in python. for i'm declaring following structures: class mib_tcprow_owner_pid(ctypes.structure): _fields_ = [('dwstate', dword), ('dwlocaladdr', dword), ('dwlocalport', dword), ('dwremoteaddr', dword), ('dwremoteport', dword), ('dwowningpid', dword)] and: class mib_tcptable_owner_pid(ctypes.structure): _fields_ = [('dwnumentries', dword), ('table', mib_tcprow_owner_pid * any_size)] where any_size initialized via first call getextendedtcptable. my question takes care of deallocating memory taken 'table' field above? array of mib_tcprow_owner_pid structures. or maybe question should be: allocates mib_tcprow_owner_pid structures in array? getextendedtcptable or python? thanks in advance! you have allocate sufficient space in tab...

g++ - C++ linking issue: multiple definition -

unfortunately cannot post of source code here. can describe structure though. header files have #ifndef/#define/#endif guards. structure follows: node.h - included tree.h tree.h - included tree.cpp , main.cpp tree.cpp main.cpp in node.h in global namespace, declare following free standing function: bool char_sort_func(path first, path second) { return (first->label() < second->label()); } (note: shown bellow, path shared_ptr) when try build, multiple definition error saying function present in both tree.o , main.o: > make g++ -c -g -wall main.cpp -i /usr/include g++ -c -g -wall tree.cpp -i /usr/include g++ -wall -o tool tree.o main.o -l /usr/lib -l boost_program_options main.o: in function `char_sort_func(boost::shared_ptr<edge>, boost::shared_ptr<edge>)': node.h:70: multiple definition of `char_sort_func(boost::shared_ptr<edge>, boost::shared_ptr<edge>)' tree.o:node.h:70: first defined here collect2: ld returned 1 ...

How to Include CData using LINQ to XML? -

i want record xml below codes in asp.net.however,i want add <![[cdata]]> in fifth element. when making shown below, it's creating ""&"bt;" instead of > character , ""&"lt;" instead of < character xml. how rid of problem? code: xelement xml = new xelement("photo", new xelement("thumbnail", textbox1.text), new xelement("filename", textbox2.text), new xelement("baslik1", textbox3.text), new xelement("baslik2", textbox4.text), new xelement("description","<>"+textbox5.text), new xelement("link", textbox6.text), new xelement("fiyat1", textbox7.text), new xelement("indorani", textbox8.text)); xdocument doc = xdocument.load(server.mappath("~/app_data/satislar.xml")); doc.root.add(xml); doc.save(server.mappath("~/app_data/satislar...

Overlaying images using CSS -

Image
i have following images: , and using css need show them on web page 1 image: i.e. smaller image in right bottom corner of bigger image on top of it. the size of bigger image not static - image different every time reload page. wrap images in <div> s display:inline-block; position: relative . can absolutely position little badge images. example: <div class="wrapper"> <img src="http://placekitten.com/200/200" width="200" height="200"> <img src="http://placekitten.com/50/50" width="50" height="50" class="badge"> </div> <div class="wrapper"> <img src="http://placekitten.com/250/200" width="250" height="200"> <img src="http://placekitten.com/25/50" width="25" height="50" class="badge"> </div> and: .wrapper { display: inline-block;...

c# - JQuery causing postback in .NET -

i created adrotator in jquery first time , when use on page uses pagemethods ajax calls server , show modal. page posts back. when remove rotator page works should. in rotator have following code in document ready function. $(".animation_control a.play").live('click', function () { $(this).removeclass('play'); $(this).addclass('pause'); play(); }); $(".animation_control a.pause").live('click', function () { $(this).removeclass('pause'); $(this).addclass('play'); clearinterval(timer); }); $(".animation_control a.pause").click(function () { }); //toggle teaser $("a.collapse").click(function () { $(".main_image .block").slidetoggle(); $("a.collapse").toggleclass("show"); }); if comment out code page stops complete page refresh , and posts async should. id...

php - How do I prevent users from being able to "back" into page from a destroyed session? -

i have created login functionality on site, , when click logout page redirects , destroys session, fine. however when click button can still view page. if refresh it, redirect me login session has been destroyed , user not have access page expected. is there way can prevent user being able view page when click button? try perform header( 'location: http://myserbver.com/anurl' ); after did destroy session. makes returning previous page @ least bit more complicated. go back, user has click twice. if you'd make more complicated, perform header( 'location: http://myserbver.com/myscript.php?oncemore=yes ' ); and if myscript.php finds isset( $_get[ 'oncemore' ] ) then perform header( 'location: http://myserbver.com/myscript.php' ); once again. myscript.php: <?php // force browser redirect once again if ( isset( $_get[ 'oncemore' ] ) { header( 'location: http://myserbver.com/myscript.php' ...

javascript - Trying to call function on a dynamically generated object name -

i'm having issues calling function on object name determined dynamically. code below illustrates how code set up, , problem i'm having occurring in function called dosomethingelse(). var obj = function(){ this.test = this.objmgr(); }; obj.prototype.objmgr = function(){ var self = this; function dosomething(){ //do processing seems unimportant particular prob dosomethingelse(); } function dosomethingelse(){ //the object need determined @ runtime, , therefore dynamic var callfunconthis = 'subobj'; //how heck can call function on object referenced in callfunconthis this[callfunconthis].a(); //doesn't work, refers dom window self[callfunconthis].a(); //doesn't work, self refers obj eval(callfunconthis).a(); //works, there better way? } var subobj = { a:function(){ }, b:function(){ } }; ...

indexing - index a bit field in MYSQL -

updated question: suppose data i'm interested in field=1 , actual ratio of data wheere field 1 vs 0 small(eg. 1%) in case, index field benefit select field =1 query? original question: have int field have either 0 or 1 value, indexing field speed select queries such as: select * xxx field=1; generally speaking, no. bi-state field doesn't speed queries when indexed because have @ half rows on average. want index entries selective - given entry in index should represent small percentage of possible values (say, less 10%, preferably fractions of percent). using index ignores of data in table, gives performance benefit. some dbms support bitmap indexes. can help, still run problem of selectivity. the updated question says number of values value 1 small (less 1 percent); index give benefit now? the answer is: for queries specify value 1, yes, index on column provide benefit, provided optimizer makes use of index. may need tweak dbms make realize i...

flash - Play swf files in C# -

i add 'shockwaveflashobject' in toolbox , drag on form , write below code nothing happen why? axshockwaveflash1.movie=application.startuppath+"\flash.swf"; axshockwaveflash1.play(); and axshockwaveflash1.loadmovie(0, application.startuppath + "\flash.swf"); axshockwaveflash1.play(); because of escape character; string path = application.startuppath+"\flash.swf"; path equal c:\users\username\documents\visual studio 2008\projects\windowsformsapplication1\windowsformsapplication1\bin\debuglash.swf see ...\debug + \f has converted debug to avoid escaping characters use @ string path = application.startuppath+@"\flash.swf"; now path equal c:\users\username\documents\visual studio 2008\projects\windowsformsapplication1\windowsformsapplication1\bin\debug\flash.swf prolly that's want get.

Delphi: Delphi and Microsoft SQL Server 2005 bad calculations from function values -

when send query on sql server 2005 microsoft sql server management studio select dbo.mov('hi',10,2) + dbo.mov('hi2',8,2) the query returns 400 the result of send function return 200 except if last 2 parameter 0 value of return 100 , value type of return function decimal(12,2) the problem, comes when query on delphi query.sql.add('select dbo.mov(''hi'',10,2) + dbo.mov(''hi2'',8,2)'); query.open; query.next; showmessage(query.fields[0].asstring); the query returns 200 (on message dialog), if sql server taking first function , ignoring second one, sql server 2005 right calculation in delphi. thanks. try clear query.sql before query.sql.add. query.sql.clear query.sql.add('select dbo.mov(''hi'',10,2) + dbo.mov(''hi2'',8,2)'); if have query stored in sql see result first one.

Is this statement correct? HTTP GET method always has no message body -

is statement correct? http method has no message body. didn't find part of rfc2616 explicitly this. and if not true, in circumstances http request include message body neither restclient nor rest console support curl does. the http specification says in section 4.3 a message-body must not included in request if specification of request method (section 5.1.1) not allow sending entity-body in requests. section 5.1.1 redirects section 9.x various methods. none of them explicitly prohibit inclusion of message body. however... section 5.2 says the exact resource identified internet request determined examining both request-uri , host header field. and section 9.3 says the method means retrieve whatever information (in form of entity) identified request-uri. which suggest when processing request, server not required examine other request-uri , host header field. in summary, http spec doesn't prevent sending message-body there suffic...

sql - How do i insert new record in this table? -

i'm sorry noob question. there're 2 tables : smaller 1 derived bigger one. how insert new record bigger table?? insert people (lname, fname, city, age, salary) values (' doe','john','paris', '25','1000$' ); but bigger table contains city number. how should insert 'paris'?? should know number beforehand?? 'paris' isn't in cities (smaller) table!! how records inserted in bigger (people) table?? edit: added if block check paris. if not exists (select 1 city city = 'paris') insert city (city) values ('paris') declare @cid int = (select cityid city city = 'paris') insert people (lname, fname, city, age, salary) values (' doe','john', @cid, '25','1000$' ) i made assumption structure of city table obviously. you parameterize @city variable , sub 'paris' everywhere in code.

c# - Serialize object without including property names -

i have simple object: [datacontract] public class myclass { [datamember(name = "myclassno")] public int myclassno { get; set; } [datamember(name = "myname")] public string myname { get; set; } } when serialize on web service get [ {"myclassno": 1, "myname": "test1"}, {"myclassno": 2, "myname": "test2"} ] but want data without property names included: [ {1, "test1"}, {2, "test2"} ] how achieve this? *edit - code use serialize is: var myobj = myopensqlconnection.query<myclass>(@"select myclassno, myname mytable"); return myobj.tolist<myclass>(); note i'm using dapper-dot-net map sql results object it impossible without writing own serializer serializes other property hash. hashes sequences of key-value fields , therefore must have unique keys each field. if tried blank values each key, in: {"":...

asp.net - Any way I can make this code cleaner/more efficient? (C#/LINQ-to-SQL) -

i've been putting auditing solution program developing, using linq update/insert operations. have come following solution (this snippet inserting) (note tables variable contains list of tables have been modified - add these list manually , call method): bindingflags b = bindingflags.instance | bindingflags.public; linqdatacontext dc = new linqdatacontext(); foreach (object table in tables) { string tablename = table.tostring().replace("project.", ""); switch (tablename) { case "job": string newjobstring = null; job jobdetails = (job)table; var prpsjob = typeof(job).getproperties(b); foreach (var p in prpsjob) { object x = p.getgetmethod().invoke(jobdetails, null); x = stripdate(x); newjobstring += p.n...

Adobe flex - Event metaData Tag and clone method -

i have few questions related events. can explain exact need of overriding clone() while creating custom events? read in flex cookbook need override clone() in case want redispatch event. mean when want event bubbled display hierarchy, dispatched event should our custom cloned event , not event object? second, need of metadata tag: [event(name="modelevent", type="com.abc.data.model.modelevent")] public class loginmodel extends eventdispatcher {} i understand need extend eventdispatcher in case want dispatch event class, in cases need use metadata tag? my third question if write dynamic customeventclass extends event" , can use dynamic keyword purpose? 1) redispatching event isn't same bubbling. have (third party) component dispatches event without bubbling. , want delegate event further. in case need redispatch event: mybutton.addeventlistener(mouseevent.click, mybuttonclickhandler); ... private function mybuttonclickhandler...

oop - designing classes and hibernate mappings -

while going through code in hibernate books ,i noticed strange things entity classes. example customer has address.the mapping given is public class customer implements serializable { @column (name="id") @id @generatedvalue (strategy=generationtype.auto) private long id; @onetoone (cascade=cascadetype.all) @joincolumn (name="address_id") private address address; ... } now,the address class given as public class address implements serializable{ ... @onetoone (mappedby="address") private customer customer; } is proper?should customer field of address ?that looks strange me.of course makes bidirectional association easy.but,if modelling class called address ,i wouldn't imagine customer field it(my knowledge/experience in oop tiny though). what guys think?..i know opinion of object oriented design gurus .. sincerely, jim i agree bit odd. that's contrived book examples you, though. it's ...

mysql - Database Aproach - Redundant data -

i have 3 tables: products (id, name, price, etc) orders (id, date, payment_method, etc) shipments (id, order_id, product_id, address, etc) my question is: correct keep in shipments table product_id? keep here find information shipped product without using orders table. i suggest: products (product_id, name, price, etc) orders (order_id, date, payment_method, etc) orderitem (orderitem_id, order_id, product_id, ...) shipment (shipment_id, order_id, ... ) shipment kind of redundant - i'd add address etc orders...

c# - Reading Text file with Linq with 2 patterns -

i need read text file myitemname = description @ moreinfo now need convert 3 fields in table. using '=' , '@' pattern. just splitting on = , @ - returns , ienumerable of anonymous class properties interested in: var items = file.readalllines(filename) .skip(1) //skip header .where( line => !string.isnullorwhitespace(line)) .select(line => { var columns = line.split('=', '@'); return new { itemname = columns[0].trim(), description = columns[1].trim(), moreinfo = columns[2].trim() }; }); this approach require separator tokens used separators exclusively - if occur in of fields, mess , void approach.

embed - How to hide embedly javascript key? -

i'm working embedly , found out key use, , pay for, in embedly javascript plainly visible can "inspect element" , see key. how can hide part of javascript, key part, people using "inspect element"? <script type="text/javascript"> $('document').ready(function(){ $('div.featuredgame').embedly({ maxwidth: 200, maxheight: 140, key: 'key removed' }); }); </script> you try , obfuscate it? here's js obfuscator use. its not 100% secure, @ least hides key, unless wanted decode it.

ajax - PHP: What is the Best Way To Search Through Values? -

i'm not sure best way , quickest way search through values. i have check list of 20 ids example below. can stored array too. '6e0ed0ff736613fdfed1c77dc02286cbd24a44f9','194809ba8609de16d9d8608482b988541ba0c971','e1d612b5e6d2bf4c30aac4c9d2f66ebc3b4c5d96'.... what next set of items json api call php stdclass. when loop through items add html each item display on website. if 1 of item's id matches ids in checklist add different html i'm doing in ajax call best , efficient way search through checklist? for example //get list of ids db , store in $checklist $checklist; $data = file_get_contents($url); $result = json_decode($data, true); foreach ( $result->results $items ) { $name = $items->name; $category = $items->category; $description = $items->description; $id = $items->id; // if id in $checklist use blue background. $displayhtml .="<div style=\...

c# 4.0 - Type parameters - get concrete type from type T : IMyInterface -

suppose have list<imyinterface> ... i have 3 classes implement imyinterface : myclass1 , myclass2 , , myclass3 i have readonly dictionary: private static readonly dictionary<type, type> declarationtypes = new dictionary<type, type> { { typeof(myclass1), typeof(funnyclass1) }, { typeof(myclass2), typeof(funnyclass2) }, { typeof(myclass3), typeof(funnyclass3) }, }; i have interface, ifunnyinteface<t> t : imyinterface i have method: public static ifunnyinterface<t> converttofunnyclass<t>(this t node) t : imyinterface { if (declarationtypes.containskey(node.gettype())) { ifunnyinterface<t> otherclassinstance = (funnyinterface<t>) activator.createinstance(declarationtypes[node.gettype()], node); return otherclassinstance; } return null; } i'm trying call constructor of funnyclasses , insert parameter myclass object. don't want know object is: want instantiate funnyclass myclass ...

php - Need help with regular expression for URLs -

was parsing urls of type http://sitename.com/catid/300/ , http://sitename.com/catid/341/ etc etc wherein parameter after catid (300,341) integers. when use following condition in .htaccess, works fine rewriterule ^(abc|def|hij|klm)/([0-9]+)/$ /index3.php?catid=$1&postid=$2 [l] but when php regex match function,like preg_match, returns 1 alphanumeric numbers too eg: echo preg_match('([0-9]+)','a123'); or echo preg_match('([0-9]+)',a123); they both return 1 ()true. dont know why matches alphanumerics. want match numbers. what doing wrong? without anchors, match numbers regardless of comes before or after them. try anchors: /^([0-9]+)$/ if don't need capture, try this: /^[0-9]+$/ results: php > echo preg_match('([0-9]+)','a123'); 1 php > echo preg_match('/^[0-9]+$/','a123'); 0 php > echo preg_match('/^[0-9]+$/',0.65); 0 php > echo preg_match('/^[0-9]+$/',666)...

asp.net - Deny access to a persistent cookie -

if logs in on pc starbucks (for example) , accidentally check 'remember me' option thereby setting persistent cookie on pc, there way of denying cookie server without resorting changing cookie name in web.config? i solved (a while actually) setting machinekey in web.config & changing when username/password changed: sub changemachinekey() dim commandlineargs string() = system.environment.getcommandlineargs() dim decryptionkey string = createmachinekey(64) dim validationkey string = createmachinekey(128) 'httpcontext.current.response.write(decryptionkey + "<br />" + validationkey + "<hr />") dim filename string = httpcontext.current.server.mappath("~/web.config") dim xmlreader xmltextreader = new xmltextreader(filename) dim xdoc xmldocument = new xmldocument() xdoc.load(xmlreader) xmlreader.close() dim node system.xml.xmlnode = xdoc.selectsinglenode("//configuration/sy...

The first build on TFS - and I get lots of compile errors. Third party assemblies cannot be located -

i trying run first build using tfs 2010. build fails because cannot locate third party assemblies such antixsslibrary.dll. need fix this? see http://www.ewaldhofman.nl/post/2010/02/09/where-is-the-additionalreferencepath-in-tfs-2010.aspx

nhibernate - Cascade ="all" not saving child entities -

Image
i think object model below saying party , partyname have many 1 relatioship. think cascade=all party.hbm sshould having nhib save child partyname(s). but isn't... can explain why partyname isn't being saved party , fix? cheers, berryl mapping <class name="party" table="parties"> <id name="id"> <column name="partyid" /> <generator class="hilo" /> </id> <discriminator column="type" not-null="true" type="string" /> <set access="field.camelcase-underscore" cascade="all" inverse="true" name="names"> <key foreign-key="party_partyname_fk"> <column name="partynameid" /> </key> <one-to-many class="parties.domain.names.partyname, parties.domain" /> </set> <subclass name="smack.core.testingsupport.nhibernate.testabledomain.so...

mapreduce - Cannot run Java class files with hadoop streaming -

whenever trying use java class files mapper and/or reducer getting following error: java.io.ioexception: cannot run program "mappertst.class": java.io.ioexception: error=2, no such file or directory i executed following command on terminal: hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar contrib/streaming/hadoop-streaming-0.20.203.0.jar -file /home/hadoop/codes/mappertst.class -mapper /home/hadoop/codes/mappertst.class -file /home/hadoop/codes/reducertst.class -reducer /home/hadoop/codes/reducertst.class -input gutenberg/* -output gutenberg-outputtstch27 assuming qualified mapper class name (including package) codes.mappertest , reducer class name codes.reducertst, package map , reduce classes jar file /home/hadoop/test.jar command should work if modify : hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar \ contrib/streaming/hadoop-streaming-0.20.203.0.jar \ -libjars /home/hadoop/test.jar \ -mapper codes.mappertst \ -reducer codes.reducer...

silverlight - How to initialize local fields of a WCF proxy class on deserialization -

in silverlight client have partial class created setting wcf reference. i've extended class adding few relaycommand properties. need initialize these properties in constructor. seems constructor not being called, believe result of of vts i'm unsuccessful in using ondeserialized attribute. what prescribed way initialize client side data members of wcf class. i've created sample project , works expected. if code doesn't - post data contract , client code. namespace silverlightapplication3.servicereference1 { public partial class somemodel { public string extendedproperty { get; set; } [ondeserializing] public void ondeserializingmethod(streamingcontext context) { this.extendedproperty = "ok"; } } } service method call: var proxy = new servicereference1.service1client(); proxy.doworkcompleted += (s,e) => debug.writeline(e.result.extendedproperty); //ok proxy.doworkasync...

regex - Match max 5 words before and after a certain word -

i need regex match @ 5 words before , after word. example: the word "the" the string "john ely gets start dodgers, while old friend takashi saito gets start brewers in bullpen game milwaukee." there should 2 results: john ely gets start the dodgers, while old friend takashi takashi saito gets start the brewers in essentially any ideas??? thanks (?:[a-za-z'-]+[^a-za-z'-]+){0,5}the(?:[^a-za-z'-]+[a-za-z'-]+){0,5} note regex engines won't deal overlapping matches.

How do I Exclude matching rows in two flat files using Informatica? -

how exclude matching rows in 2 flat files using informatica? i have flat file (source) data looks (normally lot more data): 1,2,3 4,5,6 and second flat file (source) this: 1,2,3 i want result (target) flat file looks this: 4,5,6 i know in sql there exclude (opposite of intersect) job. doing flat files , informatica. i pretty new informatica. have been doing month. might rather obvious. if tell me tranformations use great. you can use union transformation union result sets both files. give following result set . col1, col2, col3 ----------------- 1,2,3 4,5,6 1,2,3 after use aggregator transformation , select these ports (and ever want group consider them duplicate) , count in aggregator transformation. after aggregator (new column count => total_count) ---------------------------------------------------- col1, col2, col3,total_count ----------------------------- 1,2,3,2 4,5,6,1 the next step simple, pass them through filter transformation , us...

iphone - Entitlements.plist error when trying to build non ad-hoc versions? -

i searched around answer no luck.... i built ad-hoc version of app, when try build debug, release, or regular distribution build error: "codesign error: entitlements file '/users/dropbox/myapp/entitlements.plist' missing" the thing a) entitlements.plist file sitting right there in resources folder b) isn't correct path xcode project folder. c) removed key project settings> build> code signing entitlements, why looking entitlements.plist? what going on?? how can xcode stop trying find entitlements file, know isnt needed other ad-hoc builds. thanks all, think figured out. else runs this: i ended going 'targets' , right-clicking 'get info' (or alternatively project>edit active target ) , entitlement.plist listed in build tab there well. removed there , in project settings , issue solved. again, :)

java - Browse pictures on Android and move them to specific directory -

so i'm building android application, want users able press button opens window/activity. need activity allow user browse pictures saved on phone , able select want. once select pictures , press "ok" pictures need copied directory application access them from. know of code or , able save user data app on android device. , let me know if need clarification! it looks expecting complete task. instead of giving solution suggest way this, there on can go , search , find solution make learn lot of things. here articles can have reading start with. searching files on android system . create view can invoke search , select files storing files on internal storage now need homework , start hitting keyboard, i'm sure can easily

backup - How do you use wget (with mk option) to mirror a site and its externally-linked images? -

i know of wget -mkp http://example.com mirror site , of internally-linked files. but, need backup site images stored on separate domain. how download images wget, , update src tags accordingly? thank you! a modified version of @patrickhorn's answer: first cd top directory containing downloaded files. "first wget find pages recursively, albeit 1 domain" wget --recursive --timestamping -l inf --no-remove-listing --page-requisites http://site.com "second wget spans hosts not retrieve pages recursively" find site.com -name '*.htm*' -exec wget --no-clobber --span-hosts --timestamping --page-requisites http://{} \; i've tried this, , seems have worked - .htm(l) pages site i'm after, external files. haven't yet been able change links relative local copies of external files.

ASP.NET how are drop down list items available after postbacks? -

i have doubt on items available in drop down list after postbacks. i created custom web server control deriving dropdownlist: public class statelistcontrol : dropdownlist { public statelistcontrol() { this.items.add(new listitem("new york", "ny")); this.items.add(new listitem("nebraska", "ne")); this.items.add(new listitem("texas", "tx")); } } i added control page, in page_load event did following: protected void page_load(object sender, eventargs e) { if (!ispostback) { statelistcontrol1.items.add(new listitem("michigan", "mi")); } } now item added when there no postback. added button control no attached event. now when repeatedly click button, fourth entry visible after every postback. my doubt relates information saved drop down list has fourth item, when item added on first request , still available after repeated postbacks? ...

java - Get page content from Apache Commons HTTP Request -

so i'm using apache commons http make request webpage. cannot life of me figure out how actual content page, can header information. how can actual content it? here example code: httpget request = new httpget("http://url_here/"); httpclient httpclient = new defaulthttpclient(); httpresponse response = httpclient.execute(request); system.out.println("response: " + response.tostring()); thanks! use httpresponse#getentity() , httpentity#getcontent() obtain inputstream . inputstream input = response.getentity().getcontent(); // read usual way. note httpclient isn't part of apache commons . it's part of apache httpcomponents .

screenshot - Screen Capture Complications with WPF window on top -

i need capture entire screen transparent wpf window topmost window. tried 2 approaches: using system.windows.drawing.graphics.copyfromscreen using winapi getdesktopwindow both methods yield same result. entire screen except topmost transparent wpf window. wpf window w created with: w.allowstransparency = true; w.windowstyle = system.windows.windowstyle.none; w.background = new solidcolorbrush( color.fromargb( 1, 0, 0, 0 ) ); w.topmost = true; plus content of course. window covers entire screen surface. apparently, wpf window draws on surface not included in getdesktopwindow. can pls shed light on , share ideas how entire screen surface? just found solution: as far can tell there no solution graphics.copyfromscreen approach because you'd need or copypixeloperation.captureblt copypixeloperation.sourcecopy can't. usual m$ inconsistency madness... however, winapi approach works since can combine srccopy , captureblt when using bitblt. without capture...

mysql - Index IN and a range -

i need find best index query: select c.id id, type content c use index (type_proc_last_cat) left join battles b on c.id = b.id type = 1 , processing_status = 1 , category in (13, 19) , status = 4 order last_change desc limit 100"; the tables this: mysql> describe content; +-------------------+---------------------+------+-----+---------+-------+ | field | type | null | key | default | | +-------------------+---------------------+------+-----+---------+-------+ | id | bigint(20) unsigned | no | pri | null | | | type | tinyint(3) unsigned | no | mul | null | | | category | bigint(20) unsigned | no | | null | | | processing_status | tinyint(3) unsigned | no | | null | | | last_change | int(10) unsigned | no | | null | | +-------------------+---------------------+------+-----+---------+-------+ mysql> show indexes cont...