Posts

Showing posts from June, 2011

android - how to send email from hotmail and yahoo? -

i following answer no 8 following post: smtp sample code it working fine gmail. not working hotmail , yahoo. define following smtp server smtp server hotmail: smtp.live.com smtp server yahoo: plus.smtp.mail.yahoo.com how code work hotmail , yahoo? read : yahoo smtp settings , hotmail smtp settings note port numbers , other details for example, hotmail private string mailhost = "smtp.live.com"; and props.put("mail.smtp.port", "587"); props.put("mail.smtp.socketfactory.port", "587"); // because of ssl

c - Clarfication on pointer arithmetic -

*(*(p+a)+b) if a*size added address (p), why b*size added *(p+a)? *(p+a) appears value @ location , adding b*size change value, not address. however, based on read meant added address. given expression, , assuming you're talking c, p must pointer pointer. happens is: char ** p; int = 2; int b = 4; (p+a) // adds 2 * sizeof(char *) *(p+a) // evaluates char * char * c = *(p+a) (c+b) // adds 4 * sizeof(char) *(c+b) // evaluates char

How to create authentication ticket from asp.net for sharepoint 2010? -

i have asp.net website , sharepoint 2010 web application running on 2 different sub domains of same main domain. e.g. asp.net website domain aspnet.company.com , sharepoint website domain sp.company.com. i have login page on asp.net website, want issue authentication ticket sp web application user not have log in again when navigating 1 another. i tried doing using same <machinekey /> element, have indicated name="company.com" in <forms /> element. still no luck. though know possible way sp2007. i guess not work because sp2010 uses claims. can please how can done? thanks. tengiz i able solve problem. please read answers , explanations on forum (because first place gave answer on this): authentication cookie sharing between share point 2010 , asp.net 4. cheers! tengiz

c# - MSChart Control -

i have mschart control in windows form, coding in c#. have array of data populate chart. needing following these: make chart show in 10 second frames, data total around 15 minutes or more, want chart show x axis on 10 second scale. i needed implement scroll bar on bottom of chart, click show me next 10 second frame. start off showing first 10 second frame, next ones, (10 - 20, 20 - 30, etc) in each 10 second frame need plot 170 data items array. next 10 second frame show next 170 data items, , continue end. here snipplet of done far #region setupchart() public bool setupchart() { try { this.view.chart.chartareas[0].axisx.scaleview.size = 10; return true; } catch { return false; } } #endregion #region draw() public bool draw() { try { view.data = this.dllcall.getdata(1); int startsecond = 0; foreach (int16 item in view.data)

xcode - only one circle on iphone simulator! -

how can 1 finger(circle) on iphone simulator!? is there other way moving 2 circles closer!(overlapping 2 circles)? im able 2 circles holding opt button! want 1 circle.. thanks in adv., there product called simfinger circle you. assuming trying make screencast. blog linked has other tips tweaks make screencasts on simulator.

scala - Implicits, pimpl pattern etc -

let's have these classes: case class a() case class b() case class c(a: a, b: b) and these variables: val = a() val b = b() is there way instance of c implicitly , without making a , b implicit vals? i.e. if have method expecting c : def foo(c: c) the case class a notation deprecated. have use case class a() , otherwise assigning a val a result in a referring companion object of case class a generated behind scene. it's understanding wanted a refer instance of case class, not companion object. if so, you're asking possible - a , b don't have implicit, have add new implicit method scope: implicit def obtainc = new c(a, b) then, have put implicit modifier c in method foo : def foo(implicit c: c) complete session: scala> case class a() defined class scala> case class b() defined class b scala> case class c(a: a, b: b) defined class c scala> val = a() a: = a() scala> val b = b() b: b = b() scala> impli

c# - Check users ip on application load -

how ip of user on application start or load? , validate requested ip database you're looking request.userhostaddress property .

html - Use jQuery to swap/switch between 'div's? -

