Posts

Showing posts from May, 2011

c++ - Compiling with clang with c++11 enabled fails -

having following test.cpp : #include <iostream> int main() { int a{}; std::cout << "test" << std::endl; } when build latest gcc (4.8.0) g++ test.cpp -std=c++11 (gcc fails), file compiles. trying compile latest clang clang version 3.4 (trunk 182322) target: x86_64-apple-darwin12.3.0 thread model: posix the build fails: clang test.cpp -std=c++11 undefined symbols architecture x86_64: "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from: _main in test-ncubkf.o "std::ios_base::init::init()", referenced from: ___cxx_global_var_init in test-ncubkf.o "std::ios_base::init::~init()", referenced from: ___cxx_global_var_init in test-ncubkf.o "std::cout", referenced from: _main in test-ncubkf.o "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::bas...

SQL Server : stored procedure not returning the correct results -

i have created stored procedure deletes list of usernames database. output of script weird. treats input username input column. why doing ? create procedure [dbo].[sp_deleteusersfromdb]( @username varchar(500)) begin declare @sql varchar(600) exec('update [dbo].user set deleted = 1 username in (' + @username + ')') print n'deleted users db' end when run msg 207, level 16, state 1, line 1 invalid column name 'user1'. deleted users database table schema : create table [dbo].[user]( [id] [int] identity(1,1) not null, [version] [int] not null, [username] [varchar](32) not null, [deleted] [bit] null, constraint [user_pk] primary key clustered ([id] asc) ) on [primary] the @username parameter must contain quoted usernames, eg "'user1', 'user2'"

Find the difference between two dates using PHP? -

this question has answer here: how calculate difference between 2 dates using php? 29 answers i have 2 dates of form: start date: 2013-05-19 end date: 2013-05-21 now need find difference between these 2 in following form: 2013-05-20 2013-05-21 how can in php? this should converting iso unix: http://www.laughing-buddha.net/php/dates most efficient way convert iso date unix timestamp? you subtract 1 date other, divide 3600 , end difference in days, if understood question properly

Git merge failed to bring over some files -

