Posts

Showing posts from May, 2010

python - Speeding up Loading of Pandas Sparse DataFrame -

i have large pickled sparse dataframe generated, since big hold in memory, had incrementally append generated, follows: with open(data.pickle, 'ab') output: pickle.dump(df.to_sparse(), output, pickle.highest_protocol) then in order read file following: df_2 = pd.dataframe([]).to_sparse() open(data.pickle, 'rb') pickle_file: try: while true: test = pickle.load(pickle_file) df_2 = pd.concat([df_2, test], ignore_index= true) except eoferror: pass given size of file(20 gb), method works, takes really long time. possible parallelize pickle.load/pd.concat steps quicker loading time? or there other suggestions speeding process up, on loading part of code. note: generation step done on computer less resources, that's why load step, done on more powerful machine, can hold df in memory. thanks! don't concat in loop! note in docs, maybe should warning df_list = [] open(data.pickle, 'rb'

xcode/ios/coredata: Last record in tableview displays twice when after adding new record -

i having strange problem. when add record entities i.e. core data screens, table view instead of showing new record, repeats previous record. it happens entities , screens, i.e. if add records, 1,2,3 etc. display 1,1,1. other screens , entities use identical code, happens, after 8 through tenth record. in these cases, if add records named 1,2,3…10, display 1,2,3,4,5,6,7,8,8,8,8,8,8 etc. has ever encountered strange/spooky behavior? why think new record same previous record either right away or @ point i.e. when number of records hits 8 or so? note, saves fine in core data when close simulator , rebuild, shows right records. the delegate pattern seems working—somewhat—as shows new record when 1 added, shows copy of last record , record on got stuck, i.e. 8,8,8 etc. thanks suggestions. has been driving me crazy week now. am posting without code not accept code posted reason... happy post code requested. edit: #pragma mark - table view data source - (uitablev

javascript - Bootstrap Image Gallery with MixItUp Filtering -

i'm using bootstrap image gallery plugin mixitup filtering. image gallery contains on 150 images , want if thumbnail of selected filter clicked cycle through images selected filter , not images in gallery. tried create div each filter it's not working. each filter wrapped in div javascript work, don't know how. here html & js of stripped down sample , link see online: html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <title>gallery sample</title> <!-- bootstrap core css --> <link href="css/bootstrap.css" rel="stylesheet"> <!-- custom css --> <link href="css/style.css" rel="stylesheet">

PHP Built-In Server Can't cURL -

i have relatively simple script following: <?php $url = "localhost:2222/test.html"; echo "*** url ***\n"; echo $url . "\n"; echo "***********\n"; echo "** whoami *\n"; echo exec('whoami'); echo "* output **\n"; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); $output = curl_exec($ch); curl_close($ch); echo $output; when execute on command line, works - meager results within test.html. when run script loading built-in php server , browsing script, hangs. no output screen, nothing written logs. i read user permissions can in way, tried doing whoami ensure user ran built-in php server same 1 executed script on command line; are. safe_mode off, disable_functions set nothing. can exec other commands (like whoami). what else should check for? built-in php server count other user when fulfills request perhaps? to make comment answer:

angularjs - Passing scope object to Angular Directive via $compile -

i know if have directive in html, can pass objects $scope it: <mydirective some-data="somedata"></mydirective> ...where somedata might json object. is possible pass reference somedata if create directive dynamically , use $compile ? $scope.somedata = { firstname: 'john', lastname: 'doe' }; var link = $compile("<mydirective some-data='???'></mydirective>"); var content = link($scope); $(body).append(content); yes can pass object to var myapp = angular.module('myapp',[]); myapp.directive('passobject', function() { return { restrict: 'e', scope: { obj: '=' }, template: '<div>hello, {{obj.prop}}!</div>' }; }); myapp.controller('myctrl', function ($scope) { $scope.obj = { prop: "world" }; }); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular

Assignment in anonymous inner class Java -

