Posts

Showing posts from April, 2013

ASP.NET. Hiding whole site structure. Is it possible? -

i guess else opposite need hide "directory" structure of asp.net website. for reason thinking of use robots.txt follows... user-agent: * disallow: / use url rewriting, make ghost paths disable directory browsing. (directory listing denied...) use .ashx serve images. other ways may suggest. in other words not "downloader-structrure reader", strip site. as see sekurity tag missing :) p.s. not care seo a site downloader wget -r work anyway. follows links , doesn't care directories (except fact can limit depth). if want exclude legit crawlers google, using robots.txt fine. wget , rogue crawlers don't care though. the solution either requriring login (but still doesn't protect against people who'd use wget download whole site; they'll provide login information/session id) or cluttering content annoying captchas (pisses of legit users quickly) or making whole site use javascript/ajax display/load content. makes user e...

SQL server database deployment -

i build application uses sql server database. working fine in system necessary software installed. now want deploy other system. necessary install full sql server(unnecessary heavy one, run application) in system or support there? or can copy database mdf file location in new system , give proper connection string work? i newbie field, please guide me. there free express & compact versions of sql server (size & capability limited) designed run on desktop machine data local & not appropriate use full server version. you can install these using installer of choice, connect & attach mdf file directly.

java - Changing Jasper Report layout to run from left to right -

is possible create jasper report runs left right opposed usual top bottom layout. basically having header band of report running vertically instead of horizontally. for example, this: age sex location 35 m london 27 f dublin 40 m dublin to layout: age 35 27 40 sex m f m location london dublin dublin actually there property of report called "print order". changing "vertical" "horizontal" same text rotation entire report.

Clojure static typing -

i know may sound blasphemy lisp aficionados (and other lovers of dynamic languages), how difficult enhance clojure compiler support static (compile-time) type checking? setting aside arguments , against static , dynamic typing, possible (not "is advisable")? i thinking adding new reader macro force compile-time type (an enhanced version of #^ macro) , adding type information symbol table allow compiler flag places variables misused. example, in following code, expect compile-time error (#* "compile-time" type macro): (defn get-length [#*string s] (.length s)) (defn test-get-length [] (get-length 2.0)) the #^ macro reused global variable ( *compile-time-type-checking* ) force compiler checks. any thoughts on feasibility? it's possible. compiler static type checking around primitive argument types in 1.3 development branch.

php - What would be the preferred method of creating an online photo album? -

i have @ disposal php, mysql , linux server. the site i'm creating client should have back-end manageable photo gallery. i planning create in mysql, meaning have table containing mediumblob contain binary data of picture. allow me have @ 1 spot, not having rely on chance client wouldn't accidentally remove image gallery directory without updating database , forth. the alternative, of course, have images independent of mysql database, , save image paths. what i'm posting question here ask experts if there potholes in method i'm not seeing. have never tried method of creating gallery before. instance, considered bad practice retrieving large amounts of data mysql when file-system storage possible? what thoughts? (i mark correct reply erases doubt case mind) personally, wouldn't recommend reinvent wheel... if want clients/users updating data. far better existing solution. there tons of them out there. robust gallery as actual question, there ...

html - Render Apostrophe of Twitter feed is not correct in IE -

check out page using ie : http://search.twitter.com/search?q=%23testvoorklant find out apostrophe rendered & apos ;! if want use these feeds in website, how should handle problem? regards the code on page broken. when validating page w3c validator finds 43 errors , 23 warnings. a lot of errors because page typed html 4.01, contains lot of xhtml code. frequent error urls contains & characters not encoded & . the error cause problem see, code contains entity ' , doesn't exist in html. if browser displays unchanged, normal. if want clean data, can replace apostrophes, or ' in cases when needs encoded.

c# - How do I set Encoding on AlternateView -

i'm creating mailbody via using (var streamwriter = new streamwriter(foofilename, false, encoding.utf8)) { streamwriter.write(foomessage); } now i'm consuming file with var mailmessage = new system.net.mail.mailmessage { = foosender, = { foorecipient }, subject = foosubject, subjectencoding = encoding.utf8, bodyencoding = encoding.utf8 }; // foomediatype can // - system.net.mime.mediatypenames.text.html // - system.net.mime.mediatypenames.text.plain var alternateview = new system.net.mail.alternateview(foofilename, foomediatype); mailmessage.alternateviews.add(alternateview); if i'm using non-umlauts, works fine, i'm using umlauts in alternateview , broken. so how can set sort of encoding on alternateview working? var alternateview = new alternateview(foofilename, foomediatype) { contenttype = { charset = encoding.utf8.webname } };

c# - ASP.NET MVC 3 WebGrid paging issue -

my data access layer returns collection rows single page , total number of rows. unfortunately webgrid component not allow specify total number of rows or total number of pages (these properties read-only). has had deal issue before? you can use bind method on webgrid tell grid use server side paging. grdv.bind(mydata, rowcount=10000, autosortandpage=false) setting autosortandpage false tells grid mydata segment of data. show rows of data regardless of page size setting. pager built using rowcount pass in , not number of records in mydata.

layout - CSS to place a div within an area of another (not parent) div -

having css troubles , hoping can me. i'm trying place #aside right of #landing don't share same parent. unfortunately can't alter structure of divs (otherwise i'd put #aside within #container , it's fixed), looking solution. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <head> <title>test layout</title> <link rel="stylesheet" type="text/css" href="temp.css" /> </head> <body> <div id="main"> main <div id="container"> container <div id="content"> content - lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo conseq...

We don't need the new features in SQL Server 2008, but should we upgrade anyway? -

we using sql server 2005. don't need new features in sql server 2008 r2, should upgrade anyway on with? here's article why should upgrade: http://www.sqlmag.com/article/sql-server-2000/is-sql-server-2008-r2-for-you-.aspx ` upgrading 2005: more functionality if you’re running sql server 2005 there’s lot of new functionality gained moving sql server 2008 r2. sql server 2008 r2 includes new bi functionality whole set of sql server 2008 features including database , database backup compression; transparent database encryption; new date, time, , spatial data types; new filestream data type; resource governor , policy-based management.

tfs2010 - How to update current sprint team queries in TFS 2010? -

Image
we using vs 2010 , tfs 2010 microsoft scrum template . we use team queries current sprint sprint backlog query. the problem when move sprint 2 "current sprint" still points sprint 1. is there way to tell tfs in sprint 2 , have queries use variable run against instead of hard-coding sprint? for example: if @ screen shot below notice definition of query uses variable called "@project" team project. there way have variable sprint? tom, what asking not available in tfs 2010. there not dates on iterations, tfs not know current iteration is. in tfs11 (vnext) have added dates on iterations. knows in iteration are, , reflected on backlog page in web access. in preview version out not possible add filter clause queries filter on current iteration (something @currentiteration). have heard strong feedback add in product before ships. high on our wish list, need fix other things first before can ship. you can add request on user voice . if idea...

java - What makes a model change get propagated via JFace databinding? -

in order understand how jface databindings working, have model object 2 properties. changing 1 property should set other same value: public class model { private double x; private double y; private propertychangesupport changesupport = new propertychangesupport(this); public void addpropertychangelistener(string propertyname, propertychangelistener listener) { propertychangesupport.addpropertychangelistener(propertyname, listener); } public void removepropertychangelistener(propertychangelistener listener) { propertychangesupport.removepropertychangelistener(listener); } public void setx(double x) { propertychangesupport.firepropertychange("x", this.x, this.x = x); } public double getx() { return x; } public void sety(double y) { propertychangesupport.firepropertychange("y", y, this.y = y); setx(y); } public double y() { return y; ...

Regex to find a file in Tcl -

i've never used tcl previously, however, need modify file project. have used regex perl, i'm unsure of syntax tcl. what want allow user execute script , type in file name has searched. want search file once found , something. far, here's pseudo-code. set file_name [lindex $argv 0] while(true) { if { found file } { puts "found file!" { else { file not found ) puts "file not found!" } i'm not sure how check if file found or not? complete filename user via input ... if want use regular expression instead of glob patterns periodically list of files (using glob ) , search through it. helpfully, lsearch accepts regexp syntax: # regexp: set file_pattern [lindex $argv 0] # scan current directory: while 1 { set files [glob -nocomplain *] if {[lsearch -regexp $files $file_pattern] < 0} { puts "file not found" } else { puts "file found" } after 1000 ;# sleep 1 second } note...

advantage database server - ROWID parameter in procedure -

how set datatype rowid in input or output parameter? rowid peudocolumn in sql statements. calculated fixed length character column size of 18. more information available in help file .

xml - Display my tests using Eclipse JUnit plugin? -

i have written test framework company-specific language. test framework able output junit-like xml. as example, can save file , open using eclipse junit view, or disp^lay in hudson server. want have directly integrated in eclipse, in order these tests run on eclipse "save" action, , results displayed in junit view. what best way ? save them file , open file in eclipse (and if so, how ?) directly populate junit view content of xml ? (and if so, how ?) create own view (which do, i'm complete beginner in swt) i haven't tried myself, imagine little bit of trickery, possible automatically open formatted file in junit view. i think call org.eclipse.ui.ide.ide.openeditor(iworkbenchpage, uri, string, boolean) should work. because junit-formatted xml files set opened junit view. before point, need create eclipse plugin. simple plugin have 1 class listen completion of runs testing framework, , class know find resulting xml files , call openeditor o...

New OSX User: Opening up a new terminal window in current space(?) -

i'm meddling osx after few years on linux. there's lot i'm liking, 1 thing that's slowing me down if run 'terminal' command via shortcut/spotlight/quicksilver, whisks me off existing terminal in whatever space has terminal instance open. i regularly pop terminal, run quick command , close again, while staying in whatever desktop space happen on. ...so, how do on mac? cheers... go system preferences -> exposé & spaces -> spaces , check when switching application, switch to...

Converting float to decimal in SQL Server 2008 -

i have view needs return type decimal columns stored float. i can cast each column decimal follows: , cast(field1 decimal) field1 the problem approach, decimal defaults 18,0, automatically rounds float columns 0. keep precision of 12 decimal places. however, if this: , cast(field1 decimal(12,12)) field1 i runtime error: "arithmetic overflow error converting float data type numeric" the float column defined length: 8 precision: 53 in table. can not modify table. what's proper way cast decimal w/out losing decimal precision? 12, 12 means no digits before decimal separator: 12 digits in total, 12 of them being after period. use more appropriate range, say: declare @var float = 100 select cast(@var decimal(20,12)) which gives 8 digits before separator, or adjust needed.

Cannot access PHP/C++ shared memory over the web -

i sharing memory between c++ , php at php end have: $inputshm_id = shmop_open($shid, "w", 0777, 1024); where shid identifier created ftok. this works fine when run php script logged in root on server when try run remotely on web get: warning: shmop_open() [function.shmop-open]: unable attach or create shared memory segment in /var/www/html/prof/phpsm.php on line 6 ...where line 6 line i've shown above. since runs fine when run server root i'm assuming somewhere preventing web user requests connecting shared memory. does know causing this? thanks the issue selinux blocking shm access (you can verify running setenforce 0 , testing, , running setenforce 1 after), don't know way of solving other modifying policy or switching mmap.

objective c - Truncate NSDate (Zero-out time) -

i want generate new nsdate 0 hours , 0 minutes , , 0 seconds time. source date can random nsdate . is there way achieve this? documentation did not me this. example have: 2010-10-30 10:14:13 gmt want: 2010-10-30 00:00:00 gmt unsigned int flags = nscalendarunityear | nscalendarunitmonth | nscalendarunitday; nscalendar* calendar = [nscalendar currentcalendar]; nsdatecomponents* components = [calendar components:flags fromdate:date]; nsdate* dateonly = [calendar datefromcomponents:components]; date date want remove time from. this separates date , time , creates new date default time (00:00:00). edit to take time zone account: nsdate* dateonly = [[calendar datefromcomponents:components] datebyaddingtimeinterval:[[nstimezone localtimezone]secondsfromgmt]];

c# - TreeView Control -

i developing application using c#. using radiobuttonlist control inside treeview. getting collection of items database. based on collection items need select radiobuttonlist items. for example database got collection in way: read(r) write(w) based on colletion need set user permissions. if question right want bind radiobutton list based on items in database based on current row item on grid. if thats case here solution. lets have grid called mygrid, radiobuttonlist called myradio , hiddenfield called myhidden (this bind value have on "r" , "w") all have when rowdatabound event occurs have assign value myradio for example, have radiobuttonlist such <asp:radiobuttonlist id="myradio" runat="server"> <asp:listitem value="r">read</asp:listitem> <asp:listitem value="w">write</asp:listitem> </asp:radiobuttonlist> so code behind should this protected void mygrid...

PostgreSQL sockets from JavaScript (HTML5) -

i'm looking @ options connect directly--without web server or middleware--to postgresql server using javascript web browser client. on github, found 3 projects: node_postgres node-postgres postgres-js they appear in @ least active development. do same thing? i'm looking for? have experience of them recommend 1 on others? node-postgres inspired by postgres-js , same thing. however, both seem own sort of middleware, because require node.js, server-side javascript implementation of web server. cut out layer, still not same thing connecting directly postgresql server. there might way combine code in them html5 socket examples, though, make connections directly web browser client.

java - Use Google keyword corrections in program -

let's have list of words not spelled correctly. have dictionary corrects them there may words not present in dictionary. there way me search misspelled words in google , retrieve first "did mean:" suggestion made google. you search words in google going google.com url + string of words(i'm not sure of exact google search url), have search term process in background, use xpath , htmlcleaner see if there "did mean" text present. if so, present user. but think google auto-correction search, may see "searching for: corrected spelling", should take consideration.

web standards - Using a guid for displaying "secure" invoices -

i've created web site student management (martial arts schools). includes invoicing students. way users can printing invoices , handing them students. i'd create way students go invoice online. i've been considering using guids students, , using parameter query string invoice. (http://thesite.com/invoice.php?guid=e3d3d122-5ab6-4405-96ec-7c0579710813) the invoice read-only page, , allow no access rest of site. i'm not worried packet sniffing (i don't believe sniffing traffic in coffee shop concern, if have access random student invoice). i worried being able guess, or specific set of invoices (i.e. invoices of competitor). i feel i'm either crazy considering it, or it's relativity standard practice. i'm not sure which. , great sanity check. thanks that's good, secure process; lose readability of url, of course, if that's not of concern, that's solution. it's not guessable. as added security measure, might w...

storage - Don't want to store the secret Facebook/Twitter API key on mobile devices, design patterns? -

i have issue letting secret api key on world on potentially thousands of mobile devices. compromised , used malicious purposes hacker. so options me? guess private server has secret api key , web service encapsulates method calls. instead of mobile device having secret key , like: list<friends> = service.getfriends(secretkey); if secret api key compromised , used spamming/abuse purposes, must shut down use users, leaving application dead in sea. so idea can use mobile device unique device id , do: list<friends> = myservice.getfriends(deviceid); of course, malicious hacker call web service fake deviceid, @ least have control blacklist deviceid's. introduces potential bandwidth isssue, of less concern. a true pki out of question, since targetted device doesn't handle http client certificates in current version. any other ideas? you don't want publish api key facebook or twitter, obfuscated within client. your instincts correct proxy th...

Equivalent to PHP's include in C# -

what equivalent command php's include() in c# ? for example, php's include used : include("ex.php"); can same in c#? if mean in asp.net using c# can create user control (.ascx) , add in .aspx page. if doing mvc can create partial view. the closest thing can think of after creating ascx user control named "myusercontrol" in page_load or pre_render : myusercontrol cont = new myusercontrol(); this.controls.add(cont);

android - Resizing an ImageView within a TableLayout programmatically -

if have tablelayout structure (below) defines 2 imageviews. 1 specifies pixel values width/height. works expect - pic 1 resized 50px , pic2 kept @ original size: <tablelayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <tablerow> <imageview android:src="@drawable/pic1" android:layout_width="50px" android:layout_height="50px" /> <imageview android:src="@drawable/pic2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </tablerow> </tablelayout> but need above programmatically this... tablelayout tablelayout = new tablelayout(ctx); tablerow tablerow = new talerow(ctx); imageview imageviewone = new imageview(ctx); imageview imageviewtwo = new imageview(ctx); imageviewone.setimageresource(r.drawable.pic1); imageviewtwo.setimageresource(r.drawable.pic2); imageviewone.setlayoutparams(new ...

flash - Is it possible to combine Sound objects in AS3? -

is possible take 2 sound objects , combine them 1 sound object 1 sound plays, , second plays right after it? can play first sound , next right after it, cleaner combine them before playing audio. i haven't tried this, don't believe it's natively supported sound class. if want join them, i'm thinking put data 2 byte arrays , join them. but if create class can hold multiple sounds. can create private methods play sounds in order, , public methods can can start sequence playing.

Opposite of "scrollTop" in jQuery -

jquery has function called scrolltop can used find number of pixels hidden above current page view. i'm not sure why, there no scrollbottom function returns number of pixels below current page view. is there jquery plugin adds functionality? or going require elaborate math window/document height , scrolltop value? you make pretty simple plugin this: $.fn.scrollbottom = function() { return $(document).height() - this.scrolltop() - this.height(); }; then call on whatever element wanted, example: $(window).scrollbottom(); //how many pixels below current view $("#elem").scrollbottom(); //how many pixels below element

Rails 3 - Handle Incoming Messages (Allowing Users to reply to email notifications) -

right app sends out email notifications. i'd allow user reply directly email, gets ingested app , inserted database. are there rails gems, services, tutorials can point me in right direction. also, need make reply-to email have uid, replyto--uid@domain.com, don't have rely on (sender). what think? thanks a few articles started: http://railstips.org/blog/archives/2008/10/27/using-gmail-with-imap-to-receive-email-in-rails/ http://jasonseifer.com/2009/04/24/receving-email-with-rails

c# - DateTime TryParse problem -

string date = txtworkingdate.text; datetime datetime = datetime.minvalue; if (datetime.tryparse(date, out datetime)) { args.isvalid = true; } else args.isvalid = false; txtworkingdate.text "dd.mm.yyyy" becouse of validateion false if date not "dd.mm.yyyy". how c check types of date "dd.mm.yyyy", "mm/dd/yyyy" becouse valid. by using this overload , providing accepted formats: string date = txtworkingdate.text; datetime datetime; string[] formats = new[] { "dd.mm.yyyy", "mm/dd/yyyy" }; if (datetime.tryparseexact(date, formats, cultureinfo.invariantculture, datetimestyles.none, out datetime)) { args.isvalid = true; } else { args.isvalid = false; }

c++ - using template classes as method parameters -

i've 2 template classes: class1< s > , class2< t >. in class2< t >, there's method has parameter pointer object of class1< s >. should re-define class2< t > class2< s, t >? or there other best solution? problem, might have new methods referring objects of other template classes parameters. therefore, avoid having sth. like: class2< s, t , u ...> template < class s > class class1{ public: ... private: ... }; template < class t > class class2{ public: ... class2<t> * dosomething(class1<s> * ); ... private: ... }; template < class s, class t > class class2{ public: ... class2<t> * dosomething(class1<s> * ); ... private: ... }; the type of object class2::dosomething acts upon should not have part of class2 's type. make class2::dosomething() member function template : tem...

iphone - IPad SQLite Push and Pull Data from external MS SQL Server DB -

this carries on previous post (http://stackoverflow.com/questions/4182664/ipad-app-pull-and-push-relational-data). plan when ipad application starts going pull data (config data i.e. departments, types etc etc relational data used across system) webhosted ms sql server db via webservice , populate sql lite db on ipad. when load listing pull data on line again via webservice , populate sql lite db on ipad (than run select commands populate listing). my questions are: 1. efficient way transfer data across line via web? seems different way. idea have webservice each type of data pull (e.g. retrievecontactlisting) query db , convert data "something" send across line. question "something" should converting into? 2. talks odata services. suited applications complex read , writes needed? ive created simple iphone app before talked sql server db (i sent own structured xml across line) app data calls going lot larger efficiency key. i'll give "stand...

How to make a layout template in Sinatra? -

i'm new sinatra , can't figure out put application layout. i've seen inline method uses # app code __end__ @@layout %html = yield but i'd layout in it's own .haml file. what should layout file named? directory should placed in? if haven't already, create folder sinatra script lives called... views/ and put layout in there, call layout layout.haml or whatever extension (e.g. .erubis ) you'd use.

java - Why Sun's Arrays.sort implementation creates a clone of the input array? -

can please explain following code? source: arrays.class, public static <t> void sort(t[] a, comparator<? super t> c) { t[] aux = (t[])a.clone(); if (c==null) mergesort(aux, a, 0, a.length, 0); else mergesort(aux, a, 0, a.length, 0, c); } why create aux? how sort ever working if code sorts aux? isn't waste of resources clone array before sorting? 1: why create aux? because mergesort method requires source , destination array. 2: how sort ever working if code sorts aux? because mergesort method sorts from aux to a 3: isn't waste of resources clone array before sorting? no not ... using implementation of mergesort . if sort returned sorted array, doing clone (rather creating empty array) wasteful. api requires in-place sort, , means a must "destination". elements need copied temporary array "source". if take @ mergesort method, see recursively partitions array sorted, ...

php - How does an application performance monitoring tool like New Relic RPM work? -

how application performance monitoring tool new relic rpm work? how can figure out information application? if build similar php application place start? (i know new relic php available, i'm interested in how build 1 myself). a start @ php's reflection system; http://php.net/manual/en/book.reflection.php use can gather vital information using traces , profiler dumps, @ xdebug website more information. http://www.xdebug.org/

package - Ruby: cross-platform way to determine whether NFS is installed? -

i need detect whether nfs installed or not on running server in ruby code. if there way can in cross-platform way(or @ least in unix/linux)? i can't think of cross platform way there's no standards getting kernel info. think have specific guest os type. linux "modinfo nfs". solaris boxes use modinfo , search nfs in output or in /etc/dfs/fstypes. using "uname -s" tell method use.

mysql - PHP static function does not die -

class mysql { static function query($q){ return mysql_query($q)or die(mysql_error()); } } class mysql echo mysql::query('select * unknown_table'); it must die , display mysql error not. do static functions go way? works me . (basically die() work, mysql_query() needs return falsy - putting false there lets me test short circuit evaluation ). show me code relevant problem, please. does work valid query?

visual studio 2010 - I want to update my machine with VS2010 and SQL Server Express 2008 R2 -

i'm using vs2008 sql server express 2005 great success. got bits install vs2010 , sql server 2008 express r2, , plan tackle on weekend. question this: what best approach update system latest bits. i'd like uninstall vs2008 , sql server 2005 , use latest technologies. however, don't want leftover fluff after install , able know things going go planned (although seldom do). want clean configuration date latest , greatest stuff. could see problem process: uninstall sql server 2005 uninstall vs2008 install vs2010 install sql server 2008 r2 i've searched on internet tips on how approach this. i'm finding problems people have when doing this. however, that's typically internet for; when have problems. i'm reading in mind. :) going "just it", figured might best post question out here see if has suggestions or tips process. i'd appreciate comments. of course, i'll update post once i've completed steps future geeks can benefi...

python itertools skipping ahead -

i have list of lists. using itertools, doing for result in product([a,b],[c,d],[e,f,g]): # test each result and result desired product, each result containing 1 element each of lists. code tests each of results element-by-element, looking first (and best) 'good' one. there can very large number test. let's i'm testing first result 'ace'. let's when test second element 'c' find 'ace' bad result. there no need test 'acf' or 'acg'. want skip failed ace directly trying ade. anyway without throwing unwanted results on floor? if implementing nested loops, trying manipulate loop indexes inside loop , not nice ... want skip testing lot of results. can skip ahead efficiently in itertools? itertools not best way go concern have. if have 3 sets combine, loop on , when fail, break loops. (if code complex, set variable , break right outside. for i1 in [a, b]: i2 in [c, d]: i3 in [e, f, g]: ...

objective c - Is current NSDate in local timezone within range of start and end NSDates in another timezone? -

i need determine if user's current nsdate (local time zone) falls in range of 2 nsdates belonging other time zones. for example: i'm in california, , it's 20:00 pst. coffee shop in new york open between 08:00 , 00:00 est. coffee shop stored exact values , sent in xml along tz field indicating america/new_york. i need able determine if coffee shop open or not in world currently. in example, since it's 23:00 est in new york, open still. i've tried using nsdate, nstimezone, nscalendar, nsdatecomponents construct algorithm convert, i've been unsuccessful, , when think understand it, confused again. nsdate has no concept of timezone, can't figure out real value exists in it, since need pass time zones nsdateformatter see. how create method determine if [nsdate date] in [nstimezone localtimezone] between 2 nsdates in other time zone? nsdate represents single instance in time, irrespective of time zones, calendars, etc. all need compare dat...

iphone - Help me on StoreKit Implementation -

i trying create app going charge $1 sending digital photo. i want charge user when clicks send e-photo button. and created test application on itunes connect , set necessary configurations , created in app purchase…. now want create coding part ( storekit ) interacts store… can please show code can me try above scenerio thanks time update 1 // // inapppurchasetestingviewcontroller.h // inapppurchasetesting // #import <uikit/uikit.h> #import <storekit/storekit.h> @interface inapppurchasetestingviewcontroller : uiviewcontroller { } @end // // inapppurchasetestingviewcontroller.m // inapppurchasetesting #import "inapppurchasetestingviewcontroller.h" @implementation inapppurchasetestingviewcontroller - (void)viewdidload { nslog(@"view loaded"); if ([skpaymentqueue canmakepayments]) { nslog(@"can make payments"); } else { nslog(@"cannot make payments"); } [super viewdidload]; }...

Eclipse hotkey that word wraps all my code? -

alright, tenth time has happened me. i bumped hotkey in eclipse , "word-wrapped" of code!!! example (notice plus signs on new lines): // split formula 2 parts: bit/byte range, , formula. try { formulaparts = formulaandbitpositions.split(","); } catch (exception e) { msg("pd error during decode: dpn=" + dpn + " formulaandbitpositions=" + formulaandbitpositions + " e= " + e.getmessage()); return; } so every line longer 80 characters got wrapped! grrrrrrrrr! anybody know horrible horrible hotkey responsible this? it may ctrl + shift + o (format code). updates: sorry, mistake. ctrl + shift + f format code. ctrl + shift + o organize code. mix them.

store in char column getting from decimal column in db2 -

create table test1 (no decimal(4,2) ,name char(10)) create table test2 (no char(1) ,name char(10)) insert test1 values(1,'aa') insert test1 values(2,'ab') insert test1 values(3,'ac') insert test1 values(4,'ad') insert test1 values(null,'ad') insert test2 (no,name) (select cast(no char(1)),name test1) not working. clues. thanks. are intentionally using char rather varchar? varchar won't pad text spaces. when run insert, following error: insert test2 (no,name) (select cast(no char(1)),name test1) sql0445w value "1.00 " has been truncated. sqlstate=01004 the actual insert works me, suggests need char(4) or varchar(4) rather char(1). if want automatically drop digits after decimal, cast values bigint first: insert test2 (no,name) ( select cast(cast(no bigint) char(1)), name test1 ) note still run truncation issues values 10 or -1.

php - strpos issue with 0==false? -

i'm using strpos find position of string in string. first check if string found @ in there. here's line: if (strpos($grafik['data'],$ss1)<>false && strpos($grafik['data'],$ss2)<>false && strpos($grafik['data'],$ss1) < strpos($grafik['data'],$ss2)) i check if both strings contained , want first 1 placed before second one. in php manual says strpos returns false when string not found. if string starts @ 0 position (strpos returns 0 since beginning), seems statement strpos($grafik['data'],$ss1)<>false is false. somehow 0==false ? how make statement true when strpos returns 0 ? from http://www.php.net/manual/en/function.strpos.php : warning this function may return boolean false, may return non-boolean value evaluates false, such 0 or "". please read section on booleans more information. use the === operator testing return value of function. you ...

java - What are the dangers of bytecode manipulation (if any)? -

bytecode enhancement seems interesting java technique, has feel of bit of "black magic" it. there disadvantages using (other fact functionality added classes not apparent source code)? does cause problems security, serialization, etc.? are there disadvantages using (other fact functionality added classes not apparent source code)? one thing bugs created bytecode manipulation more difficult diagnose. examination of source code, , source level debugging harder. does cause problems security, the verifier should (in theory) prevent modified bytecode breaking core type system , corrupting jvm. (and goes without saying untrusted code shouldn't allowed bytecode modification, can discount scenario.) however, in past, java byte code verifiers have been less thorough. furthermore, bytecode modification : makes harder proper source code based security analysis, and could nullify (limited) security benefits of using static analysis tool such fi...

What are the required steps for learning 3D animation? -

i want develop 3d animations scientific demonstrations. familiar java & c++. not clear basics of 3d or 2d graphics, nor familiar 3d animation tools blender , maya, , haven't been able find resources learning these topics. so, beginner steps should take learn 3d graphics? when want learn visualisation in 3d application (maya, 3dmax, softimage, blender aso) software , read manuals , visit sites of developer (eg. autodesk site, blender site). in addition, there lot of forums information (cgsociety aso) , tutorial sites in internet. buy books or learning dvd´s (for example gnomon) needed topic. learn model , how make renderings (mental ray, vray) before start animation. learning 3d graphics wide field , has steep learning curve... if got decent knowledge can maybe apply animation mentor...

seo - How do search engines recognize search boxes on websites? -

i've noticed lot of time when search on google, google automatically uses search function of relevant websites , return result of website search if url. how let google , other search engines know search box on own website , open search has it? do maybe mean site search function via google chrome omnibar? to there need have a form method type get input type text element submit button on root page of domain if users go directly root page , search there, google learns of form , adds search engines accessible via omnibar (the google chrome address bar). did mean this?

multithreading - ruby simple race condition question -

i came across example of race condition: def inc(n) n + 1 end sum = 0 threads = (1..10).map thread.new 10_000.times sum = inc(sum) end end end threads.each(&:join) p sum threads run in pararell , there's chance while 1 thread reads sum's value, 1 completes incrementing it, former finish own incrementing old value, , result sum won't change. but wondering, why when replace line 'sum = inc(sum)' 'sum += 1', output appears correct. why that? is because overhead of calling method huge compared doing variable assignment , threads 'get out of sync' causing output incorrect? i assume, straight sum += 1 still able observe race condition, if had been doing longer summing loop, etc.? is because overhead of calling method huge compared doing variable assignment , threads 'get out of sync' causing output incorrect? yes. verify it, increase counter , run several tests. increased 100_000.times , ...

Which is the first method called when Java executes a program? -

i learning core java , have 1 question, "which first method called when program executed?" in addition aioobes answer a usual way start simple java program execute java this: java com.example.myclass com.example.myclass (or qualified class name) needs have main method signature: public static void main(string[] args) (you're allowed change name of parameter, arguments instead of args ). virtual machine try load named class , try invoke static method "start java program".

version control - Visual Studio keeps changing project.sln file -

i work in team on visual c++ project. following advice got we're tracking project's .sln file our scm. turns out each time pull partner (yes, use git) , open solution in vs, .sln file updated. part being updated long id appears several times (in case ending 7c44) in following segment: {828cb89e-f092-3b7a-2f8c-62e146587c44}.debug|win32.activecfg = debug|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.debug|win32.build.0 = debug|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.debugstaticcrt|win32.activecfg = debugstaticcrt|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.debugstaticcrt|win32.build.0 = debugstaticcrt|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.release|win32.activecfg = release|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.release|win32.build.0 = release|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.releasestaticcrt|win32.activecfg = releasestaticcrt|win32 {828cb89e-f092-3b7a-2f8c-62e146587c44}.releasestaticcrt|win32.build.0 = releasesta...

java - Simplest way to unit test an android library application? -

sorry if bit of vague question, im struggling find single solid example on how unit testing (isolated testing) android... here example of i'm wanting achieve: // class class calculator { public int add(int a, int b) { return a+b; } } // simple test import org.junit.assert; import org.junit.test; class calculatortests { @test public void should_add_numbers_correctly() { calculator calculator = new calculator(); int expectedresult = 5 + 5; int actualresult = calculator.add(5,5); assert.assertequal(actualresult, expectedresult); } } so 1 project contains models , logic, project contains tests said library. there no front end or ui, want bare minimum able test methods work in isolation. as long "library" doesn't contain references resources in android sdk, there isn't more regular unit testing. in eclipse workspace, have main project myandroidlibproject , create new java project (e.g. myandr...

learn Scala with TDD -

i'm learning scala now. saw there 2 test frameworks there, scalatest , specs. problem i'm not still @ ease language decide better. i'm used write tests before code, @ moment have no clear idea how in functional programming. ideally i'd learn scala in tdd fashion, there resource it? there functional koan might looking for. dick wall java posse started github project: https://github.com/relevance/functional-koans/tree/scala you need maven start via mvn package . there koan: http://www.scalakoans.org/ thanks @mikehoss!

oop - Can Scala be seen as an 'Abstraction Inversion'? -

greetings, it's provocative question, aiming open debate how abstraction inversion seen among developer community. i'm curious know think. first, here quote abstraction inversion exemples given wikipedia: http://en.wikipedia.org/wiki/abstraction_inversion creating object represent function cumbersome in object-oriented languages such java , c++, in functions not first-class objects. in c++ possible make object 'callable' overloading () operator, still necessary implement new class, such functors in stl. for me functions first-class citizen in scala, when use scala generate java bytecode, scala create specific class 'on top' of java make functional programming possible... can see abstraction inversion ? same can apply clojure or functionnal language jvm... or apache collections, exemple this: http://commons.apache.org/collections/apidocs/org/apache/commons/collections/closure.html btw, i'm not convinced wikipedia article objectivity. e...

java - unknown bytes is returned by method getBytes() -

import java.io.unsupportedencodingexception; import java.util.arrays; public class main { public static void main(string[] args) { try { string s = "s"; system.out.println( arrays.tostring( s.getbytes("utf8") ) ); system.out.println( arrays.tostring( s.getbytes("utf16") ) ); system.out.println( arrays.tostring( s.getbytes("utf32") ) ); } catch (unsupportedencodingexception e) { e.printstacktrace(); } } } console: [115] [-2, -1, 0, 115] [0, 0, 0, 115] what it? [-2, -1] - ??? also, noted, if that: string s = new string(new char[]{'\u1251'}); system.out.println( arrays.tostring( s.getbytes("utf8") ) ); system.out.println( arrays.tostring( s.getbytes("utf16") ) ); system.out.println( arrays.tostring( s.getbytes("utf32") ) ); console: [-31, -119, -111] [-2, -1, 18, 81] [0, 0, 18, 81] the -2, -1 byte order mark (bom - u+feff) indcates following t...

objective c - Strange NSPasteboard and TextEdit interaction -

i drag-dropping string 2 places in app. 1 custom nsview , 1 nstabledatasource delegate. first 1 allows me drag text textedit application, second 1 not. can drag both other apps such terminal or textmate. far can tell, i'm using close identical code both. i'm trying figure out what's wrong. it's working in principle because can drag apps. what's going on textedit? from custom nsview: (void)mousedown:(nsevent *)theevent { nsstring *teststring = @"test"; nsimage *dragimage; nspoint dragposition; nspasteboard *pboard = [nspasteboard pasteboardwithname:nsdragpboard]; [pboard declaretypes:[nsarray arraywithobjects: nsstringpboardtype, nil] owner:nil]; [pboard setstring:teststring fortype:nsstringpboardtype]; dragimage = // blah dragposition = [self convertpoint:[theevent locationinwindow] fromview:nil]; [self dragimage:dragimage at:dragposition offset:nszerosize even...

indexing - MySQL: make a compound index of 3 fields, or make 3 separate indices? -

i have mysql table has, among other attributes, timestamp, type , user_id. of them searchable and/or sortable. better create index each one, or create single compound index three, or both? pablo's answer correct, maybe you'll fail realize compound index might justified. you can have multiple indexes , having idx1(tstamp, user_id) not exclude having indx2(tstamp, type) or idx1reverse(user_id, tstamp) , on... compound indexes useful when cover of conditions in query, index propose useful for select * my_table tstamp = @ts1 , user_id = @uid , type = @type if want improve performance of such queries can consider adding composite index. the downside of indexes slows down update operations. however, general applications many more selects updates (both in terms transactions i.e. number of statements , in terms of of records affected/retrieved) , @ same time more tolerant of slower updates (users judge speed of system not time necessary update record, time n...

c# - Is there a benefit to override the default Insert/Update/Delete queries for EF -

as question asks really. the ef modeller tool allows map insert/update/delete functions sproc, there benefit overriding them? if requires custom validation, yes, if i'm happy how now, worth creating sproc's them all? i can't remember how view sql it's executing them find out exact query, should imagine it'd pretty similar standard insert/update/delete query. i can think of few cases useful: you're working legacy database doesn't quite map ef model precisely. you need queries executed on insert/update/delete, don't have rights triggers on database. soft deletes in database want abstract away from. regular delete perform soft delete. not quite sure how viable these options are, more of nhibernate guy. these theoretical options. as viewing executed queries, there's few possibilities that. attach profiler sql server instance , @ raw queries executed. there's entity framework profiler (by ayende/oren eini) isn't free, ...

java - How to inherit a RuntimeException class? -

i have 2 options: public class syntaxexception extends runtimeexception { private string msg; public syntaxexception(string m) { this.msg = m; } public string getmessage() { return "invalid syntax: " + this.msg; } } and public class syntaxexception extends runtimeexception { public syntaxexception(string m) { super("invalid syntax: " + m); } } which 1 preferred, if have think code maintainability , extendability? use second one. argument constructor of both runtimeexception , inherited class error message, there's no reason duplicate functionality given runtimeexception in code.

Input html file type + post form + button type="button" + jquery + MVC 2.0 + Asp.net -

i having 1 requirement in mvc 2.0 , asp.net. i using 1 partial user control view , using want upload multiple files. how post form without using input button type='submit'. i have use button type=button , have post form can uploaded files in controller using request.files. any appreciate. has done using jquery + mvc 2.0 + asp.net. is there way ?? have tried ajax.. form post not able files. thankx in advance. i've had great success uploadify plugin jquery. can auto upload multiple files selected without needing submit form. http://www.uploadify.com/

c# - Problem with using server-side clipboard in ASPX webapp -

i've got reporting application runs server-side reads stored bmp database (as byte[]), converts image, , places excel spreadsheet forms base report (this report delivered client download.) i'm trying use server-side clipboard handle 'pasting' of image specific range in worksheet. here's code snippet - system.drawing.image image; bitmap bm; graphics g; excel.range range; memorystream ms = new memorystream(graphrecs.elementat(0).graph, 0, graphrecs.elementat(0).graph.length); ms.write(graphrecs.elementat(0).graph, 0, graphrecs.elementat(0).graph.length); image = system.drawing.image.fromstream(ms, true); bm = new bitmap(413, 130); g = graphics.fromimage(bm); g.interpolationmode = system.drawing.drawing2d.interpolationmode.highqualitybicubic; g.drawimage(image, 0, 1, 413, 130); clipboard.setdataobject(bm, false, 4, 250); range = ws.get_range(cblkptr[6, 2], cblkptr[6, 2]); ws.paste(range, bm); clipboard.clear(); running in debug mode under vs2008 seems w...

ignore a file name in php array -

im pretty new php, found gallery script takes photos folder , displays them. i'm trying make array ignore folders in 'photos' folder named 'app_thumbnails'. the code creating array is: //read files , folders $files = array(); $dirs = array(); if ($handle = opendir($currentdir)) { while (false !== ($file = readdir($handle))) { // change filename display date $displaydate= date('js m y', strtotime($file)); // load folders array if (is_directory($currentdir . "/" . $file)) { if ($file != "." && $file != ".." ) { // set thumbnail folder.jpg if found: if (file_exists(gallery_root . "photos/" . $file . "/folder.jpg")) { $dirs[] = array( "name" => $file, "date" => filemtime($currentdir ....

flex - Combine/merge Dynamic Objects in AS3 -

i have 2 dynamic objects , want build 1 contain properties: var o1:object = {prop1:val1,prop2:val2,prop3:val3}; var o2:object = {prop3:val3a,prop4:val4}; and need obtain third object looks that: {prop1:val1, prop2:val2, prop3:val3a, prop4:val4}; basically need way iterate through object properties , add new properties third object. have mention i'm quite new as3/flash/flex. first question, mean have prop3 in both objects? need decide in case of collision that, object has precedence. secondly, check out introspection apis: http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_8.html something should work: public function mergedynamicobjects ( objecta:object, objectb:object ) : object { var objectc:object = new object(); var p:string; (p in objecta) { objectc[p] = objecta[p]; } (p in objectb) { objectc[p] = objectb[p]; } return objectc; } if property exists in , b, b's overwrite a's. not...

css - HTML A problem with floating the divs -

i have problem mentioned above. in web app, i'll generating many divs dynamically jquery(asp.net mvc). each new div can have different width, , of them must floated left i tried (test) float left 2 divs, no success. doing wrong ? each div has defined width, because when total width of divs > maindiv's width, scrollbar appear. now, in case, 2 divs not floated left here's code <div id="maindiv" style="overflow:auto; width:100%;"> <div style="width:960px; float:left; background-color:lime;"> </div> <div style="width:960px; float:left; background-color:red;"> b </div> </div> you have make sure containing div wide enough accommodate floated div's side side. so in example, have set width of containing div maindiv @ least 1920px. you need additional wrapper if want scroll-bars appear on maindiv : html: <div id="maindiv" style=...

c# - VSTO Outlook Embed Image MailItem -

i need embed image part of email, after user signature, not @ end of email, becasue if i'm sending reply of large email, embedded image it's going @ bottom of emails chain how embed image part of email content (not link outside image)? how add image after user signature? i'm work vsto, vs2008 fwk3.5 , outlook 2007 here code: public partial class thisaddin { private void thisaddin_startup(object sender, system.eventargs e) { this.application.itemsend += new microsoft.office.interop.outlook.applicationevents_11_itemsendeventhandler(application_itemsend); } private void application_itemsend(object item, ref bool cancel) { if (item outlook.mailitem) { outlook.mailitem mailmessage = (outlook.mailitem)item; //do add image after signature } } finally solved problem this: private void sendformatted(outlook.mailitem mail) { if (!string.isnullorempty(mail.htmlbody) &...

servlets - Displaying database result in JSP -

i have controller servlet forward request model servlet.now when model gets results database, forwarding jsp.i not sure write in jsp because need show table of customerlist.here part of model servlet: protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { connection connection = getdatabaseconnection(); request.setattribute("customerlist", getcustomerlist(connection)); closedatabaseconnection(connection); } private vector<customer> getcustomerlist(connection con) { string sqlstr = "select * " + "from customer " + "order name"; preparedstatement stmt = null; resultset rs = null; vector<customer> customers = new vector<customer>(); try { stmt = con.preparestatement(sqlstr); rs = stmt.executequery(); while (rs.next()) { customer c...

asp.net mvc - After updating to MVC3 RC, why don't my View Data classes show up in the Add View dialog -

background: i updated rc of mvc3, , when went add stongly-typed view, list of classes didn't contain class wanted, has been built in project. now, did compile project, , have several views work correct, model doesn't show in list. since change dialog in rc, new criteria makes class show up, considering none of them in project showed up. they altered way they're displayed in mvc 3 rc. example scroll to: project.data.models.user now it's organized in reverse user (project.data.models) this problem. nice if had filter show local objects rather referenced assemblies

jquery - Insert Business Catalyst Template Tag -

hi guys trying , if statement business catalyst in bc give template tags ie {module_webapps,5502,a,} i trying run if statement add code div. var pathname = window.location.pathname; if(pathname == '/test') { //var mod = "{module" + '_' + "webapps,5502,a,}"; $('.comment-box').html("{module" + '_' + "webapps,5502,a,}"); //alert(mod); } it come through shows text in webpage , doesnt run code. you can't that. module needs in form {module_webapps,5502,a,} @ server side rendering engine pull data out. assembling @ client end nothing.

g++ - how to set up cross-directory dependencies in gnu make -

i've got common set of make rules being used in multiple directories. each make simple: basedir:=../.. target:=thetarget include makefile.include unless overridden, have default value source code: src:= $(wildcard *.cpp) we want build object files in directory (not sources), so: objdir:= ../obj bare:= $(foreach f,$(src),$(notdir $(f) ) obj:= $(foreach o,$(bare),$(objdir)/$(o).o ) so have .o files, need each 1 fire rule based on .cpp long directory known, easy: $(objdir)/%.o: %.cpp but in of directories, there arbitrarily grouped files in subdirectories. temporarily got around hardcoding of them in central makefile: $(objdir)/%.o: a/%.cpp build... $(objdir)/%.o: b/%.cpp build... but i'd able specify build directories in variable if possible. there way set dependencies $(objdir)/x.o: a/x.cpp $(objdir)/y.o: a/y.cpp and $(objdir)/z.o: b/z.cpp without manually having list out dependencies? for matter, have dependency files (.d) $(depdir...