Posts

Showing posts from August, 2010

rest - Message body on a 404 message -

i talking co-worker reason wrote framework ground because wasn't able automatically unmarshall message body on 404 http packet. he says he's following rest principles. guess message body on 404 http packet violate principles, i'm not sure of it. if has opinion regarding this, please answer :) if use web browser go http://www.google.com/unknown 404 status code , entity body. it quite common entity bodies returned 404s. if @ description of 400 errors in httpbis spec see the server should include representation containing an explanation of error situation, , whether temporary or permanent condition.

How to write a Graph Algorithm -

trying come-up pseudocode (in latex) algorithm takes 2 graphs input - compares each node in graph - (i fill in comparing function), returns 0 if node 1 graph equal node in other graph, else returns 1. node in graph graph. checking recursive. what's mean , comparing graphs ? graphs of g1 , g2 same if of vertices have same weight[value] , |g1| = |g2| . (in simple graphs)

Integrating Events into Wordpress -

i'm in process of developing website not-for-profit organization, , thought wordpress great tool use base cms site. building site wordpress has not been problem, have been having difficult time finding plugin use them organize , advertise upcoming events. currently, use google calendar, trying move integrates more cleanly site. essentially, need wordpress events/calendar plugin these features: + add reoccurring events start , end time + each event should have own page (reoccurring events should shown single page) + display events in mini-calendar , full calendar/list view it nice have these features: * ability categorize/tag events * ability add picture go event i'm indifferent on these features: - being able rsvp - paying events - import/export calendars there many events/calendar plugins out there wordpress, can't seem decide 1 worth me spending time use website. suggestions? you can create category called "events" , desig

Objects from memory as input for Hadoop/MapReduce? -