here have class contains anonymous inner class: public class example { int value; example(int value) { this.value = value; } void bumpup() { value++; } static example makeexample(int startval) { return new counter(startval) { int bumpvalue = 2; // value = startval; void bumpup() { bumpvalue = (bumpvalue == 2) ? 1: 2; value+= bumpvalue; } }; } } if uncomment line says value = startval , eclipse throws error saying above line error. why can't put value = startval there? thanks! first of all, putting line there syntax error, because cannot have instructions outside of method. , you're attempting put instruction within body of anonymous inner class. but above all, don't need line, neither in constructor (which impossible anonymous inner class), nor in initializer block. the constructor of superc

sql server - Sharing data between stored procedures -

i have stored procedure called dbo.match . looks : create procedure [dbo].[match] @parameterfromuser nvarchar(30), @checkbool int begin --some code select rowid, percentmatch @matches end this procedure being called stored procedure : create procedure matchmotherfirstname @motherfn nvarchar(20) , @checkbool int begin select @constval = functionweight dbo.functionweights functionweights.functionid = 20; /* code execute `dbo.match` procedure in above procedure called `matchmotherfirstname` , retrieve `rownumber` , `percentmatch`, insert #temp in respective fields , , calculate `percentmatch * constval`, , insert in corresponding column called `percentage` in `#temp` */ end i need execute dbo.match stored procedure in above procedure, retrieve rowid , pecrntmatch value, @constval value have above, multiply @constval , percentmatch , store in percentage column of #temp , insert results dbo.match procedure in temporary table. dbo.match

python - How to do different anchor points for translation and rotation on a text element in an SVG -

Image
i want build svg set text using 1 anchor point x,y translation , different anchor point rotation. specifically, want translate text point (x,y) (x,y) upper left corner of text. want rotate text center point. can't translate text using center point anchor because impossible width , height of text in advance. (i using python) here's image depicting 2 anchor points i'd use. also should note want able view file in adobe illustrator. there can way svg embedded javascript: http://jsfiddle.net/bluc315m/3/ <svg width="320" height="320" viewbox="0 0 320 320" onload="init(this, 100, 100, 30)"> <script> function init(doc, x, y, ang) { var e = doc.queryselector("#txt"); var b = e.getboundingclientrect(); var w = b.width; var h = b.height; e.setattribute( "transform", "translate(" + x + "," + y + ")&quo

javascript - Weighted Polar Area Diagram -

i working on polar area chart using chart.js. ive been trying create diagram 4 quadrants, each of has different weight. i haven't been able change tooltip options vary based on values. if there other js framework helps me this, great well.

ruby on rails - Displaying multiple copies of one activerecord object -

i displaying list of articles , using will_paginate gem , endless scrolling. working fine. my problem, however, getting multiple copies of same article in view. doesn't happen time, , nor every article, enough bloody annoying. i know there no duplication in database, , problem occurs in rendering somehow. here controller: @articles = article.order("date_published desc", "random()").paginate(:page => params[:page],:per_page => 10) i trying somehow include distinct or uniq method, seems can't use either order method. i using pg db. any appreciated! the issue arises sub-sort, random() . imagine have these posts: id published title ---------------------- 1 1/1/1970 1 2 1/2/1970 2 3 1/2/1970 3 4 1/3/1970 4 if request page 1 (with page size of 2), can either 4 , 3, or 4 , 2. now, if request page 2 can either 3 , 1 or 2 , 1. because of random() sub-sort. first query may pull page result: id published t

r - EMA in the TTR package, when vector length = n, EMA = mean regardless of smoothing ratio (which becomes irrelevant)? -

i'm pretty confused on why works way. > x <- c(1,2,3) > ema <- ema(x, n=3) > ema [1] na na 2 > ema <- ema(x, n=3, ratio= .3) > ema [1] na na 2 > ema <- ema(x, n=2, ratio= .3) > ema [1] na 1.50 1.95 > ema <- ema(x, n=2) > ema [1] na 1.5 2.5 so when n equal length of vector, ema = mean, , smoothing ratio irrelevant? not getting @ all. the first non-na value occur @ observation n , equal arithmetic mean of first n observations. exponential smoothing begin @ point. the ratio argument specifies decay, , not change when first non-na observation occurs. regardless, exponential smoothing unstable until have 3 times data smoothing ratio implies. example, n=10 ( ratio=2/(10+1) ), need 30 observations before exponential moving average stabilizes. see warning , examples sections of ?ema .

javascript - Extracting value from $scope variable? -

how can assign regular javascript variable current value of angular $scope variable without binding values? //$scope.var1 initialized value, 5 var v2 = $scope.var1; //$scope.var1 changed 7 i want v2 still 5, not 7. var v2 = angular.copy($scope.var1);

keystonejs - What is the proper way to set up API endpoints for usage with Keystone? -

it's not clear in docs how 1 use existing keystone models expose api endpoints return json within keystone.js app. able expose rest api endpoints keystone , able use keystone cms capabilities manage content via interacting endpoints. thanks! now they've standardized admin api found it's pretty trivial use same methods. read apis powering react app i've done put in routes/index.js router.get('/api/:list/:format(export.csv|export.json)',middleware.initlist,require('keystone/admin/server/api/list/download')); and i've made own version of admin initlist middleware: exports.initlist = function(req, res, next) { console.log('req.keystone', req.keystone); req.keystone = keystone; req.list = keystone.list(req.params.list); if (!req.list) { if (req.headers.accept === 'application/json') { return res.status(404).json({ error: 'invalid list path' }); } req.flash('error', 'list '

macros - Open Office Base Form's record status -

i'm using openoffice base , basic macros control forms. i used program microsoft access-basic , there things don't know correspondence in openoffice base macro basic. how can retrieve current record status of form? i mean status describes if record in edit-mode, view-mode or new-record mode. in access basic these statuses described in single property specify whether record in: editmode: when value of saved record changed, until hitting save. newrecordmode: when fields empty in order user assign values of new record, until hitting save. viewmode: when user preview record, without of above actions take place. is there correspondence in openoffice base macro basic? there property or indicate these statuses? after hours of researching, found answer on own: oform = thiscomponent.drawpage.forms.getbyname("myform") oform.ismodified() (boolean edit mode) oform.isnew() (boolean newrecord mode) thanks anyway!

jqGrid FrozenColumns changing Column style Resets back -

i have used solution posted in the answer to change mouse pointer on jqgrid but having issue. when column frozen mouse pointer cursor instead of default 1 set in code. i see changing frozen column pointer default @ method somewhere being reverted original css. at time wrote the answer jqgrid didn't had frozen columns feature. if use free jqgrid 4.8 (see readme , wiki ) don't need anything. non-sortable columns have correct cursor. see the demo . if need use old jqgrid version can following var p = mygrid[0].p, cm = p.colmodel, $frozenheaders = $(mygrid[0].grid.fhdiv) .find(".ui-jqgrid-htable>thead>tr.ui-jqgrid-labels>th.ui-th-column"); $.each(mygrid[0].grid.headers, function(index, value) { var cmi = cm[index], colname = cmi.name; if(!cmi.sortable && colname !== "rn" && colname !== "cb" && colname !== "subgrid") { $("div.ui-jqgrid-sortable",v

javascript - Change network chart dynamically with d3plus.js -

i'm working on visualization of networks using d3plus library. want show different networks depending on key of object, e.g. year. there working example tree_map chart. couldn't implement same network . here code: <!doctype html> <meta charset="utf-8"> <script src="http://www.d3plus.org/js/d3.js"></script> <script src="http://www.d3plus.org/js/d3plus.js"></script> <div id="viz"></div> <script> var sample_data = [ {"name": "point1", "year": 1994}, {"name": "point2", "year": 1994}, {"name": "point3", "year": 1994}, {"name": "point4", "year": 1994}, {"name": "point5", "year": 1994}, {"name": "point6", "year": 1994}, {"name": "point7", "year&quo

node.js - How to delete records in Accumulo based on an rowkey via Accumulo proxy client -

i'm using accumulo 1.6 , want delete records giving rowkey via accumulo proxy client in nodejs. but proxy client throw "start row must less end row" when trying put same rowkey deleterows api var rowid = "1"; var proxyclient = getaccumuloproxyclient(); proxyclient.deleterows(getlogin(), table_name, rowid, rowid, callback); update: let's there table looks like: rowid | columnfamily | columnqualifier 1 name john 1 age 25 1 department sales 2 name lisa 2 age 25 2 department sales what parameters should pass deleterows function if want delete of rows of rowid equals 1? tried pass 1 start , end, complain "org.apache.accumulo.core.client.accumuloexception: start row must less end row" then tried pass start = 1 , end = 1\0 make sure start less end, nothing happend, no error threw, no rows deleted. think caused start exclude , end include de

clojure - get agent content and convert it to JSON -

i'm still newbie in clojure , i'm trying build application read 2 files , write diffrence on json file (defn read-csv "reads data." [] (with-open [rdr ( io/reader "resources/staples_data.csv")] (doseq [line (rest(line-seq rdr))] (println(vec(re-seq #"[^,]+" line)))))) (defn read-psv "reads data." [] (with-open [rdr ( io/reader "resources/external_data.psv")] (doseq [line (rest(line-seq rdr))] ; (print(vec(re-seq #"[^|]+" line)))))) (doall(vec(re-seq #"[^|]+" line)))))) (defn process-content [] (let [csv-records (agent read-csv) psv-records (agent read-psv)] (json/write-str {"my-data" @csv-records "other-data" @psv-records})) ) im getting exception: exception don't know how write json of class $read_csv clojure.data.json/write-generic (json.clj:385) please some explanation, in advance! you

c++ - Return type of '?:' (ternary conditional operator) -

why first return reference? int x = 1; int y = 2; (x > y ? x : y) = 100; while second not? int x = 1; long y = 2; (x > y ? x : y) = 100; actually, second did not compile @ - "not lvalue left of assignment". expressions don't have return types, have type , - it's known in latest c++ standard - value category. a conditional expression can lvalue or rvalue . value category. (this of simplification, in c++11 have lvalues, xvalues , prvalues.) in broad , simple terms, lvalue refers object in memory , rvalue value may not attached object in memory. an assignment expression assigns value object thing being assigned must lvalue . for conditional expression ( ?: ) lvalue (again, in broad , simple terms), the second , third operands must lvalues of same type . because type , value category of conditional expression determined @ compile time , must appropriate whether or not condition true. if 1 of operands must converted different type m

GUI programming/arrays in Python -

i need little more elaboration on arrays in gui programming. image processing, given following piece of code example of image processing: def grayscale(im): height=len(im) width = len(im[0]) row in range(height): col in range(width): average = sum(im[row][col])/3 im[row][col]=[average,average,average] return im the final line before code returns--what mean? code supposed running through pixel pixel , averaging out rgb values grayscale value--how sum of each pixel/3 average? how code know red, blue, , green values are? each color in pixel defined variation of 3 components : red, green , blue, oscillating between 0 , 255, creating 16 millions colors ( 255^3 ). a shade of gray represented 3 identical values red, green , blue. there several methods achieve grayscale convertion, including quick n' dirty average method (see others here ). since grayscale needs 1 scale (from white black), can average 3 components formu

objective c - Audio stops on background on simulator (iOS 7.1) -

audio stops when close app. , may start again if open control center (swipe bottom). it's strange. everything's fine in ios 8 simulator , devices. problem can't install ios 7 on existing devices test bug in app or it's bug in simulator. uibackgroundmodes in info.plist contains audio string object. here how configure session on app start: - (void)setaudiosession { [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayback error:nil]; [[avaudiosession sharedinstance] setactive:true error:nil]; } to play audio use avplayer class. it's ios 7 simulator bug.

javascript - Maintaining the aspect ratio of a scalable image -

i using css property transform: translatey vertically center image on page. width of image percentage of of page scaled if user enlarges or reduces browser window. here markup: <div class="item"> <img src="..." width="50%"> </div> here css: .item { width: 100%; height: 100%; text-align: center; } div.item > img { max-height: 100%; max-width: 100%; position: relative; top: 50%; transform: translatey(-50%); } this works unless browser window shorter wide in case height of image trimmed or, setting maximum height of image 100%, squished. can see problem drastically reducing height of browser window while viewing demo: https://jsfiddle.net/0zh4qvlm/ . how can maintain aspect ratio of image in instance? change css to div.item > img { max-height: 100%; max-width: 50%; width:auto; position: relative; top: 50%; transform: translatey(-50%); -webkit-trans

What is the difference between opts and options in Elixir Plug.Adapters.Cowboy.http? -

the function defined as def http(plug, opts, options \\ []) ... why there 2 arguments appear mean same thing have different names? the first options plug options. second options ones given cowboy , ranch. should rename them make clearer.

mysql - the inner join to the same table twice(ALIASES) -

this question has answer here: inner join twice in same table 2 answers i have issue inner join,these tables fk , pk table city city_id (pk) city_name state table depot dep_id (pk) capacity city_id (fk) references city table manufacturer manu_id (pk) manu_name city_id (fk) references city so want make result this: depot_city_name(references city_id) , manufacturer_city_name(references city_id) so depot_city_name show name of city depo ( references city.city_id ) and manufacturer_city_name show name of city manufacturer ( references city.city_id ) thanks you need left outer join: select c.city_id, d.depo_id, m.manu_id,c.city_name city c left outer join depo d on c.city_id=d.city_id left outer join manufacturer m on c.city_id=m.city_id edit: if want separate city name depo , manufacturer use: select c.city_id, d.depo_id, m.manu_id,

Using Linq in VB.NET to verify result set is NULL -

i'm trying validate wether or not 2 matching columns exists using linq/vb.net i believe assuming null result set being returned 'count' value should null, correct? below code; dim crewnumentered = crewnuminput.text dim crewleadernumentered = crewleadernuminput.text dim crewnumunique boolean = false using db new dbclassdatacontext dim count = (from in db.warrantypercents a.crewleadernum = crewleadernumentered , a.crewnum = crewnumentered select a.warrantypercentsid).tolist if count nothing crewnumunique = true else 'throw error end if end using the end result want perform action (code not shown) if crewnumunique == true. but when result set should null, code continuing fill 'something' count. what can fix this? edit: realized value of count isn't null instead returning string 'system.collections.generic.list`1[system.int32]'. have no clue going on.

c++ - Qt design and performance issue -

i having troubles while designing c++ qt application. among other things, application displays beams (or rays) of lasers (each laser composed around 700 segments starting same position , spaced constant angle, , small circle @ other end of segment materializing end point). here drafting of 1 laser found on internet . of time have display 12 lasers (so 12*700 segments), @ 30 frames per second. first implementation works, takes huge amount of cpu (>12%) , gui lags lot. what did implementation quite simple: have lasermodel class, filled thread receiving tcp beacons; mainwindow class qgraphicsscene* _scene ; , laserview class, instances added scene. signal @ 30fps triggers passage of datas model view using setdata() method. i did performance analysis , seems 80% of work of gui (there way more displaying these lasers) done drawline(/*…*/) methods. i sure there more elegant , efficient way that. first setdata(/*…*/) method seems quite ugly me. know should emit signal (

c - How do I use scanf to limit the user from entering a string no larger than the array? -

how use scanf limit user entering string no larger array? what i've tried far is: #include<stdio.h> int main() { const maxstring = 5; char arr[maxstring] = {}; printf("enter string: \n"); scanf("%*s", maxstring-1, arr); return 0; } but doesn't seem work. if want have user enter string terminated newline, it's idea use fgets instead of scanf . function fgets receives parameter length of buffer , won't overrun buffer. can check result figure out if truncation occured. consult documentation of c language implementation more details. fgets(arr, maxstring, stdin);

PrimeFaces tag for JSF h:inputHidden -

does have recommendations primefaces tags? specific, trying find equivalent primefaces tag input type hidden. can tell, if have primefaces tag jsf <h:inputhidden> input type hidden? you can use p:inputtext , set type="hidden" <p:inputtext value="hello world" id="hiddenfield" type="hidden" />

Visual Basic Cursor -

so new coding in vb , using vs express in order create photography payment application client. problem pressed , text cursor has changed whenever type deleted next letter. attached picture of looks like, want top revert it's original text cursor. the cursor. thank's in advance! i think hit "insert" key. hit again , should stop.

java - Bank account program. NullPointerException error -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i working on bank account program java class. still new this, , our first assignment working arrays. please excuse rookie errors lol. assignment requires array of 3 bank accounts now. need 3 classes; bank (which contains bankacct myacct[] = new bankacct), bankuser, , bankacct(which contains withdraw, deposit , see balance methods). of getting nullpointerexception in prochoice method anytime try view balance, deposit, or withdraw.the error in user class, leave comments in code show where. please, appreciated. reading textbook not finding can particular issue. thank in advance. bankacct class import java.util.scanner; public class bankacct { private double bal; private int acctnum; private string name; scanner scannerobject = new scanner(system.in); public bankacct(int pacct

python - Mysterious "'module' object has no attribute" error -

every time try serve project error: traceback (most recent call last): file "/usr/bin/pserve", line 9, in <module> load_entry_point('pyramid==1.5.2', 'console_scripts', 'pserve')() file "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 51, in main return command.run() file "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 313, in run relative_to=base, global_conf=vars) file "/usr/lib/python3.4/site-packages/pyramid-1.5.2-py3.4.egg/pyramid/scripts/pserve.py", line 344, in loadserver server_spec, name=name, relative_to=relative_to, **kw) file "/usr/lib/python3.4/site-packages/pastedeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.py", line 255, in loadserver return loadobj(server, uri, name=name, **kw) file "/usr/lib/python3.4/site-packages/pastedeploy-1.5.2-py3.4.egg/paste/deploy/loadwsgi.p

xamarin.forms - How to use SQLITE async extensions within a transaction in a Xamarin Forms PCL? -

i'm trying figure out how, in transaction, use sqlite async extension methods such insertorreplacewithchildrenasync (nuget twincoders). on startup in xamarin.forms pcl, have: using xamarin.forms; using sqlite.net; using sqlite.net.async; using sqlitenetextensions; using sqlitenetextensionsasync.extensions; ... ... static sqliteasyncconnection db; db = dependencyservice.get<isqlite> ().getasyncconnection (); as side note, additionally following, don't, having read unwise mix sync , async database operations: dbsync = dependencyservice.get<isqlite> ().getsyncconnection (); my first idea was: await db.runintransactionasync ( ( sqlite.net.async.sqliteasyncconnection tran ) => { tran.insertall withchildren ( ...); ... } but gets following warning @ build time: ... runintransactionasync(action<sqliteasyncconnection> ... cause deadlock if .... use runintransactionasync(action<sqliteconnection>) instead. if use synchronou

angularjs - How to fail a successful Angular JS $http.get() promise -

how reject or fail successful $http.get() promise? when receive data, run validator against , if data doesn't have required properties want reject request. know can after promise resolved, seems idea intercept errors possible. i'm familiar benefits of $q, want continue using $http. you can reject promise returning $q.reject("reason") next chained .then . same $http , returns promise - follows: return $http.get("data.json").then(function(response){ if (response.data === "something don't like") { return $q.reject("bad data"); } return response.data; } this done within service, pre-handles response .then specified above, , returns data - or rejection. if want @ app-level, use $http interceptors - service provides functions handle $http requests , responses, , allows intercept response , return either response - same or modified - or promise of response, including rejection. .factory("foointercep

haskell - How do you translate from lambda terms to interaction nets? -

on this paper , author suggests translation between lambda terms: data term = 0 | succ term | app term term | lam term and interaction nets: data net = -- if understood correctly apply net net net | abstract net net net | delete net net int | duplicate net net net int | erase net unfortunately can not understand compilation algorithm. seems actual algorithm missing, , have no idea means images on third page. i've tried understanding looking @ published source code, author defines using own graph rewriting dsl have learn first. how translation implemented normal haskell function? i have implementation of interaction net reduction in haskell uses stref s represent net graph structure in mutable way: data nodetype = nrot | nlam | napp | ndup int | nera deriving (show) type nodeid = int type port s = stref s (node s, portnum) data node s = node { nodetype :: !nodetype

python - Scrapy ImagesPipeline WARNING: File (unknown-error): Error downloading image from <GET -

i learning python , scrapy , learning how download images using it. kind of stuck right , cant figure out real problem is. i getting error message when run spider <none>: unsupported url scheme '': no handler available scheme and [imageflip] warning: file (unknown-error): error downloading image <get please see pipelines.py here import scrapy scrapy.contrib.pipeline.images import imagespipeline scrapy.exceptions import dropitem class priceoflipkartpipeline(object): def process_item(self, item, spider): return item class myimagespipeline(imagespipeline): def get_media_requests(self, item, info): image_url in item['image_urls']: yield scrapy.request(image_url) def item_completed(self, results, item, info): image_paths = [x['path'] ok, x in results if ok] if not image_paths: raise dropitem("item contains no images") item['image_paths'] = image_paths return item please

Ignore part of file in git when using on 2 different computers (python) -

i using python program on 2 different computers. on computer 1 path (e.g., image or something), used program, is, say, a/b/ on computer 2, equivalent path different, say, b/a/ (the image, e.g., in different folder) when want run script on computer 1 pull code , set path a/b/. make changes , push. then go computer 2 , pull. path a/b/ want pull not change path (all rest should change though of course). q1: there way automatically (prevent changes in path)? keep getting merge conflicts due path being different. q2: might not doing in optimal way, how people this? procedure wrong causing these issues. absolute paths depend on specific computer not belong in version control. solution have program read environment variable , use path. make sure set sensible default if environment variable unset.

file upload - What am I getting a 'Failed to open Stream' error in PHP? -

i have been following set of tutorials in thenewboston [php] , have been using following code. trying upload file, more on 'jpg' file, since it's first time upload file. code though, have been encountering several errors such ff: - move_uploaded_file: failed open stream: permission denied - move_uploaded_file: unable move 'tmp_file' 'file' so, doing wrong? $name = $_files['file']['name']; $tmp_name = $_files['file']['tmp_name']; if (!empty($name)) { $folder = 'files/'; if (move_uploaded_file($tmp_name, $folder.'image.jpg')) { echo 'uploaded'; } } ?> <form method="post" enctype="multipart/form-data" action="untitled%20text.php"> <input type="file" name="file"/> <br/> <br/> <input type="submit"/> </form> -

ios - Add subview to UITextView and using autolayout -

i have problem adding subview uitextview using autolayout: in subtextview : uitextview .m file: - (instancetype)initwithframe:(cgrect)frame { if(self = [super initwithframe:frame]) { _baseline = [[uiview alloc] init]; [self addsubview:_baseline]; [self setbackgroundcolor: [uicolor blackcolor]]; _baseline.translatesautoresizingmaskintoconstraints = no; [self setneedsupdateconstraints]; } } - (void)updateconstraints { [super updateconstraints]; nslayoutconstraint *constraint = nil; constraint = [nslayoutconstraint constraintwithitem:self.baseline attribute:nslayoutattributetrailing relatedby:nslayoutrelationequal toitem:self attribute:nslayoutattributetrailing multiplier:1.f

Python : Iterate through list and sublists and match first elements and do some more manipulations -

i new python, want know if there built in function or other way below in python 2.7: iterate through list , sublists , if value of first element matches value of first sublist element, delete first sublist element , put other elements in sublist in outside list. sublists. see below examples better understanding of requirement. examples: input : ['or', ['or', 'r', '-b'], 'w'] output : ['or', 'r', '-b', 'w'] here, 'or' , 'or' matched in main list , sublist, remove 'or' in sublist , put other elements in sublist 'r' , '-b' in main list input : ['and', ['and', ['or', '-p', 'r'], ['or', 'q', 'r']], ['or', '-p', '-r']] output : ['and', ['or', '-p', 'r'], ['or', 'q', 'r'], ['or', '-p', '-r']] here, &#

arrays - Why is my bash shell script working on v 3.2.5 and failing on 4.1.2? -

my bash shell script working on bash 3.2.5. have input file contains following content: 1234567 2345678 3456789 4567890 and bash shell script has following code: #!/bin/bash content=($(cat data.txt | awk {'print $1'})) (( i=0 ; i<${#content[@]} ; i++ )) if (( i==0 )) ele=`echo ${content[$i]}` else ele=`echo ","${content[$i]}` fi all=`echo $all$ele` done # should string of csv: works on bash 3.2.5 - fails on bash 4.1.2 echo $all when run bash 3.2.5 outputs: (expected output; correct) 1234567,2345678,3456789,4567890 but when run bash 4.1.2 outputs: (the last number in file; not correct) ,4567890 why same code failing in bash 4.1.2? using echo set contents of variable plain .. wrong. when wrong, mean, can it, there absolutely no reason use command substitution of echo statement fill variables in case. likewise, there no reason use cat piped awk fill array. filling array easier done simple redirection. by eliminatin