Posts

Showing posts from June, 2011

c# - can i pass in IQueryable<Foo> into IQueryable<IFoo> if the object implements that interface? -

i have object a: iqueryable<foo> and want pass function expects a: iqueryable<ifoo> foo implements ifoo why wouldn't compile? best way convert have work? co- , contra- variance added in .net 4 bcl, , not exist in .net 3.5 bcl. you can work around limitation in 3.5 using select operation cast interface type: iqueryable<foo> foos = ..; myfunc(foos.select(x => (ifoo)x)); edit (from reed's comment, below): iqueryable<foo> foos = ..; myfunc(foos.cast<ifoo>());

how to push component state changes to multiple different pages using icefaces -

in project want upload image in 1 page(ie:in 1 view),after uploading image event generated , bean1 executed.please provide solution updating loaded image page(ie second view)in use graphicimage component.how refer second view components in bean1 without generating event second view. is possible ajax push using icefaces 1.8.2 discussed above. icefaces uploads file specific path, given by {application root}/{upload directory}/{session id} the upload directory specified in web.xml. session id folder optional, depending on whether specified "uniquefolder" attribute in tag. can set upload path attribute in tag. you can store file path in string or in session variable through actionlistener inputfile. to refer path string bean2 without using backing bean, can bind components "#{bean1.pathstring}". if want use backing-bean, can do: ((bean1) gebean("bean1")).getpathstring() but if extend abstractpagebean . also, bean1 should session s

JUnit tests for collections -

i've implemented radix trie (aka patricia trie) in java, , thoroughly test it. implements map , sortedmap , navigablemap interfaces, add pretty large number of methods check. =/ i figure people wrote library classes hashmap , treemap must have had suite of junit tests (or similar) ensure behave correctly. know of way source code of these tests? i'd love put code through same paces. in google collections library, there basic test harnesses thoroughly test contracts of various structures, including maps. here link gcode page: http://code.google.com/p/google-collections/

iphone - how can I dismiss keyboard when I will just touch anywhere except UITextField? -

hello have 2 uitextfields in application, , want dismiss keyboard when touch anywhere except uitextfields how can this? use tochesbegin method purpose - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { [yourfirsttextfield resignfirstresponder]; [yoursecondtextfield resignfirstresponder]; } you not need thing else.when touch anywhere on view both textfield resign no need to know 1 having focus.and when touch textfield textfield open keyboard own.

C File updating and creating help -

i have 2 .dat(ascii) files. both sorted. 1: clients file containing ; account number , name ,balance 2: transaction file containing; account number ,date,saleamount(transaction amount) what trying accomplish create new updated clients file has updated balances clients based on adding or subtracting saleamount of matching transaction. my code far enables me : 1: if there not more 1 transactions client code runs writes .dat file clients , updated balances. 2:if there more 1 transactions client code run print screen updated clients , accounts eg: 1 james 540.00 2 john 762.00 3 paul 414.00 4 sam 502.00 will displayed , there 2 transactions john created .dat file while contain 1 james 540.00 2 john 662.00 2 john 762.00 3 paul 414.00 4 sam 502.00 my problem lies here, need find way of having created .dat contain 1 line each client ( account number) my code attached appreciated. #include <stdio.h> #include <string.h> int main(void) { int account, mat

c - Why doesn't *(ptr++) give the next item in the array? -

int my_array[] = {1,23,17,4,-5,100}; int *ptr; int i; ptr = &my_array[0]; /* point our pointer first element of array */ printf("\n\nptr = %d\n\n", *ptr); (i = 0; < 6; i++) { printf("my_array[%d] = %d ",i,my_array[i]); /*<-- */ printf("my_array[%d] = %d\n",i, *(ptr++)); /*<-- b */ } why display same thing both line , b? displays of values in my_array in order (1, 23, 17, 4, -5, 100). why '++' in line b not point ptr next element of array before dereferenced? if change line printf("ptr + %d = %d\n",i, *ptr++); /*<-- b */ the output same. why this? ptr++ increments ptr returns original value ++ptr increments , returns new value hence joke c++ - it's 1 more c use original value = c

iphone - is it possible to create a 100% leak free ipad application -

i developing ipad app , found memory leaks using instruments , analyzer. tried release objects resulted in crashing of app.. memory leaks allowed in app? if so, until extent allowed? there way remove memory leaks out app getting crashed?? generally speaking, possible make sure code write leak free. not apple frameworks , internal libraries won't leak @ all. if call alloc , new or copy make sure call corresponding release or autorelease . apps leak lot bound crash often. apps crash rejected app store.

Directory listener in Java -

