Posts

Showing posts from June, 2010

Dual command on batch file menu -

i new of this, took me hours make following: @echo off cls echo=========================================================================== echo menu echo=========================================================================== echo........................................................................... echo type 1,2 or 3 press enter: echo........................................................................... echo. echo 1 - server xxx.xxx.xxx.1 echo 2 - server xxx.xxx.xxx.2 echo 3 - exit echo. set /p opt=type 1,2 or 3 press enter: if %opt%==1 goto mstsc 1 if %opt%==2 goto mstsc 2 if %opt%==3 goto eof :mstsc 1 mstsc.exe /v:xxx.xxx.xxx.1 /admin /f goto eof :mstsc 2 mstsc.exe /v:xxx.xxx.xxx.2 /admin /f goto eof :eof exit when select options 1 , 3 work fine, when select option 2 same result option 1. it's not connecting second server, how can fixed? how can have command prompt close command executed? command

python - multithreading windows apache server -

i'm working apache 2.2, had tried run 2 threads (parallel) seeming it's not working 2 threads running sequentially. how can force running simultaneously (parallel) ?? test.wsgi:: import time def application(environ, start_response): status = '200 ok' output = str(time.time()) time.sleep(5) output += '<br/>' + str(time.time()) response_headers = [('content-type', 'text/html; charset=utf-8'), ('content-length', str(len(output)))] start_response(status, response_headers) return [output] i had inserted @ the end of httpd.conf following: include conf/extra/httpd-mpm.conf <ifmodule mpm_winnt_module> threadsperchild 253 maxrequestsperchild 0 </ifmodule> <virtualhost *> servername localhost wsgiscriptalias / c:\test\test.wsgi <directory c:\test> order deny,allow al

c# - Load/Edit and Save XML Data on a different form -

Image
at moment have application looks this: it reads data xml file dataset, , sets datasource fit datagrid when user clicks on row, data within notes section displayed within textbox below when user clicks notes button brought new form, form2, data notes textbox brought across new textbox. want able able enter new text notes textbox on form 2 , when user clicks ok saves datagrid exactly this: http://youtu.be/mdmjmobrcsk?t=28m41s the code have @ moment ok button far below, , following error because haven't wrote datagridview1 on form. i'd know how user input textbox , 'update' xml file datagrid updated new notes i'm not sure if code how have linked datagridview1_cellcontentclick textbox below on form1, think need reuse last line on new form overwrite data i'm not sure if (e.rowindex >= 0) { datagridviewrow row = this.datagridview1.rows[e.rowindex]; //the data in cells notes column turns string , copied textb

security - Auto Login from email link and PHP? -

i'm trying create link when clicked login user automatically , take them specific page. i've thought creating sort of hashed string contains user's id, username , few other pieces of info. when clicked these pieces of information looked in db , if validated login them in , redirect them specific page. for sites twitter , facebook when receive email notification , click link in email i'm automatically taken inbox on corresponding site. i'm trying duplicate behavior... are there security issues doing or there safer more preferred way? if want offer feature users, have take care of 2 things: the validity of created url must set in time (ex: 24hours, 48hours). the created url must work 1 specific user. (optionnal) created url work 1 page i propose kind of solution create url match these criteria (it's proof of concept): <?php $privatekey = 'somethingverysecret'; $username = 'cedric'; $url = 'my/personal/url';

javascript - jQuery Virtual Keyboard plugin inserts the same character twice on Windows 8 touch devices -

i'm using virtual keyboard jquery got here ( https://github.com/mottie/keyboard/ ), works fine except on touch screen tablet running firefox + windows 8 when tap on key inputs character twice, reported on github project page under issues developer not responded yet , i'm not able find root of evil, kind of appreciated! thanks project page: http://mottie.github.io/keyboard/ github: https://github.com/mottie/keyboard/ reported issue: https://github.com/mottie/keyboard/issues/184/ i faced similar problem in qt5. double input may due system synthesizing mouse event primary touch point, resulting in 2 mouse events instead of one. 1 solution replace 'mousedown' keybinding touchstart follows $(input).keyboard({ keybinding : 'touchstart', alternatively write system hook filter out mouseeventf_fromtouch events.

javascript - insertAfter() is duplicating an element when I don't want it to -

okay, i'm making chatbot, , ran problem. need make function creates chat message everytime enter key pressed. far, it's coming out nicely, 1 problem. it's duplicating element, want 1 of. to see i'm talking about, go http://jsfiddle.net/matthewkosloski/bhxma/ , type out message, hit enter. notice how there 2 "foo!" messages? want one. i'd want make these messages go top-bottom in chronological order, can't until find out why duplication occuring! function insertafter(referencenode, newnode) { referencenode.parentnode.insertbefore(newnode, referencenode.nextsibling); } var robotmessage = usermessage; function intelresponse(){ // robot var robot = document.createelement("h4"); var robottext = document.createtextnode("robot"); robot.appendchild(robottext); robot.classname = "rtitle"; document.body.appendchild(robot); insertafter(usermessage, robot);

