Posts

Showing posts from June, 2014

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; $

Read a text and click on a particular row of a table using Selenium in Java -

Image
i trying read , click value in row (row width=85) of table using selenium. far tried these 2 methods, unable locate value. attaching html code image. findelementbyxpath("//table/tbody/tr[2]/td[2]"); findelementbyxpath("//table[@width=\"85\"]/tbody/tr[2]/td[2]"); any help, appreciated. rely on id attributes table element , first td width="85" inside: findelementbyxpath('//div[@id="display"]/table[@id="tbldata"]//td[@width="85"]') note relying on width attribute doesn't seem reliable. alternatively, use indexes - second td in first tr tag inside table (indexing starts 1): findelementbyxpath('//div[@id="display"]/table[@id="tbldata"]//tr[1]/td[2]')

c# - Asp Net Web Forms Identity 2.0 Roles are Not Working -

please have install visual studio 2013. update 4. in last version have use , work follow. <location path="cadastro/cadastro_print.aspx"> <system.web> <authorization> <allow roles="medico"/> <allow roles="farmacia"/> <deny users="?"/> <allow users="*"/> </authorization> </system.web> </location> i did same in version vs 2013.4 , not worked. seems not recognize roles. i have read lot , didn´t find similar problem. seems bug. i have tried run: install-package microsoft.aspnet.providers in nuget. these package fill same data in role manager provider in web config , nothing.

vb.net - restricting a combobox to list values and outdated list values -

i creating program simplicity's sake records name of staff member receives phone call. program designed show old entries along creating new ones. the problem want user able select listed name drop box when creating new entry. list show current employees. yet, when viewing older calls combobox field needs display former employees took call may no longer in list. as far can tell microsoft control , properties there 2 options relate matter. dropdownstyle dropdown or dropdownlist . when using dropdown user can submit name (which not wanted). dropdownlist user can submit names on list, when browsing through old entries names no longer on list not appear on respective calls (which not wanted). i'm aware end having implement own combobox class wanted see if knew of more elegant fix combined both of these functionalities. thanks! it seems me have 2 modes. add mode adds new call record, while view mode displays old records. use drop down list restrict user lo

windows - Vagrant - Unable to sync folder from secondary drive -