i have application in want listen changes made particular directory. application should ping me there files added, deleted or updated in directory. you can use jnotify jnotify java library allow java application listen file system events, such as: file created file modified file renamed file deleted supported platforms windows (2000 or newer) windows notes linux inofity support (2.6.14 or newer) linux notes mac os x (10.5 or newer) mac os notes more info : download jnotify here extract zip, put .dll/.so according platform in lib path. , create class provide jnotify-0.93.jar in class path. sample code: package org.life.java.stackoverflow.questions; import net.contentobjects.jnotify.jnotify; import net.contentobjects.jnotify.jnotifylistener; /** * * @author jigar */ public class jnotifydemo { public void sample() throws exception { // path watch string path = system.getproperty("user.home");

java - How can I extract meta data from various video file formats? -

how can extract meta data various video file formats, resolution , type of codec used. (but other stuff author). not able find library that. i have found mediainfo , supplies dozens of technical , tag information video or audio file. there jni wrapper mediainfo in subs4me's source tree find useful. here code snippets show how extract information media file: file file = new file("path/to/my/file"); mediainfo info = new mediainfo(); info.open(file); string format = info.get(mediainfo.streamkind.video, i, "format", mediainfo.infokind.text, mediainfo.infokind.name); int bitrate = info.get(mediainfo.streamkind.video, i, "bitrate", mediainfo.infokind.text, mediainfo.infokind.name); float framerate = info.get(mediainfo.streamkind.video, i, "framerate", media

php - jQuery iframe popup and post form to parent -

i want create popup search box. using thickbox iframe content. in popup there other form post when popup stays , save data. want when main form (fm-form) submitted post action parent , shows search result in parent(popup closes). how can this? can use other popup? see link please see above url , click on " new search " have idea. again thanks. set target -attribute of form "_parent"

java - Facebook rocket for Android -

i new android developer. want connect app facebook. tried fb rocket code in following link: http://www.androidpeople.com/android-facebook-api-example-using-fbrocket/#idc-cover when using api key in coding app name, status gets posted successfully, when use own api key , app name, goes till login page , shows sorry, went wrong . please me solve issue. new android. you better use github source facebook,because it's standard api developed facebook itself... link https://github.com/facebook/facebook-android-sdk

c++ - Scaling a texture with a Framebuffer -

my goal able scale textures when loaded, don't have on every frame sprite gets rendered. figured best method render scaled texture onto texture, caching it. however, following code, red quads (due glclearcolor) know fbo working, not method rendering new texture texture *graphics::loadtexture(const std::string& filename, int scale = 0) { sdl_surface *surface; gluint texture; if((surface = img_load(filename.c_str()))) { // number of colors glint numberofcolors = surface->format->bytesperpixel; glenum format; // set format of texture based on number of channels if(numberofcolors == 4) { if(surface->format->rmask == 0x000000ff) { format = gl_rgba; } else { format = gl_bgra; } } else if(numberofcolors == 3) { if(surface->format->rmask == 0x000000ff) { format = gl_rgb; } else { format = gl_bgr; } } else { th

c# - restore dynamically created javascript table structure after asp.net button post back -

on runtime creating table structure using javascript , appending div placed in update panel. problem here is, when use asp.net button control, onclick of button posts page server , whatever javascript tables have created goes off. when use html input button (input type="button") don't face problem , tables stay there. have use asp.net button take necessary actions on server side. there way can restore structure or use asp.net button control alongwith dynamic javascript. appreciated. thanks. you need save table structure in hidden field before clicking/submitting on asp.net button. on post back, can redisplay that. asp.net button has property onclientclick , can use property.

ruby on rails - Heroku ignoring recent migrations -

i ran heroku rake db:migrate , 3 of recent migrations being ignored completely. i've pushed heroku , github it's heroku doesn't think these exist. git status reveals nothing amiss, , github repo contains migration files in right place. what's wrong? from you've said should work.. if you're stuck, try pulling production database heroku, migrating on local machine , pushing database heroku? at least might able see what's going on in database @ least? http://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku/

ruby on rails block sytax using &: -

so have question model , answer model , question has_many answers (it's multiple choice question). suppose questions collection of question objects. in order collect answers can this: questions.collect(&:answers) two questions: what precisely syntax mean? expand questions.collect { |q| q.answers } or there else going on here? is there way questions.collect { |q| q.answers.shuffle } using same syntax? collect(&:answers.shuffle) isn't doing it. i can't seem find in tutorials on ruby blocks on web , searching doesn't work (search engines ignore "&:"). found in inherited code. thanks yes, first question n-duplicated, regarding second: no, cannot chain methods. however , nothing stops -other writing code may puzzle people- create own tool: class symbol def to_proc proc |obj| self.to_s.split(/\./).inject(obj, :send) end end end p ["1", "2", "3"].map(&:&qu

serial port - Bash read from ttyUSB0 and send to URL -

i bash novice , struggling putting together. what trying is: 1) set port (stty) 2) read dev/ttyusb0 - data should 000118110000101 (cat or gawk?) 3) set read data variable eg data , create url eg http://domain.com/get_data.php?data= $data 4) load url wget? 5) wait more data ttyusb0 (polling or loop?) i have tried php dio extention work not reliable because stops/starts reason. any suggestions appreciated, great-full if advise best way this thanks brent this used. #set permisions sudo chmod o+rwx /dev/ttyusb0 #!/bin/bash # port setting stty -f /dev/ttyusb0 cs7 cstopb -ixon raw speed 1200 # loop while [ 1 ]; echo 'loading...' read=`dd if=/dev/ttyusb0 count=22 | sed 's/ //g'` echo $read wget http://localhost/bashtest/test.php?signal=$read echo '[press ctrl + c exit]' done

How does density value calculate in android -

can explain me formula android use calculate screen density? waiting responds))) density can calculated following formula: density = sqrt((wp * wp) + (hp * hp)) / di where: wp width resolution in pixels, hp height resolution in pixels, and di diagonal size in inches.