i did large merge develop master , git handled correctly. there 3 files existed in both branches prior merge git recognized old ones in master, marked added us . expected instead conflict resolve, because wanted changes exist in develop . thing let me resolve either add them (meaning i'd keeping old master version or remove them. choose latter , attempted merge, says i'm up-to-date. files exist in develop not in master , git seems have no clue this. why won't git let me bring these files on , can resolve this? so there 3 files in develop want in master . try this git checkout master # make sure on master branch git checkout develop -- name_of_file_1.ext name_of_file_2.ext name_of_file_3.ext this should bring on 3 files want develop in recent state.

Is it possible to run uipv6 without contiki? -

as known, uipv6 integrated contiki-os. so, possible separate uipv6 contiki-os? can run uipv6 in platform without os. i have googled long time. however, there no information issue. contiki-os modular. if want use uip-ipv6 stack.yes, can. have @ following link: http://contiki.sourceforge.net/docs/2.6/a01790.html uip-ipv6 specific features.

visual studio - Unresolved External - DirectX11 -

1>------ build started: project: setup, configuration: debug win32 ------ 1>effects11d.lib(effectapi.obj) : error lnk2019: unresolved external symbol _d3dcompilefromfile@36 referenced in function _d3dx11compileeffectfromfile 1>c:\users\josh\documents\game institute\directx\chapter 1\projects\setup\debug\setup.exe : fatal error lnk1120: 1 unresolved externals ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== i've been trying setup directx11 visual studio 2012 on windows 7 , following frank lunas instructions in directx11 book awhile , keep running errors. currently error, have 'd3dcompiler.lib' , i've updated effects library, here picture of debug mode properties: http://tinypic.com/view.php?pic=jb64vc&s=5 release mode properties same 'd' removed on 2 library files. 'effects11d' example. please me! it's driving me crazy! you don't need use legacy directx sdk unless using d3dx11 (which d...

How do supertype generics in Java work? -

i've been testing supertype generics java, i've come roadblock. sample code testing: import java.util.*; class generictests { public static void main( string[] args ) { list<b> list3 = new arraylist<b>(); testmethod( list3 ); } public static void testmethod( list<? super b> list ) { list.add( new a() ); list.add( new b() ); } } class { } class b extends { } when compiled, error is: generictests.java:20: error: no suitable method found add(a) list.add( new a() ); ^ method list.add(int,cap#1) not applicable (actual , formal argument lists differ in length) method list.add(cap#1) not applicable (actual argument cannot converted cap#1 method invocation conve rsion) cap#1 fresh type-variable: cap#1 extends object super: b capture of ? super b 1 error i thought given lower bound of b, add supertype? or apply references (i.e. arguments within method signature) becaus...

c++ - Unhandled exception at 0x00B67361 -

i trying read .dat files 2d array, tried read same files 1d arrays such each line each array. however, code below 2d array message box pop stating " unhandled exception @ 0x00b67361 in consoleapplication11.exe: 0xc0000005: access violation reading location 0x00000000." , not finish execution". what's reason behind unhandled exception? use vs 2012 express edition. do { char * s = find_data.cfilename; ifstream fin; fin.open(s); // open file if (!fin.good()) return 1; // exit if file not found // read each line of file while (!fin.eof()) { // read entire line memory char buf[max_chars_per_line]; int n = 0; int s = 0; int m = 0; // array store memory addresses of tokens in buf const char* token[max_tokens_per_line][max_tokens_per_line] = {}; // initialize 0 (m = 1; m < max_tokens_per_line; m++) ...

cordova - navigator.notification.confirm does not work on iphone for Phonegap -

i created android app phonegap calls navigator.notification.confirm. works fine android. however, when bring on mac , build in xcode don't pop notification. web searching have done see reference cordova.plist and/or phonegap.plist. not find either of files in project. have .plist. attempted add: <key>notification</key> <string>cdvnotification</string> to project plist not help. what missing? in xcode cordova.plist replaced config.xml , there have define plugin key , value

Changing the order of vector in terms of anthother in R -

i have 2 vectors a , b . =c(1, 3, 4, 5, 6, 2, 7) b =c(1.5, 5.5, 6.5, 8.5, 9.5, 0, 0) c=sort(a) i not know how can create vector of result in terms of c. how can vector in r? result = c(1.5, 0, 5.5, 6.5, 8.5, 9.5, 0) you don't want use vector c in ordering of elements of b , rather, want permute elements of b in same way sort(a) permutes elements of a . order returns permutation. note a[order(a)] same sort(a) (with default decreasing = false ). b[order(a)] [1] 1.5 0.0 5.5 6.5 8.5 9.5 0.0

java - Sending Strings Encoded by a secret key over TCP stream BadPaddingException with Windows -

i think i'm having problem specific windows operating system (windows 7) using writeutf() , readutf() methods sending encrypted strings on tcp connection. the client , server first establish connection using private-public key pair. agree on shared key used further communications. problem occurs when strings encrypted shared key , sent via writeutf() , readutf() have bad padding. first instance when occurs when encrypted acknowledgement server client using writeutf() method sent. the problem occurs sometimes! program runs smoothly through completion no errors, other times badpaddingexception thrown stating "given final block not padded" @ both client side: byte[] bytedecriptedack = decryptcipher.dofinal(encryptedack.getbytes()); and server side: byte[] bytedecriptedack = decryptcipher.dofinal(encryptedpassword.getbytes()); the problem not occur when running code on osx operating system. therefore, believe has how windows represents ...

ios - 'dismissModalViewControllerAnimated:' is deprecated -

Image
this question has answer here: dismissmodalviewcontrolleranimated deprecated 6 answers i know question has been asked, how fix problem referring line . -(void) achievementviewcontrollerdidfinish:(gkachievementviewcontroller *)viewcontroller { appcontroller *app = (appcontroller*) [[uiapplication sharedapplication] delegate]; [[app navcontroller] dismissmodalviewcontrolleranimated:yes]; } referring [[app navcontroller] dismissmodalviewcontrolleranimated:yes]; 'dismissmodalviewcontrolleranimated:' deprecated in ios 6.0 . if press alt while clicking on method in xcode, can see more information method, including availability. in availability section, suggest method use if current method deprecated. dismissmodalviewcontrolleranimated: , suggestion use dismissviewcontrolleranimated:completion: . can replace latter completion param nil. ...

javascript - Confused with set timeout -

i'm confused how these work...the timeout not seem keep running calls begin_anim once , thats it.... so hoping can see went wrong , explain how implement this? this code: //test data: //type = 'up'; //div = document.getelementbyid('theid'); //marginl = -400; function timeout_begin(type,div,marginl){ settimeout(begin_anim(type,div,marginl),1000); } function begin_anim(type,div,marginl){ if(type == 'up'){ if(marginl >= '-200'){ if(marginl > '-200'){ div.style.marginleft = '-200px'; } return false; } marginl += 2; div.style.marginleft = marginl+'px'; } return false; } hope can help! you're looking setinterval ! also, it's better pass actual function in, , can hold reference loop can stop running later if want to: var animationloop = setinterval(function () { begin_anim(typ...

hadoop - Why is Maven trying to compile my code as -source 1.3? -

i error mvn -e package in ubuntu 12.04: [error] failed execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hadoopskeleton: compilation failure: compilation failure: [error] /home/jesvin/dev/hadoop/hadoopmahoutskeleton-master/src/main/java/hadoopskeleton/app.java:[22,8] error: generics not supported in -source 1.3 [error] [error] (use -source 5 or higher enable generics) [error] /home/jesvin/dev/hadoop/hadoopmahoutskeleton-master/src/main/java/hadoopskeleton/app.java:[53,28] error: for-each loops not supported in -source 1.3 [error] -> [help 1] org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project hadoopskeleton: compilation failure @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:213) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153) @ org.apac...

curl - The provided value is not a valid RFC-2822 date -

