Posts

Showing posts from May, 2011

jquery - How to prevent CakePHP 3.0 from extending session timeout with ajax requests? -

how can prevent cakephp 3.x extending users session when background ajax calls made server? using jquery's $.ajax() well. i have setinterval running once minute user notifications. application ehr , need maintain strict session timeout. notifications javascript made sessions unlimited because ajax calls extending sessions. i thought saw in cakephp book few weeks ago can't seem find today. thanks, daren generally need handle on own, ie implement own timeout mechanism. how handle it, depends. you want exclude ajax background activity only, need have access request object, , want handle possible. given prerequisites, i'd use dispatcher filter, can extend timeout depending on whether or not current request ajax request, , destroy session before controllers involved. here's basic, pretty self-explantory example, assumes timeout option value set session configuration . src/routing/filter/sessiontimeoutfilter.php namespace app\routing\filter; use c

java - Calculator in Android Studio -

i have been trying build simple calculator in android studio.i beginner , have basic knowledge of java.i trying accept values in single text field instead of using 2 different text field.i have used on click listener on operator buttons , inside on equals button.but application closes click on operator buttons.how can use single text view 2 accept 2 numbers or more , apply mathematical operator on them? edit:as have stated have little knowledge of java.i did google search before posting question. add.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { n.settext(""); final float = float.parsefloat(n.gettext().tostring()); n.settext(""); equals.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { float b = float.parsefloat(n.gettext().tostring());

html - why do inputs created by javascript appear outside their divs? -

why inputs created javascript in simple code appearing below div instead of inside it? html: <div id="magicbuttondiv"> <p>i filler text</p> </div> javascript: function makebutton() //activated when button in part of page pressed { var text = ""; text += "<p>what gender?</p>"; text += "<input type='button' class='genderbutton' value='male' onclick='malefunction'/>"; text += "<input type='button' class='genderbutton' value='female' onclick='femalefunction'/>"; document.getelementbyid("magicbuttondiv").innerhtml=text; } css: #magicbuttondiv { box-sizing : border-box; -moz-box-sizing : border-box; -webkit-box-sizing : border-box; border : 1px solid #000000; } input.genderbutton { float. : left; margin-left : 2%; width :

entity - how big can a app engine datastore table be? -

i use word table because in console can go visit table , see entries contains. so, how big can datastore table be, in sense? haven't done app engine while don't recall. think proper term entities. , perhaps question how many instances of entity can there be? in case, hope question clear. thanks. there no limit. can add many entities of same kind want. see list of limits (quotas) of app engine. the limitation money - start getting errors once run out of daily budget.

java - SQS message acknowledgement -

my sring boot application listens amazon sqs queue. right need implement correct message acknowledgement - need receive message, business logic after in case of success need ack message(delete message queue). example, in case of error in business logic message must re-enqueued. this sqs config: /** * aws credentials bean */ @bean public awscredentials awscredentials() { return new basicawscredentials(accesskey, secretaccesskey); } /** * aws client bean */ @bean public amazonsqs amazonsqsasyncclient() { amazonsqs sqsclient = new amazonsqsclient(awscredentials()); sqsclient.setregion(region.getregion(regions.us_east_1)); return sqsclient; } /** * aws connection factory */ @bean public sqsconnectionfactory connectionfactory() { sqsconnectionfactory.builder factorybuilder = new sqsconnectionfactory.builder( region.getregion(regions.us_east_1));

html - Grid 960 take up entire width with resize -

Image
i having trouble getting 960.gs take entire width of browser. want grid 100% on resize, if scroll out text appear smaller , take less lines grid still take 100% of width. there question here when using grid 960, can still have 100% width header section? , answer set top part 100%. added code has no effect, neither setting body's width 100% , divs, ect. doing wrong? here code: <!doctype html> <html> <head> <title>my fragment</title> <meta charset="utf-8" /> <!-- symbols rendered --> <meta name="value" /> <!-- not need close --> <link rel="stylesheet" href="css/960_12_col.css"> <style> body { background:green; } div { background: white; } .grid_4 { height: 100px; } </style> &

php - My Twig template's parameters are ignored -

i'm using standalone twig instance in custom application, parameters (context) passed template seem surprisingly ignored. executing following code results in error : fatal error: uncaught exception 'twig_error_runtime' message 'variable " msg" not exist in "hello.twig" (...) test.php $options = array( 'charset' => 'utf-8', 'debug' => true, 'strict_variables' => true, ); $env = new twig_environment(new \twig_loader_filesystem(getcwd()), $options); return $env->render("hello.twig", array('msg' => 'world')); // tried return $env->loadtemplate("hello.twig")->render(array('msg' => 'world')); hello.twig hello {{ msg }} registering global variable ( $env->addglobal('msg', 'everybody') ) no more successful. did miss or should working? as elefantphace pointed out, unsecable space prese

ios - complateTransition don't dismiss the from view swift 2 -

Image
i trying set interactive transition class : class transitionmanager: nsobject, uiviewcontrolleranimatedtransitioning, uiviewcontrollerinteractivetransitioning, uiviewcontrollertransitioningdelegate, uiviewcontrollercontexttransitioning { weak var transitioncontext: uiviewcontrollercontexttransitioning? var sourceviewcontroller: uiviewcontroller! { didset { enterpangesture = uiscreenedgepangesturerecognizer() enterpangesture.addtarget(self, action:"panned:") enterpangesture.edges = uirectedge.left sourceviewcontroller.view.addgesturerecognizer(enterpangesture) } } var togosourceviewcontroller: uiviewcontroller! let duration = 1.0 var presenting = true var reverse = false var originframe = cgrectnull var shouldbeinteractive = false private var didstartedtransition = false private var animated = false private var interactive = false private var animationstyle = uimodalpresentationstyle(rawvalue: 1) private var didfinishedtran

java - Spring+JPA/Hibernate questions -

i have working code saves entity db using ejb+jpa+hibernate. need change ejb spring. below simplified manager class. //@stateless - changed @service @service public class manager { //@ejb - changed autowired @autowired private clientdao clientdao; public void addclient(client client) { clientdao.addclient(client); } } below dao class. //@stateless - changed @repository @repository public class jpaclientdao implements clientdao { @persistencecontext(unitname="clientsservice") private entitymanager em; public void addclient(client client) { em.persist(client); } } below persistence.xml. <?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java

Leverage browser caching on Blogger -

blogger doesn't have .htaccess file. how can cache on blogger? you must need know if blogger had automatically controlled platform, features experts can detect , use these features. you, have analysed page speed , found 1 of images in page needs leveraged browser cache. edit post , check image size , example below. if post / page has 1 image of size 100 kb 300x300, on post have inserted image large or small instead of original size. now click on image in edit post , set original size update post. now again analyse page speed see image has vanished , page speed improve. can every kind of content; think , discover new ways.

php - Iterate over Mongo results without running out of memory -

i need find keywords in name/description/tags, etc. of each document , remove them if found. i'm new mongo, i'm following similar script in existing codebase. first, mongocursor , fields we'll checking: /** @var mongocursor $products */ $products = $collection->find( ['type' => ['$in' => ['phones', 'tablets']], 'supplier.is_awful' => ['$exists' => true]], ['details.name' => true, 'details.description' => true] ); then, iterate through each document, check each of properties values we're interested in: /** @var \doctrine\odm\mongodb\documentmanager $manager */ $manager = new manager(); foreach ($products $product) { // find objectionable words in content , remove these documents foreach (["suckysucky's", "deuce", "a z z"] $word) { if (false !== strpos(mb_strtolower($product['details']['n

python - autoupdate module in IPython / jupyter notebook -

i wrote own module following structure: mymodule/ ├── __init__.py ├── part1.py ├── part2.py ├── part3.py └── part4.py to test module using ipython and/or jupyter notebook (formerly ipython notebook). usual module import like import mymodule let's edit code in part2.py , want use updated version of module. first thought re-importing module import mymodule job, not. reload module have close ipython's shell or restart jupyter's kernel , start again importing mymodule . however, reffering docs , ipython provides auto-update function called autoreload provides different modes , activated follows: %load_ext autoreload %autoreload 1 %aimport mymodule using both of snippets, importing mymodule that: %load_ext autoreload %autoreload 1 %aimport mymodule import mymodule # let's module here however, activated autoreload 1 or autoreload 2 neither ipython nor jupyter doing expect them , still have quit ipython's shell or restart jupyter's kernel

wamp - mysql service doesent work on windows 7 -

i trying start sql service on windows in command prompt continuously have error message: error 2003 (hy000): can't connect mysql server on 'localhost' (10061) in sql log file got following 2015-08-31 00:53:41 5348 [note] plugin 'federated' disabled. 2015-08-31 00:53:41 5348 [note] innodb: using atomics ref count buffer pool pages 2015-08-31 00:53:41 5348 [note] innodb: innodb memory heap disabled 2015-08-31 00:53:41 5348 [note] innodb: mutexes , rw_locks use windows interlocked functions 2015-08-31 00:53:41 5348 [note] innodb: compressed tables use zlib 1.2.3 2015-08-31 00:53:41 5348 [note] innodb: not using cpu crc32 instructions 2015-08-31 00:53:41 5348 [note] innodb: initializing buffer pool, size = 128.0m 2015-08-31 00:53:41 5348 [note] innodb: completed initialization of buffer pool 2015-08-31 00:53:42 5348 [note] innodb: first specified data file .\ibdata1 did not exist: new database created! 2015-08-31 00:53:42 5348 [note] innodb: setting file

vba - How to stop Excel window from staying on top when macro is running continuously? Application.screenupdating doesn't work -

i'm trying run vba macro updates http response cell every second. when macro running , switch program (chrome example), excel window (and along vba editor) pops , stays on top after couple of seconds. i have seen other posts suggesting use of application.screenupdating = false , doesn't work in case. i'm using mac if that's relevant. for info i'm running 2 subs - first 1 http response string call second sub, , second sub uses application.ontime calculate when execute first sub again. i want macro run in background whilst work on other tasks. update seems application.ontime command stealing focus. tried run following sub test , replicated problem i've been having. sub test() application.ontime + 0.01157407 / 1000, "test" '0.01157407/1000 = 1 second end sub i'm not entirely sure how test issue i've never encountered it. , cannot comment on post suggestion. however, using following sub should disable of excel

sql - Access - Selecting unique rows with newest date -

i have access database table track assignments between laptops , vehicles called records, shows computername, unitnumber it's assigned to, , date assignment recorded. id computername unitnumber daterecorded 1 lt150 5010 8/1/2015 2 lt150 788 8/30/2015 3 lt235 4009 8/4/2015 4 lt150 123 9/21/2015 now i'm trying find way query results show unique computername recent daterecorded. so results be computername unitnumber daterecorded lt150 123 9/21/2015 lt235 4009 8/4/2015 i can't figure out how make query work. tried, gives me aggregate function error. select computername, max(daterecorded) recetdate, unitnumber records group computername you don't use group by type of query. instead: select r.* records r r.daterecorded = (select max(r2.daterecorded) records r2

How to trigger an event on a select menu item with JQuery -

a basic question, i'm sure, can't seem crack. trigger simple event when specific option in select menu picked. this basic select menu item: <select id="myselect"> <option value=1>1 - not show</option> <option value=2>2 - not show</option> <option value=3>3 - show</option> </select> the item targeted event: <div id="see-me-now" style="display:none;">boo!</div> the jquery i've got far: $(document).ready(function(){ $("#myselect").change(function(){ $("#see-me-now").fadein('slow'); }); }); now, know i'm missing code, can't seem code is: $(document).ready(function(){ $("#myselect").change(function(){ $(*missing code goes here, bet*){ $("#see-me-now").fadein('slow'); }); }); }); thanks what have done right. forgot add condition . see code below: $(do

cmake - How to put several paths in CMAKE_PREFIX_PATH? -

this question has answer here: multiple cmake_prefix_paths 1 answer how can have several paths cmake needed libraries. installed zlib , libpng under /usr/local/zlib , /usr/local/libpng however, i'm doing first cmake -dcmake_prefix_path=/usr/local/zlib , issuing second command `cmake -dcmake_prefix_path=/usr/local/libpng" in order cmake recognize both. there way have both paths in same variable? i tried -dcmake_prefix_path=/usr/local/zlib:/usr/local/libpng didn't work. you need use ; character instead of : define lists.

How To select All Rows from a SAS data set that Match at least one value in another SAS Data set -

i trying read ticker names of 100 stocks / etfs 1 csv file. have 2 csv files, 1 contains data stocks / etfs on 90 day period. second contains name of 100 stock/etf tickers interested in selecting. below code, work.etfnames 1 column data set contains 100 etf names want select fulldata. how can use list of names correctly select desired data. in work.fulldata names stored in column called "ticker". have sorted data type (either etf or stock) cant figure out how select rows interested in these tables. thank you! proc import out=work.fulldata datafile="/folders/myshortcuts/myfolder/q2_2012_all.csv" dbms=csv replace; getnames=yes; datarow=2; run; proc import out = work.etfnames datafile = "/folders/myshortcuts/myfolder/etfs.csv" dbms=csv replace; getnames=yes; datarow=2; run; proc sql; create table stocks select * fulldata security eq "stock"; quit; proc sql; create table etf select * fulldata s

css - Bootstrap Tokenfield does not work in mobile Safari/iOS 8 -

Image
i using bootstrap tokenfield instrument email textbox support multiple email input. user types letter a in email textbox (the 1 red font in picture) . list of matched emails show in selection menu (the box shows email abc@gmail.com in black) after user clicks , selected email, selected value not captured. @ end got letter a in email textbox how can fix issue? it turns out using fastclick in project. swallowed click event of selection menu (of css class tt-selectable ) used bootstrap-tokenfield at end solution. fork twitter typeahead.js project , change following line $el = $(that.templates.suggestion(context)).data(keys.obj, suggestion).data(keys.val, that.displayfn(suggestion)).addclass(that.classes.suggestion + " " + that.classes.selectable); to $el = $(that.templates.suggestion(context)).data(keys.obj, suggestion).data(keys.val, that.displayfn(suggestion)).addclass(that.classes.suggestion + " " + that.classes.selectable +

Blessing a JSON into a perl class vs private properties -

i have json structure such as: { "field1" => "one", "field2" => "two", ... } i'm using perl json module, , can bless json returned me class, such as: my $result = bless($json->{output},'myclass') so far - can create methods within myclass.pm return values of field1, field2, etc. seems via bless, have direct access set properties of object. danger can things later in code like: $result->{field1} = "anythingiwant"; ...which not good. know set property _field1 indicate privacy doesn't prevent me doing $result->{_field1} = "anythingiwant"; so there best practice approach in perl handle situation? in other words, it's super convenient able bless json output class deserialize, seems dangerous. i'm looking best of both worlds can still use bless prevent client code doing anythingiwant scenario described above. i've looked moose, insideout etc i'm not sure if

graphics - R `dev.new()` freezes -

this started occur: when type command dev.new() , window stays frozen, , can't ctrl+c stop it. have kill r process in terminal. running 64-bit centos 6.7 , r 3.2.1 . here output sessioninfo() : > sessioninfo() r version 3.2.1 (2015-06-18) platform: x86_64-redhat-linux-gnu (64-bit) running under: centos release 6.7 (final) locale: [1] lc_ctype=en_us.utf8 lc_numeric=c lc_time=en_us.utf8 lc_collate=en_us.utf8 lc_monetary=en_us.utf8 [6] lc_messages=en_us.utf8 lc_paper=en_us.utf8 lc_name=c lc_address=c lc_telephone=c [11] lc_measurement=en_us.utf8 lc_identification=c attached base packages: [1] graphics grdevices utils datasets stats methods base other attached packages: [1] ggplot2_1.0.1 data.table_1.9.4 plyr_1.8.3 reshape2_1.4.1 vimcom_0.9-9 setwidth_1.0-4 colorout_1.1-0 loaded via namespace (and not attached): [1] rcpp_0.12.0 digest_0.6.8 mass_7.3-44 chron_

javascript - How can I validate file type before upload use SailsJS Skipper -

as title, can not check file type before upload. verify , don't allow save data after file uploaded successfully. below basic code updateavatar : function(data, context, req, res) { req.file('avatar').upload({ dirname: '../../assets/images/avatar' }, function (err, files) { var allowexts = ['image/png', 'image/gif', 'image/jpeg']; if (err) return res.servererror(err); if (files.length === 0) return res.badrequest('no file uploaded!'); if (allowexts.indexof(files[0].type) == -1) return res.badrequest('file type not supported!'); // save database here }); } what should correct code? sorry bad english! lot! this took me time research on, credits darkstra gave idea of can raw file properties, content-type or file name, can split file extension , our checkings you can check out answer here the main thing take note of this req.file('foo')._

Ack plugin inside the vim is not working -

i'm getting following error inside vim while using ack plugin: [ no name] || ack-grep: command not found. i have installed ack vim-plugin @ path ~/.vim/bundle/ack.vim . have checked :scriptnames , shows me proper path. added following entries .vimrc file: let g:ackprg="ack-grep -h --nocolor --nogroup --column" nmap <leader>a <esc>:ack! i'm still getting error. missing ? if error ack-grep: command not found seem vim means says: can’t find ack-grep command. seems might not problem plugin, instead problem in (shell) environment. i think next steps out to run which ack-grep shell (outside of vim), , make sure have ack-grep that’s executable , that’s in $path vim can find it. (i guess may have checked this, question doesn’t explicitly have; if have checked it, think helpful if updated question indicate have.)

go - tar typeflag directory or file when tar'ing directories in golang -

i'm not sure how set header.typeflag when tar'ing directory files , subdirectories. know if add header.typeflag = '0' it tar files not directories. how set typeflag when file or directory when untar'ing can pass in case statement tar.typedir example taken https://www.socketloop.com/tutorials/golang-archive-directory-with-tar-and-gzip package main import ( "archive/tar" "compress/gzip" "flag" "fmt" "io" "os" "strings" "path/filepath" ) func checkerror(err error) { if err != nil { fmt.println(err) os.exit(1) } } func main() { flag.parse() // arguments command line destinationfile := flag.arg(0) if destinationfile == "" { fmt.println("usage : gotar destinationfile.tar.gz source")

jquery - How to handle "TypeError: HTMLScriptElement" when scroll down with Phantomjs to load dynamic content -

i'm trying scroll down google play webpage ( https://play.google.com/store/apps/category/health_and_fitness/collection/topselling_free ) phantomjs. i've tried method described in answer( how scroll down phantomjs load dynamic content ), gives error message "typeerror: htmlscriptelement not function (evaluating 'el(kl(window.location.href))')" , doesn't works... here's code.. page.open(url, function() { page.includejs("http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js", function() { var cnt = 1; var history = 0; window.setinterval(function() { console.log(cnt); var rettext = page.evaluate(function() { window.document.body.scrolltop = document.body.scrollheight; return $("a.title").text(); }); var height = page.evaluate(function() { return document.body.scrolltop; }); cnt = cnt + 1; if(cnt

gmail - Defining a bill or invoice using Google email markup -

i know can done because i'm looking @ invoice telco in gmail inbox mobile app don't know how set gmail markup / schema make happen. the example have shows: august bill xxxx total: $xxx, due mmm dd $ total amount due $xxxx due date dd mmm issuer telco x can help? can't find guidance on email markup pages on google. it uses regular http://schema.org markup within html of email. see gmail markup reference . example adapted google's gmail markup example: <div itemscope itemtype="http://schema.org/order"> <div itemprop="merchant" itemscope itemtype="http://schema.org/organization"> <meta itemprop="name" content="amazon.com"/> </div> <meta itemprop="ordernumber" content="123-4567890-1234567"/> <meta itemprop="pricecurrency" content="usd"/> <meta itemprop="price" content="259.99

find - Passing all arguments in zsh function -

i trying write simple function in .zshrc hides errors (mostly "permission denied") find . now, how can pass arguments given calling function find ? function superfind() { echo "errors suppressed!" find $(some magic here) 2>/dev/null } i $1 $2 $3 $4 ... stupid! sure there simple way. use $@ , expands positional arguments, e.g.: superfind () { echo "errors suppressed!" find "$@" 2> /dev/null }

node.js - How to make a mutation query for inserting a list of (Array) fields in GraphQL -

recently started working on graphql, able insert data in flat schema without problem when comes array of data getting error like { "errors": [ { "message": "must input type" } ]} i testing query using postman, mutation query mutation m { addevent ( title: "birthday event" description:"welcome all" media:[{url:"www.google.com", mediatype:"image" }] location:[{address:{state:"***", city:"****"}}] ) {title,description,media,location,created,_id}} this event schema: eventtype = new graphqlobjecttype({ name: 'event', description: 'a event', fields: () => ({ _id: { type: graphqlstring, description: 'the id of event.', }, id: { type: graphqlstring, description: 'the id of event.', }, title: { type: graphqlstring, description: 'the title of event.',

html - Align <p> inline next to text -

i trying align styled p tag next echo'ed text once add display:inline; property text not align right. code: echo $flight[0]; echo '<p style="display: inline; text-align: right;">'.$flight[11].' - '.$flight[13].'</p><br>'; the text does align right. issue an inline element wide content , aligning text left, or center, or right, doesn't change visually. check example below. i've applied border can see what's going on. to provide solution, please edit question , explain result supposed like. p { border: 1px dotted red; } <p style="display: inline; text-align: left;">text aligned left</p> <br /> <p style="display: inline; text-align: center;">text aligned center</p> <br /> <p style="display: inline; text-align: right;">text aligned right</p>

cross join - Trying to calculate quartiles in MDX -

my data looks this: id |personid |companyid |dateid |throughput |amounttype 33f467ac-f35b-4f24-a05b-fc35cf005981 |7 |53 |200802 |3 |0 04ee0ff0-511d-48f5-aa58-7600b3a69695 |18 |4 |201309 |5 |0 ab058aa5-6228-4e7c-9469-55827a5a34c3 |25 |69 |201108 |266 |0 with around million rows. columns names *id refers other tables, can used dimensions. i have olap cube column throughput measure , rest dimensions. i want calculate quartile 1 , 3 of throughput measure. i followed guide: https://electrovoid.wordpress.com/2011/06/24/ssas-quartile/ post: calculating quartiles in analysis services from tried use mdx query: with set selection ([dates].[year].&[2014],[dates].[month].&[1]) set [nonemptyids] nonempty( [throughputid].[id].[id] *[throughputid].[id].[id].allmembers , {[measures].[throughput]} * [selection] ) set [throughputdata] order (

Gulp: Produce several images from one image for multiple display automatically? -

as title says, there way in gulp ? need several images included in multiple picture or img srcset attributes. , asset on-the-site (means, not user uploaded pictures). i want create 2 other images, 1 tablet, 1 mobile, using gulp-copy , not recommended. i'm assuming mobile display between 320px-500px(width), , 500-1000px(width) tablet. my strategy optimize image first, make image master, generate 2 other images, always assume source image desktop (display width > 1000px). <-- if there task can pass paramaters assuming other display, better my other challenge height of image, not have standards (and it's hard make one) each display. if i'm assuming 100px 800px image desktop one, don't know how calculate mobile , tablet. is there have ever done before? resizing image resolution in gulp? solved: gulp-responsive-images there seem several gulp tasks able this. why don't take @ these: https://www.npmjs.com/package/gulp-responsive http

css - Div stays on div on mobile version -

i'll show problem using screenshots. http://i.imgur.com/lssels7.png this desktop version of footer. when on mobile version 5th column on 6th. this how looks: http://responsivetest.net/#u=http://patwoj.hekko24.pl/wordpress|491|638|1 (bottom of page). how change place div below div? if want fix without modification in code: specify id row <!-- start: footer --> <div class="row" id="footer"> and add following code in css file @media screen , (max-width:1187px){ #footer .col-lg-1, #footer .col-lg-2, #footer .col-lg-2 div{height:auto !important;} } it fix issue.

python - Error while starting new scrapy project -

i have installed scrapy using ubuntu packages provided in scrapy website. on starting scrapy project scrapy startproject test i getting error message as. traceback (most recent call last): file "/usr/bin/scrapy", line 5, in <module> pkg_resources import load_entry_point file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3084, in <module> file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3070, in _call_aside file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3097, in _initialize_master_working_set file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 653, in _build_master file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 666, in _build_from_requirements file "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 844, in resolve pkg_resources.contex

php - Update query for two different Column in two different table-MySQL -

i working on upwork type project , want create update query bids. user has free bids (which gets default per month) , pro bids can buy amount. if apply on job want update -1 job_quota (if not 0 already), -1 pro bids in ascending order. my table structure (in user table): users job_quota -------->id 12---------------->53 buy_bids id---->no_bids--->amount_paid--->user_id 1-----> 20------------>20---------------> 53 2-----> 20------------>20---------------> 53 3-----> 20------------>20---------------> 53 i have idea - not how implement mysql query: $query=<<< sql update users set job_quota=job_quota-1 if ( job_quota !=0 ) else update buy_bids set no_bids =no_bids-1 user_id=53 sql; can suggest me how can achieve it, not looking accurate solution need , suggestion should try achieve this. many thanks. something this? update users ,buy_bids set users.job_quota = case when users.job_quota !=0

Inner classes vs. immutability in Scala -

please @ following toy example: case class person(name: string, address: person#address = null) { case class address(street: string, city: string, state: string) { def prettyformat = s"to $name of $city" // note use name here } def setaddress(street: string, city: string, state: string): person = copy(address=address(street,city,state)) def setname(n: string): person = copy(name=n) } do see bug there? yes, following code print same message (john) in both cases: val p1 = person("john").setaddress("main", "johntown", "ny") println(p1.address.prettyformat) // prints john of johntown val p2 = p1.setname("jane") println(p2.address.prettyformat) // prints john of johntown naturally because of $outer reference in address preserved in set methods, p2 inner object still refers john. issue fixed following or recreation of address object (wouldn't nice if had precooked copy-constructors in case classes?)

Export from Oracle to MongoDB using python -

i know there various etl tools available export data oracle mongodb wish use python intermediate perform this. please can guide me how proceed this? requirement: want add records oracle mongodb , after want insert newly inserted records oracle mongodb. appreciate kind of help. to answer question directly: 1. connect oracle 2. fetch delta data timestamp or id (first time records) 3. transform data json 4. write json mongo pymongo 5. save maximum timestamp / id next iteration keep in mind should think data model considerations , relational db (like oracle) , document db (like mongo) have different data model.

slidingmenu - Unable to closed Sliding menu in iOS -

Image
in application create sliding menu using swrevealviewcontroller when click on uiviewcontroller sliding menu not close automatically if view controller contain tableview on other click event how can solved problem code : swrevealviewcontroller *revealcontroller = [self revealviewcontroller]; [self.view addgesturerecognizer:revealcontroller.pangesturerecognizer]; write code on green view viewdidload method navigate view. revealcontroller=[[swrevealviewcontroller alloc]init]; revealcontroller = [self revealviewcontroller]; [self.view addgesturerecognizer:revealcontroller.pangesturerecognizer]; revealcontroller.delegate=self; [revealcontroller pangesturerecognizer]; [revealcontroller tapgesturerecognizer];

django - TypeError save() takes at least 2 arguments (1 given) -

i have error type error save() takes @ least 2 arguments (1 given) in django project. view.py file class dealsform(modelform): class meta: model = product fields = ['title','description','category','price','sale_price','slug','active','update_defaults','user'] exclude = ('user',) model.py file class product(models.model): title = models.charfield(max_length=120) description = models.textfield(null=true, blank=true,max_length=200) category = models.manytomanyfield(category, null=true, blank=true) price = models.decimalfield(decimal_places=2, max_digits=100, default=29.99) sale_price = models.decimalfield(decimal_places=2, max_digits=100,\ null=true, blank=true) slug = models.slugfield(unique=true) timestamp = models.datetimefield(auto_now_add=true, auto_now=false) updated = models.datetimefiel

c# - ajax - How to receive data both html and json from server? -

i have referenced this topic , doesn't solve problem. i'm using mvc 5 c#. have used code receive data server data type json . $.ajax({ url: "/mycontroller/myaction", type: "post", datatype: "json", success: function (data) { if (data.result) { alert('successfull'); } else { alert(data.ex); } } }); and controller code: [httppost] public actionresult myaction() { try { return json(new { result = "true", ex = "" }); } catch (exception e) { return json(new { result = "false", ex = e.message }); } } i use way data type html: $.ajax({ url: "/mycontroller/myaction", type: "post", datatype: "html", success: function (data) { $(".mydiv").append(data); } }); and controller should be: [httppost] public actionresult myaction() { return partialview("_

javascript - Scrapy - making selections from dropdown(e.g.date) on webpage -

i'm new scrapy , python , trying scrape data off following start url . after login, start url---> start_urls = [" http://www.flightstats.com/go/historicalflightstatus/flightstatusbyflight.do ?"] (a) there need interact webpage select ---by-airport--- and make ---airport, date, time period selection--- how can that? loop on time periods , past dates.. i have used firebug see source, cannot show here not have enough points post images.. i read post mentioning use of splinter.. (b) after selections lead me page there links eventual page information want. how populate links , make scrapy every 1 extract information? -using rules? should insert rules/ linkextractor function? i willing try myself, hope can given find posts can guide me.. student , have spent more week on this.. have done scrapy tutorial, python tutorial, read scrapy documentation , searched previous posts in stackoverflow did not manage find posts cover this. a million thanks. my

angularjs - How to declare a watch on the this object in a factory method in angular js? -

Image
i have factory class defined instantiating in controller. i want define method in factory declaration of user class notified when of properties changed . below link code @ code pen app.factory('user', ['$rootscope', function ($rootscope) { function user(userdata) { user.prototype.name = userdata.namesample; user.prototype.age = userdata.age; $rootscope.$watch(this, function (oldvalue, newvalue) { }, true); }; user.prototype = { name: null, age: null } return user; }]); http://codepen.io/anon/pen/qjwywp?editors=101

amazon web services - Is this the right approach to index creation in DynamoDB? -

i want create app has list of clients ids (emails in case), phone number , other important information. of time clients table searched using client id (their email) want able search using phone number. want app have text field can either type email or phone number , able retrieve client data. client ( id, phonenumber, name, lastname, etc...) after researching on dynamodb, came solution of having table clients , having index hash key ids lot of throughput read , write since querying based on attribute common task. then, created global secondary index, key attribute phonenumber, , giving low throughput number reading , writing since search of client phone number won't occasional. however, app never make update using phone number key, make updates using id key. is right approach, or there better thing do? throughput values right based on needs or think there no need have write throughput values secondary index? there maybe wrong thought process? thank much! update: let&#

Android - How to restart a clean application instance -

i'm using android bluetooth library connect remote desktop. when connection desktop lost, i'd restart fresh instance of application (that highly facilitate handling of connection lost). i tried code : intent = getbasecontext().getpackagemanager() .getlaunchintentforpackage( getbasecontext().getpackagename() ); i.addflags(intent.flag_activity_no_history); i.addflags(intent.flag_activity_clear_top); startactivity(i); but after that, still have trouble reconnecting whereas if manually kill , restart application works fine. you can restart activity when detect you've lost , found again connection. can restart activity code: public void reload() { intent intent = getintent(); overridependingtransition(0, 0); intent.addflags(intent.flag_activity_no_animation); finish(); overridependingtransition(0, 0); startactivity(intent); }

python - How to regex hashtag with digits after in python2? -

i want find hashtag 1 6 digits after python 2.7 , regex doesn't match properly. here example : chaine = "[url=http://forum.darkgyver.fr/t27142-probleme-boitier-papillon-faisceau#265132:<uid>]http://forum.darkgyver.fr/t27142-probleme-boitier-papillon-faisceau#265132[/url:<uid>]" regex = re.compile('http://forum.darkgyver.fr/(.*)\#(\d{1-6})') match = regex.search(chaine) if match: pos1 = match.start() pos2 = match.end() else: pos1 = -1 pos2 = -1 print "pos1 %d" % pos1 print "pos2 %d" % pos2 url_tempo = chaine[pos1:pos2] print "url_tempo %s" % url_tempo pospost = pos1 + url_tempo.find('#') + 1 numpost = chaine[pospost:pos2] print "numpost %s" % numpost this first regex returns "no match". perhaps hashtag not declared properly. so changed regex follows: regex = re.compile('http://forum.darkgyver.fr/(.*)\#([0-9]+(:| | |\n|