ios - how to obtain facebook credentials in iphone app when using face.com API -

i trying make sample iphone app can use faces.recognize api call. can connect face.com api using restkit, however, have no idea how obtain user id, session, etc. how can done? i think reading documentation have helped more. found related in 5 minutes of research @ face.com . there list of methods there , realted sample responses. need is, think, url: http://developers.face.com/docs/api/account-users/

How to get optional certificate in openssl -

i used openssl create smime. i have valid certificate.i tried parse certificate using following function int pkcs12_parse(pkcs12 *p12, const char *pass, evp_pkey **pkey, x509 **cert, stack_of(x509) **ca); the certificate parsed , able pkey , cert values.but ca comes out null . how stack_of(x509) value certificate. want use stack_of(x509) value in pkcs7_sign function. if ca comes out null , have no additional certificates in pkcs12 structure. not need additional certificates - if certificate signed directly ca certificate known recipient, can supply certs = null pkcs7_sign() , no additional certificates included in signed message.

Android - how to compress or downsize an image? -

imagebutton avatarbutton = (imagebutton) findviewbyid(r.id.imagebutton_avatar); avatarbutton.setimageresource(r.drawable.avatar); stravatarfilename = "image.jpg"; final uri imageuritosavecameraimageto = uri.fromfile(new file(environment.getexternalstoragedirectory()+"/folder/"+stravatarfilename)); avatarbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { intent pictureintent = new intent(android.provider.mediastore.action_image_capture); pictureintent.putextra( mediastore.extra_output, imageuritosavecameraimageto ); startactivityforresult(intent.createchooser(pictureintent, stravatarprompt), take_avatar_camera_request); editor editor = preferences.edit(); editor.putstring(preferences_avatar, imageuritosavecameraimageto.getpath()); editor.commit(); } }); i have code. takes photo , stores in 2 locations, default location on sdcard , /folder/ file want photo stored in also.

iphone - how can I put particular action as I select any row of UIPickerView? -

i writing code - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { int n=row+1; if(row == 0) return [nsstring stringwithformat:@"%d minute", n]; return [nsstring stringwithformat:@"%d minutes", n]; } now want start timer choose row, row 5 has 5 mints, want start timer 5 mints, should do, how can choose particular row , press button , timer starts event? for future if go onto google , type in name of class , "class reference" can find information need on apple website. for instance, went onto google , typed "uipickerview class reference" , got here: http://developer.apple.com/library/ios/#documentation/uikit/reference/uipickerview_class/reference/uipickerview.html . on website if read description says "the delegate must adopt uipickerviewdelegate protocol" , if click there says, under tasks: responding row selection – pickerview:d

Apply span to selected text in javascript -