i have been testing bigcommerce api calls, firstly tried orders.json call, , did got proper reply. but when added date range parameters ie min_date_created , max_date_created, gave me error. i testing using php curl, following url: https://test.mybigcommerce.com/api/v2/orders.json?min_date_created=thu, 16 may 2013 07:23:55 +0000&max_date_created=sat, 18 may 2013 18:29:59 +0000 and following error getting: [status] => 400 [message] => field 'min_date_created' invalid. [details] => stdclass object ( [invalid_reason] => provided value 'thu,' not valid rfc-2822 date. ) can 1 tell me went wrong? thanks, comment promoted answer after correct: you need rawurlencode parameters. *edit*changed urlencode rawurlencode, spaces encoded %20 rfc, opposed +'s*

vb.net - Removing a node with its children in xml -

i have following xml format: <kml xmlns="http://www.opengis.net/kml/2.2"> <document> <name>testdoc</name> <style id="style1"> <polystyle> <fill>0</fill> </polystyle> </style> <folder> <name>folder1</name> <placemark> <name>placemark1folder1</name> <lookat> <longitude>-122.0839597145766</longitude> <latitude>37.42222904525232</latitude> </lookat> </placemark> <placemark> <name>placemark2folder1</name> <lookat> <longitude>-101.083959</longitude> <latitude>26.422</latitude> </lookat> </placemark> </folder> <folder> <name>folder2</name> <placemark> <name...

visual c++ - Capture Hidden window with aero effects -

i trying capture windows hidden behind application. using windows 7 , vc++. have tried printwindow() function draws both non-client , client area of hidden window, captured window in device context doesn't show desktop composition effects(aero effects). instead shows captured window windows 7 basic theme. i have tried getwindowdc() retrive dc of hidden window, , bitblt() memory dc captured window doesn't show non-client area (caption, close button, minimize button etc) correctly. anybody faced issue? please help. click link below. leads msdn site lists existing windows functions ever of history since windows 95 windows 8 (from period microsoft started windows until present). shows old windows functions of first windows , new windows functions added new windows. http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919(v=vs.85).aspx anyway follow site. see name of each function link. click of them interested. each link there leads msdn site explain...

mysql - To what extend is table design responsible for the occurrence of deadlocks? -

we error sqlstate[40001]: serialization failure: 1213 deadlock found when trying lock; try restarting transaction . websites show solution retrying try/catch, such mysql deadlock detection via php . question is; extend table design responsible occurrence of such deadlocks? in particular interested in following example. table - id (int, primary key) - (int, foreign key -- references b.a) - b (int, foreign key -- references b.a) table b - id (int, primary key) - type (enum) - (int) a record in table a may contain value a.a , a.b both may or may not reference same record in table b . suppose deadlock occurs on insert in table a, can cause of deadlock due acquiring lock twice same table? amount of deadlocks less if split table b table b , table b' , based on value of type ? in answer please don't argue bad design. some websites show solution retrying try/catch one should always write application code handles deadlocks, , usual approach i...

Android KeyEvent getSize or getPressure -

is there way getsize() , getpressure() keyevent motionevent? in other words, motionevents have getsize() , getpressure() methods, keyevents not have these methods. moreover, motionevents , keyevents sibling classes, keyevent doesn't inherit these methods.

Unable to connect PHP and interbase -

i have system need run on interbase. when doing setup, error when trying start apache. error message: php startup: interbase: unable initialize module module compiled build id=api20090626,ts,vc6 php compiled build id=api20090626,ts,vc9 these options need match how fix that? your "interbase" module build different complier version. need find vc9 version load current php release. suggest use standard odbc driver if attempts fail. you may find more information on differently compiled php here .

Error when creating database name using full of number in SQL Server 2008 R2 -

create database name using string, database create successfully. example : if db_id('database1') null create database database1 command(s) completed successfully. but create database name using full of number, having problem example : if db_id('1234567890') null create database 1234567890 msg 102, level 15, state 1, line 1 incorrect syntax near '1234567890'. is wrong in query? try 1 - if db_id('1234567890') null create database [1234567890]

Dollar character before double quotes in Bash -

i read bash code, echo $"asdf" , $ for? what difference between $"asdf" , "asdf" ? as documented in bash manual , used localization: a double-quoted string preceded dollar sign (‘$’) cause string translated according current locale. if current locale c or posix, dollar sign ignored. if string translated , replaced, replacement double-quoted.

filter - Filtering a data frame in R and an unwanted filtered out result -

this snippet: names<-c("alice","bob","charlie") ages<-c(25,24,25) friends<-data.frame(names,ages) a25 <- friends[friends$age==25,] a25 table(a25$names) gives me output names ages 1 alice 25 3 charlie 25 alice bob charlie 1 0 1 now, why "bob" in output since data frame a25 not include "bob"? expected output (from table command): alice charlie 1 1 what missing? my environment: r version 2.15.2 (2012-10-26) platform: i386-w64-mingw32/i386 (32-bit) this question appears have answer in comments. answer shares 1 additional approach , consolidates suggestions comments. the problem describe follows: there no "bob" in "a25$names" variable, when use table , "bob" shows up. because levels present in original column have been retained. table(a25$names) # # alice bob charlie # 1 0 1 fortunate...

