Posts

Showing posts from August, 2013

python - How to save a pygame sprite-group using the shelve module -

i'm making game in want have save game feature. have sprite group want save using shelf module, 'can't pickle surface objects' error when trying save sprite group. wondering if there way use shelf module save sprite group, , if there isnt, other saving method should use? i'd store relevant values of sprites in json file when user wants save game. load game, empty sprite group, reconstruct sprites loaded data , add them group. e.g. (click on sprites drag them around , press "s" save , "w" load): import sys import json import pygame pg class actor(pg.sprite.sprite): def __init__(self, pos, color): super().__init__() self.color = color self.image = pg.surface((32, 52)) self.image.fill(self.color) self.rect = self.image.get_rect(topleft=pos) class game: def __init__(self): self.fps = 30 self.done = false self.bg_color = pg.color('gray13') sel

email - restore my zipped mail/vhosts to EML format -

i have backup of emails in zip file of inbox, comes /var/mail/vhosts (in server using postfix , dovecot)... there way export *.eml standard files? the internal structure of (zipped) /var/mail/vhosts is ./domainx ./usery: cur dovecot.index.cache dovecot.index.log dovecot-uidlist dovecot-uidvalidity dovecot-uidvalidity.5841a6de ./new: 1480697566.m521262p3329.domainx,s=712,w=732 1481232945.m96892p15057.domainx,s=712,w=732 ./tmp: (empty) alternative: outlook's .pst , prefer popular open formats eml.

excel - Pivot Table with vba -

i'm trying create pivot table using vba. need code take sheet , create pivot using data in it. columns in pivot need: "years" first , "document date" row "arrears after net due date" values need sum of "amount" i tried code below gives me "object required error" i've never make pivots before i'm not sure if i'm on right track. sub newpvt() set rng = wsa.range("a1:aa100000") set rngdata = range(rng, rng.end(xltoright)) set rngdata = range(rng, rng.end(xldown)) set rngb = wsb.range("c8") activeworkbook.pivotcaches.create(sourcetype:=xldatabase, sourcedata:=rngdata, version:=xlpivottableversion14).createpivottable tabledestination:=rngb, tablename:="pvtreporta_b", defaultversion:=xlpivottableversion14 end sub you need assign pivot table object: sub newpvt() dim rng range, rngdata range, rngb range dim pvt pivottable set wsa = worksheets("name of s

java - Use spring projection with JPA specification -

i trying ot use jpa specification api spring projection find entities matching search criteria. here's class hierarchy : **a.java** string name; instant timestamp; integer count; ... **aprojection.java** @projection(types = a.class) public interface athumbnail { public integer getcount(); public string getname(); } **arepository.java** public interface arepository extends baserepository<a, integer>, jpaspecificationexecutor<a> { page<athumbnail> findall(specification<a> var1, pageable var2); } **acontroller.java** page<athumbnail> pageda = repository.findall(getspecifiation(wherecriteria), pagingdetail); now getting compile error saying findall(org.springframework.data.jpa.domain.specification<a>,org.springframework.data.domain.pageable) in arepository clashes findall(org.springframework.data.jpa.domain.specification<t>,org.springframework.data.domain.pageable) in org.springframework.data.jpa.repository.jpaspe

python - SQL get aggregate value within a time-window in a time-series table -

i trying write sql method in python using sqlite/sqlalchemy build new table containing analyzed data mean, median, max, var on period of time, based on table contains raw time-series data. let's raw data , timestamp not evenly distributed. want table: raw data table, aggregate value on 60-second sliding time window, e.g.: raw: time value 11:11:12 12 11:11:22 24 11:11:34 16 11:12:21 18 11:12:45 22 11:13:03 15 and want get: id window_time mean median max var 1 11:11 mean(12,24,16) med(12,24,16) ... 2 11:12 mean(18,22) ... 3 11:13 ... ... how group data according timestamp? if time column of time type ( https://dev.mysql.com/doc/refman/5.7/en/time.html ) in group by. group time_format(`time`, '%h:%i') if, on other hand, column string type, things little trickier. suppose, if can guarantee every value in format hh:ii:ss, use substring . group substring(`time` 1 5) i

windows - Stackoverflow error in Fortran with OpenMP -

Image
i trying run openmp fortran code using intel fortran. at beginning of code allocate 7 large matrices: ! allocate real, allocatable :: m1(:,:,:,:,:,:,:,:,:) real, allocatable :: m2(:,:,:,:,:,:,:,:,:) real, allocatable :: m3(:,:,:,:,:,:,:,:,:) real, allocatable :: m4(:,:,:,:,:,:,:,:,:) real, allocatable :: m5(:,:,:,:,:,:,:,:,:) real, allocatable :: m6(:,:,:,:,:,:,:,:,:) real, allocatable :: m7(:,:,:,:,:,:,:,:,:) allocate(m1(2,161,20,2,2,21,30,2,2)) allocate(m2(2,161,20,2,2,21,30,2,2)) allocate(m3(2,161,20,2,2,21,30,2,2)) allocate(m4(2,161,20,2,2,21,30,2,2)) allocate(m5(2,161,20,2,2,21,30,2,2)) allocate(m6(1,161,20,2,2,21,30,2,2)) allocate(m7(1,161,20,2,2,21,30,2,2)) i run code big parallelized loop. !$omp parallel default(private) shared(m1, m2, m3, m4, m5, m7, someothervariables) some of matrices m1 m7 indeed used in subroutines, might lead creation of temporary arrays. in case code runs fine if done serially. crashes following error if ru

java 8 - JbossFuse - not found a way to get a simple rest-dsl example to work... Odd, somewhat indecipherable exception -

Image
do not know make of exception, continues appear on each deployment attempt... 2017-07-27 16:54:15,583 | warn | edhat-187/deploy | fileinstall | 9 - org.apache.felix.fileinstall - 3.5.0 | error while starting bundle: file:/c:/tools/jboss-fuse-6.3.0.redhat-187/deploy/cxf-rest4-1.jar org.osgi.framework.bundleexception: unresolved constraint in bundle aaa.bbb.ccc.cxf-rest4 [307]: unable resolve 307.0: missing requirement [307.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel)(version>=2.19.0)(!(version>=3.0.0))) @ org.apache.felix.framework.felix.resolvebundlerevision(felix.java:4002)[org.apache.felix.framework-4.4.1.jar:] @ org.apache.felix.framework.felix.startbundle(felix.java:2045)[org.apache.felix.framework-4.4.1.jar:] @ org.apache.felix.framework.bundleimpl.start(bundleimpl.java:976)[org.apache.felix.framework-4.4.1.jar:] @ org.apache.felix.fileinstall.internal.directorywatcher.startbundle(directorywatcher.java:1245)

php - Laravel DB : first() method brings the Response content must be a string -

i use laravel illuminate , error when use first() method single result: the response content must string or object implementing __tostring(), "object" given. return db::table('todos')->where("title","your list")->first(); if select get() method works: return db::table('todos')->where("title","your list")->get(); do know what's wrong first statement? when ->get() , illuminate\support\collection object back. object can returned response, since implements __tostring() method: /** * convert collection string representation. * * @return string */ public function __tostring() { return $this->tojson(); } /** * collection of items json. * * @param int $options * @return string */ public function tojson($options = 0) { return json_encode($this->jsonserialize(), $options); } /** * convert object json serializable. * * @return array */ public function json

javascript - "Can't bind to 'myComponentProperty' since it isn't a known property of 'myComponent'" -

i've created ng2 component uses child ng2 component. child component represents list item gets bound within ngforof loop in parent component: <div *ngif="blogpostlistitems"> <ng-template ngfor blogpostlistitem [ngforof]="blogpostlistitems | async"> <div> <blog-post-list-item [blogpostlistitem]="blogpostlistitem"></blog-post-list-item> </div> </ng-template> </div> the following exception getting logged console each blogpostlistitem in collection: "unhandled promise rejection: template parse errors: can't bind 'blogpostlistitem' since isn't known property of 'blog-post-list-item'. but blogpostlistitem property defined in blog-post-list-item.component.ts: import { component, input, oninit } '@angular/core'; @component({ selector: 'blog-post-list-item', templateurl: '../../../ng2/templates/blog-post-lis

java - WARNING: Failed to scan <>.jar from classloader hierarchy. FileNotFoundException -

so have project: https://github.com/leejjon/blindpool when try release app engine google app engine deployment run configuration in intellij works , deploys fine too. but lot of warnings (this one): deploying '[2017-07-27 23:15:04] maven build: blindpool. project: blindepoule. version: 6'... created temporary staging directory: c:\users\leejjon\appdata\local\temp\gae-staging-blindepoule684 reading application configuration data... jul 27, 2017 11:15:06 pm com.google.apphosting.utils.config.indexesxmlreader readconfigxml info: processed c:\users\leejjon\ideaprojects\blindpool\target\blindpool-1.0-snapshot\web-inf\appengine-generated\datastore-indexes-auto.xml beginning interaction module default... 0% scanning jsp files. 0% compiling jsp files. jul 27, 2017 11:15:07 pm org.apache.tomcat.util.scan.standardjarscanner scan warning: failed scan [file:/c:/users/leejjon/appdata/local/google/cloud%2520sdk/google-cloud-sdk/platform/google_appengine/google/appengine/tools/jav

javascript - Change route onClick of div react -

i need wrap navigational component in react in div acts link/a (i have <a></a> nested in nav item , can nest <a></a> within. need re-route user new route on click of outer div acting wrapper. have multiple navigational sections , want use onclick={this.handlenavclick(newroute)} not having success. console logging correct linkpath nothing happens on click. here function: handlenavclick(linkpath) { console.log(linkpath) let currentpath = window.location.pathname; currentpath = window.location.linkpath; }, here example of me trying re-route nav section: getnavitem() { const currentpath = window.location.pathname; const reportpath = "/reporting"; return ( <div onclick={this.handlenavclick(dashboardspath)}> <li id="nav-item-view" classname={ classnames({"active": currentpath === reportpath}, "sidebar-item")}> <div classn

python 3.x - python3 ftplib SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:645)') -

hello trying simple read , write files simple ftp file zilla server using passive mode , explicit tls have setup works fine file zilla client. cannot figure out how resolve error when reading or writing. commands other things mkdir work fine well >>> ftplib import ftp_tls >>> import subprocess >>> import io >>> import os >>> import sys >>> datetime import datetime, date, time >>> os.path import basename >>> local_filename = os.path.join(os.getcwd(), 'kansascitytestdata.csv') >>> print(local_filename) /var/www/kansascitytestdata.csv >>> myfile = open(local_filename, 'wb') >>> myfile <_io.bufferedwriter name='/var/www/kansascitytestdata.csv'> >>> command = 'retr /%s' % 'kansascitytestdata.csv' >>> command 'retr /kansascitytestdata.csv' >>> ftp = ftp_tls('111.111.111.111') #except real info >>

db2 - How can I create a temporary numbers table with SQL? -

so came upon question asked list of unused account numbers. query wrote works, kind of hacky , relies on existence of table more records existing accounts: with tmp (select row_number() over( order cusno) custtable fetch first 999999 rows only) select tmp.a tmp not in (select cusno custtable) this works because customer numbers reused , there more records unique customer numbers. but, said, feels hacky , i'd generate temporary table 1 column , x records numbered 1 through x. looked @ recursive solutions, of looked way more involved solution wound using. there easier way doesn't rely on existing tables? i think simple answer no. able make determination of absence, platform needs know expected data set. can either generate temporary table or data set @ runtime - using method you've used (or variation thereof) - or can create reference table once, , compare against each ti

git - Multiple Folder Cloud Sync -

i mod , map creator , want work on mods @ multiple pcs. unfortuantely cloud syncing tools allow single folder (dropbox folder, googledrive folder), modding tools want files in specific location (e.g. ...documents/awesomecompany/awesomegame/mods or appdata/anothercompany/maps). i don't want move files around everytime, when finish working. preferably have git, can call git init in "...documents/awesomecompany/awesomegame/mods" , push/pull files whenever needed. well, why don't use git? because git not optimized binary files , if change files, repository grow needlessly large. enough me store recent version in cloud. have checked git annex, git media , git lfs, if understand correctly, add-on must installed on server? , honest, posts i've read, don't quite understand do, seems don't upload files except tell them to? , i'm not sure if keep 1 copy/history version of file? to sum up: there convenient way synchronize folders binary files @ arbitrar

autoencoder - Feeding a hidden tensor in Tensorflow -

i have autoencoder . model not important now. suppose model takes input image , output reconstructed image. after training, see effect of 1 tensor on output. in addition, images being fed autoencoder through fifoqueue . therefore, when running following peace of code: reconstructed_image = sess.run([deconv_image], feed_dict={mu:my_vector}) where deconv_image output tensor of model , mu hidden tensor inside model; automatically feed model image queue . my question is: value inside mu replaced whatever should come input image, or, takes vector fed using feed_dict argument. any appreciated!! when running final tensor, is, evaluating last tensor of graph, run tensors depends on. if have y3 operation depends on y2 , y2 depends on y1 , then, running final tensor in graph cause y1 run first, y2 evaluated after gets input y1 , finally, output of y2 feed y3 . graph follows: y1 -> y2 -> y3 on other hand, can run (evaluate) y3 feeding inputs directly us

Kill a forked process in a docker container make the container exit on Jenkins docker slave plugin -

i using docker build , testing. during testing, test cases launch separate process(mongod process) , after test cases finish kill process. during whole test cases running time, mongod process generated , killed many times. problem have when mongod process killed, docker container exits code 137. docker file below: from ubuntu run sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list && apt-get update && apt-get install -y curl run apt-get update && apt-get install -y --no-install-recommends \ openssh-client openssh-server rsync vim \ dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev \ && curl -ol https://github.com/git/git/archive/v2.13.1.tar.gz \ && tar -zxf v2.13.1.tar.gz && cd git-2.13.1 && make configure && ./configure --prefix=/usr && make && make install && cd .. \ && apt-get remove -y dh-autoreconf

c# - ASP.NET CORE: Database Connection Issue (SQLite) in Production -

os: linux, centos proxy: apache asp.net core 1.1 problem: got moment app when decided deploy on real server. so worked , works fine on local machine. have no issues. but when published , uploaded server doesn’t work way expected. , mean database (sqlite). the app reads data db supposed to , whenever there await _db.savechangesasync() in code app crashes. i have searched on internet , didn’t me. so far have 3 different exceptions: sqlite error 8: ‘attempt write readonly database’. i changed permissions of db file 777 folder self, doesn’t help. got this: sqlite error 14: ‘unable open database file’. when tried add configure: app.useforwardedheaders(new forwardedheadersoptions { forwardedheaders = forwardedheaders.xforwardedfor | forwardedheaders.xforwardedproto }); got exemption: warn: microsoft.aspnetcore.httpoverrides.forwardedheadersmiddleware[1] parameter count mismatch between x-forwarded-for , x-forwarded

compiler errors - gcc : unknown type name -

i trying install linear solver called pdslin on ubuntu16.04 lts machine. installed dependencies when running make pdslin got warnings , errors. not understand -c in gcc -c come , whether reason of not identifying "superlu_options_t" variable. (cd src; make lib;) make[1]: entering directory '/home/afrah/pdslin/src' (make all; cd slu; make lib) make[2]: entering directory '/home/afrah/pdslin/src' gcc -c -i/home/afrah/pdslin/include -i/home/afrah/superlu_5.2.0/src -i/usr/include -ddebuglevel=0 -dprntlevel=0 -dadd_ -duse_vendor_blas -i/home/afrah/superlu_dist_5.1.2/src -dscotch_order -i/usr/local/include -i/usr/share/parmetis/include -i/usr/share/mpich-install/include -i/home/afrah/petsc/include -i/home/afrah/petsc/arch-linux2-c-debug/include -wall -dwith_hips -dwith_petsc pdslin_graph.c pdslin_graph.c: in function ‘a_plus_at_comprow_loc_with_diag’: pdslin_graph.c:51:26: warning: variable ‘sz_tcolind_loc’ set not used [-wunused-but-set-variable] int

Differences between lua 5.2 and 5.3 table libraries -

in official lua 5.3 documentation in multiple places talks changes made ipairs , table standard library made in order make them "respect metamethods," not find reference specific changes or find code samples illustrating these differences. if knows of resources detailing differences between versions extremely helpful. links: https://www.lua.org/manual/5.3/manual.html#8 https://www.lua.org/manual/5.3/readme.html#changes if remember correctly respect __len , __index , , __newindex . __ipairs no longer supported. this may not complete list, has been while since worked 5.2 much...

css - In Bootstrap3, how to change the order of collapsed elements in navbar? -

i using bootstrap3 <nav> , in sample code team used navbar-toggle collapsed class collapse elements in navbar on small screen. my question how change order of them when collapsed? made short snippet: <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-default"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".nav" aria-expanded="false"> <span class="sr-only">options</span> <span class="icon-bar"></span> <span class="icon-bar&q

java - Android getDeclaredFields() return a disorder result -

i declared class this: public class student implements serializable { private static final long serialversionuid = 8010508999597447226l; public long id; public string name; public int age; public string phone; public string address; public static void main(string[] args) { field[] fields = student.class.getfields(); system.out.println("getfields(): " + fields2string(fields)); fields = student.class.getdeclaredfields(); system.out.println("getdeclaredfields(): " + fields2string(fields)); } private static string fields2string(field[] fields) { if (fields != null) { stringbuilder sb = new stringbuilder(); (field f : fields) { sb.append(f.getname()); sb.append(","); } return sb.tostring(); } return null; } } the main running result is: (the order same student.java, expected o

How to add notification in Ruby on Rails applicatioon? -

i have application build ruby on rails, can see here: sidodi . this app has 2 models, user , outgoingmail. outgoingmail model has status can change draft final. it has 3 user role: conseptor head of division head of office the workflow is: conceptor create new outgoingmail default status draft conceptor send outgoingmail , status change draft-1 head of division check outgoingmail head of division send outgoingmail , status change draft-2 conceptor view , change outgoingmail conceptor send outgoingmail revision , status change draft-3 head of division check outgoingmail head of division send outgoingmail , status change draft-4 conceptor view , change outgoingmail conceptor send outgoingmail revision , status change draft-5 head of office check outgoingmail head of office send outgoingmail , status change draft-6 conceptor view , change outgoingmail conceptor send outgoingmail revision , status change draft-7 head of office check outgoingmail head of of

sql server - SQL join query performance issue -

Image
i have 2 tables: 1. [user].[users] -------------------------------------------------- |[userid] | int (primary key) | |[username] | nvarchar(50) | |[isverified] | bit | |[modifieddate] | datetime | -------------------------------------------------- 2. [user].[emailaddresses] -------------------------------------------------- |[userid] | int (foreign key) | |[emailaddressid] | int | |[emailaddress] | nvarchar(50) | |[isprimary] | bit | |[isverified] | bit | |[modifieddate] | datetime | -------------------------------------------------- now, when run query, performs great: select u.[userid], u.[username], u.[isverified], e.[emailaddressid], e.[emailaddress] [user].[users] u inner

javascript - Warning - Unhandled promise rejection: Can't set headers after they are sent -

i have route handler this: router.route('/sipprovider/:sipprovider_id/phonelist') .post((req, res) => { const body = req.body; if (typeof body.phones === 'undefined') { return res.status(400).json({ success: false, error: { message: 'invalid input' } }); } if (!array.isarray(body.phones) || body.phones.length === 0) { return res.status(400).json({ success: false, error: { message: 'invalid input' } }); } let = body.phones.indexof(''); while (i >= 0) { body.phones.splice(i, 1); = body.phones.indexof(''); } body.phones.map((phone) => { if (typeof phone !== 'string') { return res.status(400).json(

android - Reverse animation for Shared Element transition on Grid Recyclerview always moves to last item -

i using shared element transition on click of recyclerview item. on click of item imageview smoothly transitions detail activity. however, on clicking button, transition imageview goes last item of recyclerview. not able understand reason behind it, inputs appreciated. here code. <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.noactionbar"> <!-- customize theme here. --> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/coloraccent</item> <item name="android:windowcontenttransitions">true</item> </style> griditem.xml <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

c - Linked List elements not getting displayed -

this program in c inserts linked list @ end. when try print list elements, nothing displayed. here code : #include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; void insert(struct node *, int); int main(void) { struct node *head = null, *current; int n, i, x, data; scanf("%d", &n); for(i = 0; < n; i++) { scanf("%d", &data); insert(head, data); } current = head; while(current != null) { printf("%d ", current->data); current = current->next; } } void insert(struct node *head, int data) { struct node *newnode, *current = head; newnode = (struct node *)malloc(sizeof(struct node)); newnode->data = data; newnode->next = null; if(head == null) { head = newnode; } else { while(current->next != null) { current = current->next; }

Ng-click and ng-change aren't being fired when using component and template angular 1.6 -

i trying fire function when typed input. reason, not working when use template , component. can me figure out why happening? new angular way. component when button clicked or when typed input, ng-click , ng-change functions should fire not. (function(angular) { 'use strict'; angular .module('app') .component('coinsearch', { controller: coinsearchcontroller, controllaras: 'coin', templateurl: 'src/coinsearch.html' }); function coinsearchcontroller(cryptoservice) { var coin = this; var list = []; coin.jank="something weird"; coin.savedcoins = []; coin.searchedcoin = ''; function getcrypto() { //pulls data api cryptoservice .retrieve() .then(function(response) { coin.list = response; }); } coin.click = function() { console.log('hellooo'); }; coin.showsearch = functio

angular - Facing Error: angular4 error:val.slice is not a function? -

i running error: click refresh() or delectrole(i) button error: error typeerror: val.slice not function @ datatable.set [as value] (datatable.js:508) what's wrong? data can transmitted, needs flushed display which value not function? remove 'i',but doesn't work: import { component, oninit, viewchild } '@angular/core'; import { role } '../domain/role'; import { roleservice } '../service/role.service'; import { requestoptions , headers} '@angular/http'; @component({ templateurl: 'rolelist.html', providers: [confirmationservice] }) export class rolelist implements oninit { public loading = false; roles: any; // 开启switch active: boolean = true; delectselectedidjson: string; msgs: message[] = []; constructor(private roleservice: roleservice, private confirmationservice: confirmationservi