Posts

Showing posts from March, 2013

NHibernate GetNamedQuery can not execute stored procedure -

so have stored procedure named get_by_cat_and_tag , should return table ms , , in c# code should return list of ms objects, ms.hbm.xml contains following: <sql-query name="get_by_cat_and_tag"> <!-- return type must nhibernate mapped entity --> <return class="ms"> <return-property column="id" name="id" /> <return-property column="filename" name="filename" /> <return-property column="displaytitle" name="displaytitle" /> <return-property column="isenabled" name="isenabled" /> <return-property column="mediatype" name="mediatype" /> <return-property column="priority" name="priority" /> <return-property column="datecreated" name="datecreated" /> <return-property column="datelastmodified" name="

java - How do I output the location using gps on Android -

i trying output location textview. have used locationmanager.tostring(), give me output android.location.locationmanager@44ee7718. output location los angeles, ca 90501. the code locationmanager: locationmanager lm = (locationmanager) this.getsystemservice(context.location_service); //conversion criteria criteria = new criteria(); string bp = lm.getbestprovider(criteria, false); location location = lm.getlastknownlocation(bp); double lat = location.getlatitude(); double lon = location.getlongitude(); geocoder gc = new geocoder(this, locale.getdefault()); list<address> addresses = null; try{ addresses = gc.getfromlocation(lat, lon, 1); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } address address = addresses.get(0); final string ad = address.getaddressline(0); //ends here the code button: red.setonclicklistener(new view.onclickli

paypal - Cannot load "My Selling Tools" in a sandbox environment -

i've seen other postings people can't load "my selling tools" , happen in same boat. support hasn't responded yet , i'm hoping demo monday of windows 8/paypal api integration http://paypal.github.io/windows8sdk/ winrt apps - hence turning may favorite net community, stack overflow :) the link above gives sandbox account allow third party access, trying add account allow third party access can't bring selling tools so. able bring selling tools main login, not within sandbox login. once login sandbox environment , try access "my selling tools" hangs. browser doesn't matter, same result across browsers. nothing returned wait image. on left hand side hangs not selling tools. i've tried more ten times throughout day. of course, hope here paypal technical team replies. i can't wait hour on hold, can't. i'll make sure gets escalated. workaround, can log in sandbox account , paste url in browser: https://www.s

python - calling a second function within another function -

i open file using a_reader function. use second function print file. want because able call open file function later without printing it. ideas on best way this? here sample code know not work may explain want do def main (): a_reader = open ('c:\users\filexxx.csv','r') filename = a_reader.read() a_reader.close() def print(): print filename main() print() please see day old thread: what pythonic way avoid reference before assignment errors in enclosing scopes? the user in post had exact same issue, wanted define function within function (in case main ) adviced both me , others don't nest functions! there's no need use nested functions in python, adds useless complexity doesn't give real practical advantages. i do: def main (): a_reader = open ('c:\\users\\filexxx.csv','r') filename = a_reader.read() a_reader.close() return filename print(main

osx - User Switch Notification by Carbon in Objective C -

following codes https://developer.apple.com/library/mac/#documentation/macosx/conceptual/bpmultipleusers/concepts/userswitchnotifications.html#//apple_ref/doc/uid/20002210-cjbjdagf demonstrates how aware of user switch event . can't use code user switch purpose ,and doesn't work me. how use code notified when user switch occurs? pascal osstatus switcheventshandler (eventhandlercallref nexthandler, eventref switchevent, void* userdata) { if (geteventkind(switchevent)== keventsystemusersessiondeactivated) { // perform deactivation tasks here. } else { // perform activation tasks here. } return noerr; } void switcheventsregister() { eventtypespec switcheventtypes[2]; eventhandlerupp switcheventhandler; switcheventtypes[0].eventclass = keventclasssystem; switcheventtypes[0].eventkind = keventsystemusersessiondeactivated; switche

Trying to create an all-day event using Google Calendar API v3 for Java causes an error -

