Posts

Showing posts from August, 2012

c# - Using .files/.folders with Mono on Linux -

i'm writing c# application on linux, , i'd store applications .config files in user's home directory, i.e. if application's name foo.exe ~user/.foo/foo.exe.config instead of looking .config file in same directory assembly. possible? sure. environment.specialfolder . string appdatadir = environment.getfolderpath(environment.specialfolder.applicationdata); remember use path.combine(folder1, folder2) combine paths in order make app cross platform compatible. alternatively environment variable home : string homedir = system.environment.getenvironmentvariable("home");

How to Trust Android SSL PKCS12 Certificate -

here sample code.. system.setproperty("http.keepalive", "false"); httpsurlconnection .setdefaulthostnameverifier(new hostnameverifier() { public boolean verify(string hostname, sslsession session) { // todo auto-generated method stub return false; char[] passwkey = "pass".tochararray(); keystore ts = keystore.getinstance("pkcs12"); inputstream in = getresources().openrawresource( r.raw.certificatefile); ts.load(in, passwkey); keymanagerfactory tmf = keymanagerfactory .getinstance("x.509"); tmf.init(ts, passwkey); sslcontext context = sslcontext.getinstance("tls"); context.init(tmf.getkeymanagers(), new x509trustmanager[] { new myx509trustmanager(in, "mo...

c++ - How do I make a static library Release/Debug independent in VS2010 Express? -

i programming application , linking against sdl , opengl. in code have following lines: #pragma comment(lib, "sdl.lib") #pragma comment(lib, "sdlmain.lib") #pragma comment(lib, "opengl.lib") this works in release mode only. in debug mode, receive following linker error: libcmt.lib(invarg.obj) : error lnk2005: __initp_misc_invarg defined in libcmtd.lib(invarg.obj) libcmt.lib(invarg.obj) : error lnk2005: __call_reportfault defined in libcmtd.lib(invarg.obj) libcmt.lib(invarg.obj) : error lnk2005: __set_invalid_parameter_handler defined in libcmtd.lib(invarg.obj) libcmt.lib(invarg.obj) : error lnk2005: __get_invalid_parameter_handler defined in libcmtd.lib(invarg.obj) libcmt.lib(invarg.obj) : error lnk2005: __invoke_watson defined in libcmtd.lib(invarg.obj) libcmt.lib(invarg.obj) : error lnk2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@...

php - "Undefined index" notice after submitting HTML form -

so have sign form, , there php @ top of code. gives me error: notice: undefined index: register in /home/content/04/7195304/html/index.php on line 20 this line 20: if ($_post['register']) { here submit button: <input type="submit" class="gobutton" value="register" name="register"/> edit so here's form tags: <form action="index.php" method="post"> you should check this: if ( isset($_post['register']) ) {} to avoid getting notice.

bit manipulation - How do I store a byte into a 4 byte number without changing the bytes around it? -

so if have 4 byte number (say hex) , want store byte dd hex, @ nth byte position without changing other elements of hex's number, what's easiest way of going that? i'm guessing it's combination of bitwise operations, i'm still quite new them, , have found them quite confusing far? byte n = 0xdd; uint = 0x12345678; = (i & ~0x0000ff00) | ((uint)n << 8); edit: forgot mention, careful if you're doing signed data types, things don't inadvertently sign-extended.

android - Adding my custom View into an XML layout throws exception -

i'm trying create first custom view subclass graphview , add layout xml file. i found this question , tried apply project, seems wrong because eclipse ide tells me: de.muza3000.graph.graphview failed instantiate. and throws exception: java.lang.nosuchmethodexception: de.muza3000.graph.graphview.<init>(android.content.context, android.util.attributeset) @ java.lang.class.getconstructor0(unknown source) @ java.lang.class.getconstructor(unknown source) @ com.android.ide.eclipse.adt.internal.editors.layout.projectcallback.instantiateclass(unknown source) @ com.android.ide.eclipse.adt.internal.editors.layout.projectcallback.loadview(unknown source) @ android.view.bridgeinflater.loadcustomview(bridgeinflater.java:198) @ android.view.bridgeinflater.createviewfromtag(bridgeinflater.java:126) @ android.view.layoutinflater.rinflate(layoutinflater.java:618) @ android.view.layoutinflater.inflate(layoutinflater.java:407) @ android.view.layoutinflater.inflate(layoutinflater.j...

android - How to launch PreferenceScreen from the parent one -

i've added in app simple alertdialog asks if user wants redirected info preferencescreen. i'd know how launch child preferencescreen parent one. thanks. i don't know mean "info" preferencescreen, when writing preference xml file load in preferenceactivity subclass can nest preferencescreen tags: <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" android:orderingfromxml="true" > <preferencescreen android:title="child preference screen" android:summary="description"> <checkboxpreference android:defaultvalue="false" android:key="check1" android:title="checkbox" android:summaryoff="off" android:summaryon="on" /> </preferencescreen> </preferencescreen> the child preference screen show automatically when...

actionscript 3 - AS3 Menu not detecting clicks -

i've got buttons navigate around timeline. trying make switch statement save me time writing code. i've come with, doesn't work. buttons each have rollover function works fine. traces in there debugging. for (var a=0; a<mainbuttons.length; a++){ mainbuttons[a].buttonmode = true; mainbuttons[a].addeventlistener(rolled, hidedbases); mainbuttons[a].addeventlistener(clicked, switchview); } function switchview(e:event):void { switch (e.target.name) { case "count_btn": gotoandplay(4); trace("count"); break; case "order_btn": gotoandplay(5); trace("order"); break; case "admin_btn": gotoandplay(6); trace("admin"); break; case "serve_btn": gotoandplay(7); trace("service"); break; case "video_btn": gotoan...

php - Would it be better to include() resources (css,js) or to let the browser do another request? -

would faster include javascript file , outputting in html <script> or use src attribute , let browser make request? simply outputting instead of letting browser make request mean less requests , possibly less server load, make faster? including files , outputting them doesn't let browser cache them. if include it, every different page have overhead of downloading script again. if externally link it, , send future expiry headers , use versioning cache buster (for changes), file downloaded once per required. on topic of performance, sure minify or pack production use javascript. of course, relevant javascript. if few lines , not change, maybe could save 1 http request , place inline. 99% of time, however, in external file best practice.

open source - Updating Self-Installed PHP files? -

i in final stages of completing project ( vizulium - open-source photography cms). have 1 final remaining stumbling block: updating software. my idea wanting implement this: check newest version @ vizulium website (page displays current stable version). if newer version exists, , user requests it: a. zip updated files on vizulium server b. download files user's server c. unzip contents i have tracking system in place keeps track of updates (datetime) push. have not began step 2. in php , mysql. is typical implementation of problem? need clarify anything? i not using ftp since self-install , assume user programming-illiterate. your solution valid, needs few considerations. you should connect server via https , certificate verification query , fetch available updates. you should sign updates private key , have client verify updates authentic before applying them. if need remove obsolete file install, unzipping not this, perhaps have "upgrade.p...

Adding fields to an already existing database for Django (version < 1.7) -

i'm using django ( < v1.7), sqlite3 database engine. i trying add new field existing model's class. class has data associated it. manage.py syncdb not adding new fields db. is there way to: add new field existing class, , make sure db entry allocated it? populate new field empty string existing db entries? install south in django , can handle existing tables. check this if want use django-south, install on django, after adding new fields existing model run python manage.py schemamigration --initial it create file in project app. then, python manage.py migrate thats table altered.

oracle - Duplication of stored data -

we have oracle 8i border checkpost automation truck entry details stored . many time truck data entered once duplicated several time. how filter out such duplicated data. part of data-storage becomes huge. please advise how overcome problem the standard method use unique constraint.

filesystems - Is there a performance drop when we open a file in a directory that has huge numbers of files? -

suppose want open file in directory, there huge numbers of files. when requested program open file in there, how fast can search particular file? there performance drop looking requested file in case? ps. should depend on file systems implementation, yes? yes, depends lot on file system implementation. some file systems have specific optimizations large directories. 1 example can think of is ext3 , uses htree indexing large directories. generally speaking there some delay find file. once file located/opened, however, reading should not slower reading other file. some programs need handle large amount of files (for caching, example) put them in large directory tree, reduce number of entries per directory.

c# - How do I store source code lines in SQL Server Database and access it via DataSet -

Image
i want store following code database: fun(...); int main() { fun(3, 7, -11.2, 0.66); return 0; } fun(...) { va_list ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); } and in dataset , display on page. as of have stored questions varchar(max) datatype when try in dataset following error: failed enable constraints. 1 or more rows contain values violating non-null, unique, or foreign-key constraints. i doing in asp.net web application. edit: here table definition of table inserting data the query using insert data table: con.connectionstring = constr; cmd.connection = con; cmd.commandtext = "insert questable values(@d1,@d2,@d3,@d4,@d5,@d6,@d7, null)"; cmd.parameters.add("@d1", sqldbtype.int).value = txtqid.text; cmd.parameters.add("@d2", sqldbtype.varchar).value = txtques.text; cmd.parameters.add("@d3", sqldbtype.varchar).value = txtansa.text...

swing - Java and Windows Look & feel -

i made swing application scans images; , each image represented leaf tree the problem faced throws exception exception in thread "awt-eventqueue-0" java.lang.nullpointerexception @ com.sun.java.swing.plaf.windows.xpstyle$skin.getwidth(xpstyle.java:513) @ com.sun.java.swing.plaf.windows.xpstyle$skin.getwidth(xpstyle.java:517) @ com.sun.java.swing.plaf.windows.windowstreeui$expandedicon.geticonwidth(windowstreeui.java:138) @ javax.swing.plaf.basic.basictreeui.drawcentered(basictreeui.java:1580) @ javax.swing.plaf.basic.basictreeui.paintexpandcontrol(basictreeui.java:1464) @ javax.swing.plaf.basic.basictreeui.paint(basictreeui.java:1206) @ javax.swing.plaf.componentui.update(componentui.java:143) @ javax.swing.jcomponent.paintcomponent(jcomponent.java:763) @ javax.swing.jcomponent.paint(jcomponent.java:1027) @ javax.swing.jcomponent.painttooffscreen(jcomponent.java:5122) @ javax.swing.bufferstrategypaintmanager.paint(bufferstra...

php - how to rename file name while uploading -

i have file 2 input fields 1 file name (user type) , second 1 choosing file want upload file directory name user typed. down code i'm using guys please me how change file name user typed. <?php $filename = $_post["file"] $upload = $_files['userfile']; $target_path = "upload/"; $target_path .= $upload["name"]; $newname = "anything"; if(move_uploaded_file($upload["tmp_name"], $target_path)) { echo "uploaded successfully"; } ?> change $target_path .= $upload["name"]; $target_path .= $filename; . edit: record, have letting people upload files (and choose extension) web server raises serious security concerns. suggest @ least disabling ability execute scripts in target folder.

Creating Spectral Heat maps or Intensity maps from CDIP data using Ruby -

Image
background per coastal information data program (cdip), generating spectral heat/intensity map wave swell @ http://cdip.ucsd.edu/?nav=recent&sub=observed&units=metric&tz=utc&pub=public&map_stati=1,2,3&stn=100&stream=p1&xitem=dir_spectrum . this dynamically generated data containing energy density, duration (in seconds) & direction (in degrees 180 degrees representing south). data sample here's explanation of data: http://cdip.ucsd.edu/data_access/mem_2dspectra.cdip here's data sample buoy 100 (same buoy shown in heat/intensity/spectral map: http://cdip.ucsd.edu/data_access/mem_2dspectra.cdip?100 question how take 2-dimensional data , create heat/intensity map ensuring overlaid on polar coordinate map (and appropriate scale), example url per cdip's site? ultimately, need done in ruby, preferably using ruby-gd or rmagick, appreciate language-agnostic solutions, too. i in rush, can't finish right now, nobody ...

c# - Populate a LINQ table in code? -

question: want populate linq table code, not database. is possible ? system.data.linq.table<question> myquestions = new system.data.linq.table<question>(); then like: myquestions.rows.add(aquestion); just populate regular datatable , can use linq using system; using system.data; namespace consoleapplication10 { class program { static void main(string[] args) { var dt = new datatable(); dt.columns.add("id", typeof(int)); dt.columns.add("project name", typeof(string)); dt.columns.add("project date", typeof(datetime)); (int = 0; < 10; i++) { var row = dt.newrow(); row.itemarray = new object[] { i, "title-" + i.tostring(), datetime.now.adddays(i * -1) }; dt.rows.add(row); } var pp = p in dt.asenumerable() (int)p["id"] > 2 select p; foreach (var row in pp) { console...

xslt - EXSLT date:difference "bug" when changing month -

i'm experiencing problems when using default date:difference exslt template, provided @ http://www.exslt.org/date/functions/difference/index.html . i've been able narrow down problem , find source: xsl processor. problem is, xslt processor have access saying, difference between dates "2011-02-28t10:00:00" , "2011-03-01t10:00:00" -p27dt9h, when difference pt15h (this duration other xslt processors, such xalan , saxon calculates correctly - tested through oxygen xml editor). now, there way edit xsl template (date:difference) work xsl processor? think processor i'm using jaxp 1.3 - it's little hard figure out sap mii 12.1 documentation available. nb: not possible install xslt processor :) edit: further research has shown, "under hood", jaxp running xalan (system-property('xsl:vendor') returns "apache software foundation (xalan xsltc)") edit: source of problem has been identified (!), can't acceptable solution....

How can i check if the table mysql.proc exists -

i working on wpf application installs if mysql installed, before installation want check whether mysql.proc table exists or not. googled , ended query select * information_schema.tables table_schema = schema() , table_name = 'mysql.proc' this query returns empty row. i tried simple select statement select * mysql.proc , , returned table names of stored procedures, if table didn't exists throws exception in c# code. so there way can fire query c# , boolean value depending on whether mysql.proc table exists or not? try show tables mysql 'proc' . if there no result rows, table doesn't exist. if there 1 row, table exists. note approach isn't portable across rdbmss, though doesn't seem concern of yours. as first query, schema() returns default database, if it's not "mysql", query fail. likewise, data in table_name column doesn't include database name, comparing 'mysql.proc' fail.

java - Can a malicious user on a web application manipulate the inputs (beside the form data) that is sent by the front-end of web application? -

are there possible ways malicious user on web application can manipulate input sent front-end of web application (not talking form data, of course) requests sent e.g., when allow him edit profile or content, may manipulate ids (userid or contentid) may maliciously evil other users content? these inputs fixed on webpage & not editable still can users manipulate them? is possible users may harm in manner? how can safeguard application against this? besides, verifying user's identity , contents/properties on application prior allowing each of actions. yes of course. anything comes client can modified , cannot trusted @ all . you need server-side checks if user editing own profile or he's allowed edit. for things editing profile use userid stored in session though (assuming it's secure, i.e. stored server-side or in cryptographically signed cookies). let data go through client if it's necessary - if data available on server, don't have give use...

ios - How does the app-update process in the Apple AppStore work -

i managed squeeze down texture/image data game 20mb allow 3g downloads. stay below 20mb, if app gets updated (additional texture data). in order allow future updates, app copies textures/images main bundle documents directory (which not altered when app updated). when app starts, checks if required textures exist in documents folder. if dont exist, textures copied main-bundle document directory. updates should contain new texture data (which again copied document folder) , modified binary. possible? how apple update ios apps? approach works, if updates applied sequentially when user decides update app: 1) original version installed 2) update available -> install 3) update available -> install ... the described approach not work, when apple provides "latest" version (because previous updates missing). i hope can shed light on update process. thanks in own words: the described approach not work, when apple provides "latest" version (b...

ruby on rails - Regex to validate string having only characters (not special characters), blank spaces and numbers -

i using ruby on rails 3.0.9 , validate string can have characters (not special characters - case insensitive), blank spaces , numbers. in validation code have: validates :name, :presence => true, :format => { :with => regex } # here should set 'regex' how should state regex? there couple ways of doing this. if want allow ascii word characters (no accented characters Ê or letters other alphabets Ӕ or ל), use this: /^[a-za-z\d\s]*$/ if want allow numbers , letters other languages ruby 1.8.7 , use this: /^(?:[^\w_]|\s)*$/u if want allow numbers , letters other languages ruby 1.9.x , use this: ^[\p{word}\w\s-]*$ also, if planning use 1.9.x regex unicode support in ruby on rails, add line @ beginning of .rb file: # coding: utf-8

c# - FormsAuthenticationTicket.expiration v web.config value timeout -

this mvc2 website, having problem formsauthentication ticket. user timeouts after 30 minutes cannot re-login. during testing, datetime.now.addminutes(30) value set 5000 , ok, has changed 30 , when problem started from cookie creation formsauthenticationticket ticket = new formsauthenticationticket( 1, user.userid, datetime.now, datetime.now.addminutes(30), false, "user,user1", formsauthentication.formscookiepath); web.config file <authentication mode="forms"> <forms loginurl="~/account.mvc/logon" timeout="2880" name=".aspxformsauth" /> </authentication> does expiration value in ticket creation need >= web.config value? because manually creating authentication cookie, timeout value in web.config ignored. recommend having same value: var ticket = new formsauthenticationticket( 1, user.userid, dat...

javascript - How to directly use raw Ajax on IE -

we have webpage uses webservice.htc call web service. old page , having relability problem it. without using of available framework out there. there new (hopefully more robust) way access web service in ie 7? you can make webservice call directly using javascript.. however. cannot robust java or .net client (not clients using other technologies not robust).. you can find helpful article on code project on calling web services using java script.

audio - How can I generate a note or chord in python? -

can point me library generating notes , chords in python 2.7? have looked @ pythoninfowiki without lot of luck, pyaudio crashes , nothing else seems generate tones. i don't know if help, here's code synthetizes complex sound based on gives frequencies , amplitudes: import math import wave import struct def synthcomplex(freq=[440],coef=[1], datasize=10000, fname="test.wav"): frate = 44100.00 amp=8000.0 sine_list=[] x in range(datasize): samp = 0 k in range(len(freq)): samp = samp + coef[k] * math.sin(2*math.pi*freq[k]*(x/frate)) sine_list.append(samp) wav_file=wave.open(fname,"w") nchannels = 1 sampwidth = 2 framerate = int(frate) nframes=datasize comptype= "none" compname= "not compressed" wav_file.setparams((nchannels, sampwidth, framerate, nframes, comptype, compname)) s in sine_list: wav_file.writeframes(struct.pack('h...

Getting 'basic' datatype rather than weird nullable one, via reflection in c# -

my basic need datatypes anonymous type generated linq sql query. i have piece of code (cleverer write, since haven't delved reflection) returns datatypes anonymous types, , works elements marked 'not nullable' in linq2sql properties. so, if have string return system.string. however, when element nullable end 'full name' of being: {name = "nullable 1" fullname = "system.nullable 1[[system.decimal, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089]]"} all want extract system.decimal type in such case (and in cases of strings or whatever, i'd want system.string). i've looked through properties , can't find seems store this. private static dictionary<string, type> getfieldsfortype<t>(ienumerable<t> data) { object o = data.first(); var properties = o.gettype().getproperties(); return properties.todictionary(property => property.name, property =...

svn - How can I have directories in my Git repository which I normally don't check out? -

i'm considering moving subversion website repositories git, i'm not sure how structure new repositories. in svn, structured repos this: branches tags trunk supportdocs webdocs under trunk have directory support documents (word docs, photoshop files, etc.) , webdocs directory houses actual website. i checkout webdocs directory use in eclipse. however, git, if make existing trunk root of repo, clone grabs whole thing , makes difficult work webdocs files. should create 2 repos, 1 support docs , 1 web files? or there way can keep them both in master branch, work subfolder? you can accomplish using sparse checkouts . note clone still contain other directories, won't have them in working directory.

Why is MySQL's default collation latin1_swedish_ci? -

what reasoning behind setting latin1_swedish_ci compiled default when other options seem more reasonable, latin1_general_ci or utf8_general_ci ? the bloke wrote it co-head of swedish company . possibly similar reasons, microsoft sql server's default language us_english.

Google Maps Marker with dynamic image inside marker -

i trying add image inside of google maps marker (not info window). want avatar marker, still want retain marker icon. is there way in gmaps 3? is marker label class you're looking for? adds dom object marker can place image in.

.net - Unit testing with NUnit and Console -

i've been playing around curses sharp library (a c# wrapper pdcurses), writing unit test code handle on api , how works, , i've come question. i can run curses sharp within dll (so nunit can test it), using following code: bool consoleallocated = allocconsole(); if (!consoleallocated) throw new exception("unable allocate new console."); curses.initscr(); stdscr.add(4, 6, "this test title"); curses.endwin(); freeconsole(); allocconsole , freeconsole extern's imported kernel32. what able read console output position 4,6 string programmatically check string i've entered has been output correctly. pretty important able checks in order create curses-style app using tdd instance. i've looked on curses , stdscr objects (both curses sharp objects), , console object (from windows library) , haven't been able find way yet. have ideas? i managed find answer, in case ...

mocking - Lite Python AMQP server implementation for dev and mock? -

in django, running ./manage.py runserver nice dev, avoiding hassle setup , start real webserver. if not running django, can still setup gunicorn server easily. is there similar amqp? i don't need full implementation nor robust, easy install , run dev. pypi package great. celery not answer. don't want client, want server. mini python rabbitmq. i'm not aware of amqp broker implemented in python. , not aware of 'lite' implementation in general; think implementing amqp broker sufficiently complex try either aim close 1 of versions of amqp specification, or don't bother @ all. :) i don't quite see how running broker presents same problems running test web server web application. the web server nothing useful without application run inside it, , while you're developing application makes sense able run without needing full deployment. but not implementing internals of broker, , can configure dynamically (unlike web server) doesn'...

.net - Changing image contrast with GDI+ and C# -

my problem following : i making program, can manipulate brightness, gamma , contrast through c# code. brightness , gamma ok. have achieved through code found in net, can't contrast. the thing have found calculateramp method, has input parameters (double level, double brightness, double gamma, double contrast) . know input give brightness, gamma , contrast (the values sliders in interface), don't know level for. the other problem method when pass calculated ramp random level parameter parameter setdevicegammaramp(intptr hdc,ref ramp rmp) changes screen contrast, when move brightness slider changes made contrast slider lost. may because of using same method or not sure what. i thankful or ideas, no matter if changes current solution not full, or brand new solution - prefer - because feel in way unsure this. in advance everybody. here code of calculateramp method, function setdevicegammaramp(...) called me manipulate contrast current calculated ramp. not sure if...

asp.net - File.OpenRead access using UNC path. Impersonation not working? -

is there reason impersonation not seem work unc path using file.openread()? i'm utilizing codeproject's impersonation utility : i have user rights share i'm passing openread(). this code , it's not accessing file: try { bool canimp = imp.impersonatevaliduser(impuser, domain, imppwd); filestream fs = file.openread(filepath); logger.debug("file stream opened..."); byte[] b = new byte[fs.length]; fs.read(b, 0, b.length); fs.close(); // code continued turns out using ip address in impersonation domain, rather friendly domain name. once used friendly domain name, impersonation worked.

android - CheckedTextView Background Resource Error -

when set background property of checkedtextview leftselected_xml (in eclipse) error log shows error though program runs correctly. wrong xml drawable? there things must defined? leftselected_xml drawable <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startcolor="#c8c8c8" android:endcolor="#c8c8c8" android:angle="270" /> <corners android:radius="0dp" android:topleftradius="5dp" android:bottomleftradius="0dp" android:toprightradius="0dp" android:bottomrightradius="5dp"/> </shape> xml layout <checkedtextview android:checked="true" android:textcolor="#000000" android:id="@+id/arrivingctv" android:layout_height="wrap_content" android:text="@string/arriving" andr...

Android equivalent to .Net WebClient.uploadFileAsync -

i looking send file on android asyncronously. using c#, use webclient.uploadfileasync. found java equivelent... asynchttpclient. however, find cannot used in android. want able progress of upload. more importantly though dont want load whole file in memory; files large images , have trouble uploading @ once. so question simple, there android alternative .net's webclient.uploadfileasnyc? in android 2.3 , higher, use downloadmanager . in android 2.2 or lower, need roll more using httpclient or something.

spatial - SQL Server 2008 Geometry.STBuffer(…) really slow -

i’ve got basic sql query looks like: select top 1 [geom].stbuffer(500) [db].[dbo].[boundaries] which essential takes map boundary database , buffers 500m. problem i’m having it’s incredibly slow , server runs out of memory! i’m sure must wrong simple operation in gis program takes seconds run, whereas runs around minute before giving up. the boundary complicated, shouldn’t complicated cause server run out of memory, i’m sure of that. if reduce buffer distance 100m, runs , completes within around 14 seconds, still slow useful in realtime. any idea why might slow, , tips how can speed up? thanks, this known limitation stbuffer in sql server 2008 - prone being slow , potentially running out of memory when distance parameter larger diameter of object , object has more 1000 points. there connect item issue , fixed in sql server denali. as workaround, can try running reduce on object before invoking buffer lower complexity, , using bufferwithtolerance method pass ...

c# - how can i use a control in template? -

<style x:key="abc" targettype="{x:type window}"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type window}"> <button x:name="btn">my button!!</button> </controltemplate> </setter.value> </setter> </style> ... <window ... style="{staticresource stylemainwindow}"> how can use button btn ? come expectations, messagebox.show(this.btn1.name); was occured error @ compile time. , btn1 didn't show in intelisense. try findname method on controltemplate class. assuming this control's context: var button = (button)this.template.findname("btn", this);

CSS how to target background and make it transparent -

i using ie6 , occupicy thing can thing works opacity: 0.5; filter: alpha(opacity = 50); background-color:black; opacity: 0.5; filter: alpha(opacity = 50); this works makes text transparent how can make background colour transparent it's simple have give background: rgba(0,0,0,0.5) & ie use filter {background: transparent;-ms-filter: "progid:dximagetransform.microsoft.gradient(startcolorstr=#7f000000,endcolorstr=#7f000000)"; /* ie8 */ filter: progid:dximagetransform.microsoft.gradient(startcolorstr=#7f000000,endcolorstr=#7f000000); /* ie6 & 7 */ zoom: 1;} for more color transparency in ie have read hsla color: http://greenevillage.net/csspages/hsla.aspx

Multi User App with MVC3, ASP.NET Membership - User Authentication/ Data Separation -

i'm building simple multi-user (multi-tenant?) app asp.net mvc3 , ef4, 1 database, 1 code base, users access app using same url. once user logged in should have access data, i'm using default asp.net membership provider , have added ‘userid’ guid field on each of data tables. don't want user have access user b’s data have been adding following every action on controllers. public actionresult editstatus(int id) { if (!request.isauthenticated) return redirecttoaction("index", "home"); var status = sservice.getstatusbyid(id); // check if logged in user has access status if (status.userid != getuserid()) return redirecttoaction("index", "home"); . . . } private guid getuserid() { if (membership.getuser() != null) { membershipuser member = membership.getuser(); guid id = new guid(member.provideruserkey.tostri...

ruby - Sinatra, where to place the require statments -

i'm developing sinatra/rack app, , i've run design problem. looking around, , i'm not quite sure place bulk of require statements. i figure go in 1 of 2 places, either main.rb after requiring sinatra itself, or go in config.ru loaded @ start of application. i'm leaning towards main.rb what's loaded of testing applications. thank help. i recommend: require main app file config.ru . require sinatra , views gems in main app create individual init.rb files each of helpers, models, , routes, , require in main app. require db-related gems in models/init.rb here's example of layout use: using sinatra larger projects via multiple files note loading db-related gems , setting db in models/init.rb can (from irb) load file , have full model stack available poking at.

jquery - Disconnect Strophe Connection on Page Unload -

i've written web-based muc client using strophe.js , jquery , i'm trying send unavailable presence room , disconnect user in jquery unload event window. if user navigates away or closes browser tab, should logged out of muc. i've tested code i'm running in event through logout button have on page, i'm pretty sure stanza correct. think strophe having trouble sending stanza if browser window closing. there workaround here? i've tried onbeforeunload event (i know it's not entirely cross-browser compatible), doesn't seem work either. any advice appreciated! thanks, john ensure switch sync mode, , call flush() before sending disconnect() call. here example: var client = { connect: function(spec) { this.connection = new strophe.connection(spec.url); }, disconnect: function() { this.connection.options.sync = true; // switch using synchronous requests since typically called onunload. this.connection.flush(); ...

What's the difference between Thread.setPriority() and android.os.Process.setThreadPriority() -

if have code like: runnable r = ...; thread thread = new thread(r); thread.setpriority((thread.max_priority + thread.norm_priority) / 2); or ... runnable r = ... thread thread = new thread( new runnable() { public void run() { android.os.process.setthreadpriority(android.os.process.thread_priority_more_favorable); r.run(); } }); is android.os.process way required/preferred? why android.os.process way preferred/required if is? this not documented far can tell. the current dalvik implementation seems map java threads ony 1 underlying linux system pthreads say. threads of apps belong same thread group on system, every thread competes threads of apps. so thread.setpriority should same process.setthreadpriority , using smaller java priority scale, mapping of priorities defined in knicevalues @ vm/thread.c

python - Output unformated? -

i newbie in python. doing exercise in learnpythonthehardway mr. zed shaw. have been stuck problem here code: age=input("how old you?"); height=input("how tall you?"); weight=input("how weight?"); print ("age = %r height = %r weight = %r" %(age,height,weight)) and output: d:\python>python sample1.py how old you?22 how tall you?182 how weight?178 age = '22\r' height = '182\r' weight = '178\r' i not understanding, how that, getting "\r" output? please !!! it looks using python 3. in python 3, input() function returns string typed @ prompt. in python 2, input() function returns evaluated expression , in case if type number integer. you have 3 basic choices: find tutorial uses python 3 install python 2 use current tutorial simulate python 2 input() using eval(input(...))

html - 4 Column Div Layout -

i trying create 4 column <div> layout. why row containers not drawing border around respective row? also, approach, in css written fluid , dynamic resizing of browser window? any suggestions or appreciated. here current attempt. you need set overflow auto when using float. http://jsfiddle.net/gjjhs/

mysql - Generating unique primary Ids of int32 & int64 sizes -

i developing social web application using java , distributed nosql db(cassandra). i need generate ids new users , posts on application in sizes of 32bits , 64 bits respectively. because of building on top of distributed platform , our problem of generating ids/keys has become more complicated. although there have come solutions zookeeper/ or twitter's snowflake have helpfully been trying alleviate pain, these solutions not seem simple use. after looking @ these solutions top level view, feel going simple solution , mature. using mysql database way flickr's ticket servers, comes mind first preference seems easiest solution . http://code.flickr.com/blog/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/ i know create spof around distributed system.. still believe easiest solution days(when have less resources in terms of capital , manpower). when application grows believe switching no difficult no heavy data transferred. infancy state of ap...

Robot camera + motion detection -

i have project in (me , student) develop system robot. in robot have camera capture. my question how detect motions, movements. there solution?? technics , tools use ?? language use (possible java example) ?? thanks in advance. best regards. ali consider using opencv: http://opencv.org it has lot of useful vision algorithms built in, , supports, c, c++ , python, gpu functionality.

How to access/get the resource id of the image in an ImageButton (Android) -

i have imagebutton, , want use image associated in onclick event. i found this: android imagebutton - determine resource set but wonder there built in way find resourceid of image in imagebutton in 2 cases: 1. android:src set in xml , never changed. 2. image changed in code. thank you! this isn't possible. i'd listen mark : just use settag() , gettag() associate , retrieve custom data imageview.

c# - Strange error when trying to start my WCF service with webHttpBinding -

i'm getting strange error when try connect wcf webhttpbinding service from web browser : sendera:actionnotsupportedthe message action '' cannot processed @ receiver, due contractfilter mismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , receiver) or binding/security mismatch between sender , receiver. check sender , receiver have same contract , same binding (including security requirements, e.g. message, transport, none). my app.config: <services> <service name="mynamespace.myservice"> <host> <baseaddresses> <add baseaddress="http://localhost:9091/myservice/" /> </baseaddresses> </host> <endpoint address="" binding="webhttpbinding" contract="mynamespace.imyservice" /> </service> </services> my method looks this: [webget(uritemplate = "foo/{id}")] ...

internet explorer - How To Open A Webpage in Full Screen Mode (IE) Automatically and The User Can Still Exit It By Pressing F11 -

i've searched , googled lot, not find solution. i want open webpage full screen mode, need following features: if works ie, it's fine; it's local file, "index.html", when user open in ie, displayed in fullscreen mode automatically (without involving users pressing f11); in full screen mode, user still able press f11 normal mode. i have got lot of full screen code, either javascript or "iexplore -k" kiosk mode, both of them lock keys, preventing user pressing f11. thanks. peter as security measure cannot, not every user knows how f11. you can if make website html app ( hta ). closest thing able cross-browser create screen-sized popup minimal control interface.

c - Installing flex (lexical analyzer) on Mac -

can tell me how can install flex (lexical analyzer) on mac? searched everywhere on google , can't find it. have universal binary , extracted desktop have no idea go here. appreciated! you can use macports install flex

c# 4.0 - How to read web.config's value in ascx page -

i want access web.config's value in ascx page(design page) , have assign these values drop down list.how that?any help have @ asp.net configuration api overview see code examples on page

jquery - Dynamically remove select form fields inside divs with data taken from php -

i have form select fields dynamically generated , options taken php (same selects). "add" button working "remove" button not working perfectly, it´s not deleting , if add again, goes below ideal position. this code have: <script type="text/javascript"> //<![cdata[ $(function(){ var counter = 1; $("#addbutton").click(function () { if(counter>10){ alert("only 10 textboxes allow"); return false; } var select = $('<select>').attr({id:'select'+counter,name:'select'+counter}); $.ajax({ url: 'selects.php', datatype: "html", success: function(data) { select.html(data); } }); select.appendto("#textboxesgroup"); $("#textboxesgroup > select").wrap ( function () { return '<div id="wrap_' + this.id + '"></div>'; } ); counter++; }); $("#removebutton").click(function () { if(coun...

Current state of integrating unit tests with Haskell's Cabal? -

when google how integrate unit tests cabal files, either find http://www.haskell.org/haskellwiki/how_to_write_a_haskell_program not seem describe integration of hunit/quickcheck cabal file or see messages "wait cabal x.y support cabal test" can not find documentation either how run unit test using cabal (for example everytime "cabal build") today? make sure have latest version of cabal , cabal-install installed. have test-suite section in .cabal file. see this section of cabal's documentation explanation of how write test-suite section in cabal file , this section instructions on how run it. i've been using built-in test support time , has saved me having maintain fragile makefiles tests. there still rough edges in command line output of cabal test , have been fixed in head in next cabal/cabal-install release should smooth.

how can i remove chars between indexes in a javascript string -

i have following: var s="hi how you"; var bindex = 2; var eindex = 6; how can remove chars s reside between bindex , eindex? therefore s "hi you" first find substring of string replace, replace first occurrence of string empty string. s = s.replace(s.substring(bindex, eindex), ""); another way convert string array, splice out unwanted part , convert string again. var result = s.split(''); result.splice(bindex, eindex - bindex); s = result.join('');

javascript - Jquery way to handle all ajax success events in one place -

i have scenario need handle jquery success events in common place. because want delegate called after ajax success events. know can use $.ajaxcomplete or $.ajaxsucess that. problem ajax calls have own success handlers, $.ajaxsucess overwritten . and know can write common method can put in ajax success handlers. dont want that, want know cleaner way. is there method handler in jquery that, or whats best way it? the $.ajaxsuccess method should work fine seen in this live demo , doesn't conflict existing ajax success handlers. executed after each of them: $('#msg').ajaxsuccess(function(result) { alert('ajax succeeded'); });

Android App quits automatically if its idle for some hours -

i created new android app , succeeded in working. functionality working fine. while starting ask use name , password. problem "if application idle 4 5 hours, automatically quit , while restarting again asking login" need know how avoid automatic quit of app. i'm sorry if simple or asked quetions. i need know how avoid automatic quit of app. no, not. redirect user log in again, or, @rasel suggests, persistently cache credentials in file or database or something. android applications not , must not live forever. phones have limited ram. android terminate unused applications after period of inactivity, free ram other applications. normal, normal user close web browser after visiting web app.

optimization - PHP if OR is the second part checked on true? -

i know must simple question, know in php in statement this if ($a && $b) { } if $a false php doesn't check $b well same thing true or so if ($a || $b) { } if $a true, still check $b i know elementary stuff, can't find answer anywhere... thanks see example 1 on logical operators page in manual. // -------------------- // foo() never called operators short-circuit $a = (false && foo()); $b = (true || foo()); $c = (false , foo()); $d = (true or foo());

javascript - clearTimeout & setTimeout not working -

as follow of question , i'd know why not working $("#textarea").keydown(function(){ oldvalue = $("#textarea").val(); }); $("#textarea").keyup(function(){ var starttimer = null; if(starttimer) cleartimeout(starttimer); starttimer = settimeout(function(){ var newvalue = $("#textarea").val(); // out of comparison alert(something) // alert comparison oldvalue = newvalue; },2000); the required behavior alert message when user hasn't typed 2 seconds. works comparison part, however, doesn't stop alert message when keep typing should. instead, same number of alerts number of keys pressed. tried version of creating , deleting cookies, worked fine. wrong in particular case? you're getting new starttimer (and initializing null ) on each call keyup handler. try declaring in outside scope: (function() { var starttimer = null; var oldvalue; // declare too, isn't global $("#textarea").keydown(fu...

php - Advice on CMS, ExpressionEngine vs. Drupal or? -

i'm stuck between rock , hard place. need identify new cms company struggling (we're digital agency , produce tens of websites year of varying sizes retained clients.) we use mysource matrix (which blackbox, no technical documentation) our cms , zend framework our applications. my requirements templates available via ftp can stored in external vcs , edited in ide. templates should have templating language smarty pure php cannot misused in them. if continue develop in 90% zf way. if cms comes reasonable framework embrace drive synergies between cms projects , other bespoke applications projects. i'm not satisfied either drupal or ee solve first point. drupal enforces ftp templates allows php entered in templates. don't know how compatable smarty engine module (it hasn't been updated since 2007). ee has reasonable template syntax doesn't enforce maintenance via ftp (you can edit template via browser , break external version control.) second point not ide...

sql - Modify XML values identified through cross apply -

i've got data issue values stored in xml column in database. i've reproduced problem following example: setup script: create table xmltest ( [xml] xml ) --a row 2 duff entries insert xmltest values (' <root> <item> <flag>false</flag> <frac>0.5</frac> </item> <item> <flag>false</flag> <frac>0</frac> </item> <item> <flag>false</flag> <frac>0.5</frac> </item> <item> <flag>true</flag> <frac>0.5</frac> </item> </root> ') in xml portion incorrect entries <flag>false</flag> , <frac>0.5</frac> value of flag should true non-zero frac values. the following sql identifies xml item nodes require update: sele...

javascript - Flash Player notified that browser is closing ++ -

i've implemented flex / js logic prompt user when try navigate away app (e.g. close browser, hit button, etc) described here . works great , i've been super happy results. 1 quick question came how capture "user pressed ok on js popup , in fact leaving page" event inside flex app, in order know when user left page. assume logic similar, unfortunately not speak js , stuck. appreciated. thank you! onbeforeunload not designed give additional time page if user chooses "yes, let me leave" - there's nothing information user did close page. can tell flash function ran, , possibly that, depending on how fast user presses 'ok' believe that's it.

vba - How do I to create a copy of a custom object or collection? -

i have custom collection - let's call colparenta - , contains number of collections called colchild . want create function creates new collection, colparentb has of properties , contains same children colparenta . user can modify few properties of colparentb need to, rather having redefine ones same colparenta . colparentb should contain new instances of colchild copies of found in `colparenta. i can't right? set colparentb = colparenta colparentb.name = "copy of " & colparenta.name because makes colparentb point colparenta , changes properties of colparenta right? i'm confused. in advance. you correct in suspicions - assigning pointers, it'll reference same instance of object different name. you're going need create clone functions on colparent , colchild classes. way colchild.clone can memberwise clone , return brand new object same properties, , colparent can create new collection cloned colchild objects. be car...