i apply span class selected text on browser window in javascript (like highlight feature). i've tried with function replaceselectedtextwithhtmlstring(newstring) { var range = window.getselection().getrangeat(0); range.deletecontents(); range.innerhtml = newstring; } but not work. if try insert newstring= "< span = "myspan" > text < / span >" can't , 'text' not appear. seems not html code. how can solve it? how easy depends on need achieve. if need basic highlighting using background colour, best bet document.execcommand() . see following code this: change css of selected text using javascript if need apply more styling document.execcommand() can provide (there various other formatting commands things bold , italic, markup produces varies between browsers , isn't css based), it's trickier: in general, need surround every text node within selection in span desired class. suggest using rangy , css

MongoDb's $set equivalent in its java Driver -

is there way in can modify value of 1 of keys in mongodb via java driver. tried out following: somecollection.update(dbobject query, dbobject update); somecollection.findandmodify(dbobject query, dbobject update); but both functions replace queried document updated document. way update 1 of value of particular key in case of using $set in mongo shell.(apart making new document fields copied , 1 of fields updated). i not java expert, seems following code fit needs: basicdbobject set = new basicdbobject("$set", new basicdbobject("age", 10)); set.append("$set", new basicdbobject("name", "some name"); somecollection.update(somesearchquery, set); also @ this example .

javascript - Sending data only to chosen users using Socket.io-node -

is possible send data using socket.io-node chosen group of users? example, how implement chat different rooms? dont want .broadcast() send data logged in users. normally should have each room list of connected user , user have client object should have stored somewhere. when want send message specific room, have iterate on connected user of room , access client object , send data. in short, possible have send data each of users in group one-by-one.

functional programming - if-else branching in clojure -

i'm teaching myself clojure. in non-fp language, enough write nested if's, , if didn't put else, control flow out of if block. example: thing myfunc() { if(cond1) { if(cond2) return something; } return somethingelse; } however, in clojure, there's no return statement (that know of), if write: (defn myfunc [] (if (cond1) (if (cond2) something)) somethingelse) then there's no "return" on "something". seems kind of say, ok, here have value, let's keep on executing. obvious solution combine conditions, i.e.: (if (and (cond1) (cond2)) somethingelse) but gets unwieldy/ugly large conditions. also, take additional finagling add statement "else" part of cond1. there kind of elegant solution this? this subtle difference between imperative , functional approach. imperative, can place return in place of function, while functional best way have clear , explicit exeecution paths.

ruby - What is the solution to this blank in the code? -

this test_symbols_cannot_be_concatenated exercise in ruby koans . previous exercises had used assert_equal tests. first assert_raise on path enlightenment. def test_symbols_cannot_be_concatenated assert_raise(_____) :cats + :dogs end end nomethoderror guess, since makes no sense try sum or catenate 2 symbols.

.net - C++/CLI good coding practice, Indexed properties if-check or try..catch? -

a rather short , simple question. let's use piece of code: public ref class foo { private: system::collections::generic::dictionary<system::string ^,system::string ^> ^ adictionary; public: property system::string ^ someindexedproperty[system::string ^] { public: system::string ^ get(system::string ^ index) { return adictionary[index]; } } public: foo(void) { adictionary = gcnew system::collections::generic::dictionary<system::string ^,system::string ^>(); } }; would better surround/pre-check return if statement ( if( adictionary->containskey(index) ) or better surround return statement try..catch block? in both cases returning nullptr when fail. speed not of issue. general "this better reason" suffice. i firmly believe if there legal condition reasonably allow, should not catch exception detect it. in other words, use if statement. akin letting loops

visual studio 2008 - Placing C# Project References in a Subfolder -

i have solution multiple projects output dlls (except main application of course). copy local set true of references , fine , dandy dlls in same directory exe. my problem ugly. i'd put dll's in subfolder (actually 2 subfolders down precise). how can in visual studio 2008? i've found few questions seem similar couldn't find simple answer know has exist. edit: clearer, want know how make assembly loader references somewhere besides operating directory. users interacting of other files in directory, , less clutter there them better. edit 2: want avoid using gac. application needs self contained. or assemblyresolve public static class assemblyresolver { static assemblyresolver() { appdomain.currentdomain.assemblyresolve += new resolveeventhandler(delegate(object sender, resolveeventargs args) { return assembly.loadfrom(...); }); } }

imagemap - Image map in joomla -

i need put image map in article. i'm using joomla 1.6. tried disable editor , insert plan html, following error occuring: "fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 51484653 bytes) in c:\wamp\www\mysite\libraries\joomla\filter\filterinput.php on line 358" i tried disable "html filtering" in article manager, same error still happening. i'm editing super user. can post image map here? i had problems using image maps in past. have tried disabling wysiwyg editor?

c# - How can I get the name of my Windows Service at runtime? -

i have new windows service i'm making in c# 4.0. i'm trying drop in event logging code wrote while ago in seperate class. i want set event source name of windows service without having change code next time drop service. i'm looking this: string source = application.name but can't seem find i'm after anywhere. any takers? if code within service application, do string source = this.servicename;

MySQL Query - recent entries per group -

i'm trying select recent entries per group in table. say have table "blog_posts" has column "id" (all unique, auto incremented), "post_cat" can values 'category1' or 'category2' or 'category3', , "publish_status" column can values 'online' or 'offline'. how can select recent entries each category? i have following right now, feels it's selecting randomly: select * `blog_posts` (publish_status = 'online') group post_cat order id desc limit 10 i'd keep real simple , use trigger maintain last_post_id in category table can join on posts table - this: simple query select pc.cat_id, pc.name, u.username, bp.* post_category pc inner join blog_post bp on pc.last_post_id = bp.post_id inner join users u on bp.user_id = u.user_id order pc.cat_id; +--------+------+----------+---------+---------+---------------------+ | cat_id | name | username | post_id | user_id | pos

iphone - Many UIView animation causing performance problem? -

i have object animation... if there many(more 25) objects doing animation @ same time causing jerk while dragging... creating animation using below code in each object. how can improve performance? #define default_anim_spped 0.6 #define infinate_value 1e100f - (void)startanimating { mbackgroundimageview.frame = moriginalframe; [uiview beginanimations:nil context:nil]; [uiview setanimationrepeatautoreverses:yes]; [uiview setanimationrepeatcount:infinate_value]; [uiview setanimationduration:default_anim_spped]; cgrect tempframe=mbackgroundimageview.frame; tempframe.origin.y -= manimationoffset; mbackgroundimageview.frame=tempframe; [uiview commitanimations]; } rather creating animation each view, try having 1 animation block animates multiple views, example in common superview. i'm not sure make enough improvement 25 views case.

How to enable the HTTP logs in Android? -

i wrote simple application , getting logs, used log.i(); want core logs (for example framework logs) how httpclient, httpget, httppost, httprequest , httpresponse logs sending , receiving data. please let me know if there procedure. here, try this: https://gist.github.com/cf23c4e184228a132390

java - Illegal access: this web application instance has been stopped already -

hi have class has init-method defined in xml <bean id="appstarter" class="com.myapp.myclass" init-method="init" destroy-method="destroy"/> myclass: public class myclass{ private thread t; public void init() { t = new thread() { @override public void run() { while (true) try { dostuff(); thread.sleep(1000); } catch (exception e) { e.printstacktrace(); } } }; t.start(); } public void destroy() { t.interrupt(); } } when app starts threads runs fine, , works fine , after sometime got following exception info: illegal access: web application instance has been stopped already. not load com.sun.mail.imap.imapstore. eventual following stack t

iphone - Contactlist actionlike buttons -

don't know on how ask in way, here goes! this want; when view details of contact, have option of direct calling phonenumber, send email or lookup someones address within maps app of iphone. i creating app shows detailed information location. information shown in detailed view: phonenumber (when choosing needs call number) emailaddress (when choosing needs open emailapp) address (when choosing needs open default mapapp of iphone) do achieve actions available (somewhere)? if so, can point me in right direction? i me alot! with kind regards, douwe ios uses url schemes allow communication between apps. you'd need implement openurl:"yourformattedurlhere" in button clicks formed url send data appropriate app. you can check apple's url scheme reference details on formatting.

oop - Worker design pattern -

what "worker" design pattern? it after worker thread pattern , use queue schedule tasks want processed "offline" worker thread. solutions use pool of worker threads instead of single thread achieve performance gains utilising paralelisation.

c++ - RFC /advice: On secure/unsecure rpc/event-stream protocol design -

ssl seems quite bloated want do, , have passionate hatred openssl (nss might useable). need open tcp channel between 2 nodes used rpc / encrypted rpc / event streams / encrypted event streams. using protocol buffers define , multiplex different traffic sources. i don't want use ssl start with. need authenticated secure key-establishment (authenticated diffie-hellman) , perhaps block-cipher based stream object encypher , decypher encrypted event streams , encrypted rpc. the first thought had was, save coding time , design time building on ssl implementation, provided can socket handle ssl implementation , use unencrypted exchanges encrypted exchanges. end ugly implementation, , know doing might incompatible ssl protocol (i.e., strong-coupling between tcp state , ssl state). the second thought had was, save coding time , design time opening multiple sockets. know multi-socket protocol design evil. the third thought was, i'll encrypt everything, service in question ser

c# - Cast a dynamic variable to a given Type -

i have dynamic variable store, depending of context, object can of several types (here foo , bar ) dynamic myvar; myvar = new foo(); //or myvar = new bar(); foo , bar contains differents methods. access methods of myvar, thought possible use casts like (foo)myvar.mymethodoffoo(); (bar)myvar.mymethodofbar(); but it's not working, (dynamic expression) operation resolved @ runtime in code editor. so, how can cast dynamic object available methods , properties editor ? thank's advance. the cast operation ( (sometype)x ) has lower precedence . . therefore, code parsed (bar)(myvar.mymethodofbar()) — cast happens after method call. you need add parentheses: ((bar)myvar).mymethodofbar();

sql - how to cast the hexadecimal to varchar(datetime)? -

i have datetime exporting "cast(0x0000987c00000000 datetime)" when want datetime.it null value. how can datetime again. that looks sql server datetime format. internally stored 2 integers first 4 bytes being days since 1st jan 1900 , 2nd being number of ticks since midnight (each tick being 1/300 of second). if need use in mysql select cast( '1900-01-01 00:00:00' + interval cast(conv(substr(hex(binarydata),1,8), 16, 10) signed) day + interval cast(conv(substr(hex(binarydata),9,8), 16, 10) signed)* 10000/3 microsecond datetime) converted_datetime ( select 0x0000987c00000000 binarydata union select 0x00009e85013711ee binarydata ) d returns converted_datetime -------------------------- 2006-11-17 00:00:00 2011-02-09 18:52:34.286667 (thanks ted hopp the solution in splitting binary data)

c# - What are the advantages to wrapping system objects (File, ServiceController, etc) using the Adapter pattern vs. detouring for unit testing? -

consider following method stops service: public function stopservice(byval servicename string, byval timeoutmilliseconds double) boolean try dim service new servicecontroller(servicename) dim timeout timespan = timespan.frommilliseconds(timeoutmilliseconds) service.[stop]() if timeoutmilliseconds <= 0 service.waitforstatus(servicecontrollerstatus.stopped) else service.waitforstatus(servicecontrollerstatus.stopped, timeout) end if return service.status = servicecontrollerstatus.stopped catch ex win32exception 'error occured when accessing system api' return false catch ex timeoutexception return false end try end function in order unit test the method have 2 options: use adapter pattern wrap servicecontroller class's methods need interface can control. interface can injected service class (a.k.a inversion of control). way have loosely c

Open a hidden div in a lightbox with Mootools in Joomla 1.5 -

i using joomla 1.5.22 mootools 1.1. have module form contained in hidden div want open in joomla's built in modal box. problem have when click link form opens in modal box, opens div in module on page. html: <div id="modulebox"> <div id="clickmebutton"><a id="formclick" class="modal" href="#hiddenform">click me</a></div> <div id="hiddenform"> form code goes here </div> </div> javascript: window.addevent('domready', function() { $('formclick').addevent('click', function(){ $('hiddenform').setstyle('display','block'); }); }); so how form show in modal box? you can see talking here - http://www.internextion.com/ it's call module. added handler: 'adopt' suggested below, result little different. target div still shows below link, modal window contains link rather target.

UML Question about Sequence Diagram -

i have question regarding uml sequence diagram. let's have object customer, kioskui, kioskservice , kioskservice has last process called shownotification(); method shownotification goes customer object or kioskui? if kioskui, object have return variable customer object "<----- notification", or no longer have return kioskui customer? since sequence diagram focus on how process operates 1 other question is, tangible object printed report no longer needed shown in sequence diagram or have to? in object oriented systems see sequence diagrams depictions of objects sending messages each communicate. arrows in these diagrams show sender/receiver relation between objects in time, label arrow depict message itself, e.g. method call arguments. asking if backwards arrow should point kioskui or customer object. answer simple, depends on sent message, e.g. method call "shownotification()" return. have decide this, guess kioskui natural choice. answer i

WPF: New Row on Datagrid that bind to custom class -

i created custom data container class onpropertychanged event , observablecollection , bind datagrid in wpf. the problem everytime program start, datagrid automatically creates new row @ bottom. new row not present in observablecollection editing useless, adding new item programmatically in observablecollection erase data in new row. how can disable new row or make observablecollection updated if user start editing in new row (just in sql server management studio)? nb: if can please give me example of "correct" custom class in wpf, i'm still in wpf. meleak 's answer comment: if want disable users can add new rows set canuseraddrows="false" in datagrid . newitemplaceholder empty row, inserted observablecollection upon commit.

Visual Studio 2010 Add In using Entity Framework -

i'm creating addin launches forms-based gui. addin , gui in different projects. gui connects database , utilizes ef orm. when launch gui project vs, works great. when publish gui vs add-ins folder , run it, works fine. when launch gui add-in in vs, loads fine, tries hit database fails. ef complains metadata files. exception: specified named connection either not found in configuration, not intended used entityclient provider, or not valid. at system.data.entityclient.entityconnection.changeconnectionstring() here configuration in app.config <connectionstrings> <add name="companyentities" connectionstring="metadata=res://*/;provider=system.data.sqlclient;provider connection string=&quot;data source=testdb;initial catalog=company;persist security info=true;user id=id;password=password;multipleactiveresultsets=true&quot;" providername="system.data.entityclient"/> </connectionstrings> the th

internet explorer 7 - Joomla 1.5, CSS, IE7 and mod_menu -

i have site done in joomla here (i'm not familiar joomla, have had learn quickly) , looks great in browsers, except ie7. problem top menu doesn't render in ie7, , css after menu breaks. know it's @ least partially loading because of styles loading (the background, colours , type), main container , other divs aren't rendering. suspect either ie7 not reading correct style sheet (there 4 - 1 nomal, 1 ie7, 1 ie6 , 1 printing) , may trying implement 2 @ same time? have no more ideas how find problem, i'm hoping either else has had problem or knows how fix it. have included link home page of site, if need more information in order me, let me know. in advance. i skimmed through of css, , found section in template.css : /* begin logo */ div.art-logo { display: block; position: absolute; left: 10px; top: 20px; width: 500px; } h1.art-logo-name { display: block; text-align: { horizontalalign } ; } h1.art-logo-name, h1.art-logo-name a, h

flex - Extending DataGrid component, and adding buttons to it -

i'd extend standard datagrid component in flex mxml. want add buttons bottom of component. i've tried attempting following not working... am adding button wrong element? <mx:datagrid xmlns:fx = "http://ns.adobe.com/mxml/2009" xmlns:mx = "library://ns.adobe.com/flex/mx" xmlns:s = "library://ns.adobe.com/flex/spark"> <fx:script> <![cdata[ override protected function createchildren():void { super.createchildren(); listcontent.addchild(button); } ]]> </fx:script> <s:button id="button" label = "asdasdas"/> </mx:datagrid> you need define "not working"! getting compiler errors? or runtime errors? or button not showing up? i'll assume latter. the datagrid not have mechanism positioning or laying out it's children. button has height , wid

ajax - How to grab the result string of a server side function to update an image src on the web page in rails 3? -

ok, totally new ajax thing... , need started. basically trying rather simple believe. got select used select topic. each topic have associated in db bunch of images (10 per topic). trying do, when drop-down changed refresh images random 1 taken list corresponding selected topics. what gather research need call remote_function controller topic selected parameter , execute function new img path , replace old path new 1 on page. the problem have absolutely no clue how started on ? i using rails 3.0.3, , default ajax library: prototype.

In ruby/grit, how do I get a list of files changed in a specific commit? -

i want list of files affected commit in git. through command line, can with: git show --pretty="format:" --name-only (sha) but how can through grit in ruby? you can use your_commit.diffs returns array of grit::diff instances. grit::diff has a_path , b_path properties. some (untested) example code: paths = []; @commit.diffs.each |diff| paths += [diff.a_path, diff.b_path] end paths.uniq!

database - Security and php -

so have website given users input generate /home/content/s/a/m/p/l/e/users/profile/index.php. real question is, safe? try sanitize users input, if there more, please let me know. strip_tags(html_entity_decode($mysqli->real_escape_string($title)), allowed_tags); allowed_tags = "<br><p><b><i><hr>"; since relatively new website development, wondering if approach, because takes strain off using database same information on , on again, instead have static page information on it, or huge security hole? not know! :) not know if sort of xss attack have setup here. please help! michael p.s. if have answers or suggestions, please give me insight why is. have degree in computer science curious on how works, not quick , dirty solution. thanks. this php security checklist compiled company's internal knowledgebase. may helps. do not use deprecated functions , practices always validate user input use place holders when usin

Python Slice Assignment Memory Usage -

i read in comment here on stack overflow more memory efficient slice assignment when changing lists. example, a[:] = [i + 6 in a] should more memory efficient than a = [i + 6 in a] because former replaces elements in existing list, while latter creates new list , rebinds a new list, leaving old a in memory until can garbage collected. benchmarking 2 speed, latter quicker: $ python -mtimeit -s 'a = [1, 2, 3]' 'a[:] = [i + 6 in a]' 1000000 loops, best of 3: 1.53 usec per loop $ python -mtimeit -s 'a = [1, 2, 3]' 'a = [i + 6 in a]' 1000000 loops, best of 3: 1.37 usec per loop that i'd expect, rebinding variable should faster replacing elements in list. however, can't find official documentation supports memory usage claim, , i'm not sure how benchmark that. on face of it, memory usage claim makes sense me. however, giving more thought, expect in former method, interpreter create new list list comprehension , then copy va

VB.net Byte Array Search -

i in process of developing simple virus scanner, , searching speed improvements on following function: public function findainb(byref bytearraya() byte, byref bytearrayb() byte) integer dim startmatch integer = -1 dim offseta integer = 0 dim offsetb integer = 0 offsetb = 0 bytearrayb.length - 1 if bytearraya(offseta) = bytearrayb(offsetb) if startmatch = -1 andalso offsetb < bytearrayb.length - 8 startmatch = offsetb end if offseta += 1 if offseta = bytearraya.length exit end if else offseta = 0 startmatch = -1 end if next return startmatch end function i need turbo fast because it's searching 7800 byte arrays in selected file's bytes. kind of hard explain there alternative code above or way speed up? thanks in advance! you should check out string search algorithms boyer-moore . although you&

Magento: What is the conceptual difference between a Quote Item and a Quote Address Item? -

inspired another question saw on so, wanted see if explain difference between quote item (mage_sales_model_quote_item) , quote address item (mage_sales_model_quote_address_item)? i think understand concept of quote item (mage_sales_model_quote_item - mapped sales_flat_quote_item db table) - line item in customer's cart includes name/sku of product, quantity, , special options. don't understand quote address item mage_sales_model_quote_address_item - mapped sales_flat_quote_address_item db table) for. see has address associated it, heck for? can imagine might have multi-address shipping (which have never used) wild guess. as secondary question (actually whole reason question :/), there cases custom module dealing quote items safely ignore quote address item? its related "ship multiple addresses" each item needs mapped separate address

design patterns - How can I build UI on the fly in my view model -

i have wholly adopted mvvm pattern our silverlight app. however, of our ui data driven. 2 items... the menu. using infragistics xammenu. we have "dashboard" allows users add "snap-ins". sort of portal site such igoogle. in both cases above ui needs built @ runtime. running code in code behind because don't see easy way access ui tree in viewmodel. in order run code in view have created event in viewmodel fires once data loaded. so, have kludge reference viewmodel in view code behind. don't ugly... 2 question: how can have view message viewmodel data loaded without getting direct reference viewmodel in view code behind? pull reference data context. is possible build ui in view model , use data binding. wondering if bind "content" of contentcontrol type (not sure type be) in viewmodel? of course, bad part testability of view model seems go away. can binding used way? to answer question 1, why dont make use of mvvm light &qu

asp.net - fusion free charts and arraylist -

i trying use arraylist build graph using fusionfree cant work, keeps showing same item array list dim util new util() dim region new list(of string) dim int1 new list(of integer) each rows gridviewrow in gridview1.rows ' selects text textbox dim regions label = ctype(row.findcontrol("label1"), label) region.add(label1.text) int1.add(10) next dim strxml string, integer 'initialize <graph> element strxml = "<graph caption='sales product' numberprefix='$' formatnumberscale='0' decimalprecision='0'>" 'convert data xml , append dim x int32 x = 0 = 0 (region.count) - 2 x = (x + 1) 'add values using <set name='...' value='...' color='...'/> strxml = strxml & "<set name='" & region.item(x) & "' value='" & int1.count & &

c++ - How do you clone() in linux inside a class and namespace? -

i'm taking intro operating systems course , we're use clone() call in linux create threads , stuff them. seem having trouble using clone() @ all. i've structured code single class (called homework ) in namespace class ( course ). may problem first time i've used namespace keyword. i'm trying use things become more experienced if have dumb mistake, it. i found articles on web didn't much. i've read man page guess i'm not experienced enough understand problem is. 1 day! assistance :) i want have method catch clones inside class: // -- header -- // namespace _course_ { class _homework_ { ... int threadcatch(void *); ... }; } // -- source -- // namespace _course_ { void _homework_::threadtest(void) { ... // web article void **childstack; childstack = ( void **) malloc(kilobyte); clone(threadcatch, childstack, clone_vm | clone_files, null)