java - Default Handler - fetch tag name -

i implementing default handler in android. xml doc looks - <item> <rating>1</rating> <num>20</num> </item> i overriding characters method fetch tag values rating , num tags. public void characters(char ch[], int start, int length) { string value = new string(ch,start,length); } but how can check if value belongs rating or num tag ? example if string 'value' gets value (10 or b) how fetch tagname ie (rating or num) ? thanks string startname; public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception { startname=qname; } public void characters(char ch[], int start, int length) { //here check startname is.it can rating or num string value = new string(ch,start,length); }

vb.net - Structures in VB .NET like COBOL -

i'm converting cobol program vb .net. is there way use structures in vb net cobol does? in example: cobol: 01 var1 10 var11 pic x 10 var12 pic x move 'aa' var1 after var11 = , var12 = a is there way move string on top header of structure in vb net , every member of structure takes 'piece' of corresponding string? thank you. no. vb.net (well, it's not vb specific) string class offers lot of functionality - can index array, can ask substring s, etc. don't try literally copy aspects of cobol program. small wins can write cleaner vb code.

Sending Messages to Jboss 5.X JMS Queue using QTP 11.5 -

we trying send messages jms message queue using qtp. have given jms configuration details follows in qtp. jndi initial context factory = org.jnp.interfaces.namingcontextfactory jndi provider url - jnp://ipaddress:9199 jms connection factory- /connectionfactory but it's throwing error "'send message jms queue17' : failed initialize jms session. initial context factory missing or wrong" if change jms connection factory = /xaconnectionfactory it's throwing error "created new jms queue connection jbossconnection->connectiondelegate[17624055, id=3rd-ge7ttygh-1-ldg9lygh-xfyf4x-3192ts4, sid=120]step 'send message jms queue17' : failed start jms connection." can please let me know right connection factory name or right configuration details jboss jms queue qtp?

ios - Storing a small number of images with potential for IAP -

i'm making app. part of app choose 5 preset images. these available @ install , need bundled app. however, there potential "add" more images through in app purchases. i'm looking "best" way store these images on device potential add/unlock more images. my thoughts "coredata" heavy this. sort of plist thing reference initial 5 images. how add more through iap? with iap, download additional images upon purchase? or should bundled app @ install , unlocked when purchased? never done iap stuff before , previous apps used core-data data heavy. there 2 things consider - do want add more images after you've shipped? are images small enough can download on demand? if answer either yes, recommend going hosted content route. apple allows host content on servers . otherwise, bundle in app , unlock required. small note on security: not worry piracy @ since there no way can stop people pirating content/apps. besides, numbe...

How to pool a Java object in WebSphere Application Server 7.0? -

i have simple class object want pool in websphere application server 7.0 . my java class looks this: simplebean { string str1; string str2; simplebean() {str1="this str1";} public void setstr1(string str1) {this.str1 = str1;} public void setstr2(string str2) {this.str2 = str2;} public string getstr1() {return str1;} public string getstr2() {return str2;} } how pool simplebean in 7.0? saw there's object pool managers in don't know if pooling should setup there. don't know how use it. see object pools topic in websphere application server 7.0 infocenter more information on developing , configuring.

jquery - fancybox having issue with asp.net server control -

i using jquery.fancybox-1.3.4.pack.js opening user control pop up. parent page has server control drop downs. when click on cancel (cross mark). closes fancy box , page gets loaded without postback, none of server controls firing server event. i don't want parent page reload on click of cancel. i have user control , user control has anchor , 2 drop down (asp.net server control) the anchor tag: <a href="~/account data/view.aspx" id="a2" clientidmode="static" runat="server" target="_self" class="fancy" style="line-height:16px"></a> on click of anchor tag jquery function gets called $('a.fancy').fancybox({ type: 'ajax', oncomplete: fancyboxmanager.initialize, padding: 0, overlaycolor: '#000000', overlayopacity: 0.62, scrolling: 'no', afterclose: function () { ...

java - How to release svnkit resources after log -

