Posts

ios - UILayoutConstraint creates constraints that go offscreen -

my tableview cell 3 labels , uistepper if text in first label long moves other views on making stepper go off screen. here constraints: [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:|-15-[name(>=price@750)]-[price(==60)]-[quantity(==20)]-[stepper]-15-|" options:0 metrics:nil views:views]]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|-[name]-|" options:0 metrics:nil views:views]]; [self.contentview addconstraints:[nslayoutconstraint constraintsw...

Converting Array into Image (tif) in Python using Pillow -

i trying convert array image ( tif ) compression (it undone @ other end). however, i'm falling @ first hurdle... i have following: pillow_image = image.fromarray(image_data) which gives me error: file "/users/workspace/test-app/env/lib/python2.7/site-packages/pil/image.py", line 2155, in fromarray arr = obj. array_interface attributeerror: 'tuple' object has no attribute ' array_interface ' what i'm doing wrong here? image_data tuple of 4 numpy arrays, each (probably) of shape (h, w). need image_data single array of shape (h, w, 4). therefore, use np.dstack combine channels. at least 1 of arrays has dtype int32. use 8-bit color channel, arrays needs of dtype uint8 (so maximum value 255). can convert array dtype uint8 using astype . data not contain values greater 255. if does, astype('uint8') keep least significant bits (i.e. return number modulo 256). image_data = np.dstack(image_dat...

nginx SSI module; disable file include? -

i looking @ nginx ssi module , wondering if there way block "file" option on ssi. http://nginx.org/en/docs/http/ngx_http_ssi_module.html so not this <!--# include file="/etc/passwd" --> i wasn't able find on security in regards include file, know this? first of all, way can won't happen run nginx non-root user (there many other reasons so, , i'm sure doing already). another thing consider ssis should treated privileged code, cgi scripts are. should not allow them untrusted users. that said, answer question nginx processes ( source code ) ssi include directive treating file , uri options identically , passing them ngx_http_subrequest . same serving file request given file, in particular in name resolved relative root directive in effect. there still security considerations , in general it's safer ssi parser open , read file on it's own.

jquery - Drop down Select with Images in Option in Backbone.js template -

i trying show images in dropdown options in backbone template . each option have image in it. have tried different ways of doing couldn't succeed. can let me know correct way of doing this. here code trying: <div class="optionwrapper"> <select id="<%= id %>" class="extra_option"> <% _.each(options, function (opt) { %> <option value="1" <img src="<? echo $uploads;?>option_thumbnails/<%= opt.thumbnail_file %>">></option> <% }); %> </select> </div> <div class="optionwrapper"> <select id=<%= id %> class="extra_option"> <% _.each(options, function (opt) { %> <option value="1" <img src="<? echo $uploads;?>option_thumbnails/<%=...

oop - Python - Getting subclass from input. Do I have to write a separate function? -

i'm working in python 2.7.8. follows slight variant of problem i'm working on. i have large number of custom classes i've written inheritance tree. behavior encapsulated following example: import random class animal(object): def __init__(self, name): self.name = name self.can_own_pets = false #most animals cannot own pets self.get_features() def give_pet(self, pet): if not self.can_own_pets: print(self.name+' cannot own pet!') else: self.pets.append(pet) def is_hungry(self): return random.choice([true, false]) def get_features(self): """ in classes, features function uses self.name extract features. in problem, features extracted regular expressions determined class. """ pass class human(animal): def __init__(self, name): super(human, self).__init__(name) ...

gradle - Error building Android app in release mode, in Android Studio -

i'm trying sign android app in release mode, in android studio. i followed this official guide . have created keystore , private key. tried generate signed apk, build -> generate signed api key . build fails, following error: :app:packagerelease failed error:a problem found configuration of task ':app:packagerelease'. > file 'c:\documents\myapp\android.jks' specified property 'signingconfig.storefile' not exist. i have checked build.gradle configuration. , have found this: signingconfigs { releaseconfig { keyalias 'xxxxxxxxxx' keypassword 'xxxxxxxxx' storefile file('c:\documents\myapp\android.jks') storepassword 'xxxxxxxxx' } } but in same gradle file have this: buildtypes { release { runproguard false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' ...

php - PDO query with session doesn't return anything -

i'm starting learn pdo , while doing decided rewrite old mysql_* code. have login form according userlevel redirects different locations. done ( i think since can login correctly ). next when redirects me have query depending of userlevel show result database. problem doesn't return , there no errors in logfile. login. doing correctly? session_start(); if(isset($_post['submit'])) { include 'misc/database.inc.php'; $pdo = database::connect(); $username=$_post['username']; $password=sha1($_post['password']); $stmt = $pdo->prepare("select * users username = :username , password = :password"); $stmt->bindparam(':username', $username); $stmt->bindparam(':password', $password); $stmt->execute(); $res = $stmt -> fetch(); if ($res['userlevel'] == 1) { // save type , other information in session future use. $_session['username'] = $username; $...