Posts

Showing posts from February, 2012

Finding memory leaks in a C++ application with Visual Studio -

in linux, have been using valgrind checking if there memory leaks in application. equivalent in windows? can done visual studio 2010? visual studio assists in finding memory leaks. link should helpful.

ajax - use ajaxStart and ajaxStop jquery methods only for some of requests -

i use ajaxstart , ajaxstop jquery methods show , hide loading message when request send via ajax . following code : $('<div><img src="images/searching.gif" align="absmiddle" border="0" />please wait ...</div>') .attr('id','loading') .appendto('body') .ajaxstart(function() { $(this).animate({ top : '40px', opacity : 1.0 }, 500); }) .ajaxstop( function(){ $(this).animate({ top : '-75px', opacity : 0.1 }, 500); }); but don't want loading show requests , show of specific request . have solution problem ? separate lines of code create loader images , bind ajax events differentiate between images r...

javascript - Popunder that works on all browsers -

i using window.open(url).blur() window.focus() but works in chrome. in ie window comes when it's done loading. in firefox, window not go under @ all. don't worry, popunder not going annoying user expect it/want it. you use jquery ui's dialog achieve similar results.

php - Add Images to google MAP -

i have website contains google map.i need pin images particular place in map. possible add programetically images map. example, if data base contains image location , details of place want add.i need add images database corresponding placed in map. if possible google api can use purpose.my developing environment lamp. thanks, companion. yes. they're called info windows , attached markers. google maps api reference detailed , full of samples code. http://code.google.com/apis/maps/documentation/javascript/overlays.html#infowindows your php code output (echo) javascript add appropriate markers map.

Google Map API 3: dynamic circle with zoom level -

in google maps v3, possible have dynamic circle based on zoom level, example, in zoom level 1, radius of circle 5m, while in zoom level, radius become 20m? thanks in advance! if right have manually. create circle in body of zoom_change() event of map everytime user changes zoom.the radius of circle depends on logic of application

python - How to disable Django's CSRF protection behind a proxy -

