Posts

Showing posts from August, 2011

spam prevention - Is there a good API for blacklisted domains? -

just curious if there service paid or unpaid can send in either user's email address or domain email address , if they're known spammer or not? thanks from google'ing came across this: http://www.spamhaus.org/sbl/ looks pretty good.

Relative to absolute paths in HTML (asp.net) -

i need create newsletters url. next: create webclient; use webclient's method downloaddata source of page in byte array; get string source-html byte array , set newsletter content. but have troubles paths. elements' sources relative ( /img/welcome.png ) need absolute ( http://www.mysite.com/img/welcome.png ). how can this? best regards, alex. one of possible ways resolve task use htmlagilitypack library. some example ( fix links ): webclient client = new webclient(); byte[] requesthtml = client.downloaddata(sourceurl); string sourcehtml = new utf8encoding().getstring(requesthtml); htmldocument htmldoc = new htmldocument(); htmldoc.loadhtml(sourcehtml); foreach (htmlnode link in htmldoc.documentnode.selectnodes("//a[@href]")) { if (!string.isnullorempty(link.attributes["href"].value)) { htmlattribute att = link.attributes["href"]; att.value = this.absoluteurlbyrelative(att.value); } } ...

iphone - Where should I init my data? -

i parsing csv file when iphone app loads. takes few seconds throw splash screen while happening because loading data wakefromnib splash screen coming after done. so should work? what loading csv in applicationdidfinishlaunching: on uiapplicationdelegate ?

java - Can a Static Nested Class be Instantiated Multiple Times? -

given know of every other type of static feature of programming––i think answer 'no'. however, seeing statements outerclass.staticnestedclass nestedobject = new outerclass.staticnestedclass(); makes me wonder. yes, there nothing in semantics of static nested type stop doing that. snippet runs fine. public class multiplenested { static class nested { } public static void main(string[] args) { (int = 0; < 100; i++) { new nested(); } } } see also public static interface map.entry<k,v> public static class abstractmap.simpleentry<k,v> probably well-known nested type. instantiated multiple times. now, of course nested type can own instance control (e.g. private constructors, singleton pattern, etc) has nothing fact it's nested type. also, if nested type static enum , of course can't instantiate @ all. but in general, yes, static nested type can instantiated multiple times. note...

ios - How to use HTTP Live Streaming protocol in iPhone SDK 3.0 -

i have developed on iphone application , submitted app store. application got rejected based on below criteria. thank submitting yyyyyyyy application. have reviewed application , have determined cannot posted app store @ time because not using http live streaming protocol broadcast streaming video. http live streaming required when streaming video feeds on cellular network, in order have optimal user experience , utilize cellular best practices. protocol automatically determines bandwidth available users , adjusts bandwidth appropriately, bandwidth streams change. allows flexibility have many streams like, long 64 kbps set baseline feed. in apps have stream prerecorded m4v , mp3 files server. used mpmovieplayercontroller stream , play videos / audio. how implement http live streaming protocol in apps? can sample code? thanks in advance! there many documents apple's http live streaming: http live streaming overview i...

shader - GLSL break command -

currently learning how create shaders in glsl game engine working on, , have question regarding language puzzles me. have learned in shader versions lower 3.0 cannot use uniform variables in condition of loop. example following code not work in shader versions older 3.0. for (int = 0; < unumlights; i++) { ............... } but isn't possible replace loop fixed amount of iterations, containing conditional statement break loop if i, in case, greater unumlights?. ex : for (int = 0; < max_lights; i++) { if(i >= unumlights) break; .............. } aren't these equivalent? should latter work in older versions glsl? , if so, isn't more efficient , easy implement other techniques have read about, using different version of shader different number of lights? know might silly question, beginner , cannot find reason why shouldn't work. glsl can confusing insofar for() suggests there must conditional branching, when there isn't...

android - Accessing basic data on installed Apps -

i'm new android/java , wanted make app displays info on installed apps on device. i've used resolveinfo app list described here . but interested in determining things app category, current cache size, or last time app used. thought access using /data/data/, guess can't due security issues. any coding magic can kind of information? app category that android market concept , not exist in android os. current cache size i suspect not available sdk applications. last time app used i not sure tracked. i thought access using /data/data/, guess can't due security issues. correct.

C++ Unary - Operator Overload Won't Compile -

i attempting create overloaded unary - operator can't code compile. cut-down version of code follows:- class frag { public: frag myfunc (frag oper1, frag oper2); frag myfunc2 (frag oper1, frag oper2); friend frag operator + (frag &oper1, frag &oper2); frag operator - () { frag f; f.element = -element; return f; } private: int element; }; frag myfunc (frag oper1, frag oper2) { return oper1 + -oper2; } frag myfunc2 (frag oper1, frag oper2) { return oper1 + oper2; } frag operator+ (frag &oper1, frag &oper2) { frag innerfrag; innerfrag.element = oper1.element + oper2.element; return innerfrag; } the compiler reports... /home/brian/desktop/frag.hpp: in function ‘frag myfunc(frag, frag)’: /home/brian/desktop/frag.hpp:41: error: no match ‘operator+’ in ‘oper1 ...

php, checking correctnes of text splitting -

i need split html document on 2 parts. first part, should contain n(30) words, , next 1 should contain else. , main problem, prevent splitting tags (description , body of tags). <a **<=>** href="text" > text </a> <a href="text" > **<=>** text </a> <a href="text" > text </ **<=>** a> give me please suggestions (or if have written such function, please share code), how realize it! thanks. use dom parser, documentation can find @ http://php.net/manual/en/book.dom.php you can parse html in tree class, , result tree manipulation , saving data.

Sending an array of complex objects in the get string in C# ASP.NET MVC -

i want send array of objects in request string. know isn't optimal solution, want , running. if have class, this public class data { public int { get; set; } public int b { get; set; } } public class requestviewdata { public ilist<data> mydata { get; set; } } i thought bind mvc route web request this http://localhost:8080/request?mydata[0].a=1&mydata[0].b=2&mydata[1].a=3&mydata[1].b=4 but create array of 2 data objects without populating values 1,2, 3 or 4. is there way bind complex objects arrays? assuming have implemented method getarraytest in homecontroller public class homecontroller { public actionresult getarraytest (list<data> data) } the following work. http://localhost:8080/home/getarraytest?data[0].a=1&data[0].b=1&data[1].a=2&data[1].b=2&data[2].a=3&data[2].b=3

datetime - How do you convert YYYY-MM-DDTHH:MM:SSZ time format to MM/DD/YYYY time format in Ruby? -

for example, i'm trying convert 2011-01-19t00:00:00z 01/19/2011. what's simplest way of accomplishing this? you can use time.parse parse time string time object. can use strftime turn string format like: require 'time' time.parse("2011-01-19t00:00:00z").strftime("%m/%d/%y") #=> "01/19/2011"

c# - running quartz job in TriggerComplete event -

my program should run maximum (n) job @ time. if there more job needs run store in temp storage , after completing 1 of running job i'll pick trigger base on how trigger fails start , it's priority, , fire job at initialization phase, create example 5 job 5 corresponding trigger , add scheduler everything's fine until second job running triggercomplete of trigger listener not firing picking job run, please tell me im wrong ?? public class crawlertriggerlistener : itriggerlistener { private int maxconcurrentcrawling = 1; private int currentcount = 0; private object synclock = new object(); private dictionary firedic = new dictionary(); public string name { { return "listener"; } } public void triggerfired(trigger trigger, jobexecutioncontext context) { if (firedic.count == 0) { ischeduler sched = context.scheduler; string[] triggernamelist = sched.gettriggernames("triggergroup"); foreach (st...

python - How do I check (at runtime) if one class is a subclass of another? -

let's have class suit , 4 subclasses of suit: heart, spade, diamond, club. class suit: ... class heart(suit): ... class spade(suit): ... class diamond(suit): ... class club(suit): ... i have method receives suit parameter, class object, not instance. more precisely, may receive 1 of 4 values: heart, spade, diamond, club. how can make assertion ensures such thing? like: def my_method(suit): assert(suit subclass of suit) ... i'm using python 3. you can use issubclass() assert issubclass(suit, suit) . but why want such thing? python not java.

sql server - Wildcard characters sql only alphabet characters -

i need create rule alphabet characters i used following wildcard character sequences didn't work ! like '[a-za-z]' like 'a-z' like 'a-za-z' double negative like where somecol not '%[^a-z]%' ignoring first not, means "match character not in range z". then, reverse using first not means "don't match character not in range z" edit, after comment like '%[a-z]%' means "find single character between a-z. 111s222 matched example because s matches in like.

visual studio 2010 - Get methods covered by a unit test -

is possible following visual studio 2010 plugin? if yes, how? run unittests in solution (with code coverage enabled) wait tests complete for completed tests: determine methods called during each test (directly test or indirectly tested methods). , store names in variable in plugin. what don't know how interact testing framework code. found answer: http://msdn.microsoft.com/en-us/vstudio/ff420671.aspx

visual studio - How to get the IBM DB2 provider to work with Entity Framework 4.0 -

can please tell me how db2 provider show in "change data source" dialog window? steps: right-click on edmx design surface. select "update model database" on update wizard, click "new connection" next "data source" textbox, click "change..." in change data source window, seeing following data sources in list: microsoft sql server microsoft sql server compact 3.5 microsoft sql server database file <other> when select "other", see 2 entries in data provider dropdown: .net framework data provider microsoft sql server compact 3.5 .net framework data provider sql server how db2 provider(s) show here can use them model db2 tables? i able connect db2 using vs2010 server explorer. connection string is: "provider=ibmdadb2.db2copy1;data source=db2thloc;persist security info=true;user id=****;location=****" (stars security) the provider listed as: .net framework data provider ole db type: db2...

cryptography - Is calculating an MD5 hash less CPU intensive than SHA family functions? -

is calculating md5 hash less cpu intensive sha-1 or sha-2 on "standard" laptop x86 hardware? i'm interested in general information, not specific chip. update: in case, i'm interested in calculating hash of file. if file-size matters, let's assume 300k. yes, md5 less cpu-intensive. on intel x86 (core2 quad q6600, 2.4 ghz, using 1 core), in 32-bit mode: md5 411 sha-1 218 sha-256 118 sha-512 46 and in 64-bit mode: md5 407 sha-1 312 sha-256 148 sha-512 189 figures in megabytes per second, "long" message (this messages longer 8 kb). sphlib , library of hash function implementations in c (and java). implementations same author (me) , made comparable efforts @ optimizations; speed differences can considered intrinsic functions. as point of comparison, consider recent hard disk run @ 100 mb/s, , on usb top below 60 mb/s. though sha-256 appears "slow" here, fast enough purposes. note openssl incl...

vb.net - Background worker not working right -

i have created background worker go , run pretty long task includes creating more threads read file of urls , crawl each. tried following through debugging , found background process ends prematurely no apparent reason. there wrong in logic of code causing this. try , paste as possible make sense. while not myreader.endofdata try currentrow = myreader.readfields() dim currentfield string each currentfield in currentrow itemcount = itemcount + 1 searchitem = currentfield generatesearchfromfile(currentfield) processquerysearch() next catch ex microsoft.visualbasic.fileio.malformedlineexception console.writeline(ex.message.tostring) end ...

java - Invoke Maven-Module Build from IntelliJ -

i wondering if knows way invoke specific maven module build intellij build (or use compiled classes from) modules on depends. so instance if build module "model" in picture, seems reasonable me click package step on it. invokes mvn package step inside specific module rather mvn -am -pl module-name root module, builds dependencies. so there don't know? removed dead imageshack link i way (idea 8.1.4) open run dialog (shift-f10 on windows) click + , pick maven add maven build config fill in form, adding 1 working directory 2 maven command line options 3 maven goals 4 profiles this no different running command line . assuming want.

python - How to get HTTP status message in (py)curl? -

spending time studying pycurl , libcurl documentation, still can't find (simple) way, how http status message (reason-phrase) in pycurl. status code easy: import pycurl import cstringio curl = pycurl.curl() buff = cstringio.stringio() curl.setopt(pycurl.url, 'http://example.org') curl.setopt(pycurl.writefunction, buff.write) curl.perform() print "status code: %s" % curl.getinfo(pycurl.http_code) # -> 200 # print "status message: %s" % ??? # -> "ok" i've found solution myself, need, more robust (works http). it's based on fact captured headers obtained pycurl.headerfunction include status line. import pycurl import cstringio import re curl = pycurl.curl() buff = cstringio.stringio() hdr = cstringio.stringio() curl.setopt(pycurl.url, 'http://example.org') curl.setopt(pycurl.writefunction, buff.write) curl.setopt(pycurl.headerfunction, hdr.write) curl.perform() print "status code: %s" % ...

javascript - hiding inner tables with JQuery -

i'm trying hide inner table jquery element triggers hiding in parent table. here's code: <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> </head> <body> <script type="text/javascript"> $(function() { $(".collapsible").click(function(event) { event.preventdefault(); inner = $(this).find(".inner"); if($(inner).is(":visible") == true) { alert("hiding"); $(inner).hide("slow"); } else { alert("showing"); $(inner).show("slow"); } }); $(".inner").each(function(index, element) { $(this).hide(0); }); }); </script> <table class='outer'> <tr><td><a class='collapsible' href='#...

audio - Synchronisation in id3 -

i not clear synchronisation , unsynchronisation in id3 tags. i have read developer info, not able understand. can please me in explaining things clearly. thanks. what more precisely not understand? seems documentation quite clear. synchronisation can used (in general legasy) programs, not know id3v2, not accept tag data frame header. way, seems majority of programs not use syncronisation, , possible if faced dificulties synchronisation can try not work synchronized tags.

c# - Sort and Group in LINQ -

i have list of string tuples, (p1,p2) i'd know if there's linq statement group p1 (in ascending order), , have group contain p2 values group (in descending order). for input: ("a","b"), ("a","c"), ("d","b") i'd 2 groups: "a" , "d" (in order, every time) group "a" contains "c" , "b" (in order, every time) , group "d" contains, well, "b". is possible built-in linq classes or need iterate groups , sort them myself? nope, it's not hard - need keep track of whether you're looking @ group or elements within group. here's sample query: var query = tuple in tuples orderby tuple.p1 group tuple.p2 tuple.p1 g select new { group = g.key, elements = g.orderbydescending(p2 => p2) }; here's complete example (avoiding .net 4's tuple type simplicity if you...

c# - Text box pasting issue -

how can disallow paste in textbox if copied string contains white spaces anything has ability require javascript - user can disable. you're must better validating server-side, possibly using 1 of validation controls .

generics - Using Covariance with an Interface Base Type in .NET 4? -

i have entities created linq-to-sql. 6 of these entities (representing values in drop-down lists) implement interface i've called ivalue . did because ui layer going have account couple special cases -- notably, display if original value on record has been flagged deleted. the repository has variety of listallxxx methods these guys. of these return generic lists typed appropriate entity type. example: public static list<contacttype> listallcontacttypes(deletedoptions getdeleted) { /* requisite code */ } contacttype implement ivalue , of course. there's set of services designed retrieve ui-specific list. basic pattern thus: // 1 of these each entity type public static list<ivalue> getcontacttypelist(contacttype target) { list<ivalue> ret = lovrepository.listallcontacttypes(deletedoptions.nodeleted); preplist(ret, target); return ret; } // of above methods use guy private static void preplist(list<ivalue> list, ivalue targeten...

sql - regarding like query operator -

for below data (well..there many more nodes in team foundation server table need refer to..below sample) nodes ------------------------ \node1\node2\node3\ \node1\node2\node5\ \node1\node2\node3\node4\ \node1\node2\node3\node4\node5\ i wondering if can apply (below query not give required results) select * table_a nodes '\node1\node2\%\' to below data \node1\node2\node3\ \node1\node2\node5\ and (below not give required results) select * table_a nodes '\node1\node2\%\%\' to \node1\node2\node3\ \node1\node2\node5\ \node1\node2\node3\node4\ can above done like operator? pls. suggest. thanks you'll need combine 2 terms, , not like: select * table_a nodes '\node1\node2\%\' , nodes not '\node1\node2\%\%\' for first query, , similar solution second. that's "plain sql". there sql server specific functions count number of "\" characters in column, instance.

php - how to rate or rank votes -

i'm sorry if i'm wrong question want idea...i want have , idea of ranking algorithm include time submit there votes. nice question! okay lets bring on! first of 1 thing cannot when calculating ratings bayesianaverage you ran read on simplified takes care of following: entries little votes not true mean of votes have componentn of mean rating throughout dataset. example on imdb default rating somewhere @ 6.4. film 2 votes 10 stars each may still have between 6 , 7. more votes more meaning become alltogether , rating "pulled away" default. imdb implements minimum number of votes movies show in listings. another thing find confusing is: why time of vote important? didn't mean time of entry voted on? in our movies example released movies more important? but anyway! in both cases results achieved applying logarithmic functions. for our movie example movies relevance multiplied 1 + 1/sqrt(1 + current_year - release_year ) so 1 socket rat...

recursion - Java recursive routine doubt -

im implementing recursive routine calculate terms of multinomial expression, multinomial expansion. kind of figured translates a problem along following lines -- given set of n numbers values ranging [0,1,2,...n] maximum number of combinations sum of k can achieved. the following recursive routine -- public static string []multinomial_elements; public static void multichoose(int n,int k) { string[] result = null; system.out.print("calling multichoose with"); system.out.println(" "+integer.tostring(n)+" "+integer.tostring(k)); if(n==1) { multinomial_elements[result_iter]=multinomial_elements[result_iter]+integer.tostring(k)+"|"; ++result_iter; } else { if(k==0) { result=new string[1]; result[0]="0"; for(int a=0;a<n;a++) multinomial_elements[result_iter]=multinomial_elements[result_iter]+"0"+"|...

android - How to compare date column in sqlite where condition -

how compare date column in sqlite condition it's hard tell you're asking, sqlite website has page on date , time functions should help.

How to retrieve variables defined in a particular include file in php? -

i want know variables have been declared within include file. example code is: include file: <?php $a = 1; $b = 2; $c = 3; $myarr = array(5,6,7); ?> main file: <?php $first = get_defined_vars(); include_once("include_vars.php"); $second = get_defined_vars(); $diff = array_diff($second ,$first); var_dump($diff); $x = 12; $y = 13; ?> my attempt use difference of get_defined_vars() not seem give accurate information. gives: array(2) { ["b"]=> int(2) ["c"]=> int(3) } $a , $myarr seem missing. other methods can use? it's not thing this, hope it's needed debugging. should find difference between keys of arrays get_defined_vars return, not between values: $diff = array_diff(array_keys($second),array_keys($first)); if don't want include file, more complicated way using tokenizer : $tokens = token_get_all(file_get_contents("include_vars.php")); foreach($tokens $token) { if...

wordpress - where to get Fantastico for cPanel -

i working on project requires fantastico wordpress installation body know can ? some places not free can tell equivalent free/opensource https://netenberg.com/fantastico.php it's 45$ developer afaict. c-panel addon here, many hosts offer hosting service. here's alternative http://www.softaculous.com/ , available free or premium, free not include wordpress.

c++ - Boost function and boost lambda -

i've seen few related questions, still puzzled. what's wrong syntax: boost::function<int (int)> g = f; boost::function<int (int)> g2 = 2*g(boost::lambda::_1); i've tried boost 1.35 , 1.38 (these 2 installations have lying around) on gcc 4.3.4, , both give variations of error: no match call '(boost::function<int ()(int)>) (const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&)' you can't call function placeholder directly. have use bind . boost::function<int (int)> g2 = 2 * boost::lambda::bind(g, boost::lambda::_1); ( example )

C# Change string in dll through exe -

i'm new here , quite new c# well. been playing around bit , got hang of basic, have digged bit deep level of skill follow. i have created program have log in , have created dll in same project contain data. have done because want able alter data through program. there ftp-functions , simular involed , program several different users, can't save same password , data everyone. i have no problem calling data dll password, want change password in dll through settings-form. how can this? part of main program: public static string updatepass() { } public void apply_click(object sender, eventargs e) { string newpass = newpassfield.text; string repass = repassfield.text; int pass_value = newpass.compareto(repass); if (pass_value == 0) { } else messagebox.show("error: passwords not match!"); } part of dll password is: public static string passdata(string password...

When Django's ORM Uses Q? -

i trying use django's q functionality generate , and or sql queries, unfortunately can't seem figure out how , when django generates it's conditionals. had more complex query decided pare down see going on. example without q(): >>> myobject.objects.filter(status='value').count() 6 and q(): >>> myobject.objects.filter(q(status='value')).count() 22 and queries generates django.db.connection: [{'time': '0.001', 'sql': 'select count(*) "myobjects_myobject" "myobjects_myobject"."status" = e\'value\' '}, {'time': '0.001', 'sql': 'select count(*) "myobjects_myobject"'}] and add value: >>> myobject.objects.filter(q(status='value'), q(created_date__lt=a_date_value)).count() 22 but when reverse order get: >>> myobject.objects.filter(q(created_date__lt=a_date_value), q(status='value')...

WPF DataGrid window resize does not resize DataGridColumns -

i have wpf datagrid (from wpftoolkit package) following in application. <controls:datagrid> <controls:datagrid.columns> <controls:datagridtextcolumn width="1*" binding="{binding path=column1}" header="column 1" /> <controls:datagridtextcolumn width="1*" binding="{binding path=column2}" header="column 2" /> <controls:datagridtextcolumn width="1*" binding="{binding path=column3}" header="column 3" /> </controls:datagrid.columns> </controls:datagrid> the column width should automatically adjusted such 3 columns fill width of grid, set width="1*" on every column. encountered 2 problems approach. when itemssource of datagrid null or empty list, columns won't size fit width of grid have fixed width of 20 pixel. please see following picture: http://img169.imageshack.us/img...

java - JButton keyboard shortcuts -

i have 2 jbutton s , allow them used keyboard arrow keys whenever jframe has focus. can point me in right direction this? modified swing's action demo. the initialization of button: // sets mnemonic down, no hint display jbutton down = new jbutton(new downaction("down", null, "this down button", new integer(keyevent.vk_down)); the action: class downaction extends abstractaction { public downaction(string text, imageicon icon, string desc, integer mnemonic) { super(text, icon); putvalue(short_description, desc); putvalue(mnemonic_key, mnemonic); } public void actionperformed(actionevent e) { displayresult("action first button/menu item", e); } }

c# - How to Implement Undo for Treeview -

i working in windows application. problem is.. i have treeview & textbox control in form. each node text present in textbox saving in database. currently program working this. 1) treeview_beforeselect() : in method have written code save textbox data in database. 2) treeview_afterselect() : in method have written code data database & display in textbox. now have implement undo treeview. please suggest ideas regarding this. would simple adding time stamp field everytime persist data database? every time persist treeview, need insert new row , increment version. if want undo, need previous version.

Implementing custom MATLAB functions in Simulink -

i use custom matlab function in simulink. far have done placing embedded matlab function block. however, if custom function contains custom function compile process fails. here example of function trying embed in simulation: function [c, d, iterationscount] = decodeldpc(y, h, variance) lci = initializelq(y, h, variance); lr = getlr(lci); [lq, c] = getlq(lci, h, lr); iterationscount = 1; while(sum(mod(c * h', 2)) ~= 0) lr = getlr(lq); [lq, c] = getlq(lq, h, lr); iterationscount = iterationscount + 1; end; g = getgeneratormatrix(h); d = c/g; where initializelq , getlr custom functions well. is there method implement above function in simulation? you need use command eml.extrinsic call external matlab functions eml block. example, can put @ top of eml function, eml.extrinsic('getlr', 'initializelq'); to allow functions called. more information, see documentation

iphone - How to catch touch event in every view of an app? -

i want catch touch event in views.so should deal appdelegate . i referred iphone: detecting user inactivity/idle time since last screen touch but not success hope i'll in right direction thanks app delegate not responder. subclass uiwindow, , override it's event handling methods, because window gets touch events in first time.

Different class size between Eclipse IDE and javac -

when compile java sources under eclipse ide have bigger generated class-files, when compile javac in console. could give me reason behind that? because eclipse doesn't use javac, own compiler. other thread: how set other-than-eclipse java compiler eclipse ide from jdt website : an incremental java compiler. implemented eclipse builder, based on technology evolved visualage java compiler. in particular, allows run , debug code still contains unresolved errors. keep in mind library itself, eclipse still use 1 sun's compiler can set using procedure explained answers (nimchimpsky , elite).

caching - How to prevent HTTP 304 in Django test server -

i have couple of projects in django , alternate between 1 , every , then. of them have /media/ path, served django.views.static.serve , , have /media/css/base.css file. the problem is, whenever run 1 project, requests base.css return http 304 (not modified), because timestamp hasn't changed. when run other project, same 304 returned, making browser use file cached previous project (and therefore, using wrong stylesheet). just record, here middleware classes: middleware_classes = ( 'django.middleware.common.commonmiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.middleware.transaction.transactionmiddleware', ) i use default address http://localhost:8000 . there solution (other using different ports - 8001, 8002, etc.)? you can roll own middleware that: class noifmodifiedsincemiddleware(object): def process_request(self, re...

java - InputStream reading trouble -

i have following problem: have read inputstream sequence of data due own arrangement need read first 4 bytes unsigned short (16 bits) in way read 2 blocks of 2 bytes because meaning of bytes numbers after need read unsigned byte because meaning of remaining data ascii. someone advice me on how accomplish that? you can use java's own datainputstream. can read first 4 bytes using readint, rest using readbyte... see http://download.oracle.com/javase/6/docs/api/java/io/datainputstream.html

ruby on rails - What is causing this shift in layout? CSS? -

i have been following ror tutorial , noticed layout appears shift while moving between nav links. rather link actual project, can see talking looking @ author's personal homepage: www.michaelhartl.com/ if move between nav links @ top, whole page appears shift. guessing has nothing ror, , more css. some pages have scrollbars, others don't. when scrollbar appears shift left pixels. (if mean.)

database design - Business Reporting on an OLTP Application -

we have oltp application using oracle database 10g enterprise edition, , plan build business reporting layer meet following needs. sheilding complexity of current oltp database design improving query performance of current oltp reports providing read-only access other applications allowing business users perform adhoc reporting the solution thinking of create db cache layer using oracle materialized views(mv) on current oltp. mv's denormalized , designed reporting. mv log's synchronize changes mv using incremental refresh. my questions are, does approach make sense (mv's)? has used mv's building oltp reporting solutions? what drawbacks of approach(mv)? how using oracle cdc , tables, procedures perform synchronize. any other approaches? thank you, sherry in general, thinking of either view layer or materialized view layer reporting users. preference unless there concrete performance issues go views eye creating occasional materialized v...

r - Calculate the Area under a Curve -

i calculate area under curve integration without defining function such in integrate() . my data looks this: date strike volatility 2003-01-01 20 0.2 2003-01-01 30 0.3 2003-01-01 40 0.4 etc. i plotted plot(strike, volatility) @ volatility smile. there way integrate plotted "curve"? the auc approximated pretty looking @ lot of trapezium figures, each time bound between x_i , x_{i+1} , y{i+1} , y_i . using rollmean of zoo package, can do: library(zoo) x <- 1:10 y <- 3*x+25 id <- order(x) auc <- sum(diff(x[id])*rollmean(y[id],2)) make sure order x values, or outcome won't make sense. if have negative values somewhere along y axis, you'd have figure out how want define area under curve, , adjust accordingly (e.g. using abs() ) regarding follow-up : if don't have formal function, how plot it? if have values, thing can approximate definite integral. if have function in r, can calcula...

Android Dev.: How to populate gallery by image URL? -

i'm trying build gallery images within pulled images url website. i.e. instead of doing r.drawable.xxxx.jpg, use url represent image. is possible? if so, can show me example in code? thanks this might old post, hey library github might helpful android image loader also, on application class, set option maxpriority better outcome. cheers, hope helps...

iphone - How to pass the number of row selected from didSelectRowAtIndexPath to initWithNibName? -

i have tableview (first view) , detailview (next view) containing details of table. now on selecting particular row first view want pass index number of selected row didselectrowatindexpath of first view initwithnibname of next view. how can that? you can implement own method in view controller want instantiate , call method instead of -initwithnibname:bundle: . in method, call // in view controller - (id)initwithnibname:(nsstring *)nibname bundle:(nsbundle *)nibbundle index:(nsinteger)index { [self initwithnibname:nibname bundle:nibbundle]; // stuff index here } // in table view delegate - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { detailview *vc = [[detailview alloc] initwithnibname:@"yournibname" bundle:nil index:indexpath.row]; [self.navigationcontroller pushviewcontroller:vc animated:yes]; [vc release]; }

wpf - How to get the Row and Column count of a grid in C#? -

how row , column counts of grid in c#, regular window control grid, not datagrid or gridview thanks have tried grid.rowdefinitions.count , grid.columndefinitions.count ?

c - Executing a shared library on Unix -

some unix shared libraries provide output when called command line if executables. example: $ /lib/libc.so.6 gnu c library stable release version 2.13, roland mcgrath et al. copyright (c) 2011 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. compiled gnu cc version 4.5.2. compiled on linux 2.6.37 system on 2011-01-18. [...] in shared library of own written in c, how can provide output? i've executed library made , segment fault. note: asked on unix.stackechange.com https://unix.stackexchange.com/questions/7066/executing-a-shared-library the below definition of main responsible printing output see. defined in csu/version.c of source tree of glibc. hope helps. #ifdef have_elf /* function entry point shared object. running library program here. */ extern void __libc_main (void) __attribute__ ((noreturn)); void __libc_main (void) { __libc_print_version (); ...

UiSplitViewController doesn't autorotate -

i have run problem. ipad app somehow preventing ipad auto-rotating. app loads uisplitview both of view controllers returning yes shouldautorotatetointerfaceorientation:. have set info.plist include "supported interface orientations" key 4 orientations. when run app, however, rotating device not rotate splitview (even though receiving uideviceorientationdidchangenotification). in addition, when exit app in different orientation started in ipad home screen doesn't autorotate correct view until rotate again without app running.... ideas appreciated.... uisplitviewcontroller 1 of temperamental view controller subclasses i've ever had use. in order work "perfectly", must exist single root view in application's window. can, however, around trickery -- in case, needed uitabbarcontroller @ least 2 distinct uisplitviewcontroller s view controllers -- have take care of weird cases involving rotation , uisplitviewcontrollerdelegate callbacks ...

visual studio - C# 4.0/EF - Server-generated keys and server-generated values are not supported by SQL Server Compact -

i have moved 1 of projects vs2010/fx4.0 , using sql ce database backing store. since moving version of .net getting error: server-generated keys , server-generated values not supported sql server compact. my table was defined pk of username (string) & dooropen (datetime) sqlce required there pk on every table in fx3.5. in fx4.0 stumped. i've googled , every answer found was: sqlce not support auto-generating values (which not needing) put guid id on there , populate code. i tried approach , still getting same error! sqlce: create table [importdooraccesses] ( [rawdata] nvarchar(100) not null, [dooropen] datetime not null, [username] nvarchar(100) not null, [cardnumber] bigint not null, [door] nvarchar(4000) not null, [imported] datetime not null, [id] uniqueidentifier not null -- new column ); alter table [importdooraccesses] add constraint [pk_importdooraccesses] primary key ([id] ); the constraint used be:...

Nhibernate 3.0 and FluentNHibernate -

is building truck nhibernate , fluentnhibernate together? how's working? using production systems? how linq support? is ready release? is there nice , concise way keep date going on in world of nhibernate? (ie, without having read lots of blogs, , mailing lists ) you can find trunk fnh builds here: http://hornget.net/packages/orm/fluentnhibernate/fluentnhibernate-trunk (i haven't tried don't use fluent) nhibernate 3.0 pretty stable , new linq provider good, excelent coverage of possible linq constructs , clever, non-intrusive support of nhibernate specific concerns ( caching , fetching ) i'd use in production without concern; being in "pre-alpha" state reflects seriousness of project team, current state more similar of visual studio rc ctp or beta. update (2010-12-05) : nhibernate 3 released yesterday.

c# - A btter way to represent Same value given multiple values(C#3.0) -

i have situation looking more elegant solution. consider below cases "bkp","bkp","book-to-price" (will represent) book-to-price "aop","aspect oriented program" (will represent) aspect-oriented-program i.e. if user enter bkp or bkp or book-to-price , program should treat book-to-price. same holds second example(aspect-oriented-program). i have below solution: solution: if (str == "bkp" || str == "bkp" || str == "book-to-price" ) return "book-to-price". but think there can many other better solutions . could people please give suggestion.(with example better) i using c#3.0 , dotnet framework 3.5 i consider using dictionary<string,string> , perhaps populated configuration file or database table, alias canonical name relationships. use case insensitive key comparer. example, var map = new dictionary<string,string>( stringcomparer.ordinalignorecase ); map...

android - Droid's mediaserver dies on camera.takePicture() -

on motorola droid, firmware 2.1-update1, kernel 2.9.29-omap1, build # ese81 when attempting take picture, mediaserver dies segmentation fault. i've tried putting takepicture in timer , running few seconds after camera initialization check race conditions, no change. calling camera.open() doesn't cause crash. also, calling camera.open() causes think autofocus motor make sort of ticking sound. code breaks: import android.app.activity; import android.os.bundle; public final class choppermain extends activity { public void oncreate(bundle savedinstancestate) { try { camera camera = camera.open(); catch (exception e) { e.printstacktrace(); } camera.takepicture( new camera.shuttercallback() { public void onshutter() { ; } }, new camera.picturecallback() { public void onpicturetaken(...

How to remove carriage return and linefeed in combination from unix file -

i have file in unix in getting carriage return (^m) followed linefeed.there many other newline (enter) within file not followed linefeed.i want remove carriage return (^m) followed linefeed such other newline not followed linefeed not affected .can please suggest command this. in advance. open file using vi editor, type :%s@$@@g this remove control-m characters @ end of every line. or use below perl syntax perl -e 's/\r//g' -w -p -i to view control-m characters, use vi -b

iphone - Need advice on speeding up tableViewCell photo loading performance -

i have around 20 tableview cells each contain number (2-5) thumbnail sized pictures (they small facebook profile pictures, ex. http://profile.ak.fbcdn.net/hprofile-ak-sf2p/hs254.snc3/23133_201668_2989_q.jpg ). each picture uiimageview added cell's contentview. scrolling performance poor, , measuring draw time i've found uiimage rendering bottleneck. i've researched/thought of solutions new iphone development not sure strategy pursue: preload images , retrieve them disk instead of url when drawing cells (i'm not sure if cell drawing still slow, want hold off on time investment here) have cells display placeholder image disk, while picture asynchronously loaded (this seems best solution, i'm not sure how best this) there's fast drawing recommendation tweetie, don't know have affect if turns out overhead in network loading ( http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/ ) thoughts/implementation advice? thanks! ...

oop - Achieving polymorphism in functional programming -

i'm enjoying transition object oriented language functional language. it's breath of fresh air, , i'm finding myself more productive before. however - there 1 aspect of oop i've not yet seen satisfactory answer on fp side, , polymorphism . i.e. have large collection of data items, need processed in quite different ways when passed functions. sake of argument, let's there multiple factors driving polymorphic behaviour potentially exponentially many different behaviour combinations. in oop can handled relatively using polymorphism: either through composition+inheritance or prototype-based approach. in fp i'm bit stuck between: writing or composing pure functions implement polymorphic behaviours branching on value of each data item - feels rather assembling huge conditional or simulating virtual method table! putting functions inside pure data structures in prototype-like fashion - seems works doesn't violate idea of defining pure functions separa...

code generation - Tools for auto-generating ASP.NET MVC CRUD UI? -

does know of tools generating asp.net mvc crud user interfaces (e.g. controllers , views admin tools), given: a set of model objects. a set of repositories retrieving objects. thanks there project on codeplex called mvccrud automate repository , controller. optionally supports jqgrid (searching, sorting etc). isnt included in project simple add t4 templates generate desired view. if want normal crud functionality very quick. downside repository linq2sql, can add own using interface prity simple extend or use parts of.

redirect - php script redirecting code problem -

i'm using php script redirection after detecting search word websiter search engines . and redirection code working fine but keywods wat stay in same page. lines of code i'm getting warning message in pages. warning: headers sent (output started @ /home/friendsj/public_html/index.php:2) in /home/friendsj/public_html/index.php on line 20 below code used in pages $ref=$_server['http_referer']; if(strstr($ref,"test")){ $url="http://www.howtomark.com/robgoyette.html"; } else if(strstr($ref,"mu+word+gmail")){ $url="http://www.howtomark.com/marketbetter.html"; } else{ if(strstr($ref,"how+to+market+better")){ } } if($url !=""){ header("location:$url"); } redirections accomplished setting http header, use of header() function suggests. means can redirect before start document output. whatever start printing on line 2, later ;-)

c++ - Code using boost::asio::streambuf causes segfault -

i've experienced problems using asio::streambuf , hoping can tell me if i'm using class incorrectly. when run example code segfaults. why? to make things more confusing, code works on windows (visual studio 2008), not work on linux (with gcc 4.4.1). #include <boost/asio.hpp> using namespace std; int main() { boost::asio::streambuf stream; // put 4 bytes streambuf... int setvalue = 0xaabbccdd; stream.sputn(reinterpret_cast<const char*>(&setvalue), sizeof(setvalue)); // consume 3 of bytes... stream.consume(3); cout << stream.size() << endl; // should output 1 // last byte... char getvalue; // --------- next line segfaults program ---------- stream.sgetn(reinterpret_cast<char*>(&getvalue), sizeof(getvalue)); cout << stream.size() << endl; // should output 0 return 0; } the way i've used , seen asio::stre...