ios - Set container view height to nib loaded subview height -

i loading subviews different .xib files , adding them container view. problem can't figure out how make container view's height automatically adjust subview. when access subview.frame.size.height comes correct value. example, 44. when set height of containerview making rect containerview.frame = gcrectmake(0, 0, containerview.frame.size.width, 44) not work , keeps original height. have tried [containerview sizetofit:subview.frame.size] no avail.

ios - Concatenate NSMutableAttributedStrings in UITextView -

i'm going crazy :( working in ios6 i have uitextview text in each second append nsstring , scroll last line appended. way -> [textview settext:[textview.text stringbyappendingstring:newtext]]; [textview scrollrangetovisible:nsmakerange([textview.text length], 0)]; i use nsmutableattributedstrings instead of nsstring in order format text. i have been searching everywhere haven't found anything. there way concatenate nsmutableattributedstrings?? current in uitextview , new one?? thanks in advance

Botched Python install on Ubuntu 12.04 LTS (can't import MySQL) -

i beginner programmer trying learn python. made smart move ubuntu, being unfamiliar os environment believe botched install of python. i have installed vim , mysql. both installed correctly. vim works correctly python, mysql not. when try import mysql python get: >>> import mysqldb traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named mysqldb i believe path setup wrong python. have tried uninstall , reinstall. said might have python 2.7.5 installed when need 2.7.3 on ubuntu 12.04. here sys.path >>> import sys >>> print sys.path ['', '/home/allen/lib/python', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages'

Binary search in php over list of strings -

i have file containing 30k songs names. have use list automatic text suggestion ajax. of names start numbers. question can binary search on list ? if yes, how ? first of sort list; suppose, first letter user has typed "a"; start high = 0 , low = number of strings -1; then can define high , low index high last index starts "a" , low first index has string starts "a". 2 binary searches can achieved. so if next letter typed "b" make binary search in range high , low defined above , adjust high , low again 2 binary searches. make sure search second character of strings between high , low matched "b" , on :) note: i'd suggest use database so, queried if there's way use binary search, i'm answering way :) simple sql query: select column_name table_name column_name 'prefix%' select strings start 'prefix' stored in column 'column_name' of 'table_name' table

PHP MySQL Insert survey answers into table -

if have html , php code: <?php if(isset($_post["submit"])) { $num = $_post['number']; ($i = 0; $i < $num; $i++) { if($i==0) { echo '0'; $answer1 = $_post["answer1"]; $answer2 = $_post["answer2"]; $answer3 = $_post["answer3"]; $answer4 = $_post["answer4"]; $answer5 = $_post["answer5"]; $answer6 = $_post["answer6"]; $answer7 = $_post["answer7"]; $answer8 = $_post["answer8"]; } else { echo 'no 0'; $answer1 = $_post["answer1$i"]; $answer2 = $_post["answer2$i"]; $answer3 = $_post["answer3$i"]; $answer4 = $_post["answer4$i"]; $answer5 = $_post["answer5$i"]; $answer6 = $_post[&quo

Android: Is it possible to create both Bottom and Top tabs on the screen? -

i know if possible have different tabs on top , bottom lead different activities when clicked. googled didnt find it. thanks the thing android want should possible. if alter xml change like: <?xml version="1.0" encoding="utf-8"?> <tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <tabwidget android:id="@android:id/tabs_top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /> <framelayout android:id="@android:id/tabcontent" android:layout_w

javascript - Designing a web with fancy view -

i beginner in working in field of web apps, , want build website. question want make menu here in left side https://roadtrippers.com/ so, how can ? please need know way. thanks in advance. if want fix element side of page, use position: absolute or position: fixed in css. ( fixed remain in same place when scrolling; absolute scroll content): .sidebar { /* fix element relative window */ position: absolute; /* fix left side of element left side of window (distance of 0 between left of element , left of window) */ left: 0; /* same top , bottom */ top: 0; bottom: 0; /* fix width */ width: 75px; } the rest of interactions can done javascript.

ruby on rails - Devise is installed but no methods are found -

i installed ruby 1.9.3 rails 3 rubymine 5.4. followed installation guide install devise 3. devise:install devise user db:migrate after tried use method devise, none found, method user_signed_in or new_user_session_path etc... i'm missing simple... edit: routes.rb c:\ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=argv.shift) c:\ruby193\bin\rake routes new_user_session /users/sign_in(.:format) devise/sessions#new user_session post /users/sign_in(.:format) devise/sessions#create destroy_user_session delete /users/sign_out(.:format) devise/sessions#destroy user_password post /users/password(.:format) devise/passwords#create new_user_password /users/password/new(.:format) devise/passwords#new edit_user_password /users/password/edit(.:format) devise/passwords#edit put /users/password(.:format) devise/passwords#update cancel_user_reg

python - get_or_create not creating object from POST form -

trying create object get_or_create(). response hits, never creates object. python code: class note(models.model): user = models.foreignkey(user) topic = models.charfield(max_length=500, null=true, blank=true) created = models.datetimefield(auto_now_add=true) content = models.textfield(null=true, blank=true) type = models.foreignkey(notetype, null=true, blank=true) def __unicode__(self): return self.topic def post(request): topic = request.post['topic'] user = request.user content = request.post['content'] note_type = request.post['type'] note, created = note.objects.get_or_create(user=user, topic=topic, content=content, type=note_type) return httpresponseredirect('/home/') so exception hits , never creates object. urls fine , i'm importing model. reason why object isn't being created? theres no errors, redirects normal. traceback: environment: request method:

python - python3, ftplib storlines error -

i want upload ascii file. used work in python 2: ftp = ftplib.ftp('ftp.domain.com') ftp.login('domain.com',password) ftp.cwd('subdirectory') ftp.storlines('stor ' + 'file.htm', open('file.htm','r')) ftp.close() however, in python 3 returns error: file "/usr/local/lib/python3.3/ftplib.py", line 497, in storlines if buf[-1] in b_crlf: buf = buf[:-1] typeerror: type str doesn't support buffer api what doing wrong? i read documentation: http://docs.python.org/3/library/ftplib.html#ftplib.ftp.storlines "lines read until eof file object file (opened in binary mode) using readline() method provide data stored." so had open in binary mode: ftp.storlines('stor ' + 'file.htm', open('file.htm','rb'))

regex - Search and replace strings in Java source files using Emacs and regular expressions -

suppose had java file contained lots of single letter variable names a,x,f etc, , wanted change them more meaningful. try replacing every occurrence of ‘f’ ‘filename’, mess of places ‘f’ occurs inside word (for example in keyword if ). how go correcting problem using regular expression search , replace? i need write in emacs, using word boundaries. since new, using matcher class apply? if must using native emacs: word boundaries reasonable search boundary. matcher class java construct. if writing code search , replace. since doing in emacs, wouldn't apply. there caveat these variables can't used multiple source files or mess things up. i wouldn't raw emacs though. i'd use ide refactoring tool. emacs has java refactoring can install. using refactoring tool, tool understands syntax , more specific regular expression.

cakephp - why i am getting empty array when I see data -

i have in form <?php echo $this->form->create('vendor', array( 'url' => array_merge(array('action' => 'index'), $this->params['pass']) )); echo $this->form->input('vendor_name', array('div' => false,'empty'=>true)); echo $this->form->input('is_finalized', array('div' => false,'empty'=>true)); echo $this->form->submit(__('search', true), array('div' => false)); echo $this->form->end(); ?> and have in controller var_dump($this->request); $this->request has data property in it, when @ var_dump of it. please see below dump. when var_dump($this->request->data); empty array. can see below data there public under $this->request var_dump here var_dump of $this->request object(cakerequest)[9] public 'params' => array (size=5) 'plugin' => null 'controller

python - Why doesn't my function execute when I use exec on a string? (the string is the name of the function) -

i have following function in python: def foo(): print 1 return 1 in shell, run foo() and 1 1 as should. when run following in shell exec('foo') i nothing? why? this diluted version of larger problem. you referencing function name. add parenthesis call function: exec('foo()') this print 1 ; return value discarded nothing captures it. add print statement show return value: exec('print foo()') exec() not mean 'execute function named', means 'execute python code given'.

knockout.js - Knockout + Datatables - update bindings in cells -

i using josh buckley's datatables binding knockout. i'm trying create "delete row" button in datatable. have click data-bind on each button. datatable source hooked observable array. when user clicks on button, object removed observable array, triggers update binding, , table view subsequently gets updated. works fine, @ least first time click on button. however, once the table updated, of click bindings on "delete row" buttons stop working. presume because entire table cleared , rebuilt each time update binding called, , bindings aren't applied on new elements. how can rebind new elements generated each datatable update? alternatively, there better way handle this? custom binding: (function($){ ko.bindinghandlers.datatable = { init: function(element, valueaccessor){ var binding = ko.utils.unwrapobservable(valueaccessor()); // if binding object options field, // initialise datatable options.

materialized views - Oracle 11gR2 MView refresh failing -

hi have created 5 mviews tables in remote db 2 days in production environment. out of 1 mview, @ time of creation worked fine. 2 days after(today) mview's last refresh date still showing day before yesterday's date. i checked on dba_jobs: last_date,next_date,broken,interval,failures,what null,"23-jul-13 01:00:00", n,"trunc(sysdate+1)+1/24",12,"dbms_refresh.refresh('"occss_entmt_hk"."mv_sci_std_code_value"');" mview create statement: create materialized view mv_sci_std_code_value build immediate using index refresh force on demand start sysdate+0 next trunc(sysdate+1)+1/24 primary key using default local rollback segment using enforced constraints disable query rewrite select stv_std_code_num standard_code, stv_std_code_value standard_code_value, stv_std_code_value_desc description, stv_prnt_std_code_value parent_code sciadmin.p03_std_code_value@sci_link02.hk.bt.com p03 stv_std_code

google app engine - How to send 204 No Content with Go http package? -

i built tiny sample app go on google app engine sends string responses when different urls invoked. how can use go's http package send 204 no content response clients? package hello import ( "fmt" "net/http" "appengine" "appengine/memcache" ) func init() { http.handlefunc("/", hello) http.handlefunc("/hits", showhits) } func hello(w http.responsewriter, r *http.request) { name := r.header.get("name") fmt.fprintf(w, "hello %s!", name) } func showhits(w http.responsewriter, r *http.request) { fmt.fprintf(w, "%d", hits(r)) } func hits(r *http.request) uint64 { c := appengine.newcontext(r) newvalue, _ := memcache.increment(c, "hits", 1, 0) return newvalue } according package docs: func nocontent(w http.responsewriter, r *http.request) { // set headers want here. w.writeheader(204) // send headers 204 response c

opengl - C++ program freezes when trying to display a triangle with vertices read from data file -

i wrote small program reads 3 vertices of type double data file , displays them triangle (using lines). compiles, when run window freezes. tried debugging it, without success. created separate program reads same data same way without displaying graphically. worked. suppose problem in opengl commands. could point out mistake(s)? //to compile, use $ g++ -lgl -lglut triangulation.cpp -o triangulation #include <iostream> #include <gl/glut.h> #include <fstream>//for operation on files using namespace std; double triangle_vertices[3][2]; void draw_triangulation() { glclear(gl_color_buffer_bit); glcolor3f(0.8, 0.8, 0.0);//color of shape (red,green,blue). red+green=yellow int i=0; ifstream myfile ("data.txt"); //read file if (myfile.is_open()) { while (myfile.good()) { (i;i<3;i++) { (int j=0;j<2;j++) { myfile >&g

dia graphics program drawing curly braces -

other (1) using bezier curves or (2) using keyboard curly brace , increasing font, there way draw curly braces in dia, , if it? the reason not using 2 above bezier curve braces don't polished , cant scaled , down, , keyboard curly brace has line width thick once expanded. i'm trying show aggregations of processes in flow chart. thanks

Java: Getting the subclass from a superclass list -

i'm new java , have 2 questions following code: class animal { } class dog extends animal { } class cat extends animal { } class rat extends animal { } class main { list<animal> animals = new arraylist<animal>(); public void main(string[] args) { animals.add(new dog()); animals.add(new rat()); animals.add(new dog()); animals.add(new cat()); animals.add(new rat()); animals.add(new cat()); list<animal> cats = getcertainanimals( /*some parameter specifying want cat instances*/ ); } } 1) there way either dog or cat instances aminal list? 2) if yes, how should correctly build getcertainanimals method? animal = animals.get(i); if (a instanceof cat) { cat c = (cat) a; } else if (a instanceof dog) { dog d = (dog) a; } nb: compile if not use instanceof , allow cast a cat or dog , if a rat . despite compiling, classcastexception on runtime. so, make sure use instanceof .

javascript - Ajax form submit twice when include jcarousel script -

i'm using ajax submit form, when click button add cart form submit twice if remove jcarousel , form submit normal. <form id="formrandom1473" name="formrandom1473" method="post" action="ajax_process.php?case=add_product_ajax&amp;pid=1473"> <input type="hidden" value="1473" name="products_id"> <input type="hidden" value="1" name="qty"> <div class="add_to_cart_div"> <input type="image" border="0" id="add-to-cart-1473" title=" add cart " alt="add cart" src="includes/languages/english/images/buttons/button_in_cart.gif"> </div> </form> <script type="text/javascript"> $(document).ready(function() { $("#add-to-cart-1473").click(function () { var formrandom1473 = $("#formrandom1473"); formrandom1473.sub

php - How to get realpath for virtual paths? -

if path ../b , current directory /var/www/a/c , realpath /var/www/a/b but if b doesn't exist, realpath() returns false. is possible same path if directory doesn't exist yet? it's not available pre-defined function format realpath() , because it's impossible in reliable way. as example, on macos, doing ls /etc/.. , you'd think you'd directory listing of / . thing though /etc soft link /private/etc , doing ls /etc/.. gives listing of /private . this not calculated in advance if link did not yet exist, why there no function can solve in general sense without files/directories existing. in other words, you'd have write own function solve specific problem.

ios - Box2D rope, Javascript vs Objective-C -

i had question experienced fellers. i'm trying produce game move object chain hanging below it, i'm using box2dweb , easeljs html5/css , plan on wrapping phonegap once running properly. i've been testing on osx google chrome works great, , ios safari , have found running performance issue on iphone chain - having profiled it, biggest culprit. it series of 25 small bodies linked revolute joints. i've played ton of different methods (including rope joints) , way least stretch , bounce (i want rope). wondered start - know of better way produce rope box2d? , two, other reducing step iterations, reducing link bodies etc, there way without sucking performance? and main question guys know bit phonegap/js games - 25body chain @ 30fps asking of implementation? or might away it? i know as3.0 , js 'ok', think starting on in objectc/c++ turn year long project don't know first thing ask google... thanks in advance! josh i have found in our own projec

database - Mysql on delete set default -

i have 2 tables in database following schema: locations ( location_id int primary key, location varchar ) and venues ( venue_id int primary key, venue varchar, venue_location int foreign key locations(location_id) on delete cascade ) a big problem arouse when need delete location not venue. how can delete location not venue same location_id . should achieve requirement. example data: /*locations table , data*/ locations(1, "kathmandu"); locations(2, "ilam"); locations(3, "fikkal"); /*venues table , data*/ venues(1, "green view hotel , lodge", 2); venues(2, "hyatt hotel , lodge", 1); venues(3, "abc hotel", 3); how can remove location "fikkal" locations without affecting venues "abc hotel". know on delete cascade removing row venues while remove locations of same id. if removed on delete cascade mysql says fk constraint fails , obvious also. how tackle problem this. what thinking soluti

c# - How to assign values for multiple class property like a list of items using for loop? -

i wish set list of properties @ same time, possible? thanks! public class helper { public bool { get; set; } public bool b { get; set; } public bool c { get; set; } public void settofalse(list<property> abc) { // try set a, b, c false in loop foreach (var item in abc) { item = false; } } } why want this: wish have clean way toggle boolean properties @ once, while cannot group properties list because context viewmodel , properties bound xaml. i use list of rambda. public class helper { public bool { get; set; } public bool b { get; set; } public bool c { get; set; } public list<action<bool>> setters { get; set; } public helper() { this.setters = new list<action<bool>>() { b => this.a = b, b => this.b = b, b => this.c = b }; } public void settofalse(ienumerable<action<bool>> setters)

jquery - Adding legends and y-axis value on sparkline bar charts -

Image
i working on sparklines bar graph . until able draw simple bar graph, here jquery code: values = [0,8, 15, 10, 50, 25, 35, 70]; $('.sparkline').sparkline(values, { type: 'bar', height: '200px', barwidth: 20, barspacing: 10, barcolor: '#56aaff', zerocolor: '#000000', enabletagoptions: true, tagvaluesattribute: 'data-values', colormap: ["red", "green", "blue", "yellow", "orange", "#f2f2f2", "maroon", "pink"] }); html <p> <span class="sparkline">loading...</span> </p> please refer code @ jsfiddle . now want add legends name value of y-axis on each of bar shown below. sun,mon,tue legends , value on white color @ top of bars y-axis value. but not able achieve it. any appreciated. the more pointing sparkline's faq: http://omnipotent.net/jquery.sparkline/#s-faq

c# - Compile to Library other than DLL -

here 1 question asked compile intermediate type the problem solved of adding dll exe. problem: next problem is, these libraries big in size don't think feasible so. in project few methods of dlls being used. question: there alternative present not passing dll end user , not merging dll exe, compile intermediate file type can used in other project , parts(functions) compiled exe needed(used). there no built in mechanism in .net. you 1 of following: if these own dlls, split them. if not, ask producer of dlls compile smaller files functionality. if license permits, decompile them , split yourself. rewrite part need.

entity framework - How to couple 2 objects using the highest row version of one of the objects -

i having @ entity framework , wondering how join 2 objects 1 object contains row version column. for example public class product { [key, column(order = 1)] public guid productguid {get;set;} [key, column(order = 2)] public int rowversion {get;set;} public string displayname {get;set;} // ... more properties ... } public class deviceconfiguration { [key] public product theproduct {get;set;} [key] public string workstationname {get;set;} public string configurationstring {get;set;} } how can deviceconfiguration pick product row highest value of rowversion ? from described, have database , develop application using database. here's excellent resource working ef covers scenario facing: creating entity framework data model asp.net mvc application (1 of 10) take @ entity framework development approaches sub-chapter, you'll interested know more details the: database first if have database, entity fr

knockout.js - How to know whether the observable update/change is from View or Manual update - knockoutjs -

is there way know whether ko observable updated/changed view action [click, select, focus....] or observable updated manually. for example, <div data-bind="hasfocus: hasfocus" /> var vm = {hasfocus: ko.observable(true)}; ko.applybindings(vm); vm.hasfocus(false); in this, how know hasfocus updated view or vm vm.hasfocus(false); thanks in advance.

mime types - Python, trying to get file extension via URL -

i'm making image grabber puush service; however, whenever generate random url , attempt verify .png image, error generated. took python language earlier today, i'm new this! the error generated: traceback (most recent call last): file "run.py", line 19, in <module> extension = guess_extension(guess_type(url)) file "c:\python33\lib\mimetypes.py", line 320, in guess_extension return _db.guess_extension(type, strict) file "c:\python33\lib\mimetypes.py", line 189, in guess_extension extensions = self.guess_all_extensions(type, strict) file "c:\python33\lib\mimetypes.py", line 168, in guess_all_extensions type = type.lower() attributeerror: 'tuple' object has no attribute 'lower' the code ran: #!/usr/bin/env python import sys import urllib mimetypes import guess_type, guess_extension random import choice randoms = ['a', 'b', 'c', 'd', 'e', 'f

sql server - How to Concat String in SQL WHERE clause -

i have declared 2 variables in raw sql declare @str nvarchar(max), @str1 nvarchar (max); set @str = " , (c.bondsales_confirmed <> -1)"; set @str1 = " , (c.bondsales_issuetype = 'regular')"; my sql query is: select * t_bondsales (bondsales_ctype <> 'institute') " + str1 + str " here following error: error: sql problems: incorrect syntax near "+ str1 + str" can 1 please me proper syntax how concat string in clause? try 1 - declare @str nvarchar(max) , @str1 nvarchar (max); select @str = ' , c.bondsales_confirmed != -1' , @str1 = ' , c.bondsales_issuetype = ''regular'''; declare @sql nvarchar(max) select @sql = ' select * t_bondsales bondsales_ctype != ''institute''' + @str + @str1 print @sql exec sys.sp_executesql @sql

cocoa touch - Getting CCTouch points when user clicks on an Item -

Image
here main screen, when user clicks anywhere on screen go cctouchbegan method, far good. want when user clicks on youtube image or other image should able tell getting position , comparing cctouch values passed in cctouchbegan event. how can that? how can position of every element on screen , compare current touching point? you point user touched @ , check if point falls within bounding box of of buttons the basic idea: cocos2d::ccpoint p = ptouch->getlocation(); cocos2d::ccrect rect = this->boundingbox(); if(rect.containspoint(p)){ return true; }

java - JBossESB - queue to service mapping -

i intercepting messages sent through jbossesb. using pipeline interceptors so. the problem is, altough sender service (for example portreference < logical:blueserviceesb#bluelistener > ), name of receiver queue (not service). logical because in case, multiple services can receive messages given queue, usually, each queue mapped 1 service. i know queue mapped service, can display/save information , have displayed message: service ---> service (not service ---> queue). i know can name of queue mapped service using registry this: system.setproperty("javax.xml.registry.connectionfactoryclass", "org.apache.ws.scout.registry.connectionfactoryimpl"); // retrieving information esb registry registry reg = registryfactory.getregistry(); system.out.println(reg.findallservices()); list<epr> eprs = reg.findeprs("firstserviceesb", "simplelistener"); system.out.println(eprs); i reverse approach - queue input , service (epr = en

Using Java Profiler (VisualVM) with Oracle Application Server (OAS) -

i need optimize jsf application. it's running on localhost oracle application server 10g (oas). i use visualvm profile said application couldn't detect instance of oas. do have links or tutorials on how connect visualvm oas 10g? alternativly can try netbeans profiler. can profile web/standalone applications using netbeans profiler. we uning netbeans profiler profiling in our applications. nice tool profiling java applications. check out. https://profiler.netbeans.org/ http://wiki.netbeans.org/faqprofilerattachremoteserver

Leaflet zoom out when no tiles -

i have offline map leaflet. due reason of minimal weight in megabytes map has 2 sectors: first sector has zooms 11th 14th. second sector has zooms 11th 17th. i need when user see map in first sector , want zoom in more 14th zoom map not allow , automatically zoom out 14th zoom. and when user want zoom second sector - it's work 17th zoom. i use code: var layer1 = new l.tilelayer('map/all/{z}/{x}/{y}.png', { minzoom: 11, maxzoom: 14, errortileurl:'empty.png', opacity:1}); var layer2 = new l.tilelayer('map/center/{z}/{x}/{y}.png', { minzoom: 15, maxzoom: 17,errortileurl:'empty.png', opacity:1}); var map = new l.map('map', { center: new l.latlng(55.74178084263216, 37.607244264547475), zoom: 11, minzoom: 11, maxzoom: 17, layers: [layer1,layer2] }); you can catch event when map's zoom level changes, , make appropriate decisions here based on 1 of sectors showing. i'm not sure how y

executorservice - How to catch RejectedExecutionException when using Scala futures? -

where should catch rejectedexecutionexceptions when shutting down executor ? tried: future { option(reader.readline) } oncomplete { case success(v) => case failure(e) => e match { case ree: rejectedexecutionexception => // doesn't work } and : try { future { option(reader.readline) } oncomplete { ... } } catch { case ree: rejectedexecutionexception => // doesn't work } also doesn't work. still getting : exception in thread "pool-99-thread-1" java.util.concurrent.rejectedexecutionexception @ java.util.concurrent.threadpoolexecutor$abortpolicy.rejectedexecution(threadpoolexecutor.java:1768) @ java.util.concurrent.threadpoolexecutor.reject(threadpoolexecutor.java:767) @ java.util.concurrent.threadpoolexecutor.execute(threadpoolexecutor.java:658) @ scala.concurrent.impl.executioncontextimpl.execute(executionconte

How to stop message subscribe using NFC in windows phone? -

i have 4 pages in application. first page log in page here no use nfc read or write. , second page use both read , write actions of nfc. finally close second page , navigate first page. and use nfc card in first page reads nfc card , display contents of nfc card.but don't wrote code nfc actions in first page , use stopsubscribemessage() , it's not working. private void stopsubscribemessage() { messagebox.show(subscribedmessageid.tostring()); if (subscribedmessageid != -1 && new_device != null) { messagebox.show(subscribedmessageid.tostring()+" stop method"); new_device.stopsubscribingformessage(subscribedmessageid); subscribedmessageid = -1; } }

c# - dropdown_SelectedIndexChanged works second time only -

here trying populate dropdown list based on selected value dropdown list. here code both: <div> <asp:dropdownlist id="dropdownlist1" runat="server" autopostback="true" onselectedindexchanged="dropdownlist1_selectedindexchanged"> </asp:dropdownlist> <asp:dropdownlist id="dropdownlist2" runat="server" autopostback="true"> </asp:dropdownlist> </div> </form> and here code-behind: protected void page_load(object sender, eventargs e) { if (!ispostback) { getdeveloperid(); } } public void getprojectid() { string projname, projid, projfinal; using (var cmdscope_id = new sqlcommand("select [projectid],[projectname] [db].[dbo].[sample table]", con)) { using (var reader = cmdscope_id.executereader()) { while (reader.read())

windows - Understanding SystemParametersInfo SPI_SETFOREGROUNDLOCKTIMEOUT -

my app needs focus when get's called external tool (via api), know default is, should flash in taskbar, in case absolutely not behaviour want. in case try focus "this.activate()" (c#). this foregroundlocktimeout comes play. however, got little problem understanding systemparameterinfo spi_setforegroundlocktimeout. i know it's used set foregroundlocktimeout defines how long app has wait until gets focus requested. (for further information variable "val" intptr set 0) systemparametersinfo(spi_setforegroundlocktimeout,0,val,spif_sendwininichange + spif_updateinifile); this 1 change registry key that handles timeout (hkey_current_user\control panel\desktop\foregroundlocktimout) since change behaviour of apps, it's last resort use. now thought if don't update registry key. tried this: systemparametersinfo(spi_setforegroundlocktimeout, 0, val, 0); however doesn't change behavior of app in way, systemparametersinfo(spi_setforegroun

libraries - Only one file with GIT submodules -

from sorry if have spelling errors, english not good. my problem/question easy: i using git manage versions, , have use third-party libraries, gmaps.js example. for example, if use: $ git submodule add git://github.com/hpneo/gmaps.git webroot/javascripts in folder javascripts have files repository. i need add 1 file: gmaps.js root of remote repository. , want update submodule, in fact want update file. thank guys!

JSP: How to create number of rows in the table at run time -

how create table in jsp using data comes @ run time? trying create 1 table in jsp in want display data db table row. i want take 4 columns of db table , want display values rows jsp table , @ end of jsp table want add 1 column contain button if user clicks on whole data of particular record should displayed on other jsp page.is there simple way how can create dynamic table. there 2 options you can use scriptlets "<% javacode %>" html combination - not reccommend use jstl - keep jsp code clean can pass list of objects hibernate fetch jstl c:foreach tag. see here example

javascript - Showing forex rates with Shield UI Chart -

i want use shield ui chart access , visualize forex data. have figured out how ajax stuff: $.ajax({ url: 'http://api.apirates.com/jsonp/update', datatype: 'jsonp', success: function (data) { } ) however can’t figure out how extract desired currency rates data retrieved. the available rates returned key indexed array. can retrieved in way similar this: data.ticks.eurusd, and contain 1 values, returned each ajax call. can further assign many of exchange rates arrays, , pass them chart. need declare arrays: var eurusd = new array(); , pass chart: dataseries: [ { seriestype: 'line', collectionalias: 'eur/usd', data: eurusd, } ]

ubuntu - forkpty fails for jailed linux user -

i have ubuntu 12.04 setup on server. every registered user registered linux user & jailed limited system resource access through /etc/security/limits.conf . i tried running server 1 of registered users. app nodejs app - http://github.com/pocha/terminal-codelearn . uses https://github.com/chjj/pty.js create pseudo terminal every user comes nodejs app. the app fails 'forkpty(3) failed' error pointed line 184 of https://github.com/chjj/pty.js/blob/65dd89fd8f87de914ff1814362918d7bd87c9cbf/src/unix/pty.cc pid_t pid = pty_forkpty(&master, name, null, &winp); if (pid) { (i = 0; < argl; i++) free(argv[i]); delete[] argv; (i = 0; < envc; i++) free(env[i]); delete[] env; free(cwd); } switch (pid) { case -1: return throwexception(exception::error( string::new("forkpty(3) failed."))); i able deploy app on http://nitrous.io . have similar way jail user. tried running ulimits -a & matched every value except pending sign

ruby on rails - Why do I get an error installing Nokogiri on Ubuntu ec2? -

i'm trying use bundle install , gets stuck installing nokogiri. says: error: error installing nokogiri: nokogiri requires ruby version >= 1.9.2. but, when try ruby -v , says: ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux] what problem here? the new 1.6.0 doesn't seem compatible. used old 1.5.10 , works. thanks.

c# - Exception in ReverseGeocodeQuery -

i'm using reversegeocodequery retrieve addresses of many locations. problem i'm getting exceptiona result, following message: exception hresult: 0x80041b57 having reversegeocodequery class reference in msdn, can see listed in possible error results symbolic code of eerrorindexfailure . however, doesn't give me more information error, , stacktrace null too. my code folloing: foreach (var ev in events) { reversegeocodequery query = new reversegeocodequery(); query.geocoordinate = ev.location; query.querycompleted += (s, e)=> { if (e.error != null) return; ev.city = e.result[0].information.address.city; }; query.queryasync(); } why getting error, , how make work? apparently, api little limited , not possible make multiple reversegeocodequery calls simultaneously. in order make them one-by-one following async/await pattern, have implemented extension method: public static task<t> ex

php - Nested dropdown with dynamic data -

Image
i want create drop down list showing data 2 tables. have category table , sub_category table. have written following code, showing me items category table, , blank space after each category. want in drop down list. i have written following code, it's not giving me required output. kindly check it. <?php include 'connect.php'; echo "<select name='category'>"; $select_query= 'select * category'; $select_query_run = mysql_query($select_query); $sub_category_query="select * sub_categories id='".$select_query_array['category_id']."'"; $sub_category_query="select * sub_categories "; $sub_query_run= mysql_query($sub_category_query); while ($select_query_array= mysql_fetch_array($select_query_run) ) { echo "<optgroup label='".$select_query_array['name']."' >". // $sub_category_query

javascript - want to display one specific row with one radio button select and hiding otherone -

here have 2 radio buttons,what want if select radio button student class row should visible else profession row visible. @ time 1 row visible. <tr><td>member</td> <td><input type="radio" name="member" value="student" onclick = "select_mem()">student<br></td> <td><input type="radio" name="member" value="parent" onclick = "select_mem()">parent<br></td></tr> <tr><td>class</td> <td><select name="class" style="width:50px" > <option value="1">i</option> <option value="2">ii</option> <option value="3">iii</option> <option value="4">iv</option> <option value="5">v</option></select></td></tr> <tr><td>

Access - Linked Excel Sheet query -

Image
i working on database bring number of excel sheets together. have created link between ones in need , set relationships in access. i have first-year degree experience of microsoft software packages. not going move excel access other team members more comfortable using it. running things reports, creating forms , querying data can easier in access. the problem: i trying query data linked spreadsheet , works , doesn't. more none queries return blank when know shouldn't. is table being linked , not access table? please see example query have set up thank in advance. if assume status on date field criteria treating text, , expression: like "*/*/2013" may cause unexpected return results, depending particularly on default date format of excel. use criteria: year([status on])=2013 which more reliable, not depending on formatting of date, purely on fact recognisable date. i don't have issues linking excel files unless: the file ope

javascript - Difference between JSON.stringify and JSON.parse -

i have been confused on when use these 2 parsing methods. after echo json_encoded data , retrieve via ajax, run confusion when should use json.stringify , json.parse . i [object,object] in console.log when parsed , javascript object when stringified. $.ajax({ url: "demo_test.txt", success: function(data) { console.log(json.stringify(data)) /* or */ console.log(json.parse(data)) //this unsure about? } }); json.stringify turns javascript object json text , stores json text in string. json.parse turns string of json text javascript object.

html - setting up __DIR__ path in php -

here is output of directory path echo(__dir__); /users/tsrinivas/www/album/module/photos/view/photos/photos but want point 4 directories before,output should like. /users/tsrinivas/www/album/public/images/upload/ how achieve this? you can traverse directory tree using .. down 5 blocks , add rest of path $path = __dir__ . "../../../../../public/images/upload/"; or place __dir__ in file located in /users/tsrinivas/www/album/public/images/upload/