i need run django system (let's call alfred) behind proxy. both on same network. proxy use yuri vandermeer's django-httpproxy. (see page yvandermeer.net) both systems running django version 1.2.4 both systems in same (closed) network , on same ip. have proxy running on port 8000 , alfred on port 1337. need log on alfred using /admin site, comes default django (and have enabled). working via port 1337, need access via port 8000. when try it, alfred throwing 403 csrf error , telling me i'm acutally man-in-the-middle (- , alfred right when saying so). i tried several things disable alfreds csrf protection: i commented out csrfviewmiddleware in settings.py in middleware_classes i created disable.py , added disablecsrf class middleware classes (actually tried each[!] position) mentioned on site (questions/1785772 ) #disable.py class disablecsrf(object): def process_request(self, request): setattr(request, '_dont_enforce_csrf_checks', true) ...

tsql - Automatic "Script database as... create" for SQL Server 2008 -

i'd make daily automatic creation of creation script database in sql server 2008, meaning having (bat, exe, ... whatever) creates text file same output obtained right-clicking on database in sql management studio , script database as... --> create to... --> new query window. any hint? thanks in advance, mauro edit 1: used smo couple of things annoying needs compatibility pack in sql server 2008 (confirm?) some things not created in script (some indexes , keys , in table creation schema lost) best choice me powershell script other idea welcome! you can use smo. example: http://www.sqlteam.com/article/scripting-database-objects-using-smo-updated (see scripting objects section). more info on smo: http://msdn.microsoft.com/en-us/library/ms162169.aspx

For-loop inside a For-loop - ListArrays - Android, Java! -

this noob question have ask anyway because think i'll go crazy soon. what want achieve listview populates twitter , have implemented, 2 listarray s gets populated tweet , picture url. successful, when refresh twitter new pile of twitter gets below old ones. i clear listarrays twitter disappears in list not desirable, want add new tweets, , make new tweets on top of list. so guess 2 fold question how make list add not there?, and how make latest tweet appear on top? could use great input, code below essential part of (messy) code, refresh method. public void updatetwitter(){ twitter = new twitterfactory().getinstance(); try { queryresult result = twitter.search(new query(tweetquery)); tweets = result.gettweets(); (tweet tweet : tweets) { string tweetprofile = tweet.getprofileimageurl(); string twwwwww = tweet.gettext(); for(string tww : tweetstring){ ...

Facing problems with java.awt.Desktop in 64 bit JVM? -

i'm trying use java.awt.desktop class in application solaris amd64 machine. find desktop class not supported in 64bit jvms. public class tester { public static void main(string args[]) { system.out.println(desktop.isdesktopsupported()); } } - % java -d32 tester desktop supported : true % java -d64 tester desktop supported : false am missing here? many in advance!

Hadoop Input files Order -

i have data files arranged in folders named dates. directory structure /data/2011/01/01 /data/2011/01/02 and on , inside each directory there around 50 files need parsed , giving input hadoop /data/** /** /** can parse files. questions are how can ask hadoop order input. need parse files date date. while parsing files of particular date, need pre load datastructure associated date , in same date directory. thanks ankush you can't order input. in "worst case" scenario if have same number of input files have running tasks in cluster processed @ same moment in parallel. perhaps can create custom implementation of "fileinputformat" reads required config file , need?

C++ destructor: when the memory gets freed? -

if delete object causes destructor called, memory freed before or after destructor has finished doing whatever there in function? memory freed once least derived class subobject has been destroyed. if have: class base { }; class derived : public base { public: ~derived(); }; then first derived destroyed, base destroyed , memory deallocated.

WPF - reset ListBox scroll position when ItemsSource changes -

i have listbox itemssource collection bound property on viewmodel, of type ienumerable. when preoprty's reference changes, listbox updates expected, have problem in if have large collection of items , scroll bottom of listbox, , change reference collection containing, say, 1 item, listbox view blank , no scrollbar displayed. have scroll listbox mouse wheel, until 1 item comes view. so, think i'm after, way of resetting scroll position of listbox top, whenever itemssource property changes, displayed no matter how large or small collection. i'm unable reproduce problem (for me, listbox scrolled last item in new collection when changing itemssource ). anyway, scroll listbox top every time itemssource changes can use code behind. first listen changes in itemssourceproperty , scroll listbox top once items has been generated update made attached behavior instead avoid code behind. can used this <listbox ... behaviors:scrolltotopbehavior.s...

Setup of Facebook-C#-SDK in Visual Studio and Facebook -

i'm using http://facebooksdk.codeplex.com/wikipage?title=getting%20started&referringtitle=documentation can used localhost , visualstudio 2010 websever debug? why stuff hard? i've downloaded sample , i'm trying csaspnetfacebookapp web project work. keep getting redirected link this: server error in '/csaspnetfacebookapp' application. the resource cannot found. description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly. requested url: /csaspnetfacebookapp/facebookredirect.axd/csaspnetfacebookapp/default.aspx thanks enter code here your time: my config looks this: <httphandlers> <add verb="*" path="facebookredirect.axd" type="facebook.web.facebookappredirecthttphandler, facebook.web" /> </httphandlers> <add name=...

Parse error in PHP array -

$labels = ( 'steam' => 'steam', 'bore_water' => 'bore water', 'boiler1oil' => 'boiler 1 oil', ); parse error: syntax error, unexpected t_double_arrow on line 32: 'steam' => 'steam', can spot issue this? $labels = array( 'steam' => 'steam', 'bore_water' => 'bore water', 'boiler1oil' => 'boiler 1 oil', );

windows phone 7 - Merging dll's for winphone 7 -

i read thread on forum "how can use ilmerge windows phone 7 assemblies?" saying ilmerge did not support wp7. tried myself, , got same result. not seem work. unless i'm doing wrong! is there other way merge several dll's one, cannot find tool (besides ilmerge, , netz both seem handle .net only). have wp7 project in c# produces 5 dll's. merge them single one. easier handle people writing application on top of them. i using ms visual studio 2010 express windows phone. would thankful advice! i'm managed il merge wp7 assemblies , i've bogged here hope helps someone...

javascript - Ajax not working in firefox without alert -

function processajaxstatechangeforrowadd() { alert(0); if (req.readystate == 4) { // complete if (req.status == 200) { // ok response processforrowadd(req.responsetext); } else { alert("problem: " + req.statustext); } } } this code working fine ie, safari , firefox, if remove alert , code not work in firefox, though still works in ie , safari. can give me suggestion why not working in firefox without alert? edit: code adds row: if (window.xmlhttprequest && browserversion.indexof("microsoft") == -1 ) { // code firefox, chrome, opera, safari req = new xmlhttprequest(""); if (req) { ajaxprocessed = false; req.onreadystatechange = processajaxstatechangeforrowadd; req.open("post", url, true); req.send(); // alert("1"); } } the alert blocking. means script temporarily suspended (even if it's ...

Best practice for creating SQL Server databases for a data warehouse -

i'm create 2 new sql server databases our data warehouse: datawarehouse - data stored datawarehouse_stage - etl done i'm expecting both databases able 30gb , grow 5gb per year. not bigger 80gb (when we'll start archive). i'm trying decide settings should use when creating these databases: what should initial size be? ...and should increase database size straight after creating it? what should auto-growth settings be? i'm after best practice advice on creating databases. update: reason suggest increasing database size straight after creating it, because can't shrink database less initial size. •what should initial size be? 45gb? 30 + 3 years grow, given fits on low end cheap ssd disc ;) sizing not issue if smallest ssd 64gb. ...and should increase database size straight after creating it? that sort of stupid, or? mean, why create db small size jsut resize immedieatley after, instead of putting right size script in f...

msbuild ITaskItem output -

i'm trying use msbuild.extensionpack.web.iis7apppool task getinfo task action. task's output parameter siteinfo property, type itaskitem. propery, not collection. how can access siteinfo metadata? can access $, can web site name. tried use %(siteinfo.) no success. if output parameter itaskitem , want access metadata need assign itemgroup instead of property. <target name="test"> <msbuild.extensionpack.web.iis7apppool taskaction="getinfo" name="defaultapppool"> <output taskparameter="apppoolinfo" itemname="poolinfo" /> </msbuild.extensionpack.web.iis7apppool> <message text="apppool info = [@(poolinfo)]" /> <message text="apppool maxprocesses = [%(poolinfo.maxprocesses)]" /> <msbuild.extensionpack.web.iis7website taskaction="getinfo" name="default web site"> <output t...

syntax - C# is there a foreach oneliner available? -

i want know if there foreach oneliner in c#, if oneliner ( exp ) ? then : else . if you're dealing array can use built-in static foreach method: array.foreach(yourarray, x => console.writeline(x)); if you're dealing list<t> can use built-in foreach instance method: yourlist.foreach(x => console.writeline(x)); there's nothing built-in that'll work against arbitrary ienumerable<t> sequence, it's easy enough roll own extension method if feel need it: yoursequence.foreach(x => console.writeline(x)); // ... public static class enumerableextensions { public static void foreach<t>(this ienumerable<t> source, action<t> action) { if (source == null) throw new argumentnullexception("source"); if (action == null) throw new argumentnullexception("action"); foreach (t item in source) { action(item); } } }

C# WCF Video Streaming from growing file? -

been pulling hair out on should have been quick , easy task. i have self-hosted wcf service in need implement real-time video transcoding, transcoding isn't problem such, using ffmpeg local temp file. quick sample of code looks like; public stream streammedia(int a) { string input = @"\media\" + + ".mkv"; string output = @"\temp\transcoded\" + + datetime.now.ticks.tostring() + ".wmv"; processstartinfo pi = new processstartinfo("ffmpeg.exe"); pi.arguments = "-i " + input + " -y -ab 64k -vcodec wmv2 -b 800k -mbd 2 -cmp 2 -subcmp 2 -s 320x180 -f asf " + output; process p = new process; p.startinfo = pi; p.start(); thread.sleep(2500); return new filestream(output, filemode.open, fileaccess.read, fileshare.readwrite); } the problem facing returned stream gives me written file when returned - resulting in rather short video file :) i've played around obvious here...

Javascript "MULTIPLE Selection" Select box validation? -

i have multiple selection select box. need validated using javascript, should prompt select atleast 1 value. below multiple select box have. <select name="usrgrp[]" multiple="multiple" size="3"> <option value="11">abc</option> <option value="12">def</option> <option value="13">ghi</option> </select> please me write validation javascript select box. if (referencetoform.elements["usrgrp[]"].selectedindex == -1) { alert("please select item."); }

Is there a swedish language pack for EPiServer Relate+ 2.0? -

i've looked everywhere, can't find languages relate+ anyone got clue? i've included link gist translation relateplussv.xml

c# - How to use app settings with class libraries on winforms? -

if create app.config main app, can use using: string test = properties.settings.default.libtest; where on app.config can find: <applicationsettings> <rmanager.properties.settings> <setting name="libtest" serializeas="string"> <value>ola lib</value> </setting> </rmanager.properties.settings> the question is, if have class library, there way access same setting using: string libstring = properties.settings.default.libtest; if not, solution best access settings main app? i'd it's not correct if libruary can property main app. i'd suggest folowing: create static class (f.e. settingsmanager) in libruary (or in common lib), , after application started fill data appconfig common static class (settingsmanager). , class(settingsmanager) property can use in app , in dll. if dll , app has lot of bindings, should consider taking source dll exe app, in case able access app.config setting...

user interface - MS UI Automation not working on 3rd party ERP app -

i'm trying integrate mvc 2 project 3rd-party win32 .exe erp system. i'm trying field scrape mvc app , push data erp client. mvc front-end more stable , user-friendly erp client. don't know language erp client written in, client-server app runs on unix box, , uses obselete back-end database (pick). i've used ms ui automation load process of erp client, elements finding standard window elements (title bar, context menu, minimize, maximize, close). client erp loaded text boxes, buttons, pick lists...but ui automation doesn't recognize of them. can give insight why controls aren't recognized, , how might work around that? (and more helpful) can recommend open-source, mid-sized erp system? thanks! it quite possible ui controls not have window handles. visual foxpro applications had same issue. custom controls did not use underlying os controls window handles. as far open source erp, take @ http://www.xtuple.com/

javascript - Logic for Gold, Silver, Bronze -

i'm building game in javascript , have results generated. var score = array("5", "5", "1"); so player 1 has score of 5, player 2 score of 5 , player 3 score of 1. i want display results 3 levels - gold, silver , bronze, if top 2 results same want them both gold, leaving lowest score silver. what best way work out using javascript? ideally results array particular set of scores this: var results = array("gold", "gold", "silver"); thanks. here's code doing it: var scores = [5, 8, 1]; scores.sort(function(a, b) { return (a > b) ? 1 : ((a < b) ? -1 : 0); }).reverse(); var medals = {}; var medalsused = 0; var availablemedals = ['gold', 'silver', 'bronze']; for(var = 0; < scores.length; i++) { var score = scores[i]; var medal; if(medals[score]) { // have medal score value? use medal = medals[score]; } else { // use next available me...

email - DKIM verification and canonicalization of leading double dots -

just wondering how can verify dkim signature? using popular service gmail, yahoo mail or hotmail (if supports dkim)? also, when transfer email quoted printable in smtp, leading dot converted two, considered 1 or 2 dots when calculate body hash? 1 specification, in [rfc 4871], page 25, stated, dot-stuffing should consider 1 dot. many thanks. maybe help? http://www.mydigitallife.info/2007/08/08/how-to-check-test-and-validate-spf-record-in-dns-is-correct-and-valid/

crystal reports - Show data from quarterly records in a single row -

each quarter's sales data contained in row in data source. account 1's 4 quarters of sales data in 4 separate records, each containing account name, quarter number, , count of items purchased. the report should show, in each detail row: account name, q1 count, q2 count, q3 count, q4 count, total year count. i'm new crystal, seems should easy; how this? i'd create result list using complex sql , display on crystal report...but if you're wanting accomplish entirely inside crystal, take @ http://aspalliance.com/1041_creating_a_crosstab_report_in_visual_studio_2005_using_crystal_reports.all . here's stab @ sql required... select accountname, (select sum(itemcount) mytable quartername = 'q1') q1count, (select sum(itemcount) mytable quartername = 'q2') q2count, (select sum(itemcount) mytable quartername = 'q3') q3count, (select sum(itemcount) mytable quartername = 'q4') q4count, (select sum(itemcount) mytable...

html - Page layout acting strangely -

if go on website, lookaroundyou.net , click on usa (which there more video's anywhere else on site), websites layout changes completely. does have idea why happens? it's causing scrollbar because there more videos.

javascript - ajax positioning -

i have ajax code displayed in div @ top , left side of div, how can position ajax animation in middle , center of div? <script language="javascript"> function visiontype_kamp(type,_link_) { var url_str = "index.cfm?fuseaction=objects2.emptypopup_get_vision_tabbed&is_property_vision="+type+"&&vision_position=1&mode=1&dongu=9&is_sale=0&vision_image_display=1&is_vision_prices=1&is_vision_product_name=1&is_vision_product_detail=1&is_vision_product_detail2=0&vision_image_width=50&vision_image_height=45&this_row_id_=kamp" ajaxpageload(url_str,'vision_icerik_kamp' ,0,'',_link_); } </script> and div: <div id="vision_icerik_kamp"></div> it simple if div has predefined dimensions, assume not means has no dimensions there si no way of finding such thing middle, you've got center ...

string - Base64 in C# and PL/SQL? -

in pl/sql how can convert string (long html string new line , tags, etc) base64 easy decrypt in c#? in c# there are: convert.tobase64string() convert.tobase64chararray() bitconverter.tostring() which 1 compatible pl/sql utl_encode.base64_encode(); ? i welcome other suggestions :-) you'll want use method: convert.tobase64string() it returns base64 encoded string based off array of unsigned 8-bit integers (bytes). as alternate, can use convert.tobase64chararray() , output character array, bit odd may useful in circumstances. the method bitconverter.tostring() returns string, bytes represented in hexadecimal, not base64 encoded.

asp.net mvc - Setting SMTP on IIS Express -

i wonder if me setting smtp on iis express. from understanding iisexpress supports http , https - doesn't include ftp or smtp support this full documentation on iis express http://learn.iis.net/page.aspx/860/iis-express/

php - create cron job from another cron job -

good day all. need this: create cron job (no problem here) the cron executes php script if condition met need create cron using date returned script i have root access , everything. os centos 5.5 (even thought don't think matters long crons supported) to more specific need cron executes php script gets exact moment of time database (hours, minutes, seconds) when execute script. database can updated @ moment. first job executed once every 10 minutes. you can create /etc/cron.d/generated crontab file in script add generated entries. file_put_contents('/etc/cron.d/generated', ' ... entry contents ...', file_append'); as suggested @the myyn in comment, at may solution too, if want execute script once. in php invoke this: system(sprintf('echo %s|at %s', escapeshellarg($command), escapeshellarg(date('h:i d.m.y', $timestamp)) ); or this: $fd = popen(sprintf('at %s', escapeshellarg(date('h:i d.m.y...

java - Hibernate/JPA/Seam - Validate an Entity Programmatically? -

i have entity in jboss seam-based project makes use of hibernate validator annotations throughout. although i've got directives in jsf pages require elements, etc. i'd able 1 last failsafe validation before calling entitymanager.persist() , ending validation exception. is there way validate entity programmatically? i've never worked hibernate/jpa, i'd love hear recommendations getting working. thanks! bean validation api supports programmatic usage, see, example, hibernate validator reference .

javascript - window.onbeforeunload not working in chrome -

possible duplicate: window.onbeforeunload not working in chrome window.onbeforeunload=function(); not working in chrome.. works ie , mozila not works chrome.. there way use window.onbeforeunload=function(); in chrome......... in advance....... i have tested following in chrome , works... window.onbeforeunload = function () { alert("hello"); };

gps - Getting Location in Android for different activities -

i developing app wich uses gps in many activities. @ first thought of implementing locationlistener in each activity. wonder if possible better aproach problem having service gps. think right path follow? thanks lot. d. you can create base activity class implements locationlistener interface, , have location-aware activities subclass base activity. since only 1 activity active , in foreground @ time, there's no waste of resources here. (assuming register in onresume, , call removeupdates in onpause instance)

binary - How can I see the 0s and 1s / machine code from a executable file / object file? -

i tried this, opened a.out file text editor bunch of characters instructions in like: üÙ try hexdump . like: $ hexdump -x a.out it give that: hexadecimal dump of file. having said that, possibility might include using gdb's disassemble command .

javascript - Scriptaculous effect.slideup jerky in firefox -

i have simple effect.slideup("div_name") using scriptaculous in rails app. placed div within div mentioned guy (http://goingspare.wordpress.com/2007/08/03/fix-jerky-scriptaculous-scriptaculous-animation-effects/) , works great ... in chrome. however, in firefox div jerky , looks ugly-assed. suggestions on how solve this? should looking jquery? here code: new thread | new comment new comment <div id="create_thread" style="display:none"> <div id="new_thread_or_comment_inner"> new thread <br /> <% remote_form_for :commentthread, :url => { :action => 'createthread' } |f| %> <textarea name="commentthread[text]" id="commentthread_text" > </textarea> <a href="javascript:cancelthread()" class="button">cancel</a> <input type=...

Java Game Engines -

i have been looking game development , first programming language java. after playing many stunning games developed in c++ wondered why java not heavily used in games industry. looked @ jmonkeyengine 3 , few other game engine environments screenshots saw far less stunning. titles need speed hot pursuit form ea , assassins creed ubisoft convey such realism. why can't java produce such industry strength games ? art work? java , c# has automatic garbage collection , c++ doesn't. programmer has pay closer attention memory usage avoud dangling pointers , on. thanks guys. java , c# has automatic garbage collection , c++ doesn't. programmer has pay closer attention memory usage avoud dangling pointers , on. you have answered question. in games programming garbage collection not advantage. if performance of java more or less in par c++ tasks, , jit can aggressive optimizations beat can done during static analysis; garbage collection can make frame...

mysql - Selecting all columns that start with XXX using a wildcard? -

Image
i have several columns in databases similar names. how select based on word start with? here's example table layout: i tried selecting info particular thing (food kind in example) using $food = "vegetable"; mysql_query("select `" . $food . " %` `foods`"); but didn't seem work. any appreciated :-) edit: apparently wasn't clear example, know column's first words. columns same , no 'food kinds' ever added or deleted. php variable there determine 1 of couple of set kinds need. there's no way you're trying to. query first fetch column names, process them in php , build second query, that's more complex writing out names want. or there reason query needs dynamic? table's structure change often?

python - Webpy: how to set http status code to 300 -

maybe stupid question cannot figure out how http status code in webpy. in documentation can see list of types main status codes, there generic function set status code? i'm trying implement unapi server , it's required reply 300 multiple choices request identifier. more info here thanks! edit: discovered can set through web.ctx doing web.ctx.status = '300 multiple choices' is best solution? the way web.py 301 , other redirect types subclassing web.httperror (which in turn sets web.ctx.status ). example: class multiplechoices(web.httperror): def __init__(self, choices): status = '300 multiple choices' headers = {'content-type': 'text/html'} data = '<h1>multiple choices</h1>\n<ul>\n' data += ''.join('<li><a href="{0}">{0}</a></li>\n'.format(c) c in choices) data += '</u...

php - How do i pull data from one table and insert it into a column in another table? -

the title little under specific best explain in 1 line. my problem basically, have table in db query with; <?php include 'connect.php'; $query = mysql_query("select * mobs zone='darnolth' order lvl ") or die(mysql_error());; echo "<table border='1' cellpadding='2' cellspacing='0' width=800 id='mob' class='tablesorter'><thead>"; echo "<tr> <th> </th> <th>mob name</th> <th>level</th> <th>health</th> <th>drops</th> <th>effects</th> <th>zone</th></tr></thead><tbody>"; while($row = mysql_fetch_array( $query )) { echo "<tr><td>"; echo $row['image']; echo "</td><td width=200>"; echo $row['mobname']; echo "</td><td width=50>"; echo $row['lvl']; echo "...

What is the best way to write a large file to disk in PHP? -

i have php script needs write large files disk. using file_put_contents() , if file large enough (in case around 2 mb), php script runs out of memory (php fatal error: allowed memory size of ######## bytes exhausted). know increase memory limit, doesn't seem full solution me--there has better way, right? what best way write large file disk in php? you'll need temporary file in put bits of source file plus what's appended: $sp = fopen('source', 'r'); $op = fopen('tempfile', 'w'); while (!feof($sp)) { $buffer = fread($sp, 512); // use buffer of 512 bytes fwrite($op, $buffer); } // append new data fwrite($op, $new_data); // close handles fclose($op); fclose($sp); // make temporary file new source rename('tempfile', 'source'); that way, whole contents of source aren't read memory. when using curl, might omit setting curlopt_returntransfer , instead, add output buffer writes temporary file: ...

html - With a hidden element, you reference the ID to get the posted value, what is name for then? -

with hidden element, reference id posted value, name then? just wondering, have add attribute in html? with form element, including hidden type ones, name of element used name posted value. you have add name attribute.

python - Django: Default ordering based on a many-to-many related field values and counts -

models following: class weekday(models.model): ''' >>> w in weekday.objects.all(): ... print w ... sunday monday tuesday wednesday thursday friday saturday ''' name = models.charfield(max_length=9) def __unicode__(self): return self.name class stop(models.model): class meta: ordering = ???? name = models.charfield('stop name', max_length=32) days_open = models.manytomanyfield(weekday) the kind of ordering want is: everything has 7 days everything has sunday everything has monday etc, etc. (with tie breaker being count of weekdays , stop's name) anyone have suggestions on how approach this? should done in manager somehow? or perhaps there's simple way this? appreciate it! you can specify model fields in meta.ordering , if want implement logic described, have resort custom manager . edit: you add kind of weight field st...

Do .Net embedded resources have a size limit? -

i'm trying embed several files .net dll, 1 of them isn't showing in list of embedded resources, , don't see obvious explanation. special thing file is 77kb in size, , other files < 20kb. there limit size of resources can embedded? i googled didn't find answer (maybe don't know how google it). any answer appreciated. thanks! i use embedded resources quite bit. quick search of code found @ several on 200kb. are sure build action set "embedded resource"? can give more details of how attempting access embedded resource? you can open assembly in reflector view of embedded resources.

com - 32 and 64 bit interoperability on 64-bit Windows -

is there thorough authoritative reference discusses interoperability between 32-bit , 64-bit processes? based on googling have deduced that: a 32-bit dll can reside in 32-bit process, , 64-bit dll in 64-bit process. 32 , 64-bit processes can communicate using loosely coupled message systems, such network communications, means can communicate using com/dcom. 32 , 64-bit com components have different registry entries. component typically registered in 1 of 2 , typically seen in 1 of 2 worlds. a 32-bit process can create registered 64-bit com component if uses cocreateinstance 64-bit invocation flag, or (and guessing on one, possible?) if 64-bit component somehow registered in 32-bit registry under hood still created out of process 64-bit process, or if there 32-bit shell com component creates 64-bit component , redirects calls it? this suggests that: 1. 32-bit application can not use getobject hold of 64-bit version of excel running? or can it? how running object table (rot)...

functional programming - Python list comprehension -

possible duplicate: list comprehension running total i'm trying write concise list comprehension statement create cdf: example: print f([0.2, 0.3,0.1,0.4]) [0.2,0.5,0.6,1.0] a standard procedure (i want write list comprehension function f()): def f(probabilities) : sum = 0 returnlist = [] count in probabilities: sum +=count returnlist = returnlist + [sum] return returnlist edit: found function numpy.cumsum(). i'll check if uses list comprehensions. that operation common many languages (mainly functional ones, not only) provide abstractions it, name scanl (it's reduce intermediate results). let's call ireduce ("iterative reduce"): def ireduce(f, state, it): x in it: state = f(state, x) yield state and use it: import operator def f(probabilities): return ireduce(operator.add, 0, probabilities) print(list(f([0.2, 0.3,0.1,0.4]))) # [0.2, 0.5, 0.6, 1.0]

Warnings in Perl Eval -

i need hide warnings within eval rest of code should continue throw warning messages. here have - eval "\$value = $hash->{key}"; now value of $hash->{key} function call, like: $hash->{key} = "function(0.01*$another_var)"; the problem comes when $another_var undef (or "" ). script craps out following message - argument "" isn't numeric in multiplication (*) @ (eval 1381) line 1. any suggestions how can avoid this? 1 option thinking parse value inside parenthesis , evaluate first, quite complex data dealing with. wrap code in no warnings block. ... { no warnings; eval "\$value = $hash->{key}"; } ... you can disable specific classes of warnings. see perllexwarn hierarchy of warning categories , perldiag category particular warning belongs to. { no warnings qw(uninitialized numeric); eval "\$value = $hash->{key}"; } (blah blah blah standard disclaime...

C++ 307 Errors when trying to include winhttp.h in visual studio 2010 -

i have big big problem. i'm trying use winhttp download file c++ , i'm using visual studio 2010 in order thing. my problem program not compiling because generated 307 errors, refering winhttp.h . mention have included file. problem? thanks! there some: ------ build started: project: a, configuration: debug win32 ------ b. cpp a. cpp c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. h(50): error c2146: syntax error: missing ';' before identifier 'hinternet' c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. h(50): error c4430: missing type specifier - int assumed. note: c++ not support default-int c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. h(50): error c4430: missing type specifier - int assumed. note: c++ not support default-int c: \program files (x86)\microsoft sdks\windows\v7.0a\include\winhttp. h(51): error c2143: syntax error: missing ';' before '*' c: \p...

overloading - C++ calling completely wrong (virtual) method of an object -

i have c++ code (written else) appears calling wrong function. here's situation: utf8inputstreamfrombuffer* cstream = foo(); wstring fn = l"foo"; documentreader* reader; if (a_condition_true_for_some_files_false_for_others) { reader = (documentreader*) _new gooddocumentreader(); } else { reader = (documentreader*) _new baddocumentreader(); } // crash happens inside following call // when baddocumentreader used doc = reader->readdocument(*cstream, fn); the files condition true processed fine; ones false crash. class hierarchy documentreader looks this: class genericdocumentreader { virtual document* readdocument(inputstream &strm, const wchar_t * filename) = 0; } class documentreader : public genericdocumentreader { virtual document* readdocument(inputstream &strm, const wchar_t * filename) { // stuff } }; class gooddocumentreader : public documentreader { document* readdocument(inputstream & strm, const wchar_t...

Timing touches on an iPad -

i've been looking try , measure time between touch events (looking @ uitouch class). on uitouch class there timestamp property gives time in seconds. for application looking @ able measure in milliseconds. thanks just multiply timestamp 1000 , have milliseconds. timestamp property defined nstimeinterval typedef double .

directory - Android writing to a text file -

i have text file within raw folder of app intend use simple way save settings , read them when needed. can read file using bufferedreader , comes it, i've tried few different ways able write file , none seem work. it seems me problem never file, , assume because don't know how supposed give correct directory , file name. i've tried come with, , tend errors "no such file or directory exists" or "read-only file system". this seems simple problem relating me giving wrong information, if point me in right direction appreciated. thank you, raphy for saving settings should use sharedpreferences rather coming custom solution. sharedpreferences documentation data storage

How to handle a n:m relation correctly with PHP&MySQL? -

i've got 3 tables: +-----------------+ | validations | +----+-------+----+ | id | param | ... +----+-------+ +------------------+ | replacements | +----+-------------+ | id | replacement | +----+-------------+ +--------------------------------+ | validations-replacements | +---------------+----------------+ | validation_id | replacement_id | +---------------+----------------+ now i'm running sql query on tables (with joins of course). , receive in php sth. that: ... [6] => stdclass object ( [id] => 11 [search_param] => dänische belletristik [replacement] => denmark ) [7] => stdclass object ( [id] => 11 [search_param] => dänische belletristik [replacement] => fiction ) ... now, in php-array i've got same 'search_param' , 'id' multiple times. sucks printing screen. group data 'id' avoid that, i've got 1 'replacement' value available. what i'm looking re...

php - how to check, if the server can handle curl connection thru proxy AND validate proxies from the list? -

how check, if server can handle curl connection thru proxy , validate proxies list? curl requests can simulate normal request browser, there no difference on how servers respond curl. whether or not server accepts proxy connection depends on if proxy transparent or not. transparent proxy disguises there no evidence connection coming proxy. non-transparent proxy provide x-proxy-* headers in http request. to test whether proxy works, set curl_proxytype type of proxy using, curl_proxy option proxy host, , curl_proxyport proxy's port.. , make normal request.

php - Find a percentage value in a string using preg_match -

i'm trying isolate percentage value in string of text. should pretty easy using preg_match, because percentage sign used operator in preg_match can't find sample code searching. $string = 'i want 10% out of string'; what want end is: $percentage = '10%'; my guess i'll need like: $percentage_match = preg_match("/[0-99]%/", $string); i'm sure there quick answer this, solution evading me! if (preg_match("/[0-9]+%/", $string, $matches)) { $percentage = $matches[0]; echo $percentage; }

jquery - modal popup code placement -

is possible separate actual popup message page called from? examples have found contain call popup.js file , div containing message on same page. i'd able maintain separate page message, having trouble implementing. thank you. you can use ajax load content modal. use callback trigger showing of modal after content loaded. $('#modal-content').load('path/to/content.html', function() { $('#modal').show(); } where modal-content div wish place content in, , modal modal wrap wish show.

iis 7 - how to deny access to bot accessing an iis 7 -

on iis7 machine, getting requests these: get /scripts/){f.html(e o( 80 - 188.109.xxx.xxx java/1.4.1_04 /scripts/]||!o.support.htmlserialize&&[1, - 80 - 188.109.xxx.xxx java/1.4.1_04 /scripts/);c.extend(this,{_aspectratio:!!(j.aspectratio),aspectratio:j.aspectratio,originalelement:this.element,_proportionallyresizeelements:[],_helper:j.helper||j.ghost||j.animate j.helper|| 80 - 188.109.xxx.xxx java/1.4.1_04 /scripts/,e).html(j).prependto(f);f.find( - 80 - 188.109.xxx.xxx java/1.4.1_04 /scripts/,f.html()).html(g.spinner)}this.xhr=a.ajax(a.extend({},g.ajaxoptions,{url:d,success:function(i,h){a(c._sanitizeselector(b.hash)).html(i);c._cleanup();if(g.cache){a.data(b, - 80 - 188.109.xxx.xxx java/1.4.1_04 /scripts/,this.uidialogtitlebar).html(f|| - 80 - 188.109.xxx.xxx java/1.4.1_04 can somehow deny access these? thanks. if iis logs include remote ip address, stuff reject or deny or block rules system's firewall drop them on floor before reach iis. i'd recomm...

How to set the default format for a route in Rails? -

with default routing, request /posts/:id gets mapped "show" action :format => "html" . using xhtml elements in show action don't rendered correctly unless :content_type set xml. getting around rendering show.xml.erb , setting content_type manually follows: format.html { render :template => "/posts/show.xml.erb", :locals => {:post => @post}, :content_type => "text/xml" } this seems silly though. how can change routes.rb /posts/:id routed format=>"xml" ? thanks. default format requests: you can set default format of given route xml using defaults hash. examples: # single match defaulting xml (/plots/1 same /plots/1.xml) match 'posts/:id' => 'posts#show', :defaults => { :format => 'xml' } # using resources, defaulting xml (all action use xml default) resources :posts, :defaults => { :format => 'xml' } # using resources , mixing o...

api - Is Facebook Client-Side Flow Authentication Secure? -

to perform user authentication , app authorization in desktop application, follow documentation given on http://developers.facebook.com/docs/authentication/ page. this in app: create dialog embedded web browser navigating to`https:// www.facebook.com/dialog/oauth?client_id=<my_app_id>&scope=offline_access&redirect_uri=http://www.facebook.com/connect/login_success.html&response_type=token url. if goes (user logs in , authorizes app), extract access token redirected url , store assuming value obtained long-lived token (notice offline_access permission). question 1: means finds out app-id , access token can misuse information? i mean getting app-id simple enough considering app .net based (reflector anyone?). , getting access token if encrypt or whatever not impossible. question 2: how make whole process secure enough? yes, imagine security issue; not application, facebook itself. if encrypt key, there need method through application decryp...

python - Accessing a value in a tuple that is in a list -

[(1,2),(2,3),(4,5),(3,4),(6,7),(6,7),(3,8)] how return 2nd value each tuple inside list? with list comprehension. [x[1] x in l]

Google App Engine: template not working when displaying html form -

in python code have the_button = '''<form action="/edit" method="get" > <input type="submit" name="edit" value="edit" /> </form>''' template_values = { 'the_button':the_button } path = os.path.join(os.path.dirname(__file__), 'the.html') self.response.out.write(template.render(path, template_values)) the problem when see in page show button non-clickable, when view page source of html doesn't show code. what problem? thanks! webapp escaping raw html. try add safe filter this: {{ the_button|safe }} from django documentation : safe marks string not requiring further html escaping prior output. when autoescaping off, filter has no effect. edit: unluckily google app engine out of box runs django 0.96 not have feature. have 2 options: install more recent version of djang...

javascript - sun.org.mozilla Rhino and extending Java abstract classes -

in sun.org.mozilla version of rhino, javaadapter takes interfaces first argument instead of other kind of class according error message: javax.script.scriptexception: sun.org.mozilla.javascript.internal.evaluatorexcep tion: javaadapter: first arg should interface class (<unknown source>#11) in <unknown source> @ line number 11 is there way, no matter how hacky, extend abstract class (or normal class matter) via rhino? here offending code: var j = new javaadapter(foo.bar.abstractclass, { field : "test", method : function () { print("on enable"); } }); the other answer correct sun version of rhino. it's not entirely clear phrasing of question if switching original (mozilla) rhino option or not. specifically, when sun added rhino java, " a few components have been excluded due footprint , security reasons ", , 1 of them mozilla's javaadapter. sun wrote own "javaadapter" smaller , sim...

c# - How do I use an XmlSerializer to deserialize an object that might be of a base or derived class without knowing the type beforehand? -

in c#, how use xmlserializer deserialize object might of base class, or of of several derived classes without knowing type beforehand? all of derived classes add additional data members. i've made simple gui can serialize , deserialize class objects. serialize objects whatever inherited class (or base class) appropriate based on fields user chooses populate. i have no issues serialization; problem deserialization. how can possibly have xmlserializer deserialize data correct derived class without knowing class beforehand? create xmlreader read first node of xml file , determine class it, , seems work purposes, seems extremely inelegant solution. i've posted sample code below. suggestions? basetype objectofconcern = new basetype(); xmlserializer xserializer; xmltextreader xtextreader = new xmltextreader(default_filename); { xtextreader.read(); } while (xtextreader.nodetype != xmlnodetype.element); string objecttype = xtextreader.name; xtextreader.close(); filest...

resize - jQuery : Add class dynamically depending on the browser window resolution -

hello friends trying add class body dynamically depending on browser window resolution. here code trying use need tuning dont know jquery @ all. the options want achieve : once visitor comes site, code must check browser windows size , add class body per following rules if window size more than 1024px but less than 1280px add class .w1280 . if window size more than 1280px but less than 1440px add class .w1440 . if window size more than 1440px but less than 1280px add class .w1680 . if window size more than 1680px add class .wlarge . to achieve this, trying use following script. questions are: is correct code ? if not correct code? is best shortest possible code? if not correct code? kindly knowledge of jquery zero. function checkwindowsize() { if ( $(window).width() > 1024) { $('body').addclass('w1280'); } else { $('body').removeclass('w1280'); } if ( $(window).width() ...