i can create timed event using java v3 google calendar api (as per sample code on google's website), need create all-day event. i call event's setstart() , setend(), i.e. event.setstart(starteventdatetime); event.setend(endeventdatetime); these methods require , eventdatetime, i.e. eventdatetime starteventdatetime = new eventdatetime().setdatetime(startdatetime); eventdatetime endeventdatetime = new eventdatetime().setdatetime(enddatetime); i use setdatetime() methods setdate() causes 404 error. setdatetime() requires com.google.api.client.util.datetime object, doing datetime startdatetime = new datetime(startdate, timezone.gettimezone("utc")); datetime enddatetime = new datetime(enddate, timezone.gettimezone("utc")); passing in timezone gives time element it's not day event. i've tried setting dateonly true gives error: datetime startdatetime = new datetime(true, startdate.gettime(), 0); i can&#

jquery - Ajax Returns errorError: Access is denied on IE -

my following code works great on firefox , chrome, shows error-error: access denied on ie, can me please. on firefox returns success status , same success status on chrome not sure why doesnt work on ie 9.0 <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <meta charset=utf-8 /> <title>js bin</title> <script type="text/javascript"> $(document).ready(function () { $.support.cors = true; $('#time').html(new date()); $('#status').html(''); $('#content').html(''); $.ajax({ cache: false, url: $('#xhr_url').val() }).done(function (data, textstatus, jqxhr) { $('#status').html(textstatus+jqxhr); $.each(data.t2json.printermanufacturers.items, function (i, item) { $("#content").append('<a class="manufacturer" id="' + item.id + '&quo

Qt, QTextEdit, how to turn all the content in QTextEdit into a image. -

i want creat image contain qtextedit. , write following code create image. qsize s = textedit->framesize(); qpixmap p(s); textedit->render(&p); p.save("textcontent.png", "png"); but can not contain invisible contents.(while contents long in qtextedit) i wander if there way create image contain content in qtexteidt. , how. thanks. i think, can via qtextdocument * qtextedit::document () receive qtextdocument * of qtextedit, , draw qimage via void qtextdocument::drawcontents ( qpainter * p, const qrectf & rect = qrectf() ) it draws content of document painter p, clipped rect. if rect null rectangle (default) document painted unclipped. check man here - http://harmattan-dev.nokia.com/docs/library/html/qt4/qtextdocument.html#drawcontents or - other way - take text textedit via toplainhtml() or toplaintext() - what's more suitable needs , draw qimage via qpainter's method qpainter::drawtext()

mysql - Designing my first database schema: suggestion needed -

Image
this first database schema design. trying develop small web application department used food cost management. , doing learning purpose. how food cost management works in department: total members: 15 one admin keep record of cost. update database on daily basis. each member can order once day. if has guest on specific day can order multiple number of meal. usually members pay bill week or 2 in advance. one or 2 persons responsible bringing food outside , don't need pay lunch. transportation cost given them. food cost+ transportation cost distributed equally other 15 members expenses. database queries: from admin perspective: he manage/add daily order. (table: orders) he add payments members credited against respective member's "balance" (table: payments) he able see overview of members' order/cost history , current balance in chart 1 month @ time. if member has negative balance or less specific amount of money, notified admin dashboard.

How to get the previous day records from mysql table? -

i trying fetch previous day records table not finding how exactly. need please.. table: record_data id creationdate 1 | 2013-05-03 04:03:35 | 2 | 2013-05-03 04:03:35 | now need records created on 2013-05-03. time can anything. query should have operator. i using below query , gives me empty set. select creationdate record_data creationdate date_sub(str_to_date('2012-04-05','%d/%m/%y'),interval 1 day); fairly simple when done sql, add condition where creationdate between curdate() - interval 1 day , curdate() there no need convert creationdate date :). , belive fastest way check (which matter if go on large data sets).

html - Access normal text using jquery -

i have following html code: <div class="top_l"> <a class="shou" onclick="" href="">11</a> | <img border="0" class="" src="/">xxxxxx<a href=""></a> | <a href=""></a> | <a href=""></a> </div> how text xxxxxx using jquery(what selector used)? you can select element nodes jquery. , jquery methods consider element nodes, using jquery , plain dom api might approach here. the text node want target next sibling of image. if can reference image element, can access text node .nextsibling [mdn] property: var txt = image.nextsibling.nodevalue; // or if image jquery object var txt = image.get(0).nextsibling.nodevalue; given structure of html, this: var txt = $('.top_l > img').get(0).nextsibling.nodevalue; demo

python - Attaching file to model with flask-admin -

i'm using flask-admin provide administrative interface website. how can handle file upload sqlalchemy model, such as class product(db.model): __tablename__ = 'products' id = db.column(db.integer, primary_key=true) title = db.column(db.string(5000)) text_short = db.column(db.string(3000)) text = db.column(db.string(50000)) price = db.column(db.integer) image = db.column(db.string(1000)) , image field want store path image in /static directory? override on_model_change , upload logic there: http://flask-admin.readthedocs.org/en/latest/api/mod_model/#flask.ext.admin.model.basemodelview.on_model_change so, here's high level steps: either contribute filefield form, or change type of image field filefield in on_model_change copy uploaded file static folder , update model image field new file path hope helps.

java - Using Primefaces FileUpload with jQuery Mobile p:fileupload not rendered? -

what try: want upload pictures primefaces fileupload tag in jsf page jquery mobile. side available on desktopbrowser should have other pages. problem: when add stylesheet jquery mobile , script - whole form won't rendered/isn't visible. know how can fix this? header: <link rel="stylesheet" href="./jquery/jquery.mobile-1.3.1.min.css" /> <script type="text/javascript" src="./jquery/jquery.js"></script> <script type="text/javascript" src="./jquery/jquery.mobile-1.3.1.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="apple-mobile-web-app-capable" content="yes"/> content area jquery mobile <div id="content" data-role="content"> <h:form enctype="multipart/form-data"> <p:fileupload

c - convert IP for reverse ip lookup -

i have ip address e.g. char *ip = "192.168.1.13" , need convert "13.1.168.192" there proper possibility in c or have myself making tokens , putting them again? you use inet_pton convert binary form, making easy reverse, , convert text inet_ntop . remember ipv4 address 32-bit unsigned integer. swapping bytes around of easy. something this: const char ip[] = "192.168.0.1"; char reversed_ip[inet_addrstrlen]; in_addr_t addr; /* textual address binary format */ inet_pton(af_inet, ip, &addr); /* reverse bytes in binary address */ addr = ((addr & 0xff000000) >> 24) | ((addr & 0x00ff0000) >> 8) | ((addr & 0x0000ff00) << 8) | ((addr & 0x000000ff) << 24); /* , lastly textual representation again */ inet_ntop(af_inet, &addr, reversed_ip, sizeof(reversed_ip)); after code, variable reversed_ip contains revered address string.

c# - How to secure Web services in ASMX file? -

i have critical db connection done through web service .asmx file accessible , can open through direct browse through browser how prevent methods , allow methods access general unauthenticated users? this problem severe application. one common method use access token in web service calls. scenario this: user calls "login" web service method, passing credentials. (this should on secure connection, might want require ssl this, if don't of them.) the "login" web service method authenticates user, generates access token (a guid works nicely), stores access token (perhaps window of time token usable), , returns token user in response. all subsequent web service methods (everything needs secured) requires access token provided method argument. user passes access token in of calls. each time web service method called, system validates access token against known generated tokens (accounting window of time, if want tokens expire, recommend) and,

jquery - KendoUI Grid number column will not edit as number -

i have column called "quantity", connected field (column name) "quantity". in model have set so: ... quantity: { type: 'number', editable: true, validation: { min: 1 } } ... however, when click on cell edit it, nothing. if change type: string, works fine. number can use number rollers. how can work? the information shared not show issue comes from, missing something. check jsbin - same , works expected, try edit id field of type number . schema: { model: { id: "id", fields: { id: { type: "number" }, name: { type: "string" }, position: { type: "number" } } } }

.net - Need some advice about the correct way to write own httpclient interface -

i want create wpf application connect web api server. i'm newbie in wpf. more worse,even in .net. actually, things work, follow http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-wpf-application . after more search,i found totally work on wrong way(winform way).and seems should use mvvm style communites said. decide rewrite code. i use prism create module, , bind name , password viewmodel class. can name , password textbox. first, failed create httpclient instance every viewmodel use. below problem links hot register constructed instance in unity? so deicide write this. first create interface. public interface idata { ienumerable<device> getdevicesbyuser(user user); ienumerable<user> getusers(); currentuser getcurrentuserinfo(); } and implement interface public class httpservice : idata { httpclient client = new httpclient(); public httpservice() { client.baseaddress = new uri("https://

php - Input crash on read slashes -

i'm getting problem saving input db. i save string db as: mysql_real_escape_string($my_string) then, read , place string input using this: stripslashes($my_string) the point is, if set double slashes string, inputs crash this: <input maxlength = "150" type="text" name = "my_string12" value = "hello "this is" test" class="input-medium"/> thanks. if value php variable have trim .. use trim function: $str = 'hello "this is" test'; echo trim($str, '"'); // hello test answered paul @ here

How to recognize string in Lex file -

hi appropriate recognize string in lex. i have tried enter code here import java_cup.runtime.*; %% %cup %line num = [0-9] id = [a-za-z] pun= [:=;#@$^~] whitespace = [ \t\r\n\f] sdquo = [\"] %% ({sdquo}+) ({id}|{num})* ({sdquo}+) { return new symbol(sym.str, new string(yytext()));} but macro fail recognized. error message kept getting is: processing first section -- user code. processing second section -- jlex declarations. processing third section -- lexical rules. creating nfa machine representation. error: parse error @ line 39. description: missing brace @ start of lexical action. parse error. loose = signs in definitions of num etc. , don't place them between %% . instead place last rule between %% .

c# - MonoTouch - Add UIActionSheet to Top Navigation Bar of my ViewController -

i've got following uiactionsheet. how add top navigation bar? preferably far right button. var sheet = new uiactionsheet (""); sheet.addbutton ("discard picture"); sheet.addbutton ("pick new picture"); sheet.addbutton ("cancel"); sheet.cancelbuttonindex = 2; // dummy buttons preserve space uiimageview (int = 0; < 4; i++) { sheet.addbutton(""); sheet.subviews[i+4].alpha = 0; // , of course it's better hide them } var subview = new uiimageview(); subview.contentmode = uiviewcontentmode.scaleaspectfill; subview.frame = new rectanglef(23,185,275,210); // late steve jobs loved rounded corners. let's have respect him subview.layer.cornerradius = 10; subview.layer.maskstobounds = true; subview.layer.bordercolor = uicolor.

C# folderBrowserDialog + openFileDialog Hiding path on checkedListBox -

i have checkedlistbox; wich loads files inside folder; run/open when checked. i'm trying achieve load files inside listbox; without path. i.e: "c:\folder1\anotherfolder\myfile1.txt" in other words; want shown: filename (with or without extention). i.e: "myfile1.txt" the code i'm using: //... private string openfilename, foldername; private bool fileopened = false; //... openfiledialog ofd = new openfiledialog(); folderbrowserdialog fbd = new folderbrowserdialog(); if (!fileopened) { ofd.initialdirectory = fbd.selectedpath; ofd.filename = null; fbd.description = "please select *.txt folder"; fbd.rootfolder = system.environment.specialfolder.mycomputer; if (fbd.showdialog() == system.windows.forms.dialogresult.ok) { string foldername = fbd.selectedpath; foreach (string f in directory.

osx - XCode file not compiling -

i'm getting following 2 errors via xcode: warning: no rule process file '$(project_dir)/sqlite toolbox/en.lproj/mainwindowcontroller.m' of type file architecture x86_64 followed by: undefined symbols architecture x86_64: "_objc_class_$_mainwindowcontroller", referenced from: objc-class-ref in appdelegate.o ld: symbol(s) not found architecture x86_64 previously project building fine, attempted localization. had mainwindowcontroller.xib highlighted , choose localize option. after that, project stopped compiling. looks me reason xcode refusing compile mainwindowcontroller.m, i'm not sure how go fixing that. (i have confirmed exist in build phase compile source steps. any ideas on how fix this? that sounds if inadvertently have localized "mainwindowcontroller.m" file. following steps worked in test project fix situation: remove "mainwindowcontroller.m" project (using "remove reference" option!

eclipse - inserting data using variables in sqlite db -

hey i'am making first phonegap application , have faced problem in sqlite db , have had code create table in database , read need insert variable value in db instead of static value , here's code insert : tx.executesql('insert bus_stations (station_name,station_description,station_lat,station_long) values ("6th october","", + "111" + ,"31.963522")'); that works doesn't work , can ??! var x=111; tx.executesql('insert bus_stations (station_name,station_description,station_lat,station_long) values ("6th october","", x ,"31.963522")'); by placing insert single qoutes ' making everthing inside simple string or text. x inthere becomes nothing letter x. suggest split insert string , add variable in follows: var x = 111; tx.executesql('insert bus_stations station_name,station_description,station_lat,station_long) values ("6th october","",'

Opencart how to get module names? -

in content_top.php: <?php foreach ($modules $module) { ?> <?php echo $module; ?> <?php } ?> as understand it loops modules, can find modules used page, can edit view.. you have walk through installed modules in administration ( extenions -> modules ) , modules position content top displaying within template. guess there no easier way module settings stored serialized arrays (thus string) within setting db table, searching position content_top within database pretty uncomfortable.

c++ - WINAPI - error LNK2019, LNK2001, LNK1120 when compiling. -

very new winapi gentle. i have read "windows via c/c++" book jeffrey richter , i'm trying of basic dll stuff descibes in book. in chapter 19 make simple example. have tried make example, keep getting these 3 errors when building project: error 1 error lnk2019: unresolved external symbol __imp__add referenced in function _wwinmain@16 error 2 error lnk2001: unresolved external symbol __imp__g_nresult error 3 error lnk1120: 2 unresolved externals i have 3 files: dllchapter19.h : #ifdef mylibapi #else #define mylibapi extern "c" __declspec(dllimport) #endif mylibapi int g_nresult; mylibapi int add(int nleft, int nright); dllchapter19.cpp : //#include <windows.h> //apparently complier says should use stdafx.h instead(?) #include "stdafx.h" #define mylibapi extern "c" __declspec(dllexport) #include "dllchapter19.h" int g_nresult; int add(int nleft, int nright) { g_nresult = nleft + nright;

xsd - I am finding difficult to write a regular expression for a location element in xml schema -

location element needs accept "city, state" data(for exampler: topsail beach, nc), ending errors. me? here code snippet. <xs:element name="location" minoccurs="0" maxoccurs="1"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:pattern value="[a-za-z]*[ ]?[a-za-z]*,[ ]?[a-za-z]*"/> </xs:restriction> </xs:simpletype> </xs:element> regular expression string entry should in "city, state" format : [a-za-z ]*, [a-za-z]* it matches sample text provided i.e topsail beach, nc

android - Get the resource id for the drawable reference used in styled attribute -

having custom view myview define custom attributes: <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="myview"> <attr name="normalcolor" format="color"/> <attr name="backgroundbase" format="integer"/> </declare-styleable> </resources> and assign them follows in layout xml: <com.example.test.myview android:id="@+id/view1" android:text="@string/app_name" . . . app:backgroundbase="@drawable/logo1" app:normalcolor="@color/blue"/> at first thought can retrieve custom attribute backgroundbase using: typedarray = context.gettheme().obtainstyledattributes(attrs, r.styleable.myview, defstyle, 0); int base = a.getinteger(r.styleable.myview_backgroundbase, r.drawable.blank); which works when attribute not assigned , default r.dra

c# - Why can't I reach data within Method? -

i'm trying fill tablelayoutpanel through method goes follows: private int _rowcount; public void initpaths() { int c = 1; int = 1; while (a < _pathrows.length - 1) { var label = new label(); // // label - format. // label.dock = dockstyle.fill; label.autosize = false; label.text = _pfadzeilen[a]; label.textalign = system.drawing.contentalignment.middleleft; label.size = new system.drawing.size(22, 13); label.backcolor = system.drawing.color.transparent; tablelayoutp.controls.add(label, 3, c); //checkboxen einfügen var cbox = new checkbox(); // //checkbox format. cbox.anchor = system.windows.forms.anchorstyles.none; cbox.autosize = true; cbox.checkalign = system.drawing.contentalignment.middlecenter; cbox.name = "checkboxpfad" + a; cbox.size = new system.drawing.size(15, 14); cbox

linux - ImageMagick -liquid-rescale option error -

i want use seam carving, , found imagemagick maybe choice. install imagemagick source this indicate. my problem is: when type command convert logo_trimmed.jpg -liquid-rescale 75x100%\! logo_lqr.jpg gives following error: convert: delegate library support not built-in 'logo_trimmed.jpg' (lqr) @ error/resize.c/liquidrescaleimage/1900. i thought may because lack of liblqr support, go liquid rescale install it , make uninstall imagemagick , install again. however, problem remains same. can tell me how make convert -liquid-rescale works? hint. after installing liblqr , have install imagemagick running configure prior make , see build instructions here: http://www.imagemagick.org/script/install-source.php#unix if don't run configure not pick new library. and after you've compiled imagemagick check lqr delegate library installed running: convert -list configure | grep -i "delegates" and seeing lqr listed there.

where can I download an asp.net mvc4 template for xamarin studio mac osx -

i've tried uninstalling , re-installing , retried stable , beta channels mvc2 installed. would servicestack mvc option or barking wrong tree? from blog post , looks xamarin studio includes monodevelop's features + mobile development features. should able install , use mvc4 on xamarin studio. this ?

html parsing - how to get text between a specific span with HtmlUnit -

i'm new htmlunit , i'm not sure if right tool project. i'm trying parse website , extract values need it. need value "07:05" this, <span class="tim tim-dep">07:05</span> i know can use gettextcontent() extracting value don't know how can select specific span. used getelementbyid finding the <div> tag expression belongs when text content of div, whole line of text lot of unnecessary data. can tell me how can select expression, possibly using class name? you need browse page , interact it, this: final webclient web = new htmlunit(); final htmlpage page = web.getpage("http://www.whateveryouwant.com.br"); get elements tagname, , iterate on it: final list<domelement> spans = page.getelementtagname("span"); (domelement element : spans) { if (element.getattribute("class").equals("tim tim-dep")) { return element.getnodevalue(); } } or use xpath: //

Visual Studio 2012 - Values in debug watch are not displayed when compiled with /clr -

the debug watch doesn't display values objects std::vector example. on other hand, values of local integers displayed. when compile project without /clr option displayed correct. i tried different debugmodes (mixed, auto, managed...) , played around different settings jit, "enable .net framework source stepping" , symbol server. problem remained. (after each change of settings project clean/build again) //#pragma managed(push, off) int _tmain(int argc, _tchar* argv[]) { int = 5; //displayed correctly in debug watch vector<myint> vec; myint x(4); vec.push_back(x); // displayed name: "vec", value: "{...}" (no option expand it) vec.push_back(x+x); vec.push_back(std::move(x)); std::vector<int> vec2; vec2.push_back(a); return 0; } //#pragma managed(pop)

html - Favicon not showing up in Google Chrome -

this question has answer here: html favicon won't show on google chrome 10 answers i have favicon icon isn't showing in chrome (i'm not sure other browsers use chrome) strange thing if type path icon in url bar shows up! why doesn't icon appear? 1) clear cache. http://support.google.com/chrome/bin/answer.py?hl=en&answer=95582 , test browser, lets safari. how did import favicon? 2) how should add it: normal favicon: <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> png/gif favicon: <link rel="icon" type="image/gif" href="favicon.gif" /> <link rel="icon" type="image/png" href="favicon.png" /> in <head>

asp.net mvc 3 - Where clause like syntax in lambda expression -

i searched alot couldnt find right resolution problem. what i'm trying basic in sql dont know how make work in lambda expression here im trying do: filteredinorderquery = mycontext.websites.orderby(website.currentorderby + " " + website.sortorder).where( x => (website.websitefilterlist.contains(x.site.tostring())) && (website.cityfilterlist.contains(x.city.tostring())) ).select(x => new websitedata( x.rowid, x.pagetype, x.site, x.creationdate ?? datetime.today, x.expirationdate ?? datetime.today, x.domainregistrar, x.pin, x.area, x.city, ((x.expirationdate ?? datetime.today) - datetime.today).days.tostring() + " days")); websitefilterlist , cityfilterlist both can empty can contain more 1 item. point should able records if pass of list empty (if list

path - How to use pip install python packages locally like npm does -

say have project named foo , , and want install requests package locally project. expecting structure similar this: foo/ |-main.py |-requirements.txt |-readme.md |-python_modules/ |-|-requests ... and can pip install -r requirments.txt -t ./python_modules/ , however, doesn't work because there no __init__.py under python_modules/ programs won't automatically import every packages in python_modules . on other hand, npm install well. so question is, how let pip work same npm does? ps: know there other conventions using virtualenv or pythonbrew , still want ask question.

php - Not able to insert data in new column -

i have working code inserts data correctly now. trying add new column of movie_id in that. trying fetch movie id value xml , looping movie title data inserted in not correct. movie_name object has 3-4 movies names. trying add movie id that. $movie_name = $arrtitle[0]; $xml = simplexml_load_file("http://api.themoviedb.org/2.1/movie.search/en/xml/myapi/$movie_name"); foreach($xml->movies->movie $movies){ $arrmovie_id= $movies->id; } $movie_ids= $arrmovie_id[0]; $arrstr = explode(':',$htmlshowtime); $release = substr($arrstr[3],0,strlen($arrstr[3])-8); $director = substr($arrstr[5],0,strlen($arrstr[5])-11); $sql_movie = "insert jos_movie(movie_name,language,cast,movie_release,director,rating,rating_count,movie_ids)values('$movie_name','null','$cast','$release','$director',250,230,'$movie_ids')"; here full working code <?php // include handy xml

actionscript 3 - Embedded Image not Adding to Stage -

so have image i'm trying embed use sprite sheet. problem receiving no errors @ all, image can't added stage. it's nothing being loaded @ all. i using flash cs 5.5 compiler. here code: public class game extends movieclip { [embed(source='../assets/images/sprite_sheet_1.png')] private var sheetclass:class; private var sheet:bitmap = new sheetclass(); public function game() { addchild (sheet); } } i've tried fiddling x , y values make sure nothing covering , can't see problems that, either. it's not showing up. don't understand why it's not working intended. aid fantastic. thanks! p.s. - i'm trying embed sprite sheet because recommended better route using urlloaders, true? true because talking sprite sheets smallish flash game? you need check checkbox called "export swc" under publish settings. i'm not sure of exact phrasing because don't have same version of flash have. see t

android - Build Custom View with allways same Layout -

i have made own layout button. normaly create view this: layoutinflater inflater = layoutinflater.from(getactivity()); mybutton = inflater.inflate(r.layout.mybutton, null, false); now idea class mybutton extends view , not have write these lines each button. how can bring these 2 lines in mybutton constructor? can't write: public mybutton(context c) { = inflater.inflate(r.layout.mybutton, null, false); } how can build custom view has allways same layout can build new mybutton preloaded layout this: mybutton mybutton = new mybutton(); this layout want use mybutton: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/cell_shape" android:orientation="vertical" android:paddingbottom="@dimen/paddingbottom" android:paddingleft="@dimen/paddinghorizontal" android:paddingrigh

javascript - Cut a CSS transition short? -

i'm applying css transition element. target.style.transition = "color 10000ms ease"; target.style.color = "red"; under circumstances, want end state of transition reached immediately, without waiting transition finish. if try target.style.transition = "color 0ms"; target.style.color = "red"; the current transition continues. doing target.style.transition = "color 0ms"; target.style.color = "blue"; sets 'blue' immediately, while target.style.transition = "color 0ms"; target.style.color = "blue"; target.style.color = "red"; results in continuation of transition. (tried in both chrome , ff) is there way stop transition? to stop transition , reach end state immediately, use target.style.transition = "none"; see demo .

asp.net - incorrect syntax near nvarchar in gridview -

i have problem updating column of gridview; when try update field error: incorrect syntax near 'nvarchar'. must declare scalar variable "@pid". here piece of code: <asp:gridview id="gridview1" runat="server" name="gd" height="100px" width="435px" autogeneratecolumns="false" datakeynames="pid" datasourceid="sqldatasource1" > <columns> <asp:commandfield showeditbutton="true" showselectbutton="true" /> <asp:boundfield datafield="pid" headertext="pid" sortexpression="pid" readonly="true" /> <asp:boundfield datafield="name" headertext="name" sortexpression="name" /> <asp:boundfield datafield="hoghoghe rozane" headertext="hoghoghe rozane"

python - Is PyBluez alive? -

the pybluez project seems canonical project doing bluetooth in python (please correct me if i'm wrong). however, last version 0.18 nov 2009). issues (currently, i'm annoyed issue 43: no support python 2.7) aren't being fixed. i see activity though, wonder state. pybluez canonical way bluetooth? there alternative pybluez? (i'm alost missing bluesoleil stack support). there new version of pybluez 0.20 works python 2.7 , 3.3 https://code.google.com/p/pybluez/downloads/list

java - Calculating percentage of a map values -

made program counts number of occurrences of letters in given string using treemap(string, integer) (named alphafreq). want represent these occurrences percentages ([a=12.3] , [b=3.0] , ....etc), created treemap (string, double) (named percentage), copied keys values set zero, , edited value according in alphafreq follows: for(int i=0; i<26; i++){ int temp; character current = (char)(i+65); string frog = current.tostring(); temp = alphafreq.get(frog); int perc = (temp/cipherletters.length)*100; system.out.println(temp+"/"+cipherletters.length+" = "+perc); percentage.put(frog,(double)perc); } if string or bs, result keys have value of 0 except a=100.0 or b=100.0 if string text has other combination (say: ddjjshhiem) have value of zero. why? doing wrong?................thanks first thing change calculation of percentage to: int perc = (temp * 100)/cipherletters.length; given using integer division, ( temp / cipherletters

bash - Why isn't stdout set after executing a child process in a node.js script that's running as a daemon? -

this works expected if run command line (node index.js). when execute node.js (v0.10.4) script daemon init.d script stdout return value in exec callback not set. how fix this? node.js script: var exec = require('child_process').exec; setinterval(function() { exec('get_switch_state', function(err, stdout, stderr) { if(stdout == "on") { // something. } }); }, 5000); init.d script: #!/bin/bash node=/development/nvm/v0.10.4/bin/node server_js_file=/home/blahname/app/index.js user=root out=/home/pi/nodejs.log case "$1" in start) echo "starting node: $node $server_js_file" sudo -u $user $node $server_js_file > $out 2>$out & ;; stop) killall $node ;; *) echo "usage: $0 (start|stop)" esac exit 0 i ended not using node.js exec child_process. modified init.d script above (/etc/init.d/node-app.sh) follows: #!/bin/bash node=/home/pi/developmen

php mysql compare dates and match with user input dates -

this question has answer here: determine whether 2 date ranges overlap 30 answers i doing booking page house renting. i have datepicker users submits unix datetime: arrival , departure date. on mysql have house different seasons "season_start" date (yyyy-mm-dd), "season_end" date & "price per day". $seasons_select="select id,season_start,season_end,daily_price ".t_item_seasons." id_item=".id_item." order season_start "; $res_seasons=mysql_query($seasons_select) or die("error getting states"); $arrival_date = date('d-m-y', $arrival_date); $departure_date = date('d-m-y', $departure_date); while ($seasons_row=mysql_fetch_assoc($res_seasons)){ $start_date = date('d-m-y', strtotime($seasons_row["season_start"])); $end_date = date('d-m-y', strtotime

android - Fit just taken photo into imagebutton -

i have imagebutton, when press can take picture phone. when take picture imagebuttons gets picture source. problem is, image doesn't scale down dimensions of imagebutton. shows part of image in imagebutton instead of scaling down. after doing bit of research saw have use draw 9 patch. not possible in case, because image aren't in resources, made user itself. can me this? my code: if (requestcode == request_camera) { file f = new file(environment.getexternalstoragedirectory().tostring()); (file temp : f.listfiles()) { if (temp.getname().equals("temp.jpg")) { f = temp; break; } } try { bitmap bm; bitmapfactory.options btmapoptions = new bitmapfactory.options(); bm = bitmapfactory.decodefile(f.getabsolutepath(),btmapoptions); // bm = bitmap.createscaledbitmap(bm, 70, 70, true); btnimg.setimagebitmap(bm); string path = android.os.environment.getexternalstorag

php - html form inputs are not saved in MySQL -

i have username/password <form> , if false, display invalid users , if true display <textarea> , users can comment submit. basically, code below, then statement if login correct then.. session_start(); $_session['name'] = $name; echo "success, hi $name"; echo "<table> <tr><td>insert comment here</td><td>poster</td> <tr><td><form action='post.php' method='post'><textarea name='content'></textarea> </td> <td> $name</td> </tr> <input type='submit' name='submit' value='submit'> </form> </table>"; in relation <form> above, created post.php parse data coming <form> , insert database. <?php mysql_connect("localhost","root","") or die (mysql_error

libreoffice - How can I find a text in a spreadsheet using OObasic? -

on openoffice documentation [1], found replace example. didn't find search example. dim doc object dim sheet object dim replacedescriptor object dim integer doc = thiscomponent sheet = doc.sheets(0) replacedescriptor = sheet.createreplacedescriptor() replacedescriptor.searchstring = "is" replacedescriptor.replacestring = "was" = 0 doc.sheets.count - 1 sheet = doc.sheets(i) sheet.replaceall(replacedescriptor) next and better: can find docs list range/cell possible methods? [1] http://wiki.openoffice.org/wiki/documentation/basic_guide/editing_spreadsheet_documents first of all: https://wiki.openoffice.org/wiki/extensions_development_basic starting point. in particular xray tool helpfully. the following code shows search example: dim odoc object dim osheet object dim osearchdescriptor object dim integer odoc = thiscomponent osheet = odoc.sheets(0) osearchdescriptor = osheet.createsearchdescriptor() osearchdescriptor.searchstring

c++ - sort one vector in a class and the second vector should move with the first -

i want sort vector<vector<double> > , record original index vector<int> ex a[0][1].............[n], , a[0][0] = x, a[0][1] = y, a[0][2] = z a[0] = (1,5,3), a[1] = (3,2,1) a[2] = (2,8,4) after sorting index: 0 1 2 a[0] = (1,5,3), a[1] = (2,8,4) a[2] = (3,2,1) original index : 0 2 1 so write following code, , want use stl sort, don't know how write compare function. class point{ public: point(int totallength = 0, int elementlength = 0); vector<vector<double> > pointset; vector<double> pointindex; }; point::point(int totallength, int elementlength){ pointset.resize(totallength,vector<double>(elementlength, 0)); pointindex.resize(elementlength); } and suggestion or other way achieve it? thank reading. the first thing i'm talking introducing separate data structure points. usually, wh