Posts

Showing posts from February, 2010

c# - AppDomain Creation : Resolving "Could not load file or assembly" error -

this weird. here's code : appdomain newdomain = appdomain.createdomain("newdomain ", null, new appdomainsetup { applicationbase = @"d:\mydllfolderfullpath\" }); assembly = newdomain.load("myassembly"); this throws "could not load file or assembly" error. checked assembly's dll located under specified folder path, , name of assembly correct. when copy myassembly.dll currentdomain's main folder, works ! behaves if applicationbase setting new appdomain has absolutely no effect , keep pointing current appdomain's appbase. any ideas ? i don't know want exactly... but load dll appdomain , create instance, can this: create appdomain. setup , security info optional parameters. var appdomain = appdomain.createdomain("a friendly name identify application", null, null); load assembly: var assemblyname = assemblyname.getassemblyname(@...

asp.net - Pagination not working in asp:DataGrid -

problem: when attempt go page 2 or other subsequent page of data grid, nothing refresh page. markup: <!--main datagrid--> <asp:datagrid id="dgtasks" runat="server" pagesize="40" allowpaging="true" autogeneratecolumns="false" forecolor="#333333" gridlines="both" font-size="small" allowsorting="true" onitemdatabound="item_databound" > <headerstyle backcolor="#990000" font-bold="true" forecolor="white" horizontalalign="center" font-size="small"/> <columns> ... </columns> <selecteditemstyle backcolor="#ffcc66" font-bold="true" forecolor="navy" /> ...

c# - Managed C++ prospects -

has tried coding in managed c++? have few questions : how productive language compared c#? is there restriction on type of projects can written? can write web application in managed c++? is possible mix managed , unmanaged c++ code in 1 application? is mfc still valid in managed c++? best option when considering migration of vc++ application? i've found c# far more productive. real magic of managed c++ yes, can mix managed , unmanaged code in - inside 1 function! don't know how microsoft did (and apparently neither they, because official name feature "ijw" - "it works" :)).

javascript - Dynamically show data in the popup which is determined in onpopupshowing event handler -