i use svnkit in java application svn revisions log, after finish process on visualvm svnkit resource , thread still exist , live . ex. org.tmatesoft.svn.core.internal.util.svnhashmap$keyiterator , org.tmatesoft.svn.core.wc.defaultsvnrepositorypool$timeouttask and when try log more once effect application performance. how can release svnkit resources? code sample: public static svnlogentryhandler dologfully(string[] paths, long startrevision, long endrevision, svnrepository repository) throws svnexception { svnlogentryhandler logentryhandler = new svnlogentryhandler(); repository.log(paths, startrevision, endrevision, true, true, 0, false, null, logentryhandler); return logentryhandler; } story log entry. (svnlogentry logentry : dologfully(..,..,..,..,..).getlogentries()) { // store log entry } update i create svnrepository using svnrepositoryfactory . svnrepository repository = svnrepositoryfactory.create(svnurl.parseuriencoded(repositoryurl)); r...

python - Cherrypy behing apache with mod_python -

i have problem cherrypy deployment behind apache mod_python. i have apache configuration: 4 <virtualhost *> 5 serveradmin martin@podhola.com 6 servername pyth.madphoto.eu 7 documentroot /development/webadmin-interface/ 8 # indexes + directory root. 9 <location /> 10 pythonpath "sys.path+['/development/webadmin-interface']" 11 sethandler python-program 12 pythonhandler cherrypy._cpmodpy::handler 13 pythonoption cherrypy.setup main::start 14 pythondebug on 15 </location> 16 17 # logfiles 18 errorlog /www/madphoto.eu/pyth/logs/error.log 19 customlog /www/madphoto.eu/pyth/logs/ccess.log combined 20 </virtualhost> and cherrypy code start entire website #!/usr/bin/env python 2 # -*- coding: utf8 -*- 3 4 import os.path 5 import cherrypy 6 mako.template im...

c++ - Setter of a lambda function? -

consider following dumb example : class myclass { public: template <class function> inline double f(double x, function&& function) { return function(x); } }; with class, can call myclass::f(x, function) , lambda function execute on x , (i hope) no overhead. question : equivalent function settable member of myclass ? class myclass { public: inline double f(double x) { return _function(x); } // setter , type of protected member _function ? }; lambda functions (as other types of "callable" functions) can wrapped , stored using std::function template class, found in <functional> header. template parameter function signature syntax returntype(argumenttype1, argumenttype2, ...) so in case whole function wrapper type becomes std::function<double(double)> and thus, code becomes class myclass { public: inline double f(doubl...

tfs2012 - How can I display a tile on my TFS project home page with the remaining effort across all user stories? -

how can display tile on tfs project home page remaining effort across user stories? we're using scrum template in tfs 2012. it's easy write query number of product backlog items, or number of tasks, i'd metric showing remaining effort both. unfortunately, not possible in tfs wa. you alternatively create excel report , integrate in sharepoint dashboard.

matlab - Showing Variable's Value on Message Box -

this simple problem, have been trying times, not working. i have code: [s,h]=silhouette(cobat,g,'sqeuclidean') ms = mean(s) z = [cobat s]; i want show ms value on message box. message box going this, 'the result [here ms value placed]' any idea? you following way: h = msgbox(['the result ' num2str(ms)], 'title of message box') with num2str convert numerical result string, , square brackets concatenate "the result " result display in message box.

Running PhantomJs from command prompt using C# -

i trying run phantomjs.exe throw c# code. code : process process = new process(); processstartinfo startinfo = new processstartinfo(); startinfo.windowstyle = processwindowstyle.normal; startinfo.filename = "cmd.exe"; startinfo.workingdirectory = @"e:\"; startinfo.arguments = "some string code here"; startinfo.createnowindow = true; process.startinfo = startinfo; process.start(); when run going workingdirectory e:/ arguments not writing on cmd prompt. can buddy suggest me run arguments on cmd.exe? in order cmd.exe accept further command argument, need precede command /k (if want cmd window stay open) or /c (if want window close after command has completed). so: argument ="/c phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr chart -callback callback.js"; should need. however, if want run phantomjs program, agree tommi: run without starting cmd.exe process first (i.e. ...

javabeans - spring destroy bean manually instead of ctx.close() -

is possible tell container of spring destroy specific bean (prototype) in order save memory? i dont want user ctx.close() in order see bean destroyed, rather on runtime. if understand correctly want remove bean defined in ctx @ runtime, use beandefinitionregistry done, beandefinitionregistry has method of removebean() takes bean name parameter. beandefinitionregistry factory = (beandefinitionregistry) applicationctx.getautowirecapablebeanfactory(); then ((defaultlistablebeanfactory) beanfactory).destroysingleton("mybean"); edit reference http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/beans/factory/support/beandefinitionregistry.html#removebeandefinition%28java.lang.string%29

RegEx in C#, getting the values without criterias -

i terrible @ regex, in code below want actual numbers between sh: , , or end of line. how can achieve this? [testmethod] public void sandbox() { var regex = new regex(@"sh\:(.*?)(\,|\z)"); var matches = regex.matches("some text|sh:0000000000,sh:1111111111"); foreach (var match in matches) { console.out.writeline(match); /* getting sh:0000000000, sh:1111111111 */ /* wanting 0000000000 1111111111 */ } } just change loop below foreach (match match in matches) { console.out.writeline(match.groups[1].value); }

Django passing object ID in hiddeninput by populating -

i have form allows user edit object description. how can populate object id in form's hidden input value. done far added field called hidden_field in forms.py show hidden_field . how can link hidden_field object id models.py class school(models.model): user = models.foreignkey(user) name = models.charfield(max_length=55) description = models.charfield(max_length=300,blank=true) forms.py class schooldescriptionform(forms.modelform): description = forms.charfield(widget=forms.textarea,max_length=300) hidden_field = forms.charfield(widget=forms.hiddeninput()) class meta: model = school fields = () views.py def schooleditor(request,school_id): school = school.objects.get(pk=school_id,user=request.user) form = schooldescriptionform(instance=school) # want populate object id return render(request,'schooleditor.html',{'school':school,'form':form}) template <form method=...

how to call a javascript function in grails 2.2.2 -

i trying call javascript function not working.. please me out javascript code: <script type="text/javascript"> $(document).ready(function(){ function confirm(){ alert('hello world'); } }); </script> textbox code: <div class="full-filed"> <h3>confirm password:</h3> </div> <g:passwordfield name="confirm" value="" class="logintxtbox" placeholder="password" onclick="confirm();"/> your function available inside ready(..) function. have define funciton in main context: <script type="text/javascript"> function confirm(){ alert('hello world'); } </script>

ios - Moving a sprite by touching anywhere on the screen -

in game 1 sprite responds touches. how can make mousejoint move sprite/body regardless of touch on screen? - (void)cctouchesmoved:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint location = [touch locationinview: [touch view]]; location = [[ccdirector shareddirector] converttogl:location]; mysprite.position = location; } make sure in init method self.istouchenabled = yes;

SQLite cursor in Python with statement -

i have following code: def executeone(self, query, parameters): self.connection cursor: cursor.execute(query, parameters) return cursor.fetchone() when call method, throws me following error: attributeerror: 'sqlite3.connection' object has no attribute 'fetchone' doing wrong? the reason receiving error because connection class not have method called fetchone . need add .cursor() create instance of cursor , wrap closing work in with statement. from contextlib import closing closing(self.connectio.cursor()) cur: the easiest way deal remove with statement , manually close cursor . cur = self.connection.cursor() try: cur.execute(query, parameters) return cur.fetchone() finally: cur.close()

Web Masters API and c# WebClient -

need retrieving site feed given site using google web masters api webclient client = new webclient(); client.headers.add("authorization: googlelogin auth=" + _auth); client.headers.add("gdata-version: 2"); client.headers.add("content-type", "application/atom+xml"); stream stream = client.openread("https://www.google.com/webmasters/tools/feeds/sites/http%3a%2f%2fando.ueuo.com%2f/"); string str = reader.readtoend(); but every time server return error (400) bad request. meanwhile same code url https://www.google.com/webmasters/tools/feeds/sites/ work fine , feeds sites expected. client.headers.add("authorization: googlelogin auth=" + _auth); client.headers.add("gdata-version: 2"); client.headers.add("content-type", "application/atom+xml"); stream stream =client.openread("https://www.google.com/webmasters/tools/feeds/sites/"); streamreader reader = new streamreader(stream); stri...

java - Convert long to "unsigned, 4 byte integer in network byte order" with ByteBuffer -

the protocol i'm using requires sending current position in file "unsigned, 4 byte integer in network byte order". there several questions on this, assuming i'm using integers, not longs i attempting port nio's bytebuffer can sent in socket channel: long bytestransfered = ... number of bytes transfered... //todo: do? outbuffer[0] = (byte) ((bytestransfered >> 24) & 0xff); outbuffer[1] = (byte) ((bytestransfered >> 16) & 0xff); outbuffer[2] = (byte) ((bytestransfered >> 8) & 0xff); //todo: why netbeans nothing? outbuffer[3] = (byte) ((bytestransfered >> 0) & 0xff); are methods in bytebuffer accomplish this? in more obvious, self-descriptive way bit-shifting magic above? whether signed or unsigned, bits same. if cast long int , jvm discards high-order bits. issue comes when promoting int long : java sign-extend value, filling in high-order bits of long most-significant bit of int . to resolve problem,...

opensource "Screen Share" application -

i looking screen share tool. i looking open-source not commercial of now. preferred in java. please let me know if have information related this. thanks map you try using 1 of many open source vnc solutions available. i'd suggest using ultravnc ( http://www.uvnc.com/ ). it's open source , there's java client ( http://www.uvnc.com/features/javaviewer.html ). not sure server. alternatively, thinvnc ( http://sourceforge.net/projects/thinvnc/ ) vnc server can connected using html5 browser (any modern browser seems work). make sure grab gpl version think project has been commercialised. download sourceforge should still gpl.

javascript - Iframe working but Height always increase -

hello after hours of search found script works iframe exept little problem never stops increases height no stop... here code add script @ page want iframe <script> function alertsize(pixels){ pixels+=0; document.getelementbyid('myiframe').style.height=pixels+"px"; } </script> <script type="text/javascript"> var myheight = 0; setinterval(function(){ if(myheight != document.body.scrollheight){ myheight = document.body.scrollheight; parent.alertsize(myheight); } },500); </script> here iframe: <iframe id="myiframe" src="http://www.altasoft.gr/hermes/index.html" name="myiframe" width="100%" height="100%" scrolling="no" frameborder="0"></iframe> the problem height="100%" in markup. change fixed pixel value, , script start working. change height="100%" height="1...

c# - How to populate xml from list of paths -

how populate xml list of paths in c#? for example: c:\windows\addins c:\windows\apppatch c:\windows\apppatch\mui c:\windows\apppatch\mui\040c c:\windows\microsoft.net\framework\v2.0.50727 c:\windows\microsoft.net\framework\v2.0.50727\mui c:\windows\microsoft.net\framework\v2.0.50727\mui\0409 as input list, output should be: <node label="c:"> <node label="windows"> <node label="apppatch"> <node label="mui"> <node label="040c" /> </node> </node> <node label="microsoft.net"> <node label="framework"> <node label="v2.0.50727"> <node label="mui"> <node label="0409" /> </node> </node> </node> </node> <node label="addins" /...

gruntjs - Handling environment-specific configuration in a javascript app -

context : single-page backbone application build yeoman i way have application parameters depend on current environment (dev vs production). right using 2 separate config files, , switch dev 1 prod 1 when deploying grunt:usemin task : // index.html <!-- build:js scripts/config.prod.js --> <script src="scripts/config.dev.js"></script> <!-- endbuild --> // config.dev.js window.config = { api_host: 'localhost:9393', api_key: 'dev_api_key' } // config.prod.js window.config = { api_host = 'api.host.tld', api_key = 'prod_api_key' } this solution works smelly , doesn't allow other environment production , dev. alternatives? try this: var dev = (window.location.indexof("dev=1")) != -1 ? true : false; then type ?dev=1 after url.

database modelling challenges -

Image
i trying model student database unsure of how represent student, assessment taken, , student results. below description of scenario: several students offering 1 or more subjects, these subjects have 1 or more assessments. how represent students, subject offered, assessment taken , results of assessment taken students? have attached copy of design made far. my intension design database querying of student,subject,assessment, , assessment result can possible , easy. full-size image imho should have ternary relationship between student, subject , assessment owning assessment result. necessary in case student can have many subject same assessment. otherwise if assessment have many subject 1 given student have different choice : can keep ternary. can otherwise store subject id , result in student - assessment relationship table or student id , result in subject - assessment table. this should depend on way query tables (all subject assessment a, students ...

mediawiki - Pywikibot Error "Warning: Token not found on Example:de. You will not be able to edit any page" -

i tried install pywikibot. far good, bot able log in, apparently access api.php , when want run script says: warning: token not found on example:de. not able edit page i tried search on web, either not looking enough or there isn't problem. i faced same error when server name change. so, check hostname in family file. however, i'm not sure case because able login. may similar warning message.

python - How to send utf-8 content in a urllib2 request? -

i'm struggling following question past half day , although i've found info similar problems, nothing hits spot. i'm trying send put request using urllib2 data contains unicode characters: body = u'{ "bbb" : "asdf\xd7\xa9\xd7\x93\xd7\x92"}' conn = urllib2.request(request_url, body, headers) conn.get_method = lambda: 'put' response = urllib2.urlopen(conn) i've tried use body = body.encode('utf-8') , other variations, whatever following error: unicodeencodeerror @ ... 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128) with 1 of following call stacks: file "..." in ... 195. response = urllib2.urlopen(conn) file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py" in urlopen 126. return _opener.open(url, data, timeout) file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/urllib2.py...

ios - How to create scrollable UITabBarController in iPhone? -

i want show 10 views on uitabbar scrolling functionality. using uitabbar on uiscrollview . not able show different different views after click on item of uitabbar . please suggest how add uiviewcontroller on uitabbar items. refer following custom scrollable uitabbar sample code link, https://github.com/marxon13/m13infinitetabbar hope satisfy needs.....

jquery - A drop down menu with checkbox -

Image
i'm trying make drop down menu checkbox : before click : after click : do have idea please (it's asp.net project , i'm using jquery script) thanks basically u can use popupcontrol <asp:panel runat="server" id="panel1"> here content1 </asp:panel> <asp:panel runat="server" id="panel2"> here content2 </asp:panel> <ajaxtoolkit:popupcontrolextender id="popex" runat="server" targetcontrolid="panel1" popupcontrolid="panel2" position="bottom" />

XAMPP Virtual Host Not Loading -

i trying set local test server can test code before pushing live, although have little problem, have set httpd-vhosts.conf this: try 127.0.0.1 mw1dev in host file. after starting of apache (and mysql), go address localhost or 127.0.0.1 in browser , examine of xampp examples , tools.

Ukkonen's Algorithm Generalized Suffix Trees -

i understand ukkonen's algorithm . curious how extend have more 1 string in (ending special character "$"). i read somewhere given strings s1(say "abcddefx$") , s2(say "abddefgh$"), should insert s1 ukkonen's algo. traverse down tree s2. should search s2 in tree. once node search ends ("ab", after 'b') should resume ukkonen's algorithm there. i understand basic logic behind this. curious is, happens old suffix links. still valid??? confused triple (active_node,active_length,remainder) should (node representing "ab",0,0) start new pass??? for dealing special characters can use unicode private use areas . these few special ranges of characters reserved own use, ranges around 4000 characters in size. depending on unicode support of language using can easy or difficult. if not work, instead of inserting characters tree, wrap them in other sort of variable (struct, object, dictionary) 'extend'...

ios - Git Tf installation on Mac Osx 10.8 -

i have tried integrate git tf xcode 4.5.1 , mac osx 10.8. have followed steps written @ : " http://www.hhogdev.com/blog/2013/january/ios-git-tfs-integration-step-by-step.aspx " . @ 5. step terminal has given error " 'tf' not git command." have looked @ html files given git-tf installation folder. has written macosx version 10.5 10.6. possible use git tf mac osx 10.8? if yes, there tutorial how integrate git-tf mac osx 10.8? lot in advance. i made mistake of setting path in .bash_profile to: export path=$path:/users/<username>/git-tf following instructions here https://gittf.codeplex.com/wikipage?referringtitle=documentation . when archive utility extracts files places them in folder named git-tf-x.x.x.xxxxxx . because extracted directory named git-tf/ adjusted path variable in .bash_profile to export path=$path:/users/<username>/git-tf/git-tf-x.x.x.xxxxxx , command found.

eclipse - Attaching javadoc to libraries -

as example, i'd attach javadoc org.eclipse.swt i've read in similar threads, went build path, expanded swt library node , tried enter url javadoc location: http://help.eclipse.org/indigo/advanced/content.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/index.html trying validate tells me typical root files package-list or index.html couldn't found. pretty weird since url ends index.html. doing wrong? you can specify url javadocs if has package-list file. otherwise have use downloaded javadocs/src jar. can specify location javadocs archives in same window tried. can attached sources if want see source instead of decompiled library classes. similar post

How can I write a wait_for_ajax call in selenium where the web page uses XMLHttpRequest based AJAX calls? -

i have select box calls xmlhttprequest based ajax call populate select box. want selenium wait till select box populated. have wait xmlhttprequest's readystate variable have value 4 means data populated. in java: wait readystate change this: int trycount = 0; boolean desiredresponsereceived = false; while (desiredresponsereceived == false && trycount < 20) { string readystate = (string) js.executescript("return xhr.readystate;"); if (readystate.equals("4")) { desiredresponsereceived = true; } else { thread.sleep(250); trycount++; } } if (desiredresponsereceived == false) { driver.quit(); } one problem looking ready state is, page making more 1 xmlhttprequest. , won't know 1 which. if check after clicking relevant button (for example) fire off multiple requests. , there's no telling return first. another option in case...

linux - unmount USB drive in C++ -

i developing qt application linux (ubuntu) in use usb drive backup content. application should unmount target drive after copying stuff. have udev rule file mount usb @ specific location env{mount_options}="relatime,users,umask=0,uid=user,gid=user" user represents user name. i tried using without luck. const char* usb = "/mnt/mountpoint/usbdrive"; if (!umount(usb)) { qdebug() << "device unmounted"; } else { qdebug() << "can't unmount" << strerror(errno); //this prints operation not permitted } could please me here? using umount right? thanks in advance. appropriate privilege (linux: cap_sys_admin capability) required unmount file systems. per umount code fine. need privilege umount devices. the cap_sys_admin capability allows process perform various administrative tasks, namely: calling mount(), umount(). there 2 worth articles capabilities here: cap_sys_admin: new root overview ...

oracle - how to perform this step in sql query? -

Image
i doing excel via vba, if can in query save me lots of time. this 1 of 5 things need report working on. tables reading 3 different tables tablea tableb tablec fields tablea out_id fields tableb timestamp event_type worker operator_id new_date fields tablec worker query select tablea.out_id, tableb.timestamp, tableb.new_date, tableb.event_type, tablec.worker, tableb.operator_id tablea left outer join tableb on tablea.out_id = tableb.out_id , tableb.event_type in ('worker_ret_cmt_chance','ret_chance','worker_status_chance') left outer join tablec on tableb.worker = tablec.worker tablea.time_stamp > {?pickdate} //parameter in crystal report pick date , tablea.time_stamp < {?restdate} //parameter in crystal report pick date order tablea.out_id, tableb.timestamp here need do. in event_type column if ret_c...

How to fire query for loaded documents in marklogic server? -

i loaded xml documents marklogic server through load content, xquery , through admin interface. did sample example fetching document data, manipulating , through xquery console. but after loading document server, how put query them through xquery?? thanks in advance!! there number of ways this, depends how stored xml files: first, if documents in 1 dicrectory 'mydirectory', may use xdmp:directory("/mydirectory/") return xml files content. second, if don't know directory , root element xml files same 'root', should use /root related xml files. third, if know uri of xml file '/mydirectory/abc.xml' use doc("/mydirectory/abc.xml") fourth, if want everthing db, use doc()

c# - Sudoku Solver algorithm for int[,] -

good day all, i've been working on c# sudoku solver application sincerely underestimated difficulty of algorithms solve sudoku. i've been searching web possible algorithms implement, i've had no luck finding easy algorithm can head around. i found algorithm may work in application, person using single-dimensional array work out. i've tried change make work multidimensional array, can't work properly. could give me advice or show me how change code works multidimensional array(int[,])? can't seem find on own. code found here: http://blah.winsmarts.com/2007-1-sudoku_solver_in_c-.aspx if have algorithm work int[,], that's wonderful of course. help appreciated since i've been searching long time. in advance! the code linked logically uses 2d array, uses 1d array backing. change this: private int[] vals = new int[81]; public int this[int row, int column] { { return vals[findindex(row, column)]; } set { vals[findin...