i using this guide sort out automatic image switching @ intervals. what i'd adapt (or new ideas) images links i've got (this structural purposes, link# , image# variables actual elements in code): <div id="mygallery"> <div class="active"> <a href="link1"><img src="image1" /></a> </div> <div> <a href="link2"><img src="image2" /></a> </div> <div> <a href="link3"><img src="image3" /></a> </div> </div> i tried changing bits in tutorial referenced img div . the difference first image took ages load , none of them 'clickable' links. here, script: <script> function swapimages(){ var $active = $('#mygallery .active'); var $next = ($('#mygallery .active').next().length > 0) ? $(&#

postgresql - How do you change the character encoding of a postgres database? -

i have database set default character set sql_ascii. want switch unicode. there easy way that? dump database drop database, create new database different encoding reload data. make sure client encoding set correctly during this. source: http://archives.postgresql.org/pgsql-novice/2006-03/msg00210.php

Starting new project: database abstraction in Python, best practice for retaining option of MySQL or PostgreSQL without ORM -

i want retain flexibility of switching between mysql , postgresql without awkwardness of using orm - sql fantastic language , retain it's power without additional overhead of orm. so...is there best practice abstraction database layer of python application provide stated flexibility. thanks community! while sqlalchemy great option. there others. if find sqlalchemy not liking here other orms may work out better you. of them more lightweight, may more you're looking for. http://coobs.eu.org/xrecord/ -- description sounds may looking for. sounds pretty lightweight , database abstraction, seems little outdated. http://autumn-orm.org/ http://charlesleifer.com/blog/peewee-a-lightweight-python-orm/ -- includes benchmarks pretty basic uses done. http://elixir.ematia.de/trac/wiki -- built on top of sqlalchemy, has activerecord style syntax. may more liking. https://storm.canonical.com/frontpage -- orm used canonical.

php - How can create a mail server? -

i have sever able receive e-mails. want use php program way mails shown users. can purely php? mena, not problem send mails php not know if can receive mails php? (in way php receives post requests). added as response first answer, specify looks need smtp servers. want able communicate smtp server in programmatic way. example, want have possibility "tell" smtp server create new e-mail address. need know incoming mails stored , in format. example, how can extract "sender", "cc", "bcc" file corresponding received mail. would have sever able receive e-mails. if writing scratch you'll need the specification smtp . advise against this. smtp servers hard write, , there several open source solutions out there. my understanding of php poorly when comes multithreading, isn't solution problem. than want use php program way mails shown users servers receive mails not typically show them users. store them in standard

smalltalk - How to camelCase a String in Pharo? -

i'm trying from: 'hello how today' to 'hellohowareyoutoday' and thought ascapitalizedphrase aslegalselector trick, doesn't. what's proper way this? edit: i think should clarify question; have way transform string camelcase selector: |astring acamelcasestring| astring := astring findtokens: $ . acamelcasestring := astring first. astring allbutfirst do: [:each | acamelcasestring := acamelcasestring , each capitalized]. i wondering whether pharo has standard system method achieve same :) you don't version of pharo you're using, in stable 5.0, 'hello world selector' ascamelcase asvalidselector yields helloworldthisisaselector to i'm using run: curl get.pharo.org/50+vm | bash

css - Positioning popup window in middle of the screen without JavaScript -

i have following html , css, position popup window in middle of screen in browser window size. possible without javascript? css: .floating-window { z-index: 9999; position: absolute; width: 200px; height: 200px; cursor: default; -moz-box-shadow: 1px 1px 1px #888; -webkit-box-shadow: 1px 1px 1px #888; box-shadow: 1px 1px 1px #888; } html: <div class='floating-window box'></div> with percentages, can set box such half of on left side. width: 30%; left: 45%; /* 50% (center) - 15% (half of 30) */ you use px you'll limited absolute container width. have searched around? know there articles explaining method more extensively have.

objective c - Object handling error in iPhone, select tab in UITabView and crash -

hey everyone, i'm creating tab-view application, , in 1 tab have 7 textfields trying save information "save" button. after making connections between objects in controller.h file , actual text fields, when select tab stuff in it, application crashes , goes springboard. have debug here: 2011-02-23 08:49:02.522 tow boat 911[19138:207] *** terminating app due uncaught exception 'nsunknownkeyexception', reason: '[<uiviewcontroller 0x4e0d1d0> setvalue:forundefinedkey:]: class not key value coding-compliant key colour.' *** call stack @ first throw: ( 0 corefoundation 0x00ec6be9 __exceptionpreprocess + 185 1 libobjc.a.dylib 0x00cbb5c2 objc_exception_throw + 47 2 corefoundation 0x00ec6b21 -[nsexception raise] + 17 3 foundation 0x000286cf _nssetusingkeyvaluesetter + 135 4 foundation 0x0002863d -[nsobject(nskeyval

perl - extract every nth number -

i want extract every 3rd number ( 42.034 , 41.630 , 40.158 on ) file see example- 42.034 13.749 28.463 41.630 12.627 28.412 40.158 12.173 30.831 26.823 12.596 32.191 26.366 13.332 32.938 25.289 12.810 32.419 23.949 13.329 any suggestions using perl script ? thanks, dac you can split file's contents separate numbers , use modulo operator extract every 3rd number: my $contents = { local $/; open $fh, "file" or die $!; <$fh> }; @numbers = split /\s+/, $contents; (0..$#numbers) { $_ % 3 == 0 , print "$numbers[$_]\n"; }

Access database returns double SUM for field Income -

i have following query in access 2003 mdb. select company.name, company.address, place.name_of_place, sum(income.value) income, sum(invoice.value) invoice ((company left join invoice on company.companyid = invoice.companyid) left join income on company.companyid = income.companyid) inner join place on place.postal = company.postal group company.name, company.address, place.name_of_place, company.companyid having ((iif(isnull(sum(invoice.value)), 0, sum(invoice.value)) - iif(isnull(sum(income.value)), 0, sum(income.value))) > 0) order company.name; income field value 500, query returns 1000. there must left joins income table twice searched. how solve this? i'm thinking in program simple division 2 column, i'd rather solve on database level. regards, vajda when join company invoice, result have many rows rows in invoice. if company has 2 invoices, have 2 rows . then, when join income (which not sure how many rows per company has) result 2 rows for e

visual studio 2005 - SQL reporting services datasource not visible in designer. Why? and How do I fix it? -

so im maintaining reports in vs2005 .net project. reports use object classes business layer datasets arent listen in menu in report designer. have no clue why not makes dealing them pain. add or manipulate datasets forced use notepad edit nodes add fields , whatnot. using microsoft report viewer tool instead of reports server (not that has it). anyway, why cant see datasets in designer tool. im guessing maybe person initialy developed reports might have used newer version of visual studio , added them tfs project. benefits of business layer objects , whatnot in appcode im ready start referencing db procs directly reports , chop current datasouces out of report code. but... finding way @ least view them within vs2005 awesome me meeting of these deadlines. thoughts? that has happened me when data-source named/referenced in datasets doesn't exist. (i did find , replace in code , forgot text included in name of primary data-source report, changed name referenced in of d

java - jsf 2.0 bean extends another bean Target Unreachable, 'null' returned null -

this question has answer here: identifying , solving javax.el.propertynotfoundexception: target unreachable 8 answers public class superuser extends user implements serializable{ private static final long serialversionuid = 1l; private string username; private string pin; //getters , setters } when use in managed bean , try access in facelets file this <h:inputtext id="firstname" value="#{usermanager.superuser.firstname}" required="true" maxlength="30" size="30"/> i exception javax.el.propertynotfoundexception: /superuser/create.xhtml @18,96 value="#{usermanager.superuser.firstname}": target unreachable does mean cannot extend java beans if want access properties? thanks it means #{usermanager.superuser} returned null , hence setfirstname() cannot called on it. jsf wo

operator keyword - Logical instructions for CIL -

how can use logical operators and, or, not in cil ? there no cil opcodes operators; need implement them via conditional branching instead. instance, a && b same a ? b : false , , a || b same a ? true : b , both of relatively easy implement in il (e.g. can use brtrue opcode conditional jump based on value of a ).

Distributed Lock Service with Windows Server AppFabric Caching -

i have extension method microsoft.applicationserver.caching.datacache object found in windows server appfabric sdk looks this: using system; using system.collections.generic; using microsoft.applicationserver.caching; namespace caching { public static class cacheextensions { private static dictionary<string, object> locks = new dictionary<string, object>(); public static t fetch<t>(this datacache @this, string key, func<t> func) { return @this.fetch(key, func, timespan.fromseconds(30)); } public static t fetch<t>(this datacache @this, string key, func<t> func, timespan timeout) { var result = @this.get(key); if (result == null) { lock (getlock(key)) { result = @this.get(key); if (result == null) { result = func();

publickeytoken case-sensitivity - ASP.Net web.config issues -

i went deploy asp.net solution win2003 server. i getting error messages referred assemblies supposedly missing. it transpires publickeytokens on development machine (xp sp3 32bit) in upper case whilst same files on server (can't check @ moment if 32 or 64 bit) had lower case publickeytokens. (i used win explorer going c:\windows\assembly) amending web.config publickeytoken matched of assembly on server did trick , app worked. i've tried researching reason difference haven't found anything. can or point me in right direction why publickeytokens on different machines in different cases? many thanks neil

javascript - If I assign the results of a jQuery selector to a variable, how can I further filter that? -

i have this: var startdate = $(".startdate"); ..which should select elements class 'startdate'. i try following: startdate(".nodate").hide(); ...to hide elements 'nodate' css class fails. i'm guessing @ syntax here, silly mistake making? edit: 'nodate' elements not @ same level 'startdate' elements. should have posted xhtml snippet. there couple of ways : $('.startdate').find('.nodate').hide(); $('.nodate','.startdate').hide() $('.startdate > .nodate').hide() $('.startdate').children('.nodate').hide() $('.nodate').filter(':parent(is(.startdate))') my preferred way first one, saw second 1 somewhere didn't used it. can't remember other way yet. when remember update post.

iis 7 - IIS7 Url Rewrite Rule regex to make new path and strip extension -

how can create rewrite rule achieve following: before: content/release/0.9.html after: release-notes/0.9 right i'm having: <rule name="rewrite rule1 content"> <match url="^content/release/(.+)$" /> <action type="rewrite" url="release-notes/{r:1}" /> </rule> how can rid of ".html" in "after" output? try this: <rule name="rewrite rule1 content"> <match url="^content/release/(.+)\.html$" /> <action type="rewrite" url="release-notes/{r:1}" /> </rule>

debugging - Combatting debug code in release product -

i work in small startup development shop (3 developers), , pulled away working on fix mission critical bug or implement "absolutely critical" software feature - bug list re-prioritized on daily basis , seldom know "important" a few hours now. because of this, have found becoming more , more wary of adding code can potentially go unchecked our qa department (read: person). when implement new function, not knowing whether i'll called away @ time, try write return statement @ top make sure code never gets executed on release build. the problem statements like: public void newfunction() { return; // put break point can use debugger step meat: meat: // ... more code } are in debug mode, visual studio smart enough know meat: never executed, can't use "set next statement" command meat:. same true wrapping code in compiler directives #if !debug. instead, write things like: public void newfunction() { if("a"[0]==

javascript - How to simplify or dry syntax of this jquery code -

i'm doing same selection on whole bunch of radio button groups. thing changes name . var fcolor = $(this).closest('.branch').find('input[name="fcolor"]:checked').val(); var bcolor = $(this).closest('.branch').find('input[name="bcolor"]:checked').val(); var sidec = $(this).closest('.branch').find('input[name="sidec"]:checked').val(); var linec = $(this).closest('.branch').find('input[name="linec"]:checked').val(); how simplify code i'm not repeating code this? if you're interested in inputs name attribute, i'd select them all, create object of properties , values. if need single out ones, give them common class, , select them that. var props = {}; $(this).closest('.branch').find('input[name]:checked').each(function() { props[ this.name ] = this.value; }); you'll end structure this: props = { fcolor: "some valu

How can I compile c++ app for ipod/iphone under linux(debian) -

how can this? search info, week, , find www.emdebian.org try install g++ arm platform on pc, compile app, copy ipod, , write "cannot execute binary file" iirc, apple uses different arm binary format stock g++ does. think you'll want use llvm-gcc or clang.

c# - add windows acquisition library VERSION 2.0 -

i using c# project , want add reference. when browse c# add reference dialog gives me error. i downloaded here http://www.microsoft.com/downloads/en/details.aspx?familyid=a332a77a-01b8-4de6-91c2-b7ea32537e29&displaylang=en also dont see in list of available references. missing thanks

doublebuffered - C#, double buffer in WinForms? -

private void button3_click(object sender, eventargs e) { this.doublebuffered = true; (int = 0; < 350; i++) { using (graphics g = this.creategraphics() ) { g.clear(color.cadetblue); g.drawimage(properties.resources._256, 100, 100, i-150, i-150); } } } yet thought have doublebuffered set true, image still flickers. ideas doing wrong? thanks! as neil noted, don't need (and shouldn't) create new graphics object in each iteration of loop. these relatively expensive resources , should not created willy nilly. also, shouldn't painting inside of button click handler calling creategraphics. can lead problems, notably drawing being "undone" when paint handler invoked (i.e., every time window receives wm_paint message , refreshed). should of painting overriding onpaint , call invalidate() when need update

dom - Form fields added via AJAX fail to load into the $_POST array -

i've got plain , simple html form allows people order brochures. form first loads looking little this: <script type="text/javascript"> var tablerown = 1; </script> <form id="order" name="order" method="post" action="includes/ordercheck.php"> <input id="name" type="text" name="name" width="100" /> <table id="orderingtable"> <tr class="lastrow"> <td><div id="itemgroupdiv1"> <input type="text" class="disabled" name="itemgroup1" id="itemgroup1" /> </div></td> <td><div id="itemcodediv1"> <input type="text" name="itemcode1" id="itemcode1" class="disabled" /> </div></td> <td><div id="

jquery ajax error -

i wrote login form on submit user supposed logged in, not working. please let me know error is, form <form id ="loginform_" action=""> <a href=""id="slidedownclose">x</a> <h2> login form</h2> username:<input type="text" id="uname" name="user_name" /><br/><br/> password:<input type="password" id="password" name="password" /><br/><br/> <input type ="submit" id ="log" class="logclass" value="log in"/><br/><br/> <a id ="lost_password" href ="/frontend_dev.php/forgotpassword">forgot password </a> </form> this jquery code $(document).ready(function() { $("#loginform_").validate({ rules: { user_name: "required", password: "required"

asp.net - How can I invoke a javascript trhough a thread? -

i have thread runs querying db , returning values. if values satisfyes condition, want raise message box (javascript alert) client side. in system, users can post tasks in db, , thread going query database check if user has things do. if user has, system must alert him through message box. text simple, , statik, "hey, dude, go work, lazy!" (i'm joking, message shall "you have new task(s). please check.") it! i've done javascripts invokings clientscript.registerstartupscript , , attributes.add buttons. want call javascript functions (wich alert user has things do) midle of sub (that executed in thread), without submit, load or click event. how can it? thanks! you can't call client side script directly server side code. the best can use ajax , poll server see when operation completes , @ point call javascript function.

zend framework - how to display parentrows in a view -

i building zend framework web app around mysql sakila db. have been able display basic films table details in films view. table contains among other columns, 'language_id' , 'original_language_id' columns reference language table. have set table relationships correctly in models. not sure how display language (not id's) in films view - how , use model relationships display langauge names in view? @ controller level? here's part of films controller: class filmscontroller extends zend_controller_action { public function indexaction() { $this->view->title = 'films'; $this->view->headtitle($this->view->title); $films = new application_model_dbtable_films(); $this->view->films = $films->fetchall(); here's part of view show table <td><?php echo $this->escape($film->title);?></td> <td><?php echo $this->escape($film->description);?>&

language agnostic - Does float have a negative zero? (-0f) -

ieee floating point numbers have bit assigned indicate sign, means can technically have different binary representations of 0 (+0 , -0). there arithmetic operation example in c result in negative 0 floating point value? this question inspired called question whether can safely compare 0.0f using == , , wondered further if there other ways represent 0 cause float1 == 0.0f break seemingly equal values. [edit] please, not comment safety of comparing floats equality! not trying add overflowing bucket of duplicate questions. according standard, negative 0 exists equal positive zero. purposes, 2 behave same way , many consider existence of negative implementation detail. there are, however, functions behave quite differently, namely division , atan2 : #include <math.h> #include <stdio.h> int main() { double x = 0.0; double y = -0.0; printf("%.08f == %.08f: %d\n", x, y, x == y); printf("%.08f == %.08f: %d\n", 1 / x, 1 / y,

java - maven project: SWT 3.5 dependency: any official public repo? -

well, in short, may need grab new swt version instead of 3.3 we're using now. project has dependency , builds fine: <dependency> <groupid>org.eclipse.swt.win32.win32</groupid> <artifactid>x86</artifactid> <version>3.3.0-v3346</version> </dependency> afaicgoogle, there no more recent version in public maven repo: http://repo1.maven.org/maven2/org/eclipse/swt/ so: is there public maven repo recent builds? if not, jars install locally and/or in corporate nexus? any groupid/artifactid suggestions/conventions know of? tia ps: noob eclipse products site layout , lost in google search results and/or eclipse site itself... while answer may obvious not me, retrospectively. update : repo taken down , replaced repo.eclipse.org not hold swt artifacts. you can use nexus repository hosted @ eclipse (this repository in 'testing' status) http://maven.eclipse.org/nexus/content/repositories/testing/org

android - When I set the theme, it doesn't update on device -

what want app have "zoom-in" animation used by, e.g., google maps, when start application instant title screen animation. did in 1 title, changing existing app has proven...complicated...and i'm wondering magic managed in previous app didn't make new app. i have theme defined this: <style name="startstyle" parent="@android:style/theme.light.notitlebar.fullscreen"> <item name="android:background">@drawable/recharge</item> </style> where there's recharge.png in res/drawable. in file "theme.xml" in res/values, , reference this: <activity android:name=".mainactivity" android:theme="@style/startstyle" <!-- more ... --> </activity> when working on app, had uninstall , reinstall app changes theme ever show up. once showed up, worked. but new application never zoom, though on first run on particular device show "recharge.png" image. later (

encoding - How to deal with special chars in php -

i load utf-8 encoded json file using php this: $string = file_get_contents("_locales/de/messages.json"); when echo $string chars like delete_context":{ "message": "löschen" } where should löschen . any idea how fix that? possible resolution: php: file_get_contents encoding problem

c++ - Does set_target_properties in CMake override CMAKE_CXX_FLAGS? -

at beginning of cmake project, i'm setting general compilation flags in variable cmake_cxx_flags, like set(cmake_cxx_flags "-w -wall ${cmake_cxx_flags}") later on, need append additional configuration-specific compilation flags (stored in build_flags). can use following command this: set_target_properties(${target} properties compile_flags ${build_flags}) or have add cmake_cxx_flags manually: set_target_properties(${target} properties compile_flags "${cmake_cxx_flags} ${build_flags}") to prevent cmake_cxx_flags being overriden build_flags? use first one: set_target_properties(${target} properties compile_flags ${build_flags}) the flags stored in build_flags appended after cmake_cxx_flags when compiling sources of target. documentation hints @ this, i've tried make sure. compile_flags additional flags use when compiling target's sources. compile_flags property sets additional compiler flags used build sources

operating system - How to start learning linux kernel programming ,coding or reading? -

i have got 2 books purpose: linux kernel development robert love , o'reilly's understanding linux kernel . have started reading these books , have downloaded latest source code linux. now, here on, should go on reading these books till end or should start looking @ code... , if should start coding, start? there many directories , files confused best place start understanding code. might add have had course in operating systems , pretty comfortable concepts... please give suggestions me in proceeding further. tell me how learned start programming kernel? thank in advance... you've picked out 2 great books start learning. primarily, suggest finishing books , attempting follow along examples best possible. personally, learned being knee deep in kernel code after getting job out of college writing linux device drivers embedded devices (a lot of analog , digital acquisition cards). had no previous experience , 2 books mentioned helped immensely in getting me

winapi - How to detect serial port sniffer? -

is possible detect if serial port being sniffed process running on windows? we have application receives sensitive data cannot read other people. so, before opening serial port, need check if port being monitored. we can use createfile windows api function open serial port exclusive access rights, if monitor runs before our call, can read communication (it opens serial port shared access rights, can open port @ same time). avoid this, attempt check if port being monitored , raise exception, warning user. possible this? port sniffing requires filter driver, sysinternals' portmon utility. taking wrong kind of approach secure application. when can install filter driver, attacker has more enough privileges disable app , replace else of own making. trying detect , prevent information loss through app pointless, system has secured. serial port first thing you'll have lose, trivial tap wires.

c# - System.IO.FileNotFoundException occurs after call to DirectoryEntry() -

i debugging small c# app wrote. app seems run fine on development box throws following errors when run on other machines (all machines windows 7 pro x64 w/ .net 4 installed): application: wolapp.exe framework version: v4.0.30319 description: process terminated due unhandled exception. exception info: system.io.filenotfoundexception stack: @ wolapp.powermodel..ctor() @ wolapp.powercontroller..ctor() @ wolapp.program.main() a second error succeeds 1 kernelbase.dll, but, 1 thing @ time.... from stack trace seems unhandled exception being throwin inside of powermodel constructor, consists of this: public powermodel() { entry = new directoryentry(); } where entry field of powermodel class. have since added following try catch block public powermodel() { try { entry = new directoryentry(); } catch (system.io.filenotfoundexception e) { string ssource; strin

java - How to Load File Outside of, but Relative to, the JAR? -

i need load file outside of jar, relative ( lib/config/config.ini exact). used exact path, , works fine long working directory jar is, i.e. /path/to/jar$ java -jar jar.jar if it's run this: ~$ java -jar /path/to/jar/jar.jar it can't find it. how can correctly load file relative location of jar? try using getclassloader().getresource("classname") find url of class in jar file. you'll find it's delimited ! between path jar, , path within jar, can slice.

php - Converting Form Data to XML -

i'm using php in contact form send email need output emailed in xml format. how convert form data xml? tried looking around helpful information find asp. thanks! http://ie.php.net/manual/en/book.simplexml.php - should have , running in no time.

html5 - Javascript canvas collision side detection -

hey i'm trying side 2 objects in canvas collide. here's i'm using collision detection, checks collision, without specific side. where o1 , o2 objects taht have properties: x - position on x axis y - position on y axis w - width of rectangle h - height of rectangle var collideswith = function (o2) { var o1 = this; if ((o1.y + o1.h) < o2.y) { return 0; } if (o1.y > (o2.y + o2.h)) { return 0; } if ((o1.x + o1.w) < o2.x) { return 0; } if (o1.x > (o2.x + o2.w)) { return 0; } return 1; }; edit : here's code came collision detection on top of element: if ( (o1.y - o1.dy >= o2.y) && (o1.y - o1.dy <= o2.y + o2.h) && (o1.x + o1.w >= o2.x) && (o1.x <= o2.x + o2.w) ) { // have collision @ top end } you need double -conditions this: if ((o1.y > o2.y) && (o1.y < o2.y + o2.h)) { return 'top'

session - passing objects between 2 applications in separate JVMs -

i have portlet application running on portal server , webapp running on application server. want make call portlet application jsp app application. can make call; no issues.. can pass values in request parameter; no issues.. want pass object appserver application , not sure how this. try using java rmi . after implementing couple of interfaces can pass objects between jvm's quite easily. laird mentioned, requires serialization, done implicitly java, there's chance won't have worry it.

ruby on rails - RSpec Test Call to ActiveMailer model -

hey trying rspec test if action calls specific method in model have inherits activemailer have been having no luck. quick mockup have following scenario. model usernotifier: class usernotifier < actionmailer::base def foobaz end end controller password controller: class passwordscontroller < applicationcontroller def foobar usernotifier.foobaz end and spec: describe "get 'foobar'" "should call usernotifier foobaz method" usernotifier.should_receive(:foobaz) :foobar end end but end failure: 1) passwordscontroller 'foobar' should call usernotifier foobaz method failure/error: usernotifier.should_receive(:foobaz) (<usernotifier (class)>).foobaz(any args) expected: 1 time received: 0 times can enlighten me why rspec not register usernotifier.foobaz method being called? answered in comments ryan bigg. ended being before_filter causing method never run

Using a MySQL trigger to replace input -

is possible create trigger that, upon inserting or updating row, can use replace function replace characters escaped equivalents (specifically, making input html safe) columns in table without having know field names (so function can applied multiple tables). agree 115% sort of thing should done @ application level, due unique circumstances i'd add failsafe @ database level. i'm new triggers, take easy on me, want effect of: create trigger if not exists makehtmlsafe after insert on tablename begin loop on columns in tablename new.value = replace(old.value,"<","&lt;") end escaping complicated , error-prone. should never try roll own escaping function, risky. instead of making things more secure make far less secure. use specialized html escaping functions in front-end. when using php, htmlentities best bet: http://php.net/manual/en/function.htmlentities.php see also: what best practices avoiding xss attacks in php

.net - Storing username and password to access SQL Server from a Windows service without Integrated Security -

we have service accesses sql server, client not using integrated security , need service have rights database whenever machine turned on. have store sql server username , password? if where? (and how) yes, if want connect sql server using specific username , password, credentials need provided in connection string. and yes, storing them in plain text bit of risky business..... ... fortunately, .net allows encrypt entire sections of config files! read encrypting passwords in .net application , , contrary popular belief, available in of .net - not in asp.net. works in services, - not problem @ all. so store sql server connection string app.config service , encrypt <connectionstrings> section , done it!

Java ArrayList - Find Item - Do I need Hash? -

im learning java , having problem arraylist. have read java doc , thinking maybe need hash thing? i have object called catalogue has array list of objects created class called item. each item has fields size, colour, price, product code, (these item attributes). need include method in catalogue accepts product code , searches through arraylist find object matching product code. , returns product. have tostring method in item class lists of fields & values when called. maybe should returned when matching product code found in array list? import java.util.arraylist; public class catalogue { private arraylist<item> catalogue; public catalogue () { catalogue = new arraylist<item>(); } public void finditem(int code) { if(item.code == prodcode){ } else{ system.out.println(catalogue.get(item)); } } i looked @ java doc , read hash , maybe better me use rather iterator? i'm not

css - How to make it so that the children elements will never wrap to the next line even though the parent element's width may be small for them? -

how make children elements never wrap next line though parent element's width may small them? want them overflowed (e.i. overflow: hidden). need photo preview system (thumbnails) building. children elements left-floated. i found generic solution in forum. link answer and dan said, need see html , css this..

.net - WPF databinding - set NotifyOnValidationError to true for all bindings with validation rules -

in wpf application, want set notifyonvalidationerror true (the framework defaults false) child controls/bindings if have validationrules attached binding. indeed, nice specify other binding defaults - e.g. validatesondataerrors should true. for example, in following text box don't want have manually specify notifyonvalidationerror property. <textbox> <textbox.text> <binding path="postalcode" validatesondataerrors="true" notifyonvalidationerror="true"> <binding.validationrules> <rules:postalcoderule /> </binding.validationrules> </binding> </textbox.text> </textbox> since binding markup extension create custom markup extensions extends binding , sets properties desired defaults.

frameworks - How to make my C++ opensource crossplatform application update itself? (any boost libs for that?) -

i have app. cross platform. not way enterprise nor has more 500 users. no 1 wants bad it. has 3 packets available via http in source repository manager google code mac os windows , linux. need app check updates , download them , replace current executables/files around, restart app. me - see way distribute 2 applications - 1 checks updates or runs existing executable , executable itself... wonder used , there boost libs or other cross platform libs such stuff? i don't think there cross platform solution automatic updates. didn't seem able find here: how can enable auto-updates in qt cross-platform application?

c# - CheckBoxList Problem -

i have checkboxlist in c# databound database. display icon on right side after text each of checkboxlist items. each icon needs different though. help! you this <asp:checkboxlist id="checkboxlist1" runat="server" datasourceid="datasourceid" datatextfield="datatextfield" datavaluefield="datatextvalue" ondatabound="checkboxlist1_databound"> </asp:checkboxlist> protected void checkboxlist1_databound(object sender, eventargs e) { var checkbox = sender checkboxlist; if(checkbox != null) { foreach (listitem listitem in checkbox.items) { listitem.text = string.format("{0}<img src='{1}' />", listitem.text, getimagefor(listitem.text)); } } } private string getimagefor(string text) { // return image url check box based on text. if(text.equals("banana")) return "banana.gif"; ... ... }

printing - cURL awk { print } help -

i have in file: <yweather:condition text="partly cloudy" code="29" temp="56" date="wed, 23 feb 2011 6:53 pm mst" /> i'm using code try , print "partly cloudy", although "partly" not getting printed. grep "yweather:condition" ~/documents/weather.dat | awk '{ print $2 }' | awk 'begin { fs = "[\"]" } ; { print $2 } ' hopefully can explain how both words print. thanks! cat ~/documents/weather.dat |awk 'begin { fs = "[\"]" } ; /yweather:condition/ { print $2 } ' replaces that

cocoa - NSTokenField Suggest but don't complete -

i feel must common issue i'm struggling figure out, couldn't find else asked question so... have nstokenfield , when user begins typing make soap request , names similar have entered. issue suggestions don't match have typed. example, match email , last names, persons full name appears in suggestion array. since letters don't match, nstokenfield changes has been typed first item in array. there way turn off autocomplete , have suggestion box appear? - (nsarray *)tokenfield:(nstokenfield *)tokenfield completionsforsubstring:(nsstring *)substring indexoftoken:(nsinteger)tokenindex indexofselecteditem:(nsinteger *)selectedindex { *selectedindex = -1; return nsarray; } it turns out assigning selectedindex incorrectly if set -1 nothing selected.

.net - Reconcile XML Updates -

i have set xml files store simple bits of data. in each case data in files structured differently, storing different types of data, simple. there file on server, can either downloaded , updated offline or updated online. here's problem: happens if while user has file offline updating file updated , want upload changes server? there way handle preferably in .net? worth nothing changes not frequent. in cases new file created major changes; we're talking minor update older files , want plan update collision if happens. for example: original file: [person] [name]bob[/name] [address]123 street[/address] [phone]123-456-7890[/phone] [/person] changes made offline: [person] [name]bob[/name] [address]124 street[/address] [phone]123-456-7890[/phone] [/person] changes made online: [person] [name]bob[/name] [address]123 street[/address] [phone]124-456-7890[/phone] [/person] ideal result: [person] [name]bob[/name] [address]124 street[/address] [phone

java - Converting integers into bytes -

how following numbers, on byte conversion give results on right hand side ? guess when convert integer byte array, should convert each of digit of number correponding 4 byte array. here's cannot understand.. 727 = 000002d7 1944 = 00000798 42 = 0000002a edit: reading blog found these following lines:- if working integer column names, example, each column name 4 bytes long. lets work column names 727, 1944 , 42. the bytes associated these 3 numbers: 727 = 000002d7 1944 = 00000798 42 = 0000002a link blog: http://www.divconq.com/2010/why-does-cassandra-have-data-types/ solution the following give exact output in example: public class main { public static void main(final string[] args) { system.out.format("%08x\n", 727); system.out.format("%08x\n", 1944); system.out.format("%08x\n", 42); } } and here expected output: 000002d7 00000798 0000002a explanation how formatter works

Converting image containing text to editable text -

i have pdf file scanned hard copy . therefore pdf file has image of hardcopy . when try convert pdf word , dont editable document , rather image sitting on word document . there way can make editable word document out of ? software program or me ? it's called optical character recognition ocr there lots of software packages - in program try http://code.google.com/p/tesseract-ocr/

ms access - query criteria to output records from the last 90 minutes -

i have time/date field in select query , set criteria output records last 90 minutes. please give me proper sql copy/paste much, nathaniel select sysadm_customer_order.printed_date sysadm_customer_order; for ms access looking like select sysadm_customer_order.printed_date sysadm_customer_order (((sysadm_customer_order.printed_date) between dateadd("n",-90,now()) , now())); have @ now function , dateadd function

algorithm - Allocating resources according to rules -- is simulated annealing appropriate? -

i design application can allocate resources according rules. believe simulated annealing work, not familiar , wondering if there alternative algorithms might suitable. for example if had grid, , color each cell in grid, design algorithm find optimum or close-to-optimum solution rule set following: 1000x1000 grid must place 500 red cells, 500 blue cells, , 1000 green cells a red cell must touching red cell a blue cell must not touching blue cell a green cell may placed along edge arrangements can scored based on mean distance of colored cells upper-left hand corner would simulated annealing appropriate problem? need algorithm can compute solution reliably (seconds minutes). simulated annealing close optimal solution pretty fast. however, implementing simulated annealing correctly (which isn't code) can challenging. many people (including myself in past) implement wrong, think did right , presume algorithm isn't good. alternatives algorithms tabu searc

python - Difference of calling inherited methods in subclass? -

for python 2.5 , later, new style class, what's difference of following code snippets invoking inherited methods in subclass? class a(object): def foo(self): pass class b(a): def __init__(self): self.foo() class c(a): def __init__(self): super(c, self).foo() as long dealing single inheritance classes example gave, there not difference. in either case, python uses method resolution order(mro), (which can examine printing c.__mro__ ) find out first occurance of method foo. these both resolve base class, a's, foo implementation. however, things become interesting when have multiple inheritance. @ following example: class w(object): def foo(self): print "w" class x(w): def foo(self): #super(x,self).foo() w.foo(self) print "x" class y(w): def foo(self): print "y" class z(x,y): def __init__(self): self.foo() z.__mro__ z = z() if @ class x, can eith

how do you revert 1 or more committed files in mercurial but NOT the entire changeset -

say have files file_a , file_b , file_c . edit file_a , file_b on purpose file_c added debugging code don't plan commit. accident a hg commit -m "comment" how revert/rollback/backout file_c ? i'd happy able go hg update -r <onerevback> file_c hg commit -m "put c back" but update doesn't take filter afaik it's going revert file_a , file_b . can copy file_c somewhere, hg update , copy seems lame. there way directly in mercurial? the exact command wanted use have worked if used hg revert instead of hg update hg revert -r <onerevback> file_c hg commit -m "put c back"

c# - What are new features in linq in c#4.0? -

i c# developer , use linq much. know new features of linq in c#4.0.i know zip method there.is there new methods that? there new zip() extension method http://msdn.microsoft.com/en-us/library/dd267698.aspx , new ef 4.0 http://msdn.microsoft.com/en-us/data/aa937723 while isn't directly linq, created tuple class tree http://msdn.microsoft.com/en-us/library/system.tuple.aspx , , expanded action<t1, t2...> , func<t1, t2...> 10 parameters. i'm not sure if covariance , contravariance should listed here ( ienumerable<t> covariant, , "he" 1 of basic "objects" of linq)

javascript - iphone uiwebview hyperlink -

i have display uiwebview content using javascript stringbyevaluatingstring . in project hyperlink not working. how enable links in uiwebview? anybody know please give piece of sample code or idea. just sample try: in uiviewcontroller "own" uiwebview named: "yourwebview" // navigate new html file: [yourwebview stringbyevaluatingjavascriptfromstring:@"document.location='anewhtmlfile.html'"]; // show normal javascript alert window message: [yourwebview stringbyevaluatingjavascriptfromstring:@"alert('this alert message looks like.');"]; // ask html file own title: nsstring *apps = [yourwebview stringbyevaluatingjavascriptfromstring:@"document.title"]; nslogg(@"the title is: %@", apps); // call personal js in html document: [yourwebview stringbyevaluatingjavascriptfromstring:@"callmyjsfunctiontoshowmyalert('hallo!');"]; // whit in html file: <head> ... <scri

concatenation - MYSQL Concat not working -

update profile set favourties=concat(favourties,"123") id=1 i want append 123 in favourties if default value of favourties set null query not work. query if favourties set null , append 123 it update profile set favourties=concat(ifnull(favourties, ''),"123") id=1

casting - typecasting in C -

in code error : expected ‘const void *’ argument of type ‘struct in_addr’ i using memcmp can type cast struct in_addr const void* const void * (struct in_addr ) you need cast address of object, not object itself: (const void *)&my_obj but in fact, such casts implict, can use: &my_obj

ReSharper warning about unused parameter in JavaScript function -

if have function in javascript looks function whatever(e, obj){ //here obj } resharper tells me "parameter 'e' never used". can rid of warning other doing pointless e? update: of resharper 6.0 01 mar 2011 nightly build no longer issue.

jquery - how to use callback to apply them on newly cloned objects -

well using quicksand, want use tool tips in it, facing problem due callback code not able implement, place quicksand present , told tooltips usage it, has not explained in detail expects people know jquery before using it. http://razorjack.net/quicksand/docs-and-demos.html code saying use this $("#content").quicksand($("#data > li"), { duration: 1000, }, function() { // callback function $('#content a').tooltip(); } ); i don't know place code , how don't know jquery, , if code place in tooltips script place in , how, e-g might use 1 http://www.sohtanaka.com/web-design/...ement-tooltip/ in code put above code. if not possible above tooltip ready use tooltip can display picture in it. reading , giving me time, please me know jquery kings not issue, issue me dumb. lol take care. you can place jquery within html <script> tags. e.g. <html> <head> <script type="text/javascript" src="jquery.js&q

How to instruct StandardAnalyzer in Lucene to not to remove stop words? -

simple question : how make lucene's standardanalyzer not remove stop words when analyzing sentence ? the answer version-dependent. lucene 3.0.3 (current) , need construct standardanalyzer empty set of stop words, using this: analyzer ana = new standardanalyzer(lucene_30, collections.emptyset());

c# - Version mismatch issue when using LastWriteTime.Ticks -

i had code dataset.dataversion.adddataversionrow((new fileinfo(path + permissionfile)).lastwritetime.ticks); but when changed getting other functionality not working,i dont know why not working.this modified ,not working code long version = (new fileinfo(path + permissionfile)).lastwritetime.ticks; if (dataset.dataversion.count == 0) { dataset.dataversion.adddataversionrow(version); } else if (version > dataset.dataversion[0].version) { dataset.dataversion[0].version = version; } do need add 1 more else loop here hard answer without more information, maybe want update last entry in dataversion: int count = dataset.dataversion.count; if (count == 0) { dataset.dataversion.adddataversionrow(version); } else if (version > dataset.dataversion[count-1].version) { dataset.dataversion[count-1].version = version; }

iphone - Can't get texts on UITableViewCell -

i want multiple custom texts on cell of uitableview. want these texts after clicking on dynamically added button on cell. can't use didrowselectedatindex method. have own selector executing don't know how can texts on each cell. can me? thank make labels global variables create yur cell default style cell. add labels contentview of cell without text. add button. in method button invokes after click set texts labels. uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; customlabel1 = [[uilabel alloc] initwithframe:cgrectmake(5, 5, 50, 20)]; customlabel2 = [[uilabel alloc] initwithframe:cgrectmake(55, 5, 50, 20)]; [cell.contentview addsubview:customlabel1]; [cell.contentview addsubview:customlabel2]; } and - (ibaction) click { customlabel1.text = @"yaya";

java - Regular expressions: all words after my current one are gone -

i need remove strings text file, such as: flickr:user=32jdisffs flickr:user=acssd flickr:user=asddsa89 i'm using fields[i] = fields[i].replaceall(" , flickr:user=.*", ""); however issue approach word after flickr:user= removed content, after space. thanks you need replaceall("flickr:user=[0-9a-za-z]+", "");

vb.net - Unable to insert data into database -

i using sqlite. when try insert data tables following: mixed mode assembly built against version 'v2.0.50727' of runtime , cannot loaded in 4.0 runtime without additional configuration information. i using ado.net 2.0 provider sqlite here here here are links previous questions help.

iphone - Opening a book reader app at the some page where the app was closed -

i have app reading book, , while reading if user hit home button on iphone, , again reopen app , should open on same page in user previously, have got x position page, since book in vertical scrolling. plz let me know implement information. -(void)scrollviewdidenddecelerating:(uiscrollview *)_scrollview { cgpoint p = _scrollview.contentoffset; nslog(@"x = %f",p.x); appdelegate_iphone *delegate = [[uiapplication sharedapplication] delegate]; delegate.datavalue = p.x; } you can use nsuserdefaults save state information. -(void)scrollviewdidenddecelerating:(uiscrollview *)_scrollview { cgpoint p = _scrollview.contentoffset; nslog(@"x = %f",p.x); appdelegate_iphone *delegate = [[uiapplication sharedapplication] delegate]; delegate.datavalue = p.x; // save state nsuserdefaults* ud = [nsuserdefaults standarduserdefaults]; [ud setinteger: p.x forkey @"x-position"]; [ud synchronize]; } to retriev

Read XML file and write to a php array/file -

possible duplicate: read xml file , write php array/file hi, i need update country list of website , want automate process. country list can found here http://www.iso.org/iso/country_codes...code_lists.htm i tried way – http://www.w3schools.com/php/php_xml_parser_expat.asp (php xml expat parser) however, didn't seem work confused 'get' data , print own array later use. now want try using xml dom ( http://www.php.net/manual/en/book.domxml.php ). just want check everyone, if had simple xml file read, contained country code , country name follows: <entry> <country_name>afghanistan</country_name> <code_element>af</code_element> </entry> i want read file (dom method), , feed data separate file/array of mine accessed website. php xml functions use/recommend simple task? any in regards appreciated. simple + xml = simplexml dom support too