Posts

Showing posts from May, 2015

.net - Most Reliable ASP.NET/SQlServer Hosting -

i looking reliable hosting company asp.net/sqlserver application. suggestion appreciated. my current host has been working fine till recently. goes down once week now. i've had luck both winhost.com , discountasp.net

XNA C# getting 12 trangle faces of a cube , given (MIN,MAX) of BoundingBox -

is there eazy way or c# class 12 triangles of cube where, (min,max) coordinates known boundingbox cube want use primitivetype.trianglelist rendering face of cube dont know how static indices array of 12 triangles can defined , min ,max vertices of cube . i using c# xna thank i figured out .... working me ..not sure if geralized way static float , b , h ; static vector3 minv = new vector3(0f, 0f, 0f); static vector3 maxv = new vector3(a, b, h); vector3 topleftback = new vector3(minv.x, maxv.y, minv.z); vector3 toprightback = new vector3(maxv.x, maxv.y, minv.z); vector3 bottomleftback = new vector3(minv.x, minv.y, minv.z); //min vector3 bottomrightback = new vector3(maxv.x, minv.y, minv.z); vector3 topleftfront = new vector3(minv.x, maxv.y, maxv.z); vector3 toprightfront = new vector3(maxv.x, maxv.y, maxv.z); //max vector3 bottomleftfront = new vector3(minv.x, minv.y, maxv.z); vec...

android - Error HTTP/1.0 405 Method not Allowed -

i want make htttp connection here code try { httpclient client = new defaulthttpclient(); httppost httpmethod = new httppost("http://www.google.co.in/"); string requestbody = "some text"; httpmethod.setentity(new stringentity(requestbody)); httpresponse response = client.execute(httpmethod); textview.settext(response.getstatusline().tostring()); } but m unable , "http/1.0 405 method not allowed" error thankfull help it means requested url not accept post method. try again get.

Django Models: Time not Date? -

i know models.datefield(), want able add 24 hour time independent of date. how accomplish this? you use timefield .

javascript - Google Ajax search API -

i'm wondering, possible receive google results on own ajax api in way like, 100 results per page? without visible search field, i'd results in background create progression search phrases. my basic question is, restrictions of google search api ? --update-- is possible change language search google api ? start on, delivers .com in english kind regards --andy the largest number of results can 64, 8 per page of searcher. it possible combine of these 1 page, involves searcher making 8 calls google ajax search api. further, need create own function render results: var s; var page = 1; google.load('search', '1', {'nocss' : true}); google.load('jquery', '1.4.2'); // optional google.setonloadcallback(function() { // t&c's state should display branding, create <div id="branding"></div> google.search.search.getbranding(document.getelementbyid('branding')); s = new g...

cocoa - objective-c building my own custom calendar (nsarraycontroller observer problems) -

i have time being building own calendar because standard mac cal sucks in terms of layout. what have done make nscollectionview holds dates, , in code add each date array controller. so far works fine , cal showing! take @ ss here: http://cl.ly/0z3a2i12242b2d1m3z1n i have added observer nsarraycontroller know whenever user clicks date, allows me send message parent class telling update table-list under cal. my observer looks this: // observing our array - (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { if([keypath isequalto:@"selectionindexes"]) { if([[self.arraycontroller selectedobjects] count] > 0) { if ([[self.arraycontroller selectedobjects] count] == 1) { calendardate* obj = [[self.arraycontroller selectedobjects] objectatindex:0]; if(obj.dateobj != nil) { if(obj.isold) { ...

java - What is an efficient algorithm to find whether a singly linked list is circular/cyclic or not? -