i working on parallelization algorithm, following: read several text documents total of 10k words. create objects every word in text corpus. create pair between word-objects (yes, o(n)). , return frequent pairs. i parallelize 3. step creating pairs between first 1000 word-objects rest on fist machine, second 1000 word-objects on next machine, etc. my question how pass objects created in 2. step mapper? far aware would require input files and hence need serialize objects (though haven't worked with before). there direct way pass objects mapper? thanks in advance help evgeni update thank reading question before. serialization seems best way solve (see java.io.serializable). furthermore, have found tutorial useful read data serialized objects hadoop: http://www.cs.brown.edu/~pavlo/hadoop/ ). how parallelize steps? use #1 text documents input mapper. create object every word in mapper. in mapper key-value pair word-object pair (or object-word depending on

python - How to draw matplotlib graph in eclipse? -

i can draw matplotlib graph in command line(shell) environment, find not draw same graph inside eclipse ide. such plot([1,2,3]) not show in eclipse, writed show() in end still not show matplotlib use gtkagg backend, use pydev plugin of eclipse develop python. import matplotlib.pyplot mp mp.ion() mp.plot(x,y) mp.show()

eclipse - How to Count the number of rows in Sparql Query -

i working in eclipse , using 2 java files: admin.java , semanticsearch.java. through the admin.java logging in , checking if username , password existing in rdf file. function of login in admin.java calls semanticsearch.java runs sparql query. query giving me answer in console of eclipse , onto file. job give answer admin.java either returning value or counting rows , sending value admin.java. if number of rows 1 means username , password match , can allow user login. but not able so. have tried using count(), count() cnt, tried int res=results.next. nothing seems help. i pasting code below: admin.java semanticsearch semsearch = new semanticsearch(request.getsession()); semsearch.loaddata(realpath + rdfdatasourcefile1); semsearch.searchforuser(response.getoutputstream(),null, username, password); in semanticsearch.java public void searchforuser(outputstream out, string xslfile1, string username, string password) { string prolog = "prefix kb:<"+vuser.get

asp.net mvc - Using MVC Routes as Shortcodes -

we have been trying implement shortcodes on asp.net mvc web app allow users uniquely invoke given article/page using assigned short code. for e.g.: www.mysite.com/power map actual url: www.mysite.com/power/home/. i have created various routes throughout site map these shortcodes various actions , controllers within application. shortcode/route point of view, working great. i, however, noticed couple of interesting things. have hyperlinks use url.action method generate url pointing pages. many of these pages have short codes associated them. e.g.: have link says: <a href="<%= url.action("index", "home", new { area = "power" })%>"> go power page</a> this page has mentioned short-code assigned it. when use url.action, ideally expect create link /power/home/index or /power/home, since have route constraint mapped it, generates link /power. is there way can use actual link url when generating links? want short-codes

ruby on rails - Rubymine doesn't detect Imagemagick install? -

i installed rubymine, , imagemagick through terminal use rails papercilp. reason if run rails server through terminal works, if run server through rubymine, says imagemagick missing. anyone have thoughts? i've been trying figure out config issue hours now. it imagemagick not in path in rubymine. rubymine environment different shell. see http://devnet.jetbrains.net/docs/doc-1160;jsessionid=1858a969645f39423219a415388af557 how this.

asp.net mvc - To WebGrid or not to WebGrid...what is the answer? -

i'm reading , hearing pain points , wondering if should go route. not mention, cannot seem find definitive documentation (from microsoft). if shouldn't use it, route suggest? i'm trying new site off ground, want right first time. i should choose use webgrid if looking , display data , not have rely on external libraries. however, if you're looking fully-featured grid, not go webgrid right now. there difficulties in applying styles , doing more advanced aspects available in other popular web grid libraries. as opinion on should use - if webgrid not meet needs, check out jqgrid . it's popular package , works amazingly , easy setup , run. if more documentation on webgrid , check out microsoft's asp.net mvc 3 tutorial site.

.net - How can I resize an image in C# while retaining high quality? -

i found article on image processing here: http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing works fine. i want keep high quality when resizing image. think if can increase dpi value can achieve this. know if possible? , if so, how can implement in c#? for starters, it's worth pointing out there 2 general categories of images; vector [e.g. svg, wmf, adobe illustrator , corel draw graphics] , bitmap (also called raster) images [e.g. bitmap, jpeg , png images]. vector images formed series of mathematical equations and/or calculations. bitmap images, on other hand, made of individual dots (pixels) each corresponding particular feature on object image taken of. if should happen want resize image, first thing consider if bitmap or vector image. virtue of fact vector images obtained calculations, can resized without losing detail. case different bitmap images. since each pixel independent of other, when desire resize it

hyperlink - What's the best service to use for filtering out spam/abuse/malware links for a link shortening webapp? -

i have 2 services - lincr , linkbunch. lincr plain jane url shortening service, while linkbunch lets shorten multiple links 1 link. i've had spam posted services, had shut down lincr. now, linkbunch seems facing same problem, , it's been disabled web host reason. i can't keep shutting down sites because of bad links being posted, need malware-filtering api can use filter out links , when posted. there services let me download entire bunch of bad links check against, instead, i'd prefer doing live api call on per-link basis. can use that? finally, what's best malware filtering service out there? lincr down. on linkbunch, captcha? on either site, limit number of posts ip? use delay in response? using hidden fields reduce spam (http://www.reviewmylife.co.uk/blog/2008/05/30/hidden-field-spam-trap-for-phpformmail/)? i know i'm dodging question bit, should @ least take basic anti-spam measures before resorting api calls. apis still fail new

cocoa - Managing subviews from superview? -

have window content view. load subview on different nib file programmatically. there way change on subview can captured controls on window's content view? for instance, have tableview on subview. if selection of tableview changes, want enable button on windows's content view. possible? if yes, please guide.. thanks in advance.. there few ways you can set object creates subview delegate tableview , implement tableviewselectiondidchange in object. or can subscribe nstableviewselectiondidchangenotification notification, passing tableview: [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(tableviewselectiondidchange:) name:nstableviewselectiondidchangenotification object:tableview]; and handle in : - (void)tableviewselectiondidchange:(nsnotification *)anotification { nstableview *tableview = (nstableview *)anotification.object; nslog(@"selection changed: %i", [tableview selectedrow]); }

how to create a custom datatype in java? -

i want create custom datatype in java,for example datatype email , having following method isvalidate(string email),isemailexist(string email),getdomain(string email), id(string email),just integer class in java. integer class , can initialise object of integer class follows: integer = 100; i created class email , want initialise follows email e = "sam"; how can perform functionality in email class. import java.util.stringtokenizer; import java.util.regex.matcher; import java.util.regex.pattern; public class email { private string email; public email(string email) { this.email=email; } email() { } public boolean isvalid(string email) { string lasttoken = null; pattern p = pattern.compile(".+@.+\.[a-z]+"); // match given string pattern matcher m = p.matcher(email); // check whether match found boolean matchfound = m.matches(); stringtokenizer st = new stringtokenizer(email, "."); while (st.hasm

java - How or why were most of the "different" Apache projects so called -

please ignore obivous ones commons log4j jakarta of course capital of "java". but rather think ones tika there no real rules. people call projects want to: words like, words have meaning, or have no meaning (like acegi, abcdefghi).

printing data from phone in android -

in android application allow user print data on phone nearest printer on click of print button. is possible in android.how printers nearby? please share valuable suggestions. thanks in advance :) looks want send2printer , apparently contains api can used 3rd-party apps (i guess that's come in).

c - Once again: How to get DOM in JavaScript Engine? Has this somebody done? -

there several questions , tips getting dom spider-, trace- or jaegermonkey. has done this? somewhere out there in c embedable working js-engine including dom? or @ least easy tutorial? i suggest looking envjs or xmljs . these full dom implementations written directly in ecmascript.

Android: Redrawing a specific view inside a layout -

i have vertically aligned linearlayout contains textview, own custom view class, , i'm hoping put ad @ bottom. i'm drawing objects in custom view class (that extends view), not updated screen unless call setcontentview(r.layout.myview) , resets textview default text (what stored in xml file) don't want, , assume redraw new ad well... annoying. is there way can redraw/refresh custom view screen without affecting textview or whatever else may have on layout? how view.invalidate() ? from reference : note framework not draw views not in invalid region. to force view draw, call invalidate() .

How to uninstall ruby-oci8 -

the ruby gem using require ruby-oci8 version 2+. seems machine have ruby-oci8 version 1.0.0 . can't uninstall. i've run gem uninstall ruby-oci8 succesfully. then, using irb type require 'oci8' => true oci8::version => "1.0.0" how clean windows machine ruby-oci v1.0.0 ? thanks. http://ruby-oci8.rubyforge.org/en/faq_uninstall.html delete 3 files mentioned in link above

google app engine - django search string in string -

can search string in string/list/array in django passed through python template. in adv... there few methods searching string within string, string.find , string.rfind , string.index , string.rindex . here can find documentation them: http://docs.python.org/library/string.html if doesn't matter if strings created using template...

.net - Binding Grid column width -

facing following problem in design of xaml. i need arrive @ end arrange data grid custom datatemplate . create top grid contains 2 header lables of data items. below grid build stackpanel itemscontrol includes datatemplate displays data. ok, when run application header lables , data items below grid. problem labels , content of items not aligned correctly. thought binding width of header lable columns actualwidth of itemtemplate , unfortunately not work. is there clean way achive this? in advance ... there easy way using sharedsizegroup in grid columns , assinging grid.issharedsizescope="true" parent. e.g. <stackpanel grid.issharedsizescope="true"> <grid name="headers"> <grid.columndefinitions> <columndefinition sharedsizegroup="a"/> <columndefinition sharedsizegroup="b"/> </grid.columndefinitions>

java - LookAndFeel-independent reference of color keys -

i working on set of custom controls product of company i'm working in. this, extending lot of swing controls , overriding lot of paint methods. in order maintain consistent color scheme, receive colors paint , setbackground etc. methods using uimanager.getcolor . this fine until noticed nimbus lookandfeel, shipped current jre versions, uses totally different color keys, many things looks totally out of place. for instance, while other stock lookandfeels (metal, windows classic, windows, cde/motif, gtk) have defined key "text" bright background texts , "texttext" corresponding foreground color, "text" in nimbus black foreground color, , standard text background color not seem exist. "textfield.background" work, that, instance, doesn't exist windows lookandfeels. i suppose problem now. don't want have maintain set of color keys each laf, knows lafs added in future , company may decide use. a simple solution gettin

c# - Using Microsoft.VisualStudio.TestTools.UnitTesting without Visual Studio? -

i'm trying build open source project in sharpdevelop, tests don't compile references microsoft.visualstudio.testtools.unittesting namespace. i don't have visual studio (not express editions). there way compile project without visual studio (and without changing code use nunit)? i no, because can see namespace, ms test framework relies on visual studio.

database - MySQL: looking to SUM these UNIONs together -

ok, head hurts...! this beautiful mysql query: (select mtwitterfollowers twitfollow `media` media.id=1) union (select sum(twitterfollowers) twitfollow people left join peoplejoin on peoplejoin.people_id = people.id left join positions on position_id = positions.id peoplejoin.media_id = 1) union (select sum(twitterfollowers) twitfollow people left join peoplejoin on peoplejoin.people_id = people.id left join networkjoin on networkjoin.network_id = peoplejoin.network_id left join positions on position_id = positions.id networkjoin.media_id = 1) ...returns 3 rows of pretty numbers. ideally, i'd query return 3 "twitfollow" results, summed together. however, putting sum round them gives me error "every derived table must have own alias", , i'm little confused quite how solve that. (of course, sum results in php; assuming it's quicker using mysql server. right?) use entire query from clause of query: select sum(twitfollow) ( (s

video - DirectShow - what is it? -

what microsoft's directshow , , how relate to: codecs? containers? and exact difference between codecs , containers? in plain english: codec piece of algorithm and/or code transform audio or video raw format coded format , back; encoder , decoder. in case of video, raw format pixels in memory, , in case of audio samples. containers way write encoded data file on hard drive. or way write encoded data stream internet transmission.

deserialize graph.facebook.com JSON feed in c# -

i trying facebook posts facebook group in asp.net through graph.facebook.com/id/feed. i have managed data need, in json format. how deserialize data can use it? if in c# 4.0 can use dynamic object deserialize graph object. see c# facebook api here: http://facebooksdk.codeplex.com/ http://ntotten.com/2010/09/dynamic-objects-and-the-facebook-c-sdk/ if have class deserialize newtonsoft json library alot: http://james.newtonking.com/pages/json-net.aspx

Find Exact Match From Page Using Javascript Regex -

how find exact match whole html.below detail explanation. suppose have html below: <html> <body> ..... <table> <tr> <td> linenumber </td> <td> number </td> </tr> </table> ..... </body> </html> here want replace 'number' word. can using .replace(/number/g,'newnumber') using changing value in 'this linenumber' statement, convert statement 'this linenewnumber'. i don't want it. need change there single 'number',not word. you want match word boundaries using \b : .replace(/\bnumber\b/g, 'newnumber');

ruby on rails - add class to collection_select -

i've looked @ how set html options collection_select in rails? , i'm sure i'm missing obvious, can't work. my select looks like: <%= f.collection_select :broadcast_id, broadcasts, :id, :to_s, :include_blank => 'broadcast on...' %> and i've tried including :class => 'prevent_collapse' , nothing, {:class => 'prevent_collapse'} , gives me error. if can point out how this, i'll super grateful! collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) => f.collection_select :broadcast_id, broadcasts, :id, :to_s, {:include_blank => 'broadcast on...'}, {:class => 'prevent_collapse'} and error have? and broadcast item has got :to_s method? return class name, think.

IPhone - Is it possible to add a Custom Image as the data source for a Map View? -

i want have map view loads image provide rather using google maps. because internet not available app used. i have heard possible since map view catiledlayer , should able provide custom content, struggling find information on topic. could point me in right direction? you can't , doing violation of google map api terms. apple cannot provide such feature. must revert third-party (and non-free) services use other maps. the terms here: google maps api terms this relevant (for answer) extract terms: license restrictions. except expressly permitted under terms, or unless have received prior written authorization google (or, applicable, provider of particular content), google's licenses above subject adherence of restrictions below. except explicitly permitted in section 7, must not (nor may permit else to): 10.1 access or use service or content through technology or means other provided in service, or through other explicitly authorized means google may

comparison - Which App Engine Authentication Method should I choose? (Pros/Cons) -

i experimenting google app engine , went create app asked me choose authentication method. options 'google account' or 'openid', 'google apps domain' option doesn't interest me. however, can't find information in documentation lists pros/cons of either method. my question pros , cons of each of methods? thanks. not sure of exact pros , cons biggest with google account - users forced have google account open id - users must have account open id provider listed here . open id how logins on stackoverflow works.

windows - How to grant an account permissions to access a certificate? -

i have certificate in msmq service personal store , need grant network service permissions access certificate. the way know of using certutil.exe on win2008/7 so: certutil -service -service -repairstore msmq\my "" d:pai(a;;ga;;;ba)(a;;ga;;;sy)(a;;gr;;;ns) (thanks http://blogs.msdn.com/b/gautamm/archive/2010/10/26/https-messaging-with-client-side-certificate-fails-with-iis-error-403.aspx ) however, certutil on win2003/xp not recognize -service parameter, no good. my question how can in way works both win2003/xp , win2008/7? i need non interactive approach (command line utility, script, com/.net/win32 api). if need set acl rights on certificate's private key (which linked page suggests), posted answer here on how found that. open x509store , current certificate in hand, , set acl on private key. you can use sid of account needing access (or use well-known sid s-1-5-20 if know it's network service): ntaccount nt = new ntaccount("nt_au

NHibernate - eager fetch a collection -

i'm creating hql query uses eager fetching collections , properties. query: var result = session.createquery("from match m left join fetch m.user u left join fetch u.profileitems pi m.user.id = :p1") .setparameter("p1", user.id) .list<match>().tolist(); this works well. using nhprofiler, can see produces following sql query: select (...) `match` match0_ left outer join `user` user1_ on match0_.userid = user1_.id left outer join `profileitem` profileite2_ on user1_.id = profileite2_.user_id match0_.userid =? p0 now, can iterate on result of match instances or user instances this: foreach (user u in result.select(m => m.user)) { // .. } ... , not hit database again. however, user object has property not mapped database, isonline. calculation using current date. use property in expression, database hit. example: int = result.count(m => m.matchinguser.isonline); ... hit database e

asp.net - Javascript function call from ASP .NET Hyperlink NavigateURL property -

i have asp table create dynamically on page load event. in event, populate asp table titles , asp .net hyperlink control points .ashx page serve file client download. for particular files (image files), i'd kick off javascript function open new window file displayed in it. have code this, can't javascript function work in hyperlink navigateurl property. i'm new javascript, i'm not sure i'm missing. can i'm trying to? can not use table control? help! asp code behind protected sub page_load(byval sender object, byval e system.eventargs) handles me.load dim iwineid integer if not integer.tryparse(request.params("wineid"), iwineid) throw new invalidoperationexception("invalid request") me.lblwinename.text = utils.getwinename(iwineid) dim dtdocs new dsdocs.docsdatatable using tadocs new dsdocstableadapters.docstableadapter dtdocs = tadocs.getdatabyprodidorwineid((utils.getproduceridbywineid(iwineid)),

Custom jQuery event listener that triggers on show() -

i have div gets hidden , displayed, via .hide() , .show() . when displayed .show() need stuff. there way can setup custom event listener fires callback when div goes hidden visible? can make function , call wherever call $(#mydiv").show() happens in multiple places , keep in 1 place. you can pass function callback show method execute after show has completed: $("#mydiv").show(function(){ mycustomfunction(); });

What is PHP's isset equivalent in c# .NET 4 for properties of 'dynamic' objects? -

i working mvc 3 @ moment use viewbag. test if 1 of properties of viewbag has been assigned. know in php isset(variable), there similar in .net 4? the scenario making nested layout takes section title , section subtitle through viewbag. seperated seperator , sub title optional. don't want display seperator if sub title not set. this how imagine isset replaced .net 4 equivelant. @section header { <h2>@viewbag.sectiontitle</h2> @if(isset(viewbag.sectionsubtitle)) { <div id="section-title-seperator"> - </div><h3>@viewbag.sectionsubtitle</h3> } } next direct answer question, i'm open alternate solutions (in case i'm abusing viewbag). thanks in advance. you can check if null this: @if(viewbag.sectionsubtitle != null) . isset() in php checks if there value present. manual: isset() return false if testing variable has been set null you can use viewdatadictionary.contains

C++ Class, Assigning values during Constructor initialization -

i have 2d array declared part of classes private members. when call constructor, start assigning values 2d array. every time so, i'm hit error c2059. make sure nothing else causing error commented out line , compiler finished putting binary file. tried: variable[row] = { 0, 1, 2, 3}; variable[row][] = { 0, 1, 2, 3}; variable[row][4] = { 0, 1, 2, 3}; no luck, clues. in advance. unfortunately, can't yet initialize arrays members of classes. don't know how yours declared, here's example of do: class x { int variable[3][4]; public: x() { const int temp[][4] = { { 1, 2, 3, 4}, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; const int sz = sizeof(variable)/sizeof(**variable); std::copy(*temp, (*temp) + sz, *variable); } };

javascript - jQuery/css: selected amount of stars to light up -

i'm working on making star-voting system. there 5 stars, lighted showing current average star voted. when mouseover star, lets number 4 wish make 4 right lighten up, if mark on 2, 2 stars should mark right , on.. if full 5 stars stars lights up. stars in css classes .iconfavorite , lighten .iconfavorite_hover, code looks when 3: <div class="iconfavorite_hover"></div> <div class="iconfavorite_hover"></div> <div class="iconfavorite_hover"></div> <div class="iconfavorite"></div> <div class="iconfavorite"></div> if check out retardo.dk/videos.php?id=905 can see big green stars try mouseover them, selected amount of stars light up. how can this? here's jsfiddle of current code no jquery: http://jsfiddle.net/8vzcc/1/ does work? http://jsfiddle.net/8vzcc/33/ removes after :) should work! edit: new version, should work want work :)

oracle - Weird dos batch script reporting of %errorlevel% -

in script below, when there sql error, %errorlevel% 0 - why this? if %release% gtr 2 ( ( echo whenever sqlerror exit failure echo @release.sql echo exit ) | sqlplus x/x@orcl echo error: %errorlevel% if %errorlevel% gtr 0 goto dberror ) if remove if block (below) %errorlevel% non zero! why if statement affect error level? ( echo whenever sqlerror exit failure echo @release.sql echo exit ) | sqlplus x/x@orcl echo error: %errorlevel% if %errorlevel% gtr 0 goto dberror update : believe way testing error. think instead of: if %errorlevel% gtr 0 goto dberror .. should using: if errorlevel 1 goto dberror useful link here sigh. it's horrible dos parsing, , point @ cmd replaces %errorlevel% value. when enclose commands ( ... ) , cmd first reads in commands though written on 1 line, expanding variables goes. in first code block, %errorlevel% replaced value when block parsed . it's if wrote:

Date browsers problem - if manually changed and focus on it - did not save -

i have problem related date type i'm using in smartgwt. i set date have possibility change manually: setattribute("usetextfield", true); in firefox , chrome (and maybe other browsers , except internet explorer) if first i'm selecting date pop-up calendar , change manually , let focus on date field , going save document (actually form multiple fields) date changed manually lost, date choosed calendar saved. not happening in internet explorer. in browsers, if select calendar date , change manually , change focus everythings goes fine - manually changed date saved db. need advices. thank lot. later edit: i'm using com.smartgwt.client.widgets.form.fields.dateitem widget . dateitem date = new dateitem("a date"); date.setwidth(320); date.setwraptitle(false); date.setattribute("usetextfield", true); date.setattribute("inputformat", "yyyy/mm/dd"); date.setattribute("displayformat", "tojapanshort

django - Deploy as Jenkins User or Allow Jenkins To Run As Different User? -

i'm getting started jenkins ci, , had question i'm struggling find answers in docs or online. wonder if might able offer advice? i'm attempting use automatically deploy dev , stage branches of django projects hosted on github organisation repository (ie, private). @ moment have user "django" can access github repo via github deploy key. jenkins user can't access repo. what's best practice way of dealing - should creating ssh deploy key "jenkins" user, or should getting jenkins run "django" user? i've seen mention if hudson_user in newsgroup post, can't find reference in docs. many thanks! ludo. i have not worked github , answer may not apply @ all, use jenkins , use both cvs & subversion source control. in our system, use different username/password combinations 3 (jenkins, cvs, subversion), , has had no adverse effects yet (it has been year since deployed hudson - building 50+ projects). as long

security - Fundamental difference between Hashing and Encryption algorithms -

i see lot of confusion between hashes , encryption algorithms , hear more expert advice about: when use hashes vs encryptions what makes hash or encryption algorithm different (from theoretical/mathematical level) i.e. makes hashes irreversible (without aid of rainbow tree) here similar questions didn't go detail looking for: what difference between obfuscation, hashing, , encryption? difference between encryption , hashing well, in wikipedia ... since want explanation, i'll best here: hash functions they provide mapping between arbitrary length input, , (usually) fixed length (or smaller length) output. can simple crc32, full blown cryptographic hash function such md5 or sha1/2/256/512. point there's one-way mapping going on. it's many:1 mapping (meaning there collisions) since every function produces smaller output it's capable of inputting (if feed every possible 1mb file md5, you'll ton of collisions). the reason hard (or im

java - How can I disable Apache Commons / Log4J logging in third party libraries? -

is there apache commons / log4j logging api method can used disable logging completely, loggers in third party libraries? background: use java.util.logging in glassfish v3 web application. however, third party library in web app uses log4j logging , apache commons logging. save resources, logging should minimized or switched off. edit log4j configuration , set logging level error or fatal example hibernate: log4j.logger.org.hibernate=error this dwarf logging output zero, leaving critical error messages.

php - Is there a tool that can tell a domain's IMAP or POP3 address? -

i'm building web email client , i'm interested in easy ways figure out imap or pop3 emails. there tool figure out? i'm assuming if not, best bet try { imap.domain.com } catch{ try { mail.domain.com } catch { ...etc ... } } there no way. best bet try domain of e-mail, plus usual prefixes, suggest. then, imap server may running in non-standard port; have no way of knowing.

c++ - Magic number in boost::hash_combine -

the boost::hash_combine template function takes reference hash (called seed ) , object v . according docs , combines seed hash of v by seed ^= hash_value(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); i can see deterministic. see why xor used. i bet addition helps in mapping similar values apart probing hash tables won't break down, can explain magic constant is? the magic number supposed 32 random bits, each equally 0 or 1, , no simple correlation between bits. common way find string of such bits use binary expansion of irrational number; in case, number reciprocal of golden ratio: phi = (1 + sqrt(5)) / 2 2^32 / phi = 0x9e3779b9 so including number "randomly" changes each bit of seed; say, means consecutive values far apart. including shifted versions of old seed makes sure that, if hash_value() has small range of values, differences spread across bits.

c# - Marking ToString virtual in base class, what happens? -

consider following (linqpad) example. tostring in class x marked virtual. why output here not equal "hi, i'm y, hi, i'm x" instead typename printed? of course marking tostring virtual wrong, because defined in object virtual, trying understand happening here. void main() { y y = new y(); console.writeline(y); } // define other methods , classes here class x { public virtual string tostring() { return "hi, i'm x"; } } class y : x { public override string tostring() { return "hi, i'm y, " + base.tostring(); } } that's creating new virtual method in x called tostring() hides object.tostring() . if have: y y = new y(); x x = y; object o = y; console.writeline(y.tostring()); // shows "hi, i'm y, hi, i'm x"; console.writeline(x.tostring()); // shows "hi, i'm y, hi, i'm x"; console.writeline(o.tostring()); // calls object.tostring; shows "y" c

.net - why not reference wcf service from web project? -

in traditional way of thinking (remember dna ?) we're supposed architect our application separating layers services. when implementing asp.net mvc application, why should implement service , wrap wcf references separate dll, rather having web application reference wcf directly? i can think of 2 arguments, , thoughts on those: keep code in once place (well, still done when have wcf!) reusable service when other systems need service (well, if internal application?) on other hand, people might argument over-architecture implementing alot of layers bring more complexity solution , not yield benefits expected. i'm not fan of introducing dlls "because". been there; ot t-shirt dependency graph on it. if can't define benefit in environment/context , simplest thing - may reference web app. i've heard argument of allowing re-use, counter: soap/mex pretty-much defining this. argument testability, isolation, separation etc; , depends on how benefit

sql - Comparing 2 tables , find not existing "id" -

i have speed problem when comparing 2 tables. let's have following tables. table a 14,000 records name(varchar) , join_id(int) table b 54,209 records second_name , join_id(int) now want find rows exists in table , not in b connected joint_id ordered random ( sort of ) i tried following : select a.name , b.second_name left outer join b on a.joint_id = b.joint_id b.joint_id null limit 0,10 the query took ages , messing server , question ; is there faster way accomplish ? edit : removed rand() , can solved otherwise. still have same problem. try out suggestions below , see if can improve query time. notice gave second column fixed value of null, since when b not exist, b.second_name => null. crux of problem order rand() require full scan put rand() against each record. cannot avoid table scan. select a.name , null second_name not exists (select * b a.joint_id = b.joint_id) order rand() limit 0,10; you possibly make

c# - How to do I return an item from a custom event handler -

a project i'm working on requires me able fire off event everytime item added list. achieve this, created custom list class inheriting list , added onadd event. want return item being added eventargs added more code (given below): public class clientlistobservable<client>:list<client> { public event eventhandler<eventargs<client>> onadd; public void add(client item) { if (null != onadd) { onadd(this, new eventargs<client>(item)); } base.add(item); } } public class eventargs<client> : eventargs { public eventargs(client value) { m_value = value; } private client m_value; public client value { { return m_value; } } } this how add handler clientlist.onadd += new eventhandler<eventargs<client>>(clientlist_onadd); but, in onad

c# - Javascript confirm message problem -

i have popup confirm box able show below. but dont know if user clicked ok or cancel. scriptmanager.registerstartupscript(this, this.gettype(), "ajax", "<script language='javascript'>confirm('do u wanna change?');</script>", false); so want this. if (orignalid != newid) { scriptmanager.registerstartupscript(this, this.gettype(), "ajax", "<script language='javascript'>confirm('do u wanna change?');</script>", false); if (user clicks yes) { add data sql } else { return; } } how know user has clicked?? i have tried this i put code below in folder1\jscrip.js file dont kno how call have used ajax update panel in page cannot use clientscript.registerclientscriptinclude reference it. mentioned in 6th point @ link: http://www.dotnetcurry.com/showarticle.aspx?id=274 page.clientscript.registerclientscriptinclude("selective", resolveu

python - Joining: string and absolute path with os.path -

why not working, doing wrong? >>> p1 = r'\foo\bar.txt' >>> os.path.join('foo1', 'foo2', os.path.normpath(p1)) '\\foo\\bar.txt' i expected this: 'foo1\\foo2\\foo\\bar.txt' edit: a solution >>> p1 = r'\foo\bar.txt' >>> p1 = p1.strip('\\') # strip '\\' path not absolute >>> os.path.join('foo1', 'foo2', os.path.normpath(p1)) 'foo1\\foo2\\foo\\bar.txt' when os.path.join encounters absolute path, throws away has accumulated far. absolute string 1 starts slash (ans on windows, optional drive letter). normpath won't touch slash has same notion of absolute paths. have strip slash. and if may ask: come in first place?

javascript - I need sme help automating jqGrid filters, please -

okay, in nutshell, need automatically apply set of sorting criteria , data filters jqgrid when loads. intent user start 10 pre-filled filters , then, if choose, can alter filters or sorting see fit. so far, google-ing, trial , error , sweat, have following working: -> can load/save sort column & sort order in session cookie. -> can load search dialog pre-defined search filters. after grid loads, can open modal dialog , see proper filters , if click "find" appropriate data posted server , right results returned screen. the thing biting me in butt right is, think, easy part, escapes me. can't seem either of following: ( ) ideal thing if attach these filters grid , it's post data in advance of initial load there single trip server. ( b ) workable solution, though less ideal, grid load first page of unfiltered data first, , apply filters , re-query server filtered data. since can manually click "find" button today , works, though

Delphi for..in loop set enumeration order -

i want iterate through set of specific values. simple example below program project1; {$apptype console} var a, b: word; wait: string; begin := 0; b in [1,5,10,20] begin := + 1; writeln('iteration = ', a, ', value = ', b); end; read(wait); end. the sample code here expect , produces following iteration = 1, value = 1 iteration = 2, value = 5 iteration = 3, value = 10 iteration = 4, value = 20 now if change order of set b in [20,10,5,1] the output same original, order of values not preserved. what best way implement this? sets not ordered containers. cannot change order of set's contents. for-in loop iterates through sets in numerical order. if need ordered list of numbers, can use array or tlist<integer> . var numbers: array of word; begin setlength(numbers, 4); numbers[0] := 20; numbers[1] := 10; numbers[2] := 5; numbers[3] := 1; b in numbers begin inc(a); writel

html - Using jQuery in loaded div -

im trying use jquery on page loaded div using .load(). php gets loaded div, contains div hidden section hidden when first shown. when link pressed hidden div section slides out. works fine reason div slides finishes sliding down , cant figure out why. $(function() { //load addfood.php div user-main //this works , div hidden when addfood.php loaded page $("a[name=search]").click(function() { $(".user-main").load("addfood.php", function(){$("#addfood .addfood-body").hide();}); // here link clicked inside newly loaded div slidedown hidden div // div slides down comes right after $('a[name=openaddfood]').live('click', function() { if ($("#addfood .addfood-body").is(":hidden")) { $('img[name=openaddfood]').addclass('rotate'); $('#addfood .addfood-body')

Reading client side text file using Javascript -

i want read file (on client side) , content in array. 1 file. have following , doesn't work. 'query_list' textarea want display content of file. <input type="file" id="file" name="file" enctype="multipart/form-data"/> <script> document.getelementbyid('file').addeventlistener('change', readfile, false); function readfile (evt) { var files = evt.target.files; var file = files[0]; var fh = fopen(file, 0); var str = ""; document.getelementbyid('query_list').textcontent = str; if(fh!=-1) { length = flength(fh); str = fread(fh, length); fclose(fh); } document.getelementbyid('query_list').textcontent = str; } </script> how should go it? want loop on array , run sql queries. i

ruby - Problem on Rails fixtures creation sequence -

i reading book rails sitepoint , given these models: story.rb class story < activerecord::base validates_presence_of :name, :link has_many :votes def latest find :all, :order => 'id desc', :limit => 3 end end def to_param "#{id}-#{name.gsub(/\w/, '-').downcase}" end end vote.rb class vote < activerecord::base belongs_to :story end and given fixtures stories.yml one: name: mystring link: mystring two: name: mystring2 link: mystring2 votes.yml one: story: 1 two: story: 1 these tests fail: story_test.rb def test_should_have_a_votes_association assert_equal [votes(:one),votes(:two)], stories(:one).votes end def test_should_return_highest_vote_id_first assert_equal votes(:two), stories(:one).votes.latest.first end however, if reverse order of stories, first assertion , provide first vote first assertion, passes story_test.rb def test