java - Lucene field not searchable -

updated original question i created program pulls in content database , indexes it. during process, build string variable called searchfield consists of various different information. once string built, make following call. doc.add(new field("search", this.striphtmltags(searchfield), field.store.no, field.index.analyzed)); i know string not empty, because put in print statement show contents , right data making doc.add(). when search key words in fact show in searchfield, no hits. i'm not sure other details provide, , i'm sure there more needed, please me understand better , can solved! thanks in advance! try doc.add(new field("search", this.striphtmltags(searchfield), field.store.yes, field.index.analyzed));

Android Widget RemoteView ImageButton setImageSource -

would use image button in widget layout. want image clickable, clicking on image change image. not sure how set in widgetprovider remoteview. know how this? how change image within onreceive in widget provider? thanks thanks specifically how change image within onreceive in widget provider? call setimageviewbitmap() , setimageviewresource() , or setimageviewresource() on remoteviews in onupdate() method, or in intentservice invoke onupdate() method, or anywhere else using appwidgetmanager update app widget.

design - Pros and cons of making database IDs consistent and "readable" -

question is rule of thumb database ids "meaningless?" conversely, there significant benefits having ids structured in way can recognized @ glance? pros , cons? background i had debate coworkers consistency of ids in our database. have data-driven application leverages spring ever have change code. means, if there's problem, data change solution. my argument making ids consistent , readable, save ourselves significant time , headaches, long term. once ids set, don't have change , if done right, future changes won't difficult. coworkers position ids should never matter. encoding information id violates db design policies , keeping them orderly requires work that, "we don't have time for." can't find online support either position. i'm turning gurus here @ sa! example imagine simplified list of database records representing food in grocery store, first set represents data has meaning encoded in ids, while second not:

c++ - How to organize import and export code for versioned files? -

if application has able open (and possibly save) file format last n releases, how should code organized sanely updating file format easy , less error-prone? assume file format in xml, , functions take in objects export , produce objects import. append number end of each function name, , copy/paste , increment number each new version? that's maintaining multiple versions of version-controlled functions within source code. perhaps magic @ build time? firstly, supporting import of old versions lot easier export. because later versions different because support more features. hence saving old format may mean loss of data. consequently, experience has been on supporting import of multiple versions, spanning on decade. xml of course smart solution. designed problem in mind. key point me clean code structure follows clean data model. provided new versions add features , these represented support additional tags, not have recode handling of existing tags @ all. now could

java - Use two digits from the same jTextfield to perform a calculation -

i have completed basic calculator part of assignment. using 2 text feild enter opperands. , press operator display answer. however, both integers supposed entered same textfield, how do that? i have considered using array or stack, could'nt work. i included code below... calculator ready, , works well, multiplication division addition , subtraction, , displays answer in text area, 2 numbers added or subtracted... typed 2 seperate fields, once pressing opperand calculation done (reverse polish notation), however, how can eliminate use of 2nd field, , enter first value textfield, press enter insert second value same text field , pressing enter. saving first vala , second val b (integers). has same textfield. /* * change template, choose tools | templates * , open template in editor. */ /* * calcu.java * * created on feb 9, 2011, 10:11:37 pm */ /** * * @author halaseh */ public class calcu extends javax.swing.jframe { /** creates new form calcu */ publ