whenever run vagrant up , same error: $ vagrant bringing machine 'www' 'virtualbox' provider... there errors in configuration of machine. please fix following errors , try again: vm: * host path of shared folder missing: /d/project and here relevant setup in vagrantfile : config.vm.synced_folder "d:\\cq", "/var/www/project", owner: "www-data", group: "www-data" my directory setup bit weird, maybe issue lies there. i'll list out can think of might causing vagrant up fail. my project lives in d:\ drive (not primary c:\ drive). source directory (java project) contained within target directory. want sync target dir (including sub-dir source) host machine win7, box ubuntu/trusty64 per this article i'm getting started vagrant, i'm sure i'm missing obvious, research isn't turning useful. i've tried adding... config.vm.provider :virtualbox |vb| vb.customize ["setextradata&quo

reporting services - Controlling row group in ssrs -

Image
i converting crystal report ssrs , need group variable. grouped variable , report looked fine except 1 thing. consider following grouped section (row grouping) +---------+------+----------+ | section | name | number | +---------+------+----------+ | 1 | aaa | 111-1111 | | | bbb | 222-2222 | | | ccc | 333-3333 | | 2 | ddd | 444-4444 | | | eee | 555-5555 | +---------+------+----------+ the thing trying achieve have section number heading instead of column , not column group talking about. report trying achieve move section heading each group , report like +-----------+----------+ | section | 1 | |name | number | | aaa | 111-1111 | | bbb | 222-2222 | | ccc | 333-3333 | | section 2 | | | name | number | | ddd | 444-4444 | | eee | 555-5555 | +-----------+----------+ i have been trying make change end changing structure of report. when googled grouping gave me column level ,

coordinates - Find the x and y of a case in a maze ( in C) -

i want find distance between case(n) , case(m), n!=m how can find x0, x1, y0 , y1 using case number, height , width in maze ? there formule ? float distance(maze* maze, int start, int end) { float x0 = ..??.. float x1 = ..??.. float y0 = ..??.. float y1 = ..??.. float dx = x0 - x1; float dy = y0 - y1; return sqrtf(dx*dx+dy*dy); } example of maze : <----------- width -------------> case0 | case1 | case2 | case3 | case4 | case5 | case6 | case7 | height case8 | case9 | case10 | case11 | first calculate indexes: int x0 = m % width; // % = modulo operation int y0 = m / width; int x1 = n % width; int y1 = n / width; int dx = x1 - x0; int dy = y1 - y0; return sqrtf(dx*dx + dy*dy); make sure perform index calculations int . int-division truncates decimals. modulo operation returns remainder of division. x % width yields value in range 0 .. width-1 .

python - How to Rename Multiple Columns on a Reset Index with Pandas -

i'm trying figure out if there way rename pandas columns when try reset index. see in documentation can use "name" parameter set column name of reset index if there 1 column, i'm curious if there way multiple columns. for example: df1 = pd.dataframe({ 'a' : ['a1', 'a1', 'a2', 'a3'], 'b' : ['b1', 'b2', 'b3', 'b4'], 'd1' : [1,0,0,0], 'd2' : [0,1,1,0], 'd3' : [0,0,1,1], }) df1.set_index(['b','a']).stack().reset_index() the result leaves with: out[82]: b level_2 0 0 b1 a1 d1 1 1 b1 a1 d2 0 2 b1 a1 d3 0 3 b2 a1 d1 0 4 b2 a1 d2 1 you do: df1.set_index(['b','a']).stack().reset_index(name='my_col') in order set name of last column i'm wondering if there way use parameter set name of 'level_2' column well. the first thing came mind try: df1.set_in

Makefile creating several mains as unit testing C++ -

i quite new makefiles want create c++ project unit tests. my project directory looks this: makefile src/ main.cpp file1.cpp file1.h file2.cpp file2.h ... test/ file1_test.cpp file2_test.cpp ... i want makefile compile program in src/ , compile programs in test/ directory. each *_test.cpp file contains main() function. have tried lot of things every time try compile run new problem , feels should quite easy task. (btw, got inspired tutorial http://c.learncodethehardway.org/book/ex28.html ) thanks help! edit: my current makefile looks this. (i had make changes fit more general example) cflags = libs = ldflags = -l/usr/local/ cc = g++ sources=$(wildcard src/**/*.cpp src/*.cpp) objects=$(patsubst %.cpp,%.o,$(sources)) target=build/myprogram test_src=$(wildcard test/*_test.cpp) tests=$(patsubst %.cpp,%.o,$(test_src)) tests_prg=$(patsubst %.cpp,%,$(test_src)) tests_obj=$(patsubst test/%_test.cpp,src/%.o,$(test_src)) all: $(target)

Haskell Compiled IO-Action order and Flushing -

this question has answer here: io happens out of order when using getline , putstr 3 answers i'm encountering strange behaviour io, within compiled haskell code. here's what's going on: -- myscript.hs main = putstr "enter name: " <- getline putstrln (a ++ " - that's nice name!") i run in ghci calling main , works 1 expect, first printing enter name: , doing whatever it's afterwards. however, when compile ghc (with , without --make ), first prompts line, , then prints @ once, this: $ ./myscript jimmy johnson enter name: jimmy johnson - that's nice name! to clarify, want occur in following sequence: $ ./myfixedscript enter name: jimmy johnson jimmy johnson - that's nice name! could explain why happens is, , how sequence io way expect to. note i've tried changing first line of do statem

dynamic programming - Obtaining the longest increasing subsequence in Python -

can tell me why code doesn't produce each increasing subsequence? used dynamic programming solve can't figure out why code fails. parameter a sequence of integers. def lis(a): # make list of lists l = list() in range(0, len(a)): l.append(list()) #the first increasing subsequence first element in l[0].append(a[0]) in range(1, len(a)): j in (0, i): # new larger increasing subsequence found if (a[j] < a[i]) , ( len(l[i]) < len(l[j]) ): l[i] = l[j] l[i].append(a[i]) # print increasing subsequence print l[i] example output produced = [3, 5, 10, 0, 1, 100, 2, 4, 7] algorithm: [3, 5] [3, 5, 10] [0] [1] [3, 5, 10, 100] [2] [3, 5, 10, 100, 4] [3, 5, 10, 100, 4, 7] none correct output: [3] [3, 5] [3, 5, 10] [0] [0, 1] [3, 5, 10, 100] [0, 1, 2] [0, 1, 2, 4] [0, 1, 2, 4, 7] two mistakes found in code 1.you assumed list immutable not in pytho

node.js - Installing Ionic framework- setting up env variables - Not working. -

i new js , planning build simple application i installing ionic , cordova using npm -g install ionic , did same cordova also. it gets installed in /usr/local/lib/ionic ionic points -> /usr/local/lib/node_modules/ionic/bin/ionic i this /usr/local/bin/ionic -> /usr/local/lib/node_modules/ionic/bin/ionic ionic@1.2.8 /usr/local/lib/node_modules/ionic ├── connect-livereload@0.4.0 ├── progress@1.1.7 ├── open@0.0.5 ├── colors@0.6.2 ├── ncp@0.4.2 now how set env variables? export ionic="/usr/local/lib/node_modules/ionic" export path=$path:$ionic/bin is right? i tried downloading ionic files, put them under /home/softwares/ionic , changed bashrc to export ionic="~/softwares/ionic" export path=$path:ionic what this? put short, npm install of ionic not work. if ionic -v or try ionic start blahblah blank nothing comes up. change node link: #run node #and in case displayed /usr/sbin/node. #if says command not found, skip 3. remove

python - With Django, what is the best practice way to add up a specific field on each object in a queryset? -

this how i'm getting total of each object.balance in queryset. feels wrong. there better way? (i'm struggling explain/write question see code below :) ) # models.py ... class foo(models.model): ... balance = models.decimalfield( max_digits=10, decimal_places=2, ) ... ... # utils.py ... def get_the_total(): objects = foo.objects.all() total_balance = 0 object in objects: total_balance += object.balance return total_balance ... there sum() built-in django: foo.objects.aggregate(sum('balance'))

mongodb - How do I return only unique collection fields from a Meteor collection? -

i have simple to-do app users enter to-do , tag submit. when click tag on left side, displays to-do associated it. filter list on left side unique tags. can't seem find anywhere. help? http://i.imgur.com/qcv6jmr.png http://i.imgur.com/vq0akip.png this works: template.all.helpers({ linklist: function() { var = *yourcollection*.find().fetch(); var *youruniquefielditems* = _.pluck(everything,"*yourfield*"); return _.uniq(*youruniquefielditems*); }, the top voted answer here: meteor: how search distinct field values aka collection.distinct("fieldname") similar mongo's doesn't work, author of post found solution himself. unfortunately, it's buried in comments , it's not actual answer.

Solving Rendering Artifacts in Frame Buffer with WebView and EditText on Android 5.0? -

Image
after upgrading nexus 5 android 5.0, activity default focus on edittext not render correctly (edittext repeats down across screen grey dots in between , if click again or dump viewhierarchy uiautomator, return normal rendering). (i upload image, don't yet have reputation images). note: after have loaded webview within application (though in separate activity). same screen renders correctly prior loading first webview in application. note: problem on android 5.0 , (so far) on nexus 5. not have 5.0 (non-nexus) device try. edit: happened on htc 1 android 5.01. note: have tried disabling hardware acceleration, modifying inputmode, , defaultfocus. has seen or solved problem? ended solving changing softinputmode (similar previous webview/keyboard issues, time native view , edittext). getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_visible);

api - Powershell Invoke-RestMethod -

i'm trying create powershell script access dyn's api , perform checks/updates on dns zones use/test. i'm following api details , here's first link, https://help.dyn.com/session-log-in/ here's beginning of rest script i've put together: $url = "https://api2.dynect.net/rest/session/" $body = @{customer_name='mahcompany';user_name='mahname';password='mahpass'} invoke-restmethod -method post -uri $url -body $body this produces following results: invoke-restmethod : remote server returned error: (406) not acceptable. @ line:12 char:9 + $test = invoke-restmethod -method post -uri $url -body $body + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (system.net.httpwebrequest:httpwebrequest) [invoke-> restmethod], webexception + fullyqualifiederrorid : webcmdletwebresponseexception,microsoft.powershell.commands.invokerestmethodcommand

Spring MVC + Thymeleaf java.io.IOException: The filename, directory name or volume label syntax is incorrect -

i'm building web app on spring mvc framework , using thymeleaf template engine. i had working app before adding new rest controller. ioexception thrown java.io.ioexception: filename, directory name or volume label syntax incorrect java.io.ioexception: filename, directory name or volume label syntax incorrect @ java.io.winntfilesystem.canonicalize0(native method) @ java.io.win32filesystem.canonicalize(win32filesystem.java:414) @ java.io.file.getcanonicalpath(file.java:618) @ org.eclipse.jetty.util.resource.fileresource.getalias(fileresource.java:195) @ org.eclipse.jetty.server.handler.contexthandler.checkalias(contexthandler.java:1599) @ org.eclipse.jetty.server.handler.contexthandler.getresource(contexthandler.java:1583) @ org.eclipse.jetty.webapp.webappcontext.getresource(webappcontext.java:360) @ org.mortbay.jetty.plugin.jettywebappcontext.getresource(jettywebappcontext.java:338) @ org.eclipse.jetty.webapp.webappcontext$context.getresource(webappcontext.java:1325) @

java - Hibernate Query for unmapped join table -

i'm j2ee newbie trying learn hibernate. have 2 tables, system , game, , join table called systems_game. i want able put in game_id , of systems game. i using annotations on system.java , game.java create many-to-many relationship. @manytomany(targetentity = system.class, cascade = { cascadetype.all }) @jointable(name="systems_game", joincolumns = { @joincolumn(name="game_id") }, inversejoincolumns = { @joincolumn(name="system_id") }) private list<game> games; and here method using try result want. @override public list getgamesystem(){ return sessionfactory.getcurrentsession().createquery("from systems_game s s.game_id=1").list(); } when runs, get "request processing failed; nested exception org.hibernate.hql.ast.querysyntaxexception: systems_game not mapped [from systems_game s s.game_id=1]" i know don't have systems_game mapped in hibernate.cfg.xml file, don&

terminal - Batch renaming of files with a modified timestamp on Linux -

as part of personal project have generated large number of frames. i want rename around 6000 png image files in terminal within name have time frame represents. e.g frame_0001.png frame_ddmmyy_hhmmss.png frame_0001.png frame_201114_134612.png frame_0002.png frame_201114_134613.png , on... the first frame starts @ 13:46:12 on 20th november 2014. want rest of images renamed sequentially named after date , time represent. any appreciated. with perl's (p)rename : rename -n "s/\d+/$(date +%d%m%y_%h%m%s)/" frame_0001.png

amazon web services - Ansible EC2 - Perform operation on set of instances -

this obvious, how execute operation against set of servers in ansible (this ec2 plugin)? i can create instances: --- - hosts: 127.0.0.1 connection: local - name: launch instances local_action: module: ec2 region: us-west-1 group: cassandra keypair: cassandra instance_type: t2.micro image: ami-4b6f650e count: 1 wait: yes register: cass_ec2 and can put instances tag: - name: add tag instances local_action: ec2_tag resource={{ item.id }} region=us-west-1 state=present with_items: cass_ec2.instances args: tags: name: cassandra now, let's want run operation on each server: # not work - runs command on localhost - name: test - touch file file: path=/test.txt state=touch with_items: cass_ec2.instances how run command against remote instances created? for running against newly created servers, use temporary group name , following using second

multithreading - C++ app performance varies when using threads -

i have c++ app 2 threads. app displays gauge on screen, indicator rotates based on angle received via udp socket. problem indicator should rotating @ constant rate behaves time slows down @ times, , fast-forwards catch @ other times, pauses intermittently. each frame, display (main) thread guards copy of angle udp thread. udp thread guards writing shared variable. use windows criticalsection object guard 'communication' between threads. udp packet received @ approximately same rate display update. using windows 7, 64 bit, 4-core processor. i using separate python app broadcast udp packet. use python function, time.sleep, keep broadcast @ constant rate. why application slow down? why application seem fast-forward instead of snapping latest angle? proper fix? edit: not 100% sure angle values remembered when app seems 'fast forward'. app snapping value (not sure if 'latest') @ times. edit 2 : per request, code. void app::udp_update(dword thread_id)

ios - Leak when downloading with AFNetworking -

Image
basically when file done downloading, there's "something" in memory never gets released. here's simplistic example of code causing problem, memory goes around 50mb , sits there , never gets released (see screenshots below). idea of what's going on? -(void)download { nsstring* urlstring = @"http://download.thinkbroadband.com/50mb.zip"; nsmutableurlrequest* request = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:urlstring]]; afhttprequestoperation* operation = [[afhttprequestoperation alloc] initwithrequest:request]; [operation setdownloadprogressblock:^(nsuinteger bytesread, long long totalbytesread, long long totalbytesexpectedtoread) { nslog(@"%lldmb of %lldmb downloaded", totalbytesread / 1024 / 1024, totalbytesexpectedtoread / 1024 / 1024); }]; [operation setcompletionblockwithsuccess:^(__weak afhttprequestoperation *operation, id responseobject) { nslog(@"download completed.&qu

Java POST request to ASP.NET fails, C# works -

i have asp.net web api2 application controller has: public class licensecontroller : apicontroller { [route("license")] [httppost] public xmldocument postlicense([frombody] xmldocument inputstream) { xmldocument doc = new xmldocument(); doc.loadxml("<root/>"); return doc; } } and if post c# app, receives request , returns "root/>": static void main(string[] args) { string xml = "<david><shirley/></david>"; uri httpsite = new uri(phonehomeuri + "/license"); webrequest wreq = webrequest.create(httpsite); wreq.usedefaultcredentials = true; wreq.preauthenticate = true; wreq.credentials = credentialcache.defaultcredentials; wreq.method = "post"; wreq.contenttype = "text/xml"; str

c - Openssl how to find out what the bit size of the public key in an X509 certificate is -

if have x509* openssl has provided me, what's best way figure out bit-ness of rsa public key in certificate? can't quite figure out. i'm pretty sure if i'm in ssl certificate verification callback, can x509 ptr with x509 * cert = x509_store_ctx_get_current_cert(the_x509_store_ctx); and surmise public key this evp_pkey *public_key = x509_get_pubkey(cert); and need check whether it's rsa, presumably? if (public_key && (evp_pkey_rsa == public_key->type)) and once know got public key , it's rsa, i'd this: int key_length = bn_num_bits(public_key->pkey.rsa->n); but i've found while works quite nicely on openssl 0.9.8, on 1.0.1h segfaults on windows. bignum 'n' doesn't seem valid - data ptr in has garbage pointer. any idea what's wrong? as suggested, rsa modulus size in bytes (so not "bit size"...) use: evp_pkey * public_key = x509_get_pubkey(cert); rsa *rsa_key = evp_pkey_get1_rsa(pub

sockets - Python 3.4 - Connect to imap server using only TLSv1 -

i'm trying connect imap mail server using tlsv1 in python 3.4. after troubleshooting (most of determined mail server supports tlsv1), i've found can connect server using openssl: openssl s_client -connect mail.calpoly.edu:993 -tls1 as sockets package in python 2.7: python 2.7.6 (default, mar 22 2014, 22:59:56) [gcc 4.8.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import ssl >>> import socket >>> >>> sock = socket.socket(socket.af_inet, socket.sock_stream) >>> ssl_sock = ssl.wrap_socket(sock=sock, ssl_version=ssl.protocol_tlsv1) >>> ssl_sock.connect(('mail.calpoly.edu', 993)) >>> ssl_sock <ssl.sslsocket object @ 0x7fbab6e7aed8> when try connect in python 3.4, however, handshake error: python 3.4.0 (default, apr 11 2014, 13:05:11) [gcc 4.8.2] on linux type "help", "copyright", "credits

c - using function to print two variables -

the function seems not work, correct form when print variable(string) in function? void f1(char ara, char arb) { printf("acronym found:\n %s - %s\n", ara, arb); } int main(void) { char arc[20],ar1[] = "afaik",ard1[] = "as far know"; printf("welcome internet system\nenter \"quit\" exit program\n"); { printf("enter string: "); scanf("%s", &arc); if (strcmp(arc, ar1) == 0) f1(ar1, ard1); ....... just change type of arguments in f1 pointer variable. void f1(char *ara, char *arb) because while giving char take 1 character has 1 byte store character. when convert character pointer, have 4 bytes store string.

Pagination with large json results using PHP and AngularJS -

so have parse large set of data that's been formatted json, stored in database. require_once('db.php'); error_reporting(1); $getusers = mysqli_query($db, 'select * mcmmo_users limit 300'); $rows = array(); while ($r = mysqli_fetch_assoc($getusers)) { $skills = array(); $temprow = $r; $getskills = mysqli_query($db, "select * mcmmo_skills user_id = '" . $r['id'] . "' limit 300"); while ($r = mysqli_fetch_assoc($getskills)) { unset($r['id']); $skills[] = $r; } $temprow['skills'] = $skills; $rows[] = $temprow; } header('content-type: application/json'); echo json_encode($rows); which outputs: [{"id":"1","user":"user1","lastlogin":"1402936307","skills":[{"user_id":"1","taming":"4","mining":"534","woodcutting":"

html - How to get a <img> tag the focus -

i have below code in html page: <img id="image_java" alt="image_not" src="images/java-icon.png"> in css page below code: #image_java: focus { outline: 2px solid blue; } i have tried: img:focus{ outline: 2px solid blue; } but non of them seem work, suppose display blue margin around image when focus. 1 know how that? thank you!!! you can't "focus" image unless have interactive element or navigate using tab. try adding interactive element on wrapper div so: html <a class="imageanchor" href="#"> <img id="image_java" alt="image_not" src="http://www.w3schools.com/images/w3logotest2.png" /> </a> css .imageanchor:focus img{ border: 2px solid blue; } http://jsfiddle.net/4x7wg7sb/1/

list - Haskell recursion odd -

i have define own predicate function recursively searches list of numbers , returns true if finds odd number, false otherwise. i have set x = [1..100] test data need show. however, bit unsure how recursion search list. i'm not looking definitive answer explanation on how recursion go around searching in list. what want function any odd : any :: (a -> bool) -> [a] -> bool odd :: integral => -> bool odd :: integral => [a] -> bool anyodd :: integral => [a] -> bool anyodd = odd if want define anyodd function have use recursion: anyodd :: integral => [a] -> bool anyodd [] = undefined anyodd (x:xs) | odd x = undefined | otherwise = undefined you need replace undefined actual logic.

Dynamically cross-join multiple different-size collections together in Linq (C#) -

i have unknown number of buckets(collections), , each bucket having unknown number of entities i need produce cartesian product of entities, endup single collection has arrays of entities , in each array, there 1 representetive every bucket. so if have 5 buckets (b1..b5), , buckets b1, b2 have 1 item each, , bucket b3, b4 , b5 have 4, 8 , 10 items each, i'll have collection of 320 arrays, , each array have 5 items. the stupud issue here, both size of buckets , number of buckets unknown @ development time. performance not super important here, of time, buckets have 1 entity, , there times when of buckets contain 20-30 items...and i'll have 5-30 buckets i'd love utilize linq here in someway, brain getting fried try imagine how work you create extension method following: public static class enumerableextensions { public static ienumerable<tvalue []> permutations<tkey, tvalue>(this ienumerable<tkey> keys, func<tkey, ienumerable&

emacs - tern auto-complete gives ac-show-menu (wrong-type-argument stringp nil) -

i'm trying tern autocomplete working. i'm on osx 10.10 stacktrace: http://pastebin.com/fdsc2ymv i found link maybe regarding issue: https://github.com/auto-complete/auto-complete/issues/309 my version of popup latest (0.5.1) here segment of init.el looks like ;; javascript mode (require 'js2-mode) (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) (add-hook 'js2-mode-hook (lambda () (tern-mode t))) (eval-after-load 'tern '(progn (require 'tern-auto-complete) (tern-ac-setup))) any ideas? i've tried directly copying repo, adding load path, i'm inclined believe it's auto-complete. not sure if problem, had error until added .tern-project file project root directory. { "plugins": { "node": { } } }

javascript - How to know which data has been changed in an array? -

i'm trying data has been changed in array. use case first time data fetch ajax , show within row , fetch new data using $http every 5 second. need know if new data same old one. if yes value has changed i've update background color.. what i've tried var app = angular.module('app', []); app.controller('listingcontroller', function($scope, $http, $timeout){ $scope.listings; setinterval(function(){ $http.get('_includes/ajax.php?req=get'). success(function(data, status, headers, config) { $scope.listings = data; console.log(data); }). error(function(data, status, headers, config) { // log error }); }, 5000); }); app.controller('rentaldatecontroller', function($scope, $log){ console.log($scope.listings); $scope.$watch('listings.third_column', fu

c++ - want to efficiently overcome mismatch between key types in a map in Boost.Interprocess shared memory -

i'm creating map (from string string in example) in shared memory using boost.interprocess. compiler seems want force me, during retrieval map, allocate memory in managed segment (unnecessarily) contain query term. i'd able values in shared map more efficiently, matching map's keys against instances in non-shared memory, without performing allocation. it's refusing compile if try use std::string or const char * argument map's find method. (see compiler error messages @ bottom). do need define sort of comparator method between shared-memory key type , non-shared equivalent ( std::string in example)? if so, should , how should make map use it? if not, should do? here's code, followed compiler errors. problem towards bottom of main() . // shmap2.cpp #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/containers/map.hpp> #include <boost/i