i developing firefox extension. on 1 <menupopup> , onpopupshowing calls javascript function. javascript function extracts list of names. these names have displayed in same popup. how can this? need pass data (just use beans in java) browser javascript function. data can change every time popup called. you need modify dom rapresenting menupopup. example: <menulist> <menupopup id="mymenupopup"> <menuitem id="firstitem" label="mozilla" value="http://mozilla.org"/> <menuitem id="seconditem" label="slashdot" value="http://slashdot.org"/> <menuitem id="thirditem" label="sourceforge" value="http://sf.net"/> </menupopup> </menulist> now if want add item: var mymenupopup = document.getelementbyid("mymenupopup"); var newitem = document.createelement("menuitem"); newitem.setattribute("id...

3d - Draw on different side of a cube -

i draw colorcube on scene. i want draw image on front , image on right side of it. i know must load image textureloader , add texture and put texture on cube.but didn't know how put on right side of it. the colorcube class 'all in one' class quick test purpose. if want create cube particular behavior, texture, color, etc. it's better create 1 scratch. check links (in french can read code) : http://deven3d.free.fr/java3d/chap03.htm#formesbase http://deven3d.free.fr/telechargements/fichiers/java3d/chap03/box3d/box3d.java http://deven3d.free.fr/telechargements/fichiers/java3d/chap03/quadarray3d/quadarray3d.java

validation - Rails - validates_uniqueness_of model field with the inverse of :scope -

i'm trying validate uniqueness of field in model 1 catch - shouldn't raise error if records have shared relation. sake of example, here's mean: class product < activerecord::base belongs_to :category end class category < activerecord::base has_many :products end >>> category.create({ :name => 'food' }) # id = 1 >>> category.create({ :name => 'clothing' }) # id = 2 >>> p1 = product.new({ :name => 'cheese', :category_id => 1, :comments => 'delicious' }) >>> p2 = product.new({ :name => 'bread', :category_id => 1, :comments => 'delicious' }) >>> p3 = product.new({ :name => 't-shirt', :category_id => 2, :comments => 'delicious' }) >>> p1.save >>> p2.save # should succeed - shares same category duplicate comment >>> p3.save # should fail - comment unique category_id = 1 if use validates_uni...

Rails 3 nested resource route problem as form_for -

i have nested resources in routes.rb - ( my rake:routes gist ) namespace(:admin) resources :restaurants resources :menus resources :menu_items end end in controller: def new @restaurant = restaurant.find(params[:restaurant_id]) @menu_item = @restaurant.menu_items.build end trying create new menuitem (action #new), url: http://127.0.0.1:3001/admin/restaurants/1/menu_items/new error: nomethoderror in admin/menu_items#new showing /home/fps/workspace3/peded/app/views/admin/menu_items/_form.html.erb line #1 raised: undefined method `admin_menu_items_path' #<#<class:0xb6582d78>:0xb6581f2c> extracted source (around line #1): 1: <%= form_for @menu_item |f| %> ... how make form work? created out of nifty:scaffold update i tried in _form: <%= form_for [:restaurant, @menu_item] |f| %> but ended similar error: showing /home/fps/workspace3/peded/app/views/admin/menu_items/_form.html.erb line #1 raised: undefined method `r...

web services - technologies beside scaling web applications in a distributed nature -

i interested in theory scale web applications in distributed nature, i.e. when there platform/stack can extended others applications running on different servers, etc. i researching field , feels lack of right keywords :) interesting concepts found far: opensocial through api aka web services , shopify (shopify it's hosted ecommerce solution) semantic web not quite sure one am on right way or lost anything? :) thanks.

javascript - jQuery $.ajax Not Working in IE8 but it works on FireFox & Chrome -

i have following ajax call works in firefox , chrome not ie: function getajaxdates( startdate, numberofnights, opts ) { var month = startdate.getmonth() + 1; var day = startdate.getdate(); var year = startdate.getfullyear(); var d = new date(); var randnum = math.floor(math.random()*100000000); $.ajax({ type : "get", datatype : "json", url : "/availability/ajax/bookings?rand="+randnum, cache : false, data : 'month='+month+'&day='+day+'&year='+year+'&nights='+numberofnights, contenttype : 'application/json; charset=utf8', success : function(data) { console.log('@data: '+data); insertcelldata(data, opts, startdate); }, error:function(xhr, status, errorthrown) { console.log('@error...

database - mysql PDO how to bind LIKE -

in query select wrd tablename wrd '$partial%' i'm trying bind variable '$partial%' pdo. not sure how works % @ end. would select wrd tablename wrd ':partial%' where :partial bound $partial="somet" or select wrd tablename wrd ':partial' where :partial bound $partial="somet%" or entirely different? +1 karim's answer covers it. say: "select wrd tablename wrd concat(:partial, '%')" to string joining @ mysql end, not there's particular reason in case. things bit more tricky if partial wrd looking can contain percent or underscore character (since have special meaning operator) or backslash (which mysql uses layer of escaping in operator — incorrectly, according ansi sql standard). hopefully doesn't affect you, if need case right, here's messy solution: $stmt= $db->prepare("select wrd tablename wrd :term escape '+'"); $escaped= str_repl...

c - Using fseek with a file pointer that points to stdin -

depending on command-line arguments, i'm setting file pointer point either towards specified file or stdin (for purpose of piping). pass pointer around number of different functions read file. here function getting file pointer: file *getfile(int argc, char *argv[]) { file *myfile = null; if (argc == 2) { myfile = fopen(argv[1], "r"); if (myfile == null) fprintf(stderr, "file \"%s\" not found\n", argv[1]); } else myfile = stdin; return myfile; } when it's pointing stdin, fseek not seem work. that, mean use , use fgetc , unexpected results. expected behavior, , if so, how move different locations in stream? for example: int main(int argc, char *argv[]) { file *myfile = getfile(argc, argv); // assume pointer set stdin int x = fgetc(myfile); // expected result int y = fgetc(myfile); // expected result int z = fgetc(myfile); // expected result int foo = bar(myfile...

c# - Getting SCOPE_IDENTITY from SQL Server on Insert -

i guess late , i'm tired see i'm doing wrong. here i'm trying: int imageid = imagedal.addimage(new sqlparameter[] { new sqlparameter("@image_id", sqldbtype.int, int32.maxvalue, parameterdirection.output, true, 0, 0,"image_id", datarowversion.current,dbnull.value), new sqlparameter("@image", sqldbtype.image, 11, parameterdirection.input, true, 0, 0,"image", datarowversion.current,image) }); public int addimage(sqlparameter[] spparams) { sqlhelper.executenonquery(basedal.connectionstringimages, insert_image_sql, spparams); return convert.toint32(spparams[0].value); } stored procedure: [dbo].[sp_insert_image] -- add parameters stored procedure here @image_id int out, @image image begin insert images (image) values (@image) select @image_id = scope_identity(); end go i dbnull spparams[0].value. i've tried setting...

.net - What Date Format Should I Send When Using Oracle.DataAcess -

converting usind micorsofts syste.data.oracleclient believe called oracles odt (oracle.dataaccess 10.2.0.100). when try , send date error "ora-1858: non-numeric character found numeric expected". code worked great using system.data.oracleclient. cmd.parameters.add(new oracleparameter("i_first_loss_event_date", oracledbtype.date)).value = .losseventsmessages(0).losseventtime thanks, dave as per table 3-10 in oracle data provider .net developer's guide , data type of value property of parameter should system.datetime (unless you're willing use odp.net-specific type, in case should oracledate or 1 of oracletimestamp types, depending on column/parameter type).

c# - Unmanaged Process in Mono -

i want create mono application start , stop several processes. need able start , stop processes mono application, not need advanced features of managed processes. users able customize available processes "preferences" menu. the problem is, need able create idlehandler, handler not fire, because application never able, due processes, , gui (gtk#) becomes unresponsive due weight of processes. there way start , stop unmanaged processes mono? lowering priority of processes not possible, because lead audio dropouts. here basic description of application try make: http://ix.residuum.org/monomultijack.html could not trigger init.d script starts jackd? (just assuming there init.d script since we're talking daemon) if there isn't such script, not make one? daemon launches in background, process starting bash-process runs script, exits when daemon launched in background. stopping work same way.

c# - How to notify table-data change to a client program? -

suppose have application access data resident in central db server , more 1 user access data client machines networked db server. suppose 2 client machines running copy of application , 2 users accessing same db table. how can automatically refresh data on gui, being viewed 1 client, change made client in db table-data? which technology should used solve particular scenario in .net? wcf? you looking notification push model. you'd have create seperate connections server each client. lots of hard work. wcf / sockets this. comet in web server environment. much easier way poll server every 15 seconds or client , check if there has been update. store last updated timestamp on server , if greater timestamp have refresh.

Is it possible to make Lucene queries in alfresco that find nodes based on their parent/children properties -

is possible make lucene query in alfresco finds nodes based on parent/children properties? example want find nodes have property "foo" set '1' , have nodes associated them child association property "baz" set '2' (maybe specifing somehow name of child association) something @crl\:numeroatto:"6555" , @crl\:firmatario:"marco rossi" where "numeroatto" property of parent node , "firmatario" property of child. association type "firmatari" (it's not in query because don't know how use it) to clearer i'm trying tell lucene: "find nodes have property numeroatto set 6555 , have children (association type children: firmatari) property "firmatario" set marco rossi. thanx in advance there no direct lucene way this. another idea: first return of parent nodes , build searches based on root of each returned node.

locking - Release another user's lock obtained with sp_getapplock on SQL Server -

we have system uses sp_getapplock create exclusive mutex time opens order in gui. used prevent multiple people making changes order simultaneously. sometimes people open order , go home, leaving open. blocks being able make changes order. emails, calls , end doing kill <spid> in enterprise manager. i've gotten sick of , want make quick self-service webform. the main problem i've run kill requires sysadmin privileges, not want give user our website runs as. have tried sp_releaseapplock doesn't let release user's lock (even when calling sysadmin). so, question; know of alternative method release lock obtained user using sp_getapplock ? the documentation pretty clear on point: locks placed on resource associated either current transaction or current session. locks associated current transaction released when transaction commits or rolls back. locks associated session released when session logged out. when server shuts down reason, locks r...

node.js & socket.io using client specific variables -

socket.on('connection', function(client){ var clientid = client.sessionid; console.log('connection '+clientid); var player = 0; client.on('message',function(data){ handleclientdata(data,clientid); }); client.on('disconnect',function(){ console.log('server has disconnected'); }); }); is variable "player" unique client? how can get/set variable function? thanks. it's variable local anonymous function runs when socket connection established. if want read function, either move global scope or pass function 1 of arguments. if want set function, either move global scope or pass function , read value when function returns. if explain want use player for, there's clearer answer.

android - add string to string array and display last/previous string in that string array -

i want add current string in textview view string array in arrays.xml.then display last/previous string of array in textview (settext). you cannot modify arrays.xml @ runtime -- sorry! need modify in-memory arraylist or instead.

c++ - How to implement the observer pattern safely? -

i'm implementing mechanism similar observer design pattern multithreaded tetris game. there game class contains collection of eventhandler objects. if class wants register listener game object must inherit game::eventhandler class. on state change events corresponing method called on eventhandler interface of each listener. code looks like: class game { public: class eventhandler { public: eventhandler(); virtual ~eventhandler(); virtual void ongamestatechanged(game * ingame) = 0; virtual void onlinescleared(game * ingame, int inlinecount) = 0; private: eventhandler(const eventhandler&); eventhandler& operator=(const eventhandler&); }; static void registereventhandler(threadsafe<game> ingame, eventhandler * ineventhandler); static void unregistereventhandler(threadsafe<game> ingame, eventhandler * ineventhandler); typedef std::set<eventhandler*> eventhandlers; ...

Python module audiolab returns error when function is called -

i need install python module audiolab research project, , while have managed install , module import in python shell, returns error in calling 1 of basic functions in module, wavread(). i using python2.7.1 mainly, though did try backtracking , installing audiolab python2.6.6, find same error message after importing , calling wavread() function. my operating system mac os x 10.5.8 intel processor. this how goes: import numpy import scipy import scikits.audiolab audio x, fs, nbits = audio.wavread('test.wav') traceback (most recent call last): file "<pyshell#3>", line 1, in <module> x, fs, nbits = audio.wavread('test.wav') file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/scikits.audiolab-0.11.0-py2.7-m...

XPath select certain amount of levels only -

if have xml structure this <root> <sub> <node /> <node /> </sub> <sub> <node /> <sub> <sub> <sub> <node /> </sub> </sub> <sub> <sub> <sub> <node /> </sub> <node /> </sub> </sub> <node /> <node /> </root> is there xpath syntax select first 3 levels of nodes? so collect <root> <sub> <node /> <node /> </sub> <sub /> <sub> <sub /> </sub> <sub> <sub /> </sub> <node /> <node /> </root> update just explain i'm doing, i've got asp:treeview, binding asp:xmldatasource, , want tree view go 3 nodes deep. may possible on treeview or xmldatasource control way, xpath seemed obvious thanks, psy you can add rule matc...

[WPF]: Styling a scrollbar, but the ListView scrollbar is not affected by the style -

i styling scrollbar in resourcedictionary without giving key value: <style targettype="{x:type scrollbar}"> ... </style> bur reason component of type scrollbar affected style. not listview component's scrollbar! i think scrollbars have same style since not using key value in style definition! any ideas? the default wpf behavior implicit scrollbar style apply scrollbars in listbox. if not occurring in application there overriding default behavior. have template applied listbox? my test app prove out default styling behavior below: <window x:class="testscrollbarstyle.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="window1" height="300" width="300"> <window.resources> <style targettype="scrollbar"> <setter property="background...

c# - NUnit / Testdriven.Net conflicting results -

when run test in nunit = red bar. [test] public void changingvalueviapropertydescriptorraisespropertychangednotification() { propertychangedeventargs pceventargs = null; subjectvm.propertychanged += (sender, e) => { pceventargs = e; }; propertydescriptor descriptor = subjectvm.getproperties().find(schoolmeta.name, false); descriptor.setvalue(null, "school's out summer."); assert.isnotnull(pceventargs); assert.areequal("school", pceventargs.propertyname); } however, when run test within visual studio testdriven.net passes (it's ok when run console app). when fails nunit it's because propertychanged null, subjectvm view model class inherits propertychanged base class. am blame, or looking @ nunit bug? different test harnesses execute tests in different orders: if test has implicit dependency on fixture's execution order, causing problem (i've been burned befo...

c++ - Any way to profile code for cache behavior? -

as title says i'd somehow cache behavior of code. i'm running windows 7 64-bit edition, compiling on visual studio 2008 professional edition, compiling c++ code. i understand there's valgrind under linux, there free alternatives use, or methods otherwise? vtune give pretty detailed cache , pipeline analysis. it's not cheap though. believe level/edition of vs (i remember "team edition" on xp) had decent profiler.

file io - access to the path is denied C# -

when running application can access file.. when running executable created, cannot access file.. suggestions? the error getting : access path 'e:\javascript.js' denied. check user permissions path & exe. here's how: source

asp.net - When radio button selection changes do not cause refresh? -

when selection of radio buttons change show/hide panel in next table cell. have hiding , showing fine each time causes page refresh top. way stop refresh? hide , show panel dynamically. <table> <tr> <td> <asp:radiobuttonlist runat="server" id="rblplayerstatus" autopostback="true" > <asp:listitem>free agent</asp:listitem> <asp:listitem>i have teammate</asp:listitem> </asp:radiobuttonlist> </td> <td> <asp:panel runat="server" id="pnlteammate"> <asp:label runat="server" id="lblteammate" text="choose teammate" /> </asp:panel> </td> </tr> </table> use ajax.asp.net library - add scriptmanager item, , updatepanel....

c# - Problems by inserting values from textboxes -

i'm trying insert current date database , allways message(when press button on form save access database), data type incorect in conditional expression. code: string constring = "provider=microsoft.jet.oledb.4.0;" + "data source=c:\\users\\simon\\desktop\\save.mdb"; oledbconnection empconnection = new oledbconnection(constring); string insertstatement = "insert obroki_save " + "([id_uporabnika],[id_zivila],[skupaj_kalorij]) " + "values (@id_uporabnika,@id_zivila,@skupaj_kalorij)"; oledbcommand insertcommand = new oledbcommand(insertstatement, empconnection); insertcommand.parameters.add("@id_uporabnika", oledbtype.char).value = users.idtextbox.text; insertcommand.parameters.add("@id_zivila", oledbtype.char).value = idtextbox.text; insertcomm...

memory - C++: "Watch" usage of "new", "delete" operators -

i'd track down when , how memory gets allocated in program , print out debugging purposes under circumstances! how can print out message allocated memory amount every time new used allocate memory in program? an excellent way debug memory problems use external monitor such valgrind . hook memory allocation , deallocation of program, , print out report @ end of program showing allocations didn't deallocate. no modification or recompilation of program necessary method.

linux - CSV FILE generator in C -

is there c program can run on linux box, , create csv file of given dimensions(rows x columns) , store on hard disk? a csv file plain text file comma separated values , can therefore create hand in plain text editor. there specification in rfc 4180 . often first row used column names such as: name, account no, amount niels, 1234, $0.99 thomas, 8888, $10.00 per, 3454, $9.00 rasmus, 9412, $99.99 a small c program create plain , empty csv file like: /* * makecsv.c */ #include <stdio.h> int main(int argc, char **argv) { if( argc != 3) { printf("mandatory arguments: <rows> <cols>\n"); return 1; } int row, col; for(row = 0; row < atoi(argv[1]); row++) { for(col = 0; col < atoi(argv[2]); col++) { if(col > 0) { printf(", "); } /* default values "row x col" */ printf("\"%dx%d\"", row, ...

Oracle ODBC: Why are national characters changed to Latin equivalent in SELECT result -

i have oracle 11 database connect using both jdbc , odbc. jdbc works well, in odbc polish letters in select result changed latin equivalent, example ą -> a , Ó -> o etc. tested application , simple python program uses odbc module. same value database returned as: zamoŚĆ - jdbc zamosc - odbc my environment: db server: oracle database 11g release 11.2.0.1.0 - 64bit production client machine: windows server 2008 r2 64 bit oracle clients in 32 bit , 64 bit versions in: c:\oracle\ora1120_32bit , c:\oracle\ora1120_64bit odbc manager reports oracle driver version as: 11.02.00.01 i think locales set poland/polish, not visible set command line utility. anybody knows odbc or environment setting responsible translation of polish letters latin equivalents? i suspect value of client character set not same in both cases. can check value of nls_lang setting: since on windows, should set in registry (probably hkey_local_machine -> software -> oracle...

coding style - What is a good rule for when to prepend members with 'this' (C#)? -

if accessing member field, property, or method, i'm never sure when should prepend 'this'. i not asking cases required, in case local variable has same name. talking cases meaning same. more readable? there standards, best practices, or rules of thumb should following? should consistent throughout class, or entire code base? i recommend using microsoft's guidelines, verified stylecop: http://blogs.msdn.com/sourceanalysis/ the general rule is, prepend members "this." when defined in class, unless static, in case cannot. here rule directly stylecop: sa1101: call {method or property name} must begin 'this.' prefix indicate item member of class.

db2 - Delphi TBytesField - How to see the text properly - Source is HIT OLEDB AS400 -

we connecting multi-member as400 iseries table via hit oledb , hit odbc. you connect table via alias access specific multi-member. create alias on as400 way: create alias aliasname table(membername) we can query each member of table way: select * aliasname we testing in delphi6 first, move d2010 later we using hit oledb as400. we pulling down records table , field being seen tbytesfield. have tried odbc driver , sees tbytesfield well. directly on as400 can query data , see readable text. can use iseries navigation tool , see readable text well. however when bring down delphi client via hit oledb or hit odbc , try view via asstring see unreadable text.. this: ñðð@ðõñððððñ÷@õôððõñòøóóöøñðÂÁÕÒ@ÖÆ@ÁÔÅÙÉÃÁ@@@@@@@@ÂÈÙÉâãæÁðòñè@Ôk@k@ÉÕÃk@@@@@@@@@ç i jumbled text above, character types show up. when did test in d2010 text looks japanse or chinese characters, if display ansistring looks in delphi 6. i thinking may have code pages or character sets, have no exp...

extjs - Ext.direct buffer -

i have question ext.direct.addprovider. using remoter provider. know there option add buffer multiple requests. looking buffer waits xxx amount of time, , sends request. also, there way send request when user clicks on button ? thx, yoni okay, found attribute enablebuffer can specify xxx amount of time send request. for second question, there way send request when user clicks on button ? yoni

java - How to reduce copy-pasting? -

if have number of similar classes, say: integer i0; integer i1; integer i2; integer i3; integer i4; integer i5; integer i6; integer i7; integer i8; integer i9; and wanted avoid doing this: i0 = 0; i1 = 1; i2 = 2; i3 = 3; i4 = 4; i5 = 5; i6 = 6; i7 = 7; i8 = 8; i9 = 9; i'm thinking of doing similar achieve same result: int cnt = 0; for(classname : arrayofclassnames { classname = cnt++; } how do that? [ clarification ] appears misunderstood. thinking more along lines of having 10 separate classes still, not 1 array having 10 items. use array or arraylist? // using array integer[] ints = new integer[10]; (int = 0; < 10; i++) { ints[i] = i; } // using array list arraylist<integer> ints = new arraylist<integer>(); (int = 0; < 10; i++) { ints.add(i); } following on update, looking can achieved using class.forname(classname).newinstance(); however, suggest whatever save in time code it, lose in readability , ease of mainten...

c++ - Is there a fastest way to count object repetitions in an array than a HashTable? -

i'll try clear can. have implemented solution , works, need know if best use other data structure instead of hash table it's college question, submitted teacher , works, wanted see if have done differently. so, problem: given image ( ppm 3,all data stored ascii in rgb ) e.g. p3 # p3 means colors in ascii, 3 columns , 2 rows, # 255 max color, rgb triplets 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0 i need divide each pixel constant given wich power of 2 ( 2,4,8…………64,128) c= 32; pixel2(255/c,255/c,255/c) = pixel2(7,7,7) then, need convert pixels patches of given width,and patch accumulate rgb values of pixels contains e.g. w=3; imagew = 10; imageh=10; patch[0].r = pixel[0].r + pixel[1].r + pixel[2].r + pixel[10].r + pixel[11].r + pixel[12].r + pixel[20].r + pixel[21].r + pixel[22].r; patch[0].g = same g component; patch[0].b = same b component; patch[1].r = pixel[1].r + pixel[2].r + p...

Invalidating Memcached Keys on save() in Django -

i've got view in django uses memcached cache data more highly trafficked views rely on relatively static set of data. key word relatively: need invalidate memcached key particular url's data when it's changed in database. clear possible, here's meat an' potatoes of view (person model, cache django.core.cache.cache): def person_detail(request, slug): if request.is_ajax(): cache_key = "%s_about_%s" % settings.site_prefix, slug # check cache see if we've got result made. json_dict = cache.get(cache_key) # cache hit? if json_dict none: # that's negative ghost rider person = get_object_or_404(person, display = true, slug = slug) json_dict = { 'name' : person.name, 'bio' : person.bio_html, 'image' : person.image.extra_thumbnails['large'].absolute_url, } cache.set...

osx - Accessing a unix domain socket in Mac OS X -

i'm trying write (raw byte transfer, no fancy stuff) data unix domain socket in mac os x (10.6) terminal (bash). socat not available , doesn not compile straight source in os x. according google versions of netcat support udss neither of these once compiled source: http://netcat.sourceforge.net/ http://nc110.sourceforge.net/ any ideas? openbsd's nc supports -u connect unix-domain sockets, , should reasonably portable. source in cvs (see anoncvs access ), , debian has tarballs .

linux kernel - Asynchronous Read/Writing with libraw1394 -

i'm trying 2 computers communicate each other on firewire. both of computers running ubuntu 9.10 , both have read/write access /dev/raw1394 node. i'm using firecontrol test sending read/write requests. if can work firecontrol, should able figure out how same in code. on computer a, this: computera $ ./commander work now copyright (c) 2002-2007 manfred weihs software comes absolutely no warranty. no adapter specified! got handle current generation number (driver): 1 1 card(s) found nodes on bus: 2, card name: ohci1394 using adapter 0 found: 2 nodes on bus, local id 1, irm 1 current generation number (adapter): 7 entering command mode type 'help' more information! command: w . 0 0 0xde insufficient arguments operation! command: w . 0 0 2 0xde writing node 0, bus 1023, offset 000000000000 2 bytes: 00 de write succeeded. ack code: complete since computer on node 1, send node 0. go comput...

java - Hibernate Entity Inheritance between Tables and Views -

i have 2 tables , view. tablea has fields. tableahistory has same fields tablea. viewall union of tablea , tableahistory, additionally has field called "current_vers" denotes current version ('y' tablea rows , 'n' tableahistory rows). it seems should able take existing hibernate entity bean tablea , extend create view viewall. when this, however, errors regarding dtype column don't have. how should this? edit : need able query view, have results tablea beans. it looks trying create audit trail. answer based on assumption. the best hibernate approved solution use hibernate envers . allows fine grained control of fields audit , strong versioning implementation works across relationships , inheritance boundaries. envers has apis support accessing prior versions see changes, timestamp, version etc. if still have flexibility in adding this, suggest using envers.

c++ - Xpressive >>= Operator -

i toying around boost xpressive , having trouble following snippet #include <iostream> #include <string> #include <boost/xpressive/xpressive.hpp> using namespace std; using namespace boost::xpressive; int main() { string s("123"); sregex rex = _d; rex >>= _d; smatch what; regex_search(s, what, rex); cout << "match: " << what[0] << endl; return 0; } the result of running program match of 1 opposed expected 12 . sregex::operator>>= have different meaning/use intuitively assumed? expecting yield sregex similar _d >> _d . xpressive doesn't support >>= operator. fact code compiles @ considered bug. try: rex = rex >> _d; however, building regex piecemeal make regex perform poorly.

jmf - When the last version of Java Media Framework was released? -

when released latest version of jmf? useful study jmf? please suggest me.. there small amount of source there? why? suggest me.. the last version released 2003 , there has been addon in 2004 far know (mp3 support). then, there haven't been changes anymore. jmf superseded jmc (java media components), in development javafx, has less features right jmf (i.e. streaming missing). there open source works enrich current jmf ( 1 , 2 ) or provide own api ( 3 ).

how to resolve Jboss deployment error? -

17:19:30,298 error [profileservicebootstrap] failed load profile: summary of incomplete deployments (see previous errors details): deployments missing dependencies: deployment "jboss.web.deployment:war=/root" missing following dependenc ies: dependency "jboss.web:service=webserver" (should in state "create", s in state "** not found depends on 'jboss.web:service=webserver' **") deployment "jboss.web.deployment:war=/test" missing following dependenc ies: dependency "jboss.web:service=webserver" (should in state "create", s in state "** not found depends on 'jboss.web:service=webserver' **") deployment "jboss.web.deployment:war=/admin-console" missing following dependencies: dependency "jboss.web:service=webserver" (should in state "create", s in state "** not found depends on 'jboss.web:service=webserver' **") deployment...

html - How to change text color for link in tr element with CSS -

i'd change background , text color when mouse hovers on row in table: tr { background-color:#fff; color:#000; } tr:hover { background-color:#000; color:#fff; } this works if there aren't links in tr elements, when there are, link color remains black (because of a { color: #000; } ?). how specify in css links in tr element should change color when mouse hovers on tr ? how about tr:hover { color: #cc0000; } is looking ?

javascript - how to change behavior of contenteditable blocks after on enter pressed in various browsers -

when pressing enter in <div contenteditable="true"> </div> in firefox <br /> produced - that's ok. in chrome or ie new <div> or <p> created. should make chrome , ie behave firefox . as douglas said earlier, browsers try clone previous tag when customer starts new paragraph on editable page. discrepancy occurs when browser has nothing depart - e.g. when page body empty. in case different browsers behave differently: ie starts wrap every string <p> tag, chrome wraps each line in <div>. to increase cross-browser experience, webkit developers have introduced defaultparagraphseparator command. can use following javascript on page loading chrome change default paragraph separator <p> tag: document.execcommand('defaultparagraphseparator', false, 'p');

iphone - iOS UIButton in UITableView Header -

i have subview acts container view in table header. in that, have uibutton. button not receiving touch events. (yes wired in ib...) so question is, common problem have buttons not receiving events in header? need forward events? i can't post code, since appear more of ib problem. experience before? update: if put button in footer, no container view, work. perhaps it's because in view inside header?? wow, feel moron. didn't have user interaction enabled. sorry wasting time guys...

HAML & SASS/COMPASS: Is it possible to share variables between? -

i'm getting used working compass , haml , it's pretty awesome. however, great if 2 work more closely together. seems not possible, might have overlooked or didn't search properly. i guess mean this: general variable file: $container-id = "container" $primary-column-id = "navbar" haml file: !!! 5 %html(lang="en") %head %title %body #{$container-id} %section#{$primary-column-id} compass file: #{$container-id} { width: 900px; } #{$primary-column-id} { width: 400px; } from research , usage, not supported (without sort of custom outside solution). agree awesome feature in theory, assume doesn't exist because of separation of concerns . for example, specific haml files have aware of linkage other specific sass files when compiled, , pick declared variables. happen sass <- -> sass, via partials. however, idea above -> markup (haml) blending styling (sass/scss). though refer...

New to OOP in PHP question about defining classes -

i am, title says, new oop self taught in php. have system running built in procedural php getting bit difficult modify due size. investigating re-write in php oop make easier maintain. i making lists of classes @ moment. our system administering driving schools have school, instructors, pupils , lessons can see objects , hence classes. question comes fact have 1 school many instructors, pupils , lessons when building program need display lists of these objects. therefore list of of them considered class in own right or when comes programming necessary create instance each instructor, pupil , lesson. or missing fundamental in design of oop system. as say, working out oop please gentle me. many colin thanks comments far. more think more realise, @ least me. list of in system object. imagine each item in list form, now, selection of item result in new script being run create new instance of pupil, instructor etc. along executing methods new instance. i forget frame...

c# - problem parsing with XMLReader (using ReadSubTree) -

im trying build simple xml controls parser in cf application. in code below string im trying parse looks this: "<panel><label>text1</label><label>text2</label></panel>" the result want code panel 2 labels. problem when first label parsed subreader.read() returns false in parsepanelelementh method, , falls out of while statement. since im new xmlreader must missing simple. apreciated ! peace. static class xmlparser { public static control parse(string axmlstring) { xmlreader reader = xmlreader.create(new stringreader(axmlstring)); return parsexml(reader); } public static control parsexml(xmlreader reader) { using (reader) { while (reader.read()) { if (reader.nodetype == xmlnodetype.element) { if (reader.localname == "panel") { return parsepanelelemen...

c# - Accept any certificate for SSL -

i have small tcpclient app connect server using ssl (sslstream class) my question is, how accept ssl certification when connecting? thanks, public static bool remotecertificatevalidationcallback(object sender, x509certificate certificate, x509chain chain, sslpolicyerrors errors) { return true; }

Visual C# 2010 Express: Specify default access modifier for new classes? -

whenever create new classes using visual studio 2010 express c# creates them no access modifier. 9 times out of 10 want new classes public. how can have visual studio create empty class templates "public" modifier default? the trick create new item template named class. when add > new class, template selected default rather built-in class template. (i not sure if behaviour guaranteed works on machine (tm).) create template: right-click in project , choose add > class. can accept default name (class1) -- temporary file. modify generated class as, example adding public modifier. save everything. choose file > export template. choose item template , specify relevant file (class1.cs). click next until template options page. template name, enter class. click finish. delete temporary class1.cs file. now add > class , should see class template being used default instead of built-in one.

Common Lisp: How to check set equality, ignoring order? -

similar question: setting equal function in common lisp using "eq" except, i'd compare 2 sets equality, disregarding order. how this? there number of set functions in cl. among can use (null (set-exclusive-or set-a set-b)) .

java - How to set up default schema name in JPA configuration? -

i found in hibernate config file set parameter hibernate.default_schema : <hibernate-configuration> <session-factory> ... <property name="hibernate.default_schema">myschema</property> ... </session-factory> </hibernate-configuration> now i'm using jpa , want same. otherwise have add parameter schema each @table annotation like: @entity @table (name = "projectcategory", schema = "schemaname") public class category implements serializable { ... } as understand parameter should somewhere in part of configuration: <bean id="domainentitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> <property name="persistenceunitname" value="jiramanager"/> <property name="datasource" ref="domaindatasource"/> <property name="jpavendoradapter"> ...

java - Log4j FileAppender issue in Tomcat server -

i working on webapplication , have requirment generate log files @ run time impex process.here use case validating xml file , validation error being handled custom error handler.this error hanlde passed underlying validator (jaxb 2.x validator),so have create log file when instance of error hanlder being created. using log4j logging api here code create log file @ run time xmlerrorhandler<object> errorhandler=new xmlerrorhandler<object>(logfilelocation); logfilename=errorhandler.getlogfilename(); validator.seterrorhandler(errorhandler); validator.validate(source); i creating log file inside xmlerrorhandler constructor since point have control here code log file creation fileappender appender; try { appender = new fileappender(layout, sb.tostring(), false); log.addappender(appender); log.setadditivity(false); log.setlevel(level.warn); } catch (ioexc...

Binding to object properties in C++ -

i've seen in wpf can bind control values properties of other controls. how binding accomplished in c++? for example, if have class called car , guage control called rpm, how tie value of rpm member variable car.rpm, when car.rpm changes, automatically (as in without specific update call coded me) reflected rpm control? general answers or directions pertinent resources fine also, i'm beginning dabble in c++ , haven't had google luck particular question. edit: see comments further clarification. it sounds want have pointer value car.rpm in gauge control. control never updated want to. in pure c++ sounds work observer-observable pattern, or simple callback function.

c# - Determine if a decimal can be stored as int32 -

i doing custom serializing, , in order save space, want serialize decimals int, if possible value wise. performance concern, since dealing high volume of data. current method use is: if ((value > int32.minvalue) && (value < int32.maxvalue) && ((valueasint = decimal.toint32(value)) == value)) { return true; } can improved? do have negative values? i'm guessing yes since have minvalue check, otherwise can skip it. use unsigned int allow convert more of double values ints. edit: also, if have more positive numbers, can swap first 2 conditions. way first 1 fail, decreasing total number of comparisons.

Get CSS bg image from web page on VB.NET -

i have code of web page , contains lots of "divs" backgroud images this: style="background-image: url(/images/image1.jpg)" is there easy way in vb.net urls bg images page? you can start getting html using webclient : dim client new webclient() ' add user agent header in case ' requested uri contains query. client.headers.add("user-agent", "mozilla/4.0 (compatible; msie 6.0; windows nt 5.2; .net clr 1.0.3705;)") dim data stream = client.openread(args(0)) dim reader new streamreader(data) dim s string = reader.readtoend() console.writeline(s) data.close() reader.close() from here can parse string (s) looking matches "backgroudn-image: {*}" - else need chime in, regex-fu horrible. regex.matches() - msdn

automake+libtool+c++ = very bloated interface -

first have "include_headers = 'my public headers'" , "libfoobar_la_sources = 'private sources' 'private headers'". fine. compile/install/link. when "nm -c my_instaed_lib.so" get: 00005be0 t yyget_debug(void*) 00005b00 t yyget_extra(void*) 00005bf0 t yyset_debug(int, void*) 00005bb0 t yyset_extra(fm4::leximpl*, void*) 00005b40 t yyget_column(void*) 00005b10 t yyget_lineno(void*) 00006180 t yyset_column(int, void*) 000061e0 t yyset_lineno(int, void*) ... this never declared in header. 000091f0 t fm4::prcimpl::collectmacro() 000089d0 t fm4::prcimpl::collectquote() 00008870 t fm4::prcimpl::collectcomment() 00009350 t fm4::prcimpl::collect() 000093f0 t fm4::prcimpl::process() 00008700 t fm4::prcimpl::prcimpl(fm4::processor*) 00008590 t fm4::prcimpl::prcimpl(fm4::processor*) 00009970 w fm4::prcimpl::~prcimpl() 00009a00 w fm4::prcimpl::~prcimpl() ... this in private not installed header. i read automake/libtool manual twice,...

sql server - sql raiseerror error.number wrong in VB -

i wrote t-sql query includes test valid employeeno. if employeeno not valid, following: raiserror(5005, 10, 1, n'invalid employee no') return @@error back in vb.net test sql exception , found when employee no invalid error.number not 5005 expect, 2732. what explanation this? thank you. you can't raise error 5005 in own code. db engine can this. error 2732 error says can't raise messages < 50000 select description sys.sysmessages m m.error = 2732 , msglangid = 1033 error number %ld invalid. number must %ld through %ld , cannot 50000.

c# - login asp.net redirect with parameters -

i'm writing login page login default "admin" , password reading xml file (fileupload control). how redirect main page, , know path file("fileupload.name")? method of redirecting appropiate? (sth redirecting parameters...but how? you question not clear redirect user man page after successful login this: //i assume bool variable userisvalid set after validating user if (userisvalid) { //if user redirected login page go requested page if (request.querystring["returnurl"] != null) { formsauthentication.redirectfromloginpage("user_name", false); } else { //set auth cookie formsauthentication.setauthcookie("user_name", false); //and redirect main page parameters if response.redirect("mainpage.aspx?prameter1={0}&parameter2={1}", param1, param2); } } else { //user not valid, processing }

python - Retrieve the two highest item from a list containing 100,000 integers -

how can retrieve 2 highest item list containing 100,000 integers without having sort entire list first? in python, use heapq.nlargest . flexible approach in case ever want handle more top 2 elements. here's example. >>> import heapq >>> import random >>> x = range(100000) >>> random.shuffle(x) >>> heapq.nlargest(2, x) [99999, 99998] documentation: http://docs.python.org/library/heapq.html#heapq.nlargest

sql - What really 'STATISTICS' do? -

what statistics do? , where use in query optimization senarios? you not manually use statistics. sql server's query optimizer does. used determine if , indexes query. at point, recommend start reading basics: http://technet.microsoft.com/en-us/library/cc966419.aspx

.NET WinForms ToolStrip alternatives -

i'm looking replacement standard winforms toolstrip control, because standard toolbar control looks outdated. for example, devexpress has ribbon control, that's not exact equivalent. i'm sure there must many custom-written toolbars winforms, having difficulties finding any. although can create own control, it's not best solution. the .net toolstrip controls can custom rendered using class derives toolstriprenderer . this codeproject article shows example of this. custom toolstriprenderer provided renders toolstrip controls though part of office 2007. source code available. you can use old mainmenu , contextmenu , toolbar classes instead of toolstrip controls. these controls rendered in current operating system style. note: these not direct replacements have different api's strip controls if application far development won't easiest solution.

c# - Whats a "shallow copy" of an objects -

possible duplicate: what difference between deep copy , shallow copy? i saw today here: http://msdn.microsoft.com/en-us/library/system.web.routing.route.aspx , 1 of member functions was: "memberwiseclone - creates shallow copy of current object. (inherited object.)" so whats "shallow copy" verse ... "deep copy"? shallow copy replaces properties on current level of object, means if have object property have same reference original. not problem if properties value types or primitives of course.

What is JDBC's Connection.isClosed() good for, and why is Snaq DBPool misbehaving on close? -

i have following code in java: if(!conn.isclosed()) { conn.close(); } instead of working, awarded with: java.sql.sqlexception: connection closed my connection object snaq.db.cacheconnection i checked javadocs isclosed, , state that: this method cannot called determine whether connection database valid or invalid. typical client can determine connection invalid catching exceptions might thrown when operation attempted. so questions are: 1) jdbc's isclosed() anyway? since when use exceptions in java check validity? 2) correct pattern close database? should close , swallow exceptions? 3) idea why snaqdb closing connection? (my backend postgres 8.3) i'll answer questions corresponding numbers: i agree you, seems strange isclosed provides closed state on best effort basis, , code still has prepared catch exception when closing connection. think reason connection may closed @ time database, , status returned query state method...

iis - Access client certificate properties from WCF Service -

i writing wcf service need access hash code of client certificates used connect service. i looking property or method similar request.clientcertificate asp.net 2.0 days cannot find allows easy access client certificate. our service set such running ssl using basichttpbinding , security mode of "transport". iis has been set require ssl , accept certificates. one thing note our server certificate used secure endpoint different ca of client certificates - client certificates intended validated solely through custom code (thus need hash code of connecting certificate). i have created custom implementation of idispatchmessageinspector see if there access client certificate there no avail. has attempted , had success before? looks best option implement custom certificate validator service. class derives x509certificatevalidator , registered through config file. there's more complete information on how on this article .

signal processing - Reducing moire when downsampling halftone comic images -

how can reduce moire effects when downsampling halftone comic book images during live zoom on iphone or ipad? i writing comic book viewer. nice provide higher resolution images , allow user zoom in while reading comic book. however, client averse moire effects , not allow feature if there noticeable moire artifacts while zooming, of course there are. modifying images less susceptible moire work if modifications not perceptible. blur prohibited, removes beloved halftone dots. the images black , white halftone , line art. originals 600 dpi ship application half @ best, 2500 pixels or less tall. so options? if write custom downsampling algorithm fast enough real time on these devices? there other tricks can do? work avoid size ratios have visual moire effects? as zoom in out, there peaks moire effects worst. there way calculate points , zoom nearby scale not bad? any suggestions welcome. have little experience image , signal processing, enjoying opportunity learn....