this question has answer here: how detect loop in linked list? 21 answers how can find whether singly linked list circular/cyclic or not? tried search couldn't find satisfactory solution. if possible, can provide pseudo-code or java-implementation? for instance: 1 → 3 → 5 → 71 → 45 → 7 → 5 , second 5 third element of list. the standard answer take 2 iterators @ beginning, increment first 1 once, , second 1 twice. check see if point same object. repeat until 1 incrementing twice either hits first 1 or reaches end. this algorithm finds circular link in list, not it's complete circle. pseudo-code (not java, untested -- off top of head) bool hascircle(list l) { iterator = l.begin(), j = l.begin(); while (true) { // increment iterators, if either @ end, you're done, no circle if (i.hasnext()) = i.next(); else return...

.net - C#: proprietary DLLs requiring access to my assemblies -

my solution uses proprietary assembly, when debugging solution throws exception saying can't find assembly meant 1 of projects in solution. i cannot add reference proprietary assembly because have dll. when compile single application directory , run app works fine, want debug. where should assemblies placed if want proprietary assembly in solution see them? i assume issue there no path specified , looking in default directory of kind. this started. http://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.100).aspx also search msdn assemblyresolve, link additional articles deepen knowledge on subject. hth!

python - django - How to cross check ModelAdmin and its inlines? -

i have 2 models (modelparent , modelchild) same m2m fields on subject model. modelchild has foreign key on modelparent , modelchild defined inline modelparent on admin page. ### models.py ### class subject(models.model): pass class modelparent(models.model): subjects_parent = manytomanyfield(subject) class modelchild(models.model): parent = foreignkey(modelparent) subjects_child = manytomanyfield(subject) ### admin.py ### class modelchildinline(admin.tabularinline): model = modelchild class modelparentadmin(admin.modeladmin): inlines = [modelchildinline] admin.site.register(modelparent, modelparentadmin) i have 1 important restriction though, modelchild's subjects_child field must not reference subject subject_parent subjects_parent. so, if select same subject (in subject_parent , subject_child) on admin page both models, how can validate this? if 1 field changes validate against db, if both change (subject_parent , subject_chil...

php - MySQL insert with undefined foreign key -

i have table such schema (simplified): create table folders( id int(11) unsigned not null auto_increment, parent int(11) unsigned not null, primary key (id), index fk_folders_folders_id (parent), constraint fk_folders_folders_id foreign key (parent) references folders (id) on delete cascade on update cascade ) 1 folder can have many subfolders , can belongs 1 folder. if it's root folder parent contain it's own id. the problem is: how can create root folder? id auto_increment , can after inserting row cant insert row while parent not defined. recursion... you can remove not null attribute parent field, way can have root. of course, in case have garantee folder tree cosistency in code , not through database. mysql reference manual not advise users this: you advised use foreign keys reference unique , not null keys. http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html but it's you.

php - Is it possible to count the number of keys in an array? -

i've googled found no answers, guess it's not possible. if there way, i'd love know it. thanks the number of keys in array number of elements in array, keys must unique. so: $numkeys = count($array);

design - Architecture Options - forms and a cms-like pdf producing system -

customer has asked system involves set of pdf forms, web ui , various functions (log-in, administration, permissions, usual) , there's few rubs i've identified , feedback or maybe different ideas on how go it. main focus data contained within these forms. (don't think winforms, think forms fill out , file) first off, pdf forms uncontrollable in sense can. not. be. modified. wrote tool while (pdf-orm on codeplex) take pdf forms (the fill-out kind) , turn them objects they're easier work in code , return pdf. part handled rather nicely. problem begins come out of data contained within forms , how best handle that. granted, of field names horrible (person1 instance) @ least they're manageable. these forms -will- change , must changed in reasonable time frame (ideally few days) maintainability/flexibility huge focus. granted, not forms change @ same time necessarily, on course of few months few years, change. more concerning, names/fields of generated pd...

"Out of Memory" error in Lotus Notes automation from VBA -

this vba function sporadically fails notes automation error "run-time error '7' out of memory". naturally, when try manually reproduce it, runs fine. function togmt(byval x date) date static ntsession notessession if ntsession nothing set ntsession = new notessession ntsession.initialize end if (do stuff) end function to put in context, vba function being called access query, 3-4 times per record, 20,000 records. performance reasons, notessession has been made static. ideas why sporadically giving out-of-memory error? (also, i'm initiating notessession can convert datetime gmt using lotus's rules. if know better way, i'm listening). edit per mr. ross's question, isolated (or thought did) query , it's supporting function. before tried suggestion, added arguments first determine row & field crashed on. ran few times , crashed on first field of first row. then presto! ran fine. tried backtrack see d...

lua - Popping the first element off an array -

i have array x in lua. set head = x[1] , rest = rest of array, rest[1] = x[2] , rest[2] = x[3] , etc. how can this? (note: don't care if original array gets mutated. in javascript head = x.shift() , x contain remaining elements.) head = table.remove(x, 1) "pop" bit of misnomer, implies cheap operation, , removing first element of table requires relocating rest of contents--hence name "shift" in javascript , other languages.

java - How to get fan list of Facebook page or can overwrite facebook social plugin css? -

we trying facebook social plugin. html code follow: <iframe border='0' src=' http://www.facebook.com/plugins/likebox.php?id=1185611481&width=243&height=400&connections=15&stream=false&header=false ' scrolling='yes' frameborder='0' allowtransparency='false' style='border:0px; overflow:hidden; width:243px; height:300px; background-color: #03869e; color: white;'> <iframe> as replace inner html of frame on load. want our own css apply html. replace whole html , have own css unable set our css. we doing in gwt. there way can list of fans can display want , can apply css? or check given user fan of page? you can try, css insertion using javascript : <script type="text/javascript"> var link = document.createelement("link"); link.rel = "stylesheet"; link.href = "style.css" var myframe = frames["your-frame"].document; frame.head.ap...

javascript - how to declare five variables and declare each variable on its own line -

i need little bit more of understanding this. in example have know doing wrong because can not pull in windows screen. 1 of 5 variables have. question have put javascript.css or can <script> not understanding different use js.css or using <script> thanks. var stock[0] ="cisco"; var changenet[0] ="0.155 0.72%"; var lastsale[0] =$21.775; document.write("<p><strong>stock[0]<strong>: " + stock[0] +"cisco" + changenet[0] +" up"+ lastsale[0] +"to buy at.<\/p>"); ok going show have been working on hours , still can not pull on web page... <!doctype html public"-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org.tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <head> <title>project 4-1</title> </head> <body> <script type="text/javascript"> <!--hide incompatible browers var stock[0] ="cisco...

objective c - Global NSString -

i need create nsstring, can set value in 1 class , in another. how can it? if write: nsstring *globalstring = @"somestring"; anywhere outside method, class definition, function, etc... able referenced anywhere. (it global!) the file accesses declare external extern nsstring *globalstring; this declaration signifies being accessed file.

Android ActivityGroup - NullPointerException -

i'm trying use activity groups - since use tabs, , want have tabs when loading , activity after list item clicked,. i'm getting nullpointerexception in following line: view view1 = s1_group.group.getlocalactivitymanager() .startactivity("s1", intent) .getdecorview(); code .. . lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { intent intent = new intent(getapplicationcontext(), s1.class); intent.addflags(intent.flag_activity_clear_top); log.d("test","before view"); try{ view view1 = s1_group.group.getlocalactivitymanager() .startactivity("s1", intent) .getdecorview(); settings_group.group.setcontentview(view1); } catch (exception e){ ...

c# - How to copy one element of a generic collection -

i need copy 1 element of generic collection , add list. similar this: private list<calculationresult> cantileverresults = new list<calculationresult>(); cantileverresults.add(cantileverresults[previousindex]); the problem solution when modify new element, previousindex element changes well. believe because reference-type, not value-type. how can copy (clone?) information 1 element without affecting each other further? you need create new object when adding it. this can done in several ways - helper method takes object of type ( calculationresult ) , returns new one. perhaps have constructor overload this. there many ways achieve such thing - implementing icloneable , having clone method return new object. for example, if create constructor overload, how use it: cantileverresults.add(new calculationresult(cantileverresults[previousindex]));

regex for date in java -

can me regular expression in java string "feb. 26, 2009 8:08 pst"???? use simpledateformat instead of using regexp. read the tutorial more info. upd: regexp like: "(jan|feb|mar).*pst" list of months should contain 12 (instead of 3 in example). it's very unreliable.

profiler - Can not load xdebug profile by webgrind -

i have tried use webgrind profiling application when click on update button show error: could not open d:\program files\xampp\tmp/ reading. d:\program files\xampp\htdocs\webgrind\library\preprocessor.php, line 49 i check permission folder tmp , sure it's allow full control everyone. folder d:\program files\xampp\tmp has file xdebug_profile.6096, mean xdebug worked correctly (i tested xdebug using netbeans xdebug , works normally). my system: windows vista xampp 1.7.3 webgrind 1.02 anyone have experience of this? please me! think have thang. try adding directory directive vhost. should allow server access folders outside of it's directory. i've added vhost use localhost on windows machine. #template vhost container namevirtualhost *:80 <virtualhost *:80> documentroot c:\www servername localhost customlog logs/localhost-transfer.log combined errorlog logs/localhost-error.log # non configurable settings direct...

.net - Remove duplicate characters using a regular expression -

i need match second , subsequent occurances of * character using regular expression. i'm using replace method remove them here's examples of before , after: test* -> test* (no change) *test* -> *test test** *e -> test* e is possible regular expression? thanks if .net can cope arbitrary amount of behind, try replacing following pattern empty string: (?<=\*.*)\* . ps home:\> 'test*','*test*','test** *e' -replace '(?<=\*.*)\*','' test* *test test* e another way pattern: (?<=\*.{0,100})\* where number 100 can replaced size of target string. and testing following mono 2.0: using system; using system.text.regularexpressions; public class test { public static void main() { regex r = new regex(@"(?<=\*.*)\*"); console.writeline("{0}", r.replace("test*", "")); console.writeline("{0}", r.replace...

php - something went wrong with CURLOPT_FOLLOWLOCATION? -

i have problem when im trying upload file amazon s3, gives me error dnt seem understand: warning: curl_setopt() [function.curl-setopt]: curlopt_followlocation cannot activated when safe_mode enabled or open_basedir set in /var/www/vhosts/??????/httpdocs/actions/s3.php on line 1257 the problem says in error message - have safe_mode or open_basedir enabled in php.ini. either edit php.ini disable whichever 1 of have on, or don't use php's flavor of curl. if can't edit php.ini you'll have find new host or find new solution.

Help reducing a Lisp function -

i have lisp function returns either max of 2 values, or min of 2 values. right code has relatively complex expressions evaluate value1 , value2. (defun treemax (bilist &optional ismin) (cond ;; compute minimum (ismin (min (complex_expression_1) (complex_expression_2))) ;; compute maximum (t (max (complex_expression_1) (complex_expression_2))))) the problem here complex_expression_1 , complex_expression_2 take many many lines of code. not repeat them. there more efficient way of calling this? essentially i'm trying unary-if on functions rather values. if familiar c or variants, concept i'm looking is: ((ismin ? min : max) complex_expression_1 complex_expression_2) whereby conditionally select function send arguments to. make sense? (defun treemax (bilist &optional ismin) (funcall (if ismin #'min #'max) (complex_expression_1) (complex_expression_2)))

c++ - multiple definition in header file -

given code sample: complex.h : #ifndef complex_h #define complex_h #include <iostream> class complex { public: complex(float real, float imaginary); float real() const { return m_real; }; private: friend std::ostream& operator<<(std::ostream& o, const complex& cplx); float m_real; float m_imaginary; }; std::ostream& operator<<(std::ostream& o, const complex& cplx) { return o << cplx.m_real << " i" << cplx.m_imaginary; } #endif // complex_h complex.cpp : #include "complex.h" complex::complex(float real, float imaginary) { m_real = real; m_imaginary = imaginary; } main.cpp : #include "complex.h" #include <iostream> int main() { complex foo(3.4, 4.5); std::cout << foo << "\n"; return 0; } when compiling code, following error: multiple definition of operator<<(std::ostream&, complex const&) i'v...

c# - Events still appear in calendar app after RemoveEvents is called on them using Monotouch -

i developing iphone app using monotouch. able add events defaultcalendarfornewevents calendar (the same calendar i'm using find , delete them) without problem. however, every time call method in app remove event calendar, every instance of event still shows in calendar application if calendar application shut down , restarted, or ensured not running while app manipulating calendar. i'm getting breakpoints on removeevents line, , returning true. function: public static void deschedulereminderevent(string presc_id_for_del) { ekeventstore store = new ekeventstore(); ekcalendar calendar = store.defaultcalendarfornewevents; if (calendar != null) { nsdictionary readonlydic = dstor.dictionaryforkey("savedcalreminders"); if(readonlydic != null) { nsmutabledictionary savedcalreminders = nsmutabledictionary.fromdictionary(readonlydic); foreach(nsstring prescid in savedcalreminders.keys) { if(string.c...

c# - Exception Details: System.NotSupportedException: Object doesn't support this property or method -

object doesn't support property or method description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.notsupportedexception: object doesn't support property or method quite possibly 1 of straightforward, honest , accurate exception messages of time. second favorite, after "object reference not set instance of object". you calling someobject.somemethod() , version of object not support method. throws exception let know. fix not calling method.

c++ - templated method on T inside a templated class on TT : Is that possible/correct -

i have class myclass templated on typename t. inside, want method templated on type tt (which unrelated t). after reading/tinkering, found following notation: template <typename t> class myclass { public : template<typename tt> void mymethod(const tt & param) ; } ; for stylistic reasons (i have templated class declaration in 1 header file, , method definitions in header file), won't define method inside class declaration. so, have write as: template <typename t> // type of class template <typename tt> // type of method void myclass<t>::mymethod(const tt & param) { // etc. } i knew had "declare" typenames used in method, didn't know how exactly, , found through trials , errors. the code above compiles on visual c++ 2008, but: is correct way have method templated on tt inside class templated on t? as bonus: there hidden problems/surprises/constraints behind kind of code? (i guess specializa...

python - Google Data API: how to do authentication for desktop applications -

i wonder best/easiest way authenticate user google data api in desktop app. i read through docs , seems options clientlogin or oauth. for clientlogin, seems have implement ui login/password (and related things saving somewhere etc.) myself. wonder if there more support there may pop default login/password screen , uses os keychain store password, etc. wonder why such support isn't there? wouldn't standard procedure? leaving implementation dev (well, possibility leave impl dev of course), guess many people have come ugly solutions here (when wanted hack small script). oauth seems better solution. however, there seems code missing and/or code found seems relevant web applications. esp., followed documentation , got here . in introduction, speaks web application. later on, need specify callback url not make sense desktop application. wonder consumer key/secret should put doesn't make sense desktop app (esp. not open-source one). searched bit around , said here (on s...

c++ euclidean distance -

this code compiles , runs not output correct distances. for (int z = 0; z < spaces_x; z++) { double dist=( ( (spaces[z][0]-x)^2) + ( (spaces[z][1]-y)^2) ); dist = abs(dist); dist = sqrt(dist); cout << "for x " << spaces[z][0] << " y " << spaces[z][1] << " dist "<< dist << endl; if (dist < min_dist) { min_dist = dist; index = z; } } does have idea problem be? the syntax ^ 2 not mean raise power of 2 - means xor. use x * x . double dx = spaces[z][0] - x; double dy = spaces[z][1] - y; double dist2 = dx * dx + dy * dy;

java - relationship set between table and mapping table to use joins -

i have 2 table "module" table , "staffmodule" i'm wanting display list of modules staff present on staffmodule mapping table. i've tried from module join staffmodule sm id = sm.mid with no luck, following error path expected join! however thought had correct join allow not can 1 help staffmodule hbm <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- generated apr 26, 2010 9:50:23 hibernate tools 3.2.1.ga --> <hibernate-mapping> <class name="hibernate.staffmodule" schema="walk" table="staffmodule"> <composite-id class="hibernate.staffmoduleid" name="id"> <key-many-to-one name="mid" class="hibernate.module"> <column name="m...

css - Customize SharePoint:FormFields to a specific height -

i'm customizing newform.aspx page , i've created few new sharepoint:formfields in form of textboxes. i'm looking customize height of these boxes on case-by-case basis, can't figure out. i've looked displaysize, controls width of specific textboxe, , i've seen adding in: style> .ms-long{width:100px;} </style> but changes every sharepoint:formfield size, not one. any great! thanks! i've done before using jquery. jquery can query dom elements (ie. fields) attribute of choice (e.g. attribute title) , manipulate it. see jan tielens series integrating sharepoint , jquery. http://weblogs.asp.net/jan/archive/2008/11/20/sharepoint-2007-and-jquery-1.aspx or google sharepoint + jquery.

python - Deleting specific control characters(\n \r \t) from a string -

i have quite large amount of text include control charachters \n \t , \r. need replace them simple space--> " ". fastest way this? thanks i think fastest way use str.translate() : import string s = "a\nb\rc\td" print s.translate(string.maketrans("\n\t\r", " ")) prints a b c d edit : once again turned discussion performance, here numbers. long strings, translate() way faster using regular expressions: s = "a\nb\rc\td " * 1250000 regex = re.compile(r'[\n\r\t]') %timeit t = regex.sub(" ", s) # 1 loops, best of 3: 1.19 s per loop table = string.maketrans("\n\t\r", " ") %timeit s.translate(table) # 10 loops, best of 3: 29.3 ms per loop that's factor 40.

Sequences expansion and variable in bash -

i having problem builtin sequences (ie: not using seq) in bash when seq number variable. example, works , print me 1 2 3: for in {1..3};do echo $i;done but : bash-3.2$ a=3;for in {1..$a};do echo $i;done fail , print me {1..3} only this works zsh , know have alternative make counter thing wondering if bug or brace expansion feature! in bash, brace expansion performed before variable expansion. see shell expansions order. $ a=7; echo {1..3} {4..$a} 1 2 3 {4..7} if want use variable, use c-style for loops in shawn's answer.

linux - Support for 802.1x Authentication in a device not supporting it earlier -

i working on embedded system linux kernel 2.6.10 not supporting 802.1x authentication mode in wired network. helpful if there specific pointers on how proceed have authentication. , wanted know whether sufficient change kernel level driver (upgrade it) or need changes application layer also? (atleast protocol specifications ieee 802.1x understanding authentication happens @ lower layer itself) in advance. i have got answer this. needed have wpa_supplicant dependancies built. able build , cross compile them successfully.

Voicexml how many words in grammar -

i want have dynamic grammar in voicexml file (read single products , create grammar php) my question is, if there advice or experience how many words should writte source read products. don't know structure or pronunciation of words, let's a) words rather different each other b) words rather have same structre or pronunciation c) mix of a) , b) thanks in advance i'm assuming mean srgs grammars when indicate dynamic grammar voicexml. unfortunately, you're going have performance testing under reasonable load know sure. i've transmitted 1m+ grammars under conditions. i've done 10,000 name lists. i've come across platforms can utilize few dozen entries. the speech recognition (asr) , voicexml platform going have significant impact on results. and, number of concurrent recognitions grammar relevant along overall recognition load. the factors mention have impact on recognition performance , cpu load, i've typically found size of g...

Why is UnknownHostException not caught in Exception (java)? -

my code looks : try { string htmlpagetext=readfromhtml("http://www.yahoo.com"); } catch (exception e) { system.out.println("===here==="); } method readfromhtml() take url , return html page. works fine. i'm trying simulate "site down" situation, unplugged internet connection. thought, error should caught , result "===here===", instead, returned: java.net.unknownhostexception: http://www.yahoo.com" and never printed out "===here===". unknownhostexception extension of java.lang.exception , why not caught in catch clause? need catch (unknownhostexception ex) it? what readfromhtml method source code ? guess method throws kind of exception not unknownhostexception... somewhere else in code exception left unhandled.

Real life example fo Floating Point error -

is there examples of company burned floating point data caused rounding issue? we're implementing new system , monetary values stored in floats. think if can show actual examples of why has failed it'll have more weight theory of why values can't stored properly. these examples embedded world (ariane 5, patriot) not floating-point rounding errors stricto sensu. ariane 5 bug bug in conversion. patriot bug introduced during adaptations of software. involves computations in different precisions inherently unrepresentable constant (which happens innocuous-looking 0.10). there 2 problems foresee binary floats monetary values: decimal values common 0.10 cannot represented exactly. if precision small, have been clean overflow raising exception becomes hard-to-track loss of precision. note base-10 floating-point formats have been standardized precisely monetary values: currencies worth 1/1000000 of dollar, never exchanged in less thousands, , maximum amount...

make_tuple with boost::python under Visual Studio 9 -

trying build following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object sequence) { return make_tuple(sequence[0],sequence[-1]); } available here , end compilation error under visual studio 9 error c2668: 'boost::python::make_tuple' : ambiguous call overloaded function 1> c:\program files\boost_1_42_0\boost/python/detail/make_tuple.hpp(22): 'boost::python::tuple boost::python::make_tuple<boost::python::api::object_item,boost::python::api::object_item>(const a0 &,const a1 &)' 1> 1> [ 1> a0=boost::python::api::object_item, 1> a1=boost::python::api::object_item 1> ] 1> c:\program files\boost_1_42_0\boost/tuple/detail/tuple_basic.hpp(802): or 'boost::tuples::tuple<t0,t1,t2,t3,t4,t5,t6,t7,t8,t9> boost::tuples::make_tuple<boost::python::api::object_item,boost::python::api::object_item>(const ...

frameworks - Comparing GWT and Turbo Gears -

anyone know of tutorials implemented across multiple web application frameworks? for example, i'm starting implement gwt's stock watcher tutorial in turbo gears 2 see how difficult in turbo gears 2. likewise, i'll looking turbo gears 2 tutorial implement in gwt. but hate re-create wheel - wondering if familiar such projects and/or interested in helping me work on such project. thanks, --spencer while possible combine 2 frameworks, hope convince not so. most web-frameworks, including turbogears, have server-side page flow management. page served user generating html, user interacts clicking on links or posting form, browser sends fresh request server, , server responds new html altogether. ajax'ify page using js library, or framework has support. but, in general, transition 1 view done on server side. gwt totally different. there single html page in system. once page downloaded, happens on browser through javascript. when user clicks on link, j...

php - why libxml2 quotes starting double slash in CDATA with javascript -

this code: <?php $data = <<<eol <?xml version="1.0"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <script type="text/javascript"> //<![cdata[ var = 123; // js code //]]> </script> </html> eol; $dom = new domdocument(); $dom->preservewhitespace = false; $dom->formatoutput = false; $dom->loadxml($data); echo '<pre>' . htmlspecialchars($dom->savexml()) . '</pre>'; this result: <?xml version="1.0"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"><![cdata[ //]]><![cdata[ var = 123; // js code //]]><![cdata[ ]]></script...

joomla : authentication -

i have made folder in joomla directory. in folder have file. i want authenticate these files direct access using url name? how can achieved? i'm not sure if best way, can create php script (let's call joomla-auth.php ) containing this: <?php define( '_jexec', 1 ); define('jpath_base', dirname(__file__)); define( 'ds', directory_separator ); require_once ( jpath_base .ds.'includes'.ds.'defines.php' ); require_once ( jpath_base .ds.'includes'.ds.'framework.php' ); $mainframe =& jfactory::getapplication('site'); if (jfactory::getuser()->id == 0) die("access denied: login required."); ?> then, @ top of php scripts need joomla authentication, do: <?php include 'joomla-auth.php'; ?> if have php script, , need information authenticated user, use jfactory::getuser() . if have .html file, can change extension .php , add 3 lines above top. chances are...

php - Modify the server side functions using jquery -

i developing 1 website using cakephp , jquery technologies. server-side there functions handles sql queries. as per requirement want modify server side functions on client side using jquery ajax call. e.g. : below function on server side modify users information. function modifyuser(username,userid) { //update query statements } then jquery ajax call this: $.ajax({ url: 'users/modiyuser', success: function() { alert("updation done") or statements. } }); and want modify above i.e. server side function depending upon client input criteria. $.ajax({ function users/modiyuser(username,userid) { // write here other statements gives me other output. } }); above ajax call syntax may not present, think understood trying wants modify/override server side functions on client side. please let me know there way resolve above mentioned requirement. thanks in advance you cannot call php functions client directly. can make http re...

How to check group for containing certain elements in SQL? -

i have simple table: id num 1 7 1 5 1 4 2 5 2 4 2 7 3 4 3 7 how select ids having num 5 7 , 4 for example ids: 1, 2 select `id` `table` `num` in (4, 5, 7) group `id` having count(*) = 3

javascript - change background color with change in mouse position -

i wondering if possible set background-color of mouse coordinates. what have is: i have div-a draggable , other divs droppable. what need : i need highlight other divs on page droppable, whenever div-a passes on them. have mouse coordinates, possible apply css on bases of mouse coordinates using jquery. something following may work. need deal window's scrollleft , scrolltop perfect. want throttle , memoize (if drop positions don't change) too. also, more performance can tweaked out of caching offset() , binding mousemove when needed, , tweaking each loop utilize optimized loop (e.g. for(var i=droppables.length;i>-1;){var self = droppables.eq(--i);...} ). also note change color of divs when mouse passes on them...not when draggable passes on them...this makes things little more complicate function below should send in right direction. $(document).mousemove(function(e){ // should throttled... var x = e.pagex, y = e.pagey; ...

Sharepoint site continuously propmting for username and password -

a particular sharepoint web application(site collection) continuously prompting username , password indefinite times , not letting users view application properly. but when add users farm administrators, web application(site collection) working fine. ideally, can’t add users farm administrators. please me in resolving issue. regards, priya i've seen when sharepoint site not in web browser's intranet zone. ie browser, can add url intranet zone or change browser's authentication setting use "automatic logon current username , password".

authentication - PHP: Use PHP to authenticate with .htaccess when uploading to a subfolder of the protected folder -

i'm trying upload files subfolder of protected folder. here hierarchy looks like: /basefolder(.htaccess)/tool/script.php /basefolder(.htaccess)/tool/uploadhandler.php /basefolder(.htaccess)/tool/files/here(subfolder)/ the simple .htaccess file basefolder is: authuserfile "/path/" authtype basic authname "admin dashboard" require valid-user the script sends data typical php upload handler attempts save file in subfolder. when code gets stage browser prompts me user/pass again. is there way authenticate using php don't prompted password every time? exempt upload.php file http password protection , use sessions or cookie set user allowed upload. for example, in php file upload form: session_start(); $_session['can_upload'] = true; // set if user access upload form // page; sessions preferable cookies since set cookie named // "is_allowed" "1"—you have use kind of token validation // if use...

c++ - Ignore user input outside of what's to be chosen from -

i have program in user must make selection entering number 1-5. how handle errors might arise them entering in digit outside of bounds or character? edit: sorry forgot mention in c++ be careful this. following produce infinite loop if user enters letter: int main(int argc, char* argv[]) { int i=0; { std::cout << "input number, 1-5: "; std::cin >> i; } while (i <1 || > 5); return 0; } the issue std::cin >> i not remove input stream, unless it's number. when loops around , calls std::cin>>i second time, reads same thing before, , never gives user chance enter useful. so safer bet read string first, , check numeric input: int main(int argc, char* argv[]) { int i=0; std::string s; { std::cout << "input number, 1-5: "; std::cin >> s; = atoi(s.c_str()); } while (i <1 || > 5); return 0; } you'll want use safer atoi though.

c# - How do I build a JSON object to send to an AJAX WebService? -

after trying format json data hand in javascript , failing miserably, realized there's better way. here's code web service method , relevant classes looks in c#: [webmethod] public response validateaddress(request request) { return new test_addressvalidation().generateresponse( test_addressvalidation.responsetype.ambiguous); } ... public class request { public address address; } public class address { public string address1; public string address2; public string city; public string state; public string zip; public addressclassification addressclassification; } public class addressclassification { public int code; public string description; } the web service works great using soap/xml, can't seem valid response using javascript , jquery because message server has problem hand-coded json. i can't use jquery getjson function because request requires http post, i'm using lower-level ajax function instead:...

vb.net - Creation date column in SQL table -

what easiest way automatically fill datetime column in sql data table date row created? using sql server 2005 if matters. edit: i've tried using getdate() default , works insert query not when tableadapter adds row. alter table table add column not null default (getdate())

javascript - Implicit cast/number check produces 'unexpected X' JSLint error -

this nothing serious, question out of curiosity. following script in jslint.com gives strange , 'unexpected' error. script works, still know if can explain error. var hashvar = parseint(location.hash.replace('#',''), 10); if(hashvar-0 === hashvar){l();} error: problem @ line 3 character 4: unexpected 'hashvar'. enjoy weekend, ulrik you want this: var hashvar = parseint(location.hash.replace('#', ''), 10); if ( !isnan(hashvar) ) { l(); } this code has same functionality original code. btw, this: if ( !isnan(hashvar) ) { l(); } can further reduced this: isnan(hashvar) || l(); ;-) explanation: the return value of parseint can be: a) integer numeric value b) nan value therefore, if want test whether return value integer or not, use isnan() .

Implementing callback functions in C -

i newbie c. trying implement callback function using function pointers. i getting error :test_callback.c:10: error: expected identifier or ‘(’ before ‘void’ when try compile following program: #include<stdio.h> void (*callback) (void); void callback_proc () { printf ("inside callback function\n"); } void register ((void (*callback) (void))) { printf ("inside registration \n"); callback (); /* calling initial callback function pointer */ } int main () { callback = callback_proc;/* assigning function function pointer */ register (callback);/* passing function pointer */ return 0; } what error?can help? register c keyword: use name function. you have parantheses around callback parameter. should be: void funcname(void (*callback) (void))

spreadsheet - Is it possible to insert date automatically in one cell in MS excel 2007 -

i have 1 excel document 2 columns. add text in 1 column on daily basis , want on second column current date , time automatically gets added. that field can hidden , can when wanted want date time when added in row is possible try today() or now() function? return today's date. warned tomorrow if open spreadsheet cell show tomorrow's date. need have macro copy , paste values date cell. i think other thing do, use keyboard shortcuts ctrl + ; or ctrl + : insert current date , time in active cell. since places value, don’t need worry if date or time changes. manual, , may or may not after.

bit manipulation - A question in java.lang.Integer internal code -

while looking in code of method: integer.tohexstring i found following code : public static string tohexstring(int i) { return tounsignedstring(i, 4); } private static string tounsignedstring(int i, int shift) { char[] buf = new char[32]; int charpos = 32; int radix = 1 << shift; int mask = radix - 1; { buf[--charpos] = digits[i & mask]; >>>= shift; } while (i != 0); return new string(buf, charpos, (32 - charpos)); } the question is, in tounsignedstring, why create char arr of 32 chars? 32 characters how need represent int in binary (base-2, shift of 1, used tobinarystring ). it sized exactly, guess has never made business sense attempt optimisation.

linux - How to map a function name and line number by a memory address in C language? -

how can map function name , line number memory address in gcc ? i.e assuming prototype in c language: void func() { // address of caller , maybe avoided memoryaddress = get_call_address(); // line source code executing , calls func() linenumber = get_lineno_from_symbol ( &memoryaddress ); // grab name calls func() functionname = get_func_from_symbol ( &memoryaddress ); } so there existing apis provided gcc or whatever , can meet requirements ? many of response ;-p if include header #include <execinfo.h> then can use backtrace() function determine address of calling line, , backtrace_symbols() retrieve names of functions. however, not give line numbers (though may give enough information debugging, if require). if absolutely need line numbers, you'll need to: ensure program (and libraries) compiled debugging enabled ( -g flag gcc) use addr2line program translate addresses (retrieved backtrace() ) file/line number refer...

c# - Is it bad practice to use an enum that maps to some seed data in a Database? -

i have table in database called "orderitemtype" has 5 records different orderitemtypes in system. each orderitem contains orderitemtype, , gives me referential integrity. in middletier code, have enum matches values in table can have business logic different types. my dev manager says hates when people this, , not sure why. there better practice should following? i time , see nothing wrong this. fact of matter is, there values special application , code needs react differently values. manager rather hard-code int or guid identify type? or rather derive special object orderitem each different type in database? both of suck worse enum.

php - How do I convert a string to an associative array of its keywords -

take string example: "will see in london tomorrow , kent day after tomorrow". how convert associative array contains keywords keys, whilst preferably missing out common words, this: array ( [tomorrow] => 2 [london] => 1 [kent] => 1) any appreciated. using blacklist of words not included $str = 'will see in london tomorrow , kent day after tomorrow'; $skip_words = array( 'in', 'the', 'will', 'see', 'and', 'day', 'you', 'after' ); // words in sentence aren't skipped , count values $words = array_count_values( array_diff( explode( ' ', $str ), $skip_words ) ); print_r( $words );

amazon ec2 - How best to have many users control EC2 instances? -

summary: how can several developers able start , stop shared amazon ec2 instance? i've got project i'm using ec2 instance work persists day day, 'start' server when come office, , 'stop' when leave. work several other developers , use ec2 instance. we'd first person start work each day 'start' instance, , last home 'stop' instance ... can't 'start' or 'stop' instance. (they can launch other instances ami if give them launch permission, new instance. particular instance persistent machine state yesterday.) we on consolidated billing account, gives no access rights. i'm looking @ amazon iam, seems needs overhaul of our current user setup (1 developer = 1 aws account, account under consolidated billing) disruptive if doesn't work, or if there's better way achieve same goal. (and frankly, i've not got toy script work yet under iam either, though suspect iam correct way approach problem - need read ...

asp.net - Problem showing modelstate errors while using RenderPartialToString -

im using following code: public string renderpartialtostring(controllercontext context, string partialviewname, viewdatadictionary viewdata, tempdatadictionary tempdata) { viewengineresult result = viewengines.engines.findpartialview(context, partialviewname); if (result.view != null) { stringbuilder sb = new stringbuilder(); using (stringwriter sw = new stringwriter(sb)) { using (htmltextwriter output = new htmltextwriter(sw)) { viewcontext viewcontext = new viewcontext(context, result.view, viewdata, tempdata, output); result.view.render(viewcontext, output); } } return sb.tostring(); } return string.empty; } to return partial view , form through json. works should, modelstate errors validationsummary not show. json return default form not highlight validation errors or show valid...

iphone - alrm sound not works -

i want set alrms use code. uilocalnotification *localnotif = [[uilocalnotification alloc] init]; if (localnotif == nil) return; localnotif.firedate = itemdate; localnotif.timezone = [nstimezone defaulttimezone]; localnotif.alertbody = @"appointment"; localnotif.alertaction = @"view"; //localnotif.soundname = uilocalnotificationdefaultsoundname; localnotif.soundname = @"iphone_alarm.mp3"; //localnotif.soundname=@"sound.mp3"; localnotif.applicationiconbadgenumber = 1; [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; [localnotif release]; it shows alerts not play sound, sound name having correct case , spell.on device not having vibration. try defining full path mp3 file: localnotif.soundname = [[nsbundle mainbundle] pathforresource:@"iphone_alarm" oftype:@"mp3"]; not sure vibration though.