Posts

Showing posts from February, 2015

java - How to stop incrementing and decrimenting at the end of an array? -

i'm beginner in programming. want make android app 3 views. text view (display text), , buttons (forward , back). i made array of words one, two, three, four, five displayed. put one on xml . when user clicks forward shows two when click forward again shows three , when user clicks back shows two . can until poit. the problem when reaches five , user clicks forward , when reaches one , user clicks back crashes. i want button nothing, not goes one . want user know end of list. same problem back button. want stays on one . code. please help. public class aba extends appcompatactivity { int = 0; string[] mylist = { "one", "two", "three", "four", "five" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_aba); } //incremen

html5 - Minify CSS included in html header with grunt task -

i have html file width css file included in head section has been minified cssmin, additionally html has been minified htmlmin grunt task succesfully, there little problem html minified, css , javascript included directly on head secction not minified htmlmin, obiously task if html, not css or javascript. how can minify css , javascript included in head section? for example: dummy initial html file: <!doctype html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>some title</title> <link href="mycss.min.css" type="text/css" rel="stylesheet"> <style> .class1 { color: black; /* other properties */ } .class2 { color: white; /* other properties */ } /* more , more classes */ </style> </head> <body> ht

javascript - Return list to JSON to Angularjs -

it such must have sent content controller on angularjs shall come forth words such l in or e, goes in other words, of words let words sign has single letter. there no fault forward console , believe problem not specify value side. i have try here: a circular reference detected while serializing object of type 'subsonic.schema .databasecolumn'. load.js var app = angular.module('wordspreads',[]); app.controller('wordspreadslistvalue', function ($scope, $http) { $http( { method: 'get', url: '../profile/mwordspreads' }).success(function (response) { $scope.entries = data.list;; }); console.log("test");//it not appear in console log. }); controller: [httpget] public jsonresult mwordspreads() { wordsspreadslistvalue model = new wordsspreadslistvalue(); var db = helpertotables.dbvalue; model.list = db.wordspreads.tolist();

python - numpy: Why is there a difference between (x,1) and (x, ) dimensionality -

i wondering why in numpy there 1 dimensional array of dimension (length, 1) , 1 dimensional array of dimension (length, ) w/o second value. i running quite frequently, e.g. when using np.concatenate() requires reshape step beforehand (or directly use hstack / vstack ). i can't think of reason why behavior desirable. can explain? edit: suggested on of comments question possible duplicate. more interested in underlying workings of numpy , not there distinction between 1d , 2d arrays think point of mentioned thread. the data of ndarray stored 1d buffer - block of memory. multidimensional nature of array produced shape , strides attributes, , code uses them. the numpy developers chose allow arbitrary number of dimensions, shape , strides represented tuples of length, including 0 , 1. in contrast matlab built around fortran programs developed matrix operations. in days in matlab 2d matrix. around 2000 (v3.5) generalized allow more 2d, never less. numpy

php - App is not working on WAMP but It works in online server -

Image
i made basic login app using online sqlite database( http://demo3534535.16mb.com ) works fine on online server. want run on local server using wamp in gennymotion emulator. what change in code have do? working online code is: dbconnect.php <?php define('host','mysql.hostinger.in'); define('user','u756_userd'); define('pass','pass345'); define('db','u754113_demo'); $con = mysqli_connect(host,user,pass,db) or die('unable connect'); mainactivity.java public class mainactivity extends appcompatactivity implements view.onclicklistener { private static final string register_url = "http://192.168.1.102/user/register.php"; public static final string key_username = "username"; public static final string key_password = "password"; public static final string key_email = "email"; private edittext edittextusername; priv

text - Python/Pygame Title Rendering -

i'm trying render title little project i'm working on. i've replicated same code used create options set (merely ease) yet isn't working. wondering if knows i'm going wrong? it's obvious i'm not experienced when comes python. here's code: import pygame class option: hovered = false def __init__(self, text, pos): self.text = text self.pos = pos self.set_rect() self.draw() def draw(self): self.set_rend() screen.blit(self.rend, self.rect) def set_rend(self): self.rend = menu_font.render(self.text, true, self.get_color()) def get_color(self): if self.hovered: return (255, 255, 255) else: return (100, 100, 100) def set_rect(self): self.set_rend() self.rect = self.rend.get_rect() self.rect.topleft = self.pos class title: hovered = false def __init__(self, text, pos): self.text = text

java - WebSphere 7 - How can I determine which objects are using up heap memory at runtime? -

issue: have intermittent out of memory issues websphere recovering. trying determine how can find out using of memory. have app dynamics not work websphere. is way way determine using of memory have heap dump out of memory crash? server: websphere 7.5 java version: ibm 1.6 you can generate heap dump (snapshot of heap @ point of time) , thread dump/javacore (list of threads in jvm @ point of time) while websphere application server running. to obtain dumps, need use wsadmin tool. start wsadmin tool , execute following commands. jacl version: set jvm [$admincontrol querynames websphere:type=jvm,process=<servername>,node=<nodename>,*] $admincontrol invoke $jvm generateheapdump $admincontrol invoke $jvm dumpthreads jython version (untested): jvm = admincontrol.querynames ('websphere:type=jvm,process=<servername>,node=<nodename>,*') admincontrol.invoke(jvm, 'generateheapdump') admincontrol.invoke(jvm, 'dumpthrea

asp.net mvc - Entity Framework - Simple Inject use Interfaces as Models -

i'm trying implement context this idbset<iroom> rooms { get; set; } however ef doesn't support interfaces. i've following service may create iroom / room : public virtual void createsamples() { room room = new room(); room.encrypted = true; room.token = guid.newguid(); room.name = "teste-" + room.token.tostring(); room.notracking = true; room.private = true; room.userid = this.membership.currentuser; room.createdby = room.modifiedby = this.membership.currentuser; this.context.rooms.add(room); this.context.savechanges(); } this "ef interface model" came because want replace room room = new room(); with iroom room = objectfactory.create<iroom>(); ps: behind scenes objectfactory.create<> calls injector container , gets object using getinstance<> the problem here context accepts room not iroom since declaration is: idbset<room> rooms { get; set; } if isn'

sum - Conditional summation in r -

i have data frame 63 columns , 1128 rows. the columns consist of weightsrep, lon lat, v1.....v60, v[i] represents precipitation data. i want create vector [1:60] contains sum of weightsrep v not equal 0. for example (imagine these columns): if weights rep = 0.2,0.3,0.2 and v1 = 10,0,8 then sum of weightreps = 0.2+0.2 df <- data.frame(rep=c(0.2,0.3,0.2), lon=c(35,36,37), lat=c(-90,-91,-92), v1=c(10,0,8), v2=c(3,4,5), v3=c(9,20,4)) v <- as.vector("numeric") for(i in 1:3) v[i] <- sum(df$rep[df[,i+3]!=0])

javascript - Apply CSS to active router link [Angular 2] -

this question has answer here: how highlight current menu item? 29 answers i apply special css style properties active router links: <a [routerlink]='link'>{{name}}</a> here tried far (using default router-link-active class): .router-link-active { color: #000; font-weight: bold; } it doesn't work , don't understand why. currently angular 2 has built in attribute can use on link used [routerlink] routerlinkactive need have: <a [routerlink]='link' routerlinkactive="router-link-active">{{name}}</a> and recognize route current active route , apply router-link-active class. note: for using routerlink on tags other a tags, (personally using on button) routerlinkactive doesn't work should work on next release of router - https://github.com/angular/angular/iss

c# - ASP.NET vNext reference local project to another local project -

i trying reference local project local project. structure of project is: root src projecta project.json projecta.b project.json global.json in trying reference projecta projecta.b. in global.json have specified: { "projects": [ "src" ], "sdk": { "version": "1.0.0-beta8" } } in projecta.b in dependency section have following: "projecta": "1.0.0-*" nothing seems work though. i've tried pack projecta nuget package, can't seem find information on how reference local nuget package. there no needs make projecta nuget package, vs that. solution folder run dnu restore. or delete project.lock.json force tooling restore packages

c - Detecting the data type by reading a string -

so i've wondered, simplest way check user input (stdin). came conclusion, ideally scanf user input , print out results. though i'm confused, how should this. here's thinking: #include <stdio.h> int main(){ char input[30]; printf("please enter text\n"); scanf("%s", &input); ... so here's part can't wrap head around of. i'd do, run through entire word (input), character character. basically, if string consits of numbers (0-9), i'd input identified number. otherwise, detect string. i've done fair bit of research (although keep in mind i'm absolute beginner), there way strcmp() function, i'd prefer avoiding other libraries, such string.h altogether , simple way, i've tried explain. just it. #include <stdio.h> int checkifnumber(const char *word) { /* check until string ends */ while (*word != '\0') { /* return 0 if character isn't number */

List reformating in R -

this question has answer here: split comma-separated column separate rows 4 answers i have df: keggnumber cor colors x1 c00095 -2.623973e-01 red x2 c17714, c00044 -2.241113e-01 red x3 c00033 -3.066684e-01 red and format 2 column dataframe each individual keggnumber matched color . this: keggnumber colors c00095 red c17714 red c00044 red c00033 red essentially, new dataframe take rows of old dataframe more 1 keggnumber , splits them up, while keeping same color each. tidyr makes quite easy: library(tidyr) df %>% separate_rows(keggnumber) ## cor colors keggnumber ## 1 -0.2623973 red c00095 ## 2 -0.2241113 red c17714 ## 3 -0.2241113 red c00044 ## 4 -0.3066684 red c00033 chop off cor column if like. a less-pretty base option:

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

python - python3: re.sub works randomly -

i’ve got multiple block of text surrounded these html tags: <code type="block" lexer="python"> text </code> minimal working example i need replace them other text (in minimal example here, simple string: "replacement"). provide 2 sample blocks: 1 correctly replaced, other 1 not: can’t understand why, don’t seem different. test included print(old_blockcode, "\n\n", new_blockcode, "\n_______", "\n\n") makes me think issue in re.sub, beats me why. #!/usr/bin/python3 import re filecontent = """<code type="block" lexer="python">import re old_code, new_code in zip(codes_list, highlighted_list): pattern = re.sub(old_code, new_code, filecontent) pattern.append(pa)</code> <code type="block" lexer="python">import re inputfile = "test" outputfile = "testout"</code> """ blockcodes_list = [] blockhig

swift - iOS - How can I return latitude and longitude? -

i can't return latitude , longitude. 0.0 , 0.0. what can these values? code : func forwardgeocoding (address: string) -> (double, double) { let geocoder = clgeocoder() var latitude: double = 0.0 var longitude: double = 0.0 geocoder.geocodeaddressstring(address) { (placemarks: [clplacemark]?, error: nserror?) -> void in if error != nil { print(error?.localizeddescription) } else { if placemarks!.count > 0 { let placemark = placemarks![0] clplacemark let location = placemark.location latitude = double((location?.coordinate.latitude)!) longitude = double((location?.coordinate.longitude)!) print("before : \(latitude, longitude)") } } } print("after : \(latitude, longitude)") return (latitude, longitude) } this viewdidload: override func viewdidload() { super.viewdidload() forwardgeocoding("new york, ny, united states") } re

junit4 - android espresso login once before running tests -

i've been trying cover android app tests , have started using espresso recently . pretty impressed far. of app's functionality requires users logged in. , since tests independent, requires registering new user each test. works fine time required each test increases considerably because of this. i trying find way register user once in class (of tests) , use same user account perform tests in class. one way have been able have 1 test ( @test ) method runs other tests in order want. or nothing approach, since gradle cat task outputs results once @ end without providing info intermediate tests may have passed/failed. i tried @beforeclass approach did not work (no gradle output class had used debug option , seemed took long time before moved on next class of tests). is there better approach register user once @ start of class , logout once @ end of testing? any appreciated. ideally test login/logout functionality in set of tests test different login/logout s

Regex unicode in python 2.x vs 3.x -

i have simple function tokenizing words. import re def tokenize(string): return re.split("(\w+)(?<!')",string,re.unicode) in python 2.7 behaves this: in [170]: tokenize('perché.') out[170]: ['perch', '\xc3\xa9.', ''] in python 3.5.0 this: in [6]: tokenize('perché.') out[6]: ['perché', '.', ''] the problem 'é' should not treated character tokenize. thoght re.unicode enough make \w work in way mean? how same behaviour of python 3.x in python 2.x ? you'll want use unicode strings, third parameter of split not flags , maxsplit : >>> help(re.split) on function split in module re: split(pattern, string, maxsplit=0, flags=0) split source string occurrences of pattern, returning list containing resulting substrings. if capturing parentheses used in pattern, text of groups in pattern returned part of resulting list. if maxsplit nonzero,

php - Why is this bugging out? -

this question has answer here: php parse/syntax errors; , how solve them? 12 answers error: warning: mysqli_fetch_row() expects parameter 1 mysqli_result, boolean given in /home/iwatchdevelopers/public_html/emp/servadv/reasonofban.php on line 13 code: <?php $name = $_get['name']; $con = mysqli_connect("", "", "", ""); // check connection if(mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $query = "select reason bans username = " . $name; $result = mysqli_query($con, $query); $row = mysqli_fetch_row($result); if ($result === true){ echo($row['reason']); }else{ echo("please notify sloss2003 bans broken.") } php syntax error: change-> if $result== true then{ echo($row['reason']); } to if ($result

bash - ls command and size of files in shell script -

count=0; #count counting ifs=' ' x in `ls -l $input`; #for loop using ls command a=$(ls -ls | awk '{print $6}') #print[6] sizes of file echo $a b=`echo $a | awk '{split($0,numbers," "); print numbers[1]}'` echo $b if [ $b -eq 0 ] # b size of file count=`expr $count + 1` #if b 0 , count increase 1 one fi echo $count done i want find 0 size files . using find command. second thing want count number of has 0 size of files using ls command , awk. doesn't true code . mistake ? your main mistake you're parsing ls ! if want find (regular) files empty, , if have version of find supports -empty predicate, use it: find . -type f -empty note recurse in subfolders too; if don't want that, use: find . -maxdepth 1 -type f -empty (assuming find supports -maxdepth ). if want count how many empty (regular) files have: find . -maxdepth 1 -type f -empty -printf x | wc -m and if want perform both

algorithm - highest weighted path for multiple destinations -

i have directed cyclic weighted graph. want find path highest of weights, in length of x vertices, , don't care destination. want find highest cost. this can solved via dynamical-programming-like algorithm. as have few hundreds of nodes , x round 10. can assign each node v array fv size x, , fv[i] represents maximum cost source node v length i. let s source. set fs[0] = 0, , other fs[i] = -infinity. all other arrays initialized -infinity array. now, for each node v, following update: fv[i] = max{fv[i], fw[i-1] + cost(w, v) | w neighbor of v} repeat above updates @ least x times, , check fv[x] v maximum possible value want. you can use information retrieve path, should easy do. above algorithm special case of bellman-ford algorithm

java - Group by query in a nested document -

document structure: collection: mycollection { "_id" : objectid("578818ba8872933f6452c5b5"), "user" : objectid("578818ba8872933f6452c5b5") , "entries" : { "items" : [ { "_id" : objectid("578819018872933f6452c5ba") "date" : isodate("2016-07-14t22:57:58.715z"), "values" : [ { "type" : a, "value" : 4 }, { "type" : b, "value" : 3 }, ... ] }, ... ] } } expected result group date (day wise, ignore time part) average value each type { "_id" : "2016-07-14", "values" : [ { "type" : "a", "avgvalue" : 3.2 }, { "type" : "b&

android - ReyclerView - programmatically scroll with predefined time -

i need dragging similar action on recyclerview , when reach top or bottom end of recyclerview want scroll smoothly... i following: post runnable scroll until user not near enough start/end of recyclerview anymore. mscroll = new runnable() { @override public void run() { rvimages.smoothscrollby(0, mscrolldist.get()); mhandler.postdelayed(mscroll, 100); } }; the problem, need define, scrolling desired distance should done in 100ms, overall scrolling smooth. how can achieve that? use custom linearlayoutmanager public class mycustomlayoutmanager extends linearlayoutmanager { //we need mcontext create our linearsmoothscroller private context mcontext; public mycustomlayoutmanager(context context) { super(context); mcontext = context; } //override method? check. @override public void smoothscro

Proc Neural Error in SAS. Catalog xxx.yyy Does Not Exist -

so running proc neural in sas enterprise miner , keep getting error message below. have referenced , used exact same dataset in other procedures within same program. have created library data1 consists of blahblah data. have idea why not work? beyond baffled this. clarify, libname data1 'filepath'; used create library , filepath contain blahblah.sas7bdat file. proc neural data=data1.blahblah dmdbcat=data1.blahblah random=12345; note: data file `data1.blahblah.data in format native host, or file encoding not match session encoding. cross environment data access used, might require additional cpu resources , reduce performance. note: procedure neural used (total process time): real time 0.01 seconds cpu time 0.01 seconds error: catalog data1.blahblah not exist. error: dmdb catalog data1.blahblah constructed data set no valid observations. note: closing neural application. note: sas system stopped processing

c++ - Can a friend of A<T> be also a friend of A<A<T>>? -

consider following code: #include <vector> template<typename t> class container; template<typename t> container<container<t>> make_double_container(const std::vector<std::vector<t>>&); template<typename t> class container { std::vector<t> v; friend container<container<t>> make_double_container<t>(const std::vector<std::vector<t>>&); public: container() {} explicit container(std::vector<t> v) : v(v) {} }; template<typename t> container<container<t>> make_double_container(const std::vector<std::vector<t>>& v) { container<container<t>> c; for(const auto& x : v) { c.v.push_back(container<t>(x)); } return c; } int main() { std::vector<std::vector<int>> v{{1,2,3},{4,5,6}}; auto c = make_double_container(v); return 0; } the compiler tells me that: main.cpp: in ins

java - Exposure classes -

soo, tried write code when 1 class acts each other class. here class warior "tim" , class witcher "max". console should speak "now max hp.. 50" or "now tim's hp.. 50 hp", console sayed "now max hp.. 25" or "now tim's hp.. 25 hp".. 75 - 25 = 50; 100-50=50; sayed 75 - 25 = 25; 100-50=25; please :c import java.util.random; public class maxvstimvoidversion { public static void main(string[] args) { warior tim = new warior(); tim.agility = 100; tim.attack = 25; tim.hp = 100; tim.wariorlvl2 = true; witcher max = new witcher(); max.mana = 150; max.attack = 50; max.hp = 75; max.witcherlvl1 = true; random = new random(); int b = a.nextint(2); if (b == 0) { tim.meleeattack(); system.out.print("now max's hp.." + max.hp); } else if (b == 1) { max.mag

Android's Vertical Linear Layout weighting doesn't take into account actionbar height -

Image
for spanish wotd app have 3 cardviews sitting in linear layout. top , bottom ones equally weighted , middle 1 more important weighted accordingly. no matter what, bottom 1 seems hang on screen (about size of actionbar), after changing around weights. it appears when android calculating percentages, doesn't account actionbar @ all. i've done other people has said including changing match_parent , 0dp height, nothing working. have no idea why. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:co

c# - Remove Line Break or Carriage Return -

i have in database values like: hd1_des |hd1_has |hd -----------|-----------|---------- 25023132-1 |24974875-3 |25045370-0 24826798-6 |24829389-12|25045328-0 but when retrieve them datagridview, have this: hd1_des |hd1_has |hd -----------|-----------|---------- 25023132- |24974875- |25045370- 1 |3 |0 24826798- |24829389- |25045328- 6 |12 |0 for retrieve use templatefields in gridview. in label control, i've tried fix using: htmlencode="false" i tried replace using: text='<%# ((string)eval("id1des")).replace("\n", "") %> in sp in sql tried: select replace(replace([id1_desde], char(13), ' '), char(10), ' ') 'id1d'. and in code using datareader tried: saclote.id1desde = dr["id1d"].tostring().replace("\n", "<br />"); but still not results. this more caused narrow column. make wider, can acc

javascript - How to access $http.get caller variable -

consider simple angularjs code: $http.get( url ).then(function ( response ) { var cache = new cache(url); cache.response = response; }); my problem above code nondeterministic. sometime url not match when response server. i edit 10 contact data simultanously. work, cache requests server , put javascript object. i have written simple service achieve that, suffers above bug. here code: angular.module('myapp') .factory('save', function($http, $q) { // private object var cache = function(url) { this._url = url; this.response = {}; this.savedeferred = null; this.savedeferredfulfilled = false; }; cache.prototype.$save = function () { return $http.put( this._url ).then(function (response) { this.response = response; return response; }); }; //public method var draft = { caches: {}, get: function ( url ) { if (draft.caches.hasownproperty(url)) {

python - Summing Groups of Columns within a Pandas Dataframe -

i have pandas dataframe 600 columns (df1), , want sum values of each column in groups of 6. in other words, want create new dataframe (df2) has 100 columns, each column being sum of 6 columns input dataframe. example, each row first column in df2 sum of first 6 columns in df1 (keeping rows separate). dataframe using has string values each column name (here represented single letters) for df1: b c d e f g h j ... 0 9 6 3 4 7 7 6 0 5 2 ... 1 8 0 6 6 0 5 6 5 8 7 ... 2 9 0 7 2 9 5 3 2 1 7 ... 3 5 2 9 6 7 0 3 8 5 0 ... 4 7 1 0 7 4 0 2 0 5 8 ... 5 0 9 2 0 4 9 5 7 6 2 ... i want first column of df2 be: g ... 0 36 1 25 2 32 3 29 4 19 5 24 where each row sum of first 6 columns of row. nex

javascript - VS2015 error "Application is not currently attached to a script debug target that supports script diagnostics" -

i created js & html5 blank app visual studio 2015 . when running in vs debugger in "local machine" mode, following error message: application not attached script debug target supports script diagnostics just ignoring error not workable @ least breakpoints , console.log("text") not work. i'm having default options in vs. running normal win10 , automatic updates on. reinstallation of vs2015 did not solve issue. this worked me although doing different. got same error message using ie 11 accessing html file local file system (was mucking around html). seems ie developer tools don't mode of operation (why?!). here's story... file on local windows laptop: c:\temp\test.html can opened in these browsers: url: file:///c:/temp/test.html (in chrome) url: c:\temp\test.html (in ie 11) in chrome tools commands in console can run no problem e.g. console.log("hi"); in ie developer tools fails message cited op. i ha

How to launch multiple programs in VBScript? -

so, i'm starting programming classes in college courses , have make script launch multiple programs. can out? have far: set objshell = createobject("wdscript.shell") objshell.run """c:\program files (x86)\skype\phone\skype.exe""" objshell.run """c:\program files (x86)\steam\steam.exe"" set objshell = nothing x=msgbox("running skype , steam!",0+64,"succeeded") set objshell = createobject("wscript.shell")

Insufficient system resources, capture video from web camera java -

i'm trying capture video using jxcapture . manage once when i'm trying capture second time video in same program got troubles. code following: public videocapture videocapture = videocapture.create(videoformat.wmv); public capturevideofromwebcamera(){} public void start(string filename){ list<videosource> availablevideosources = videosource.getavailable(); system.out.println("availablevideosources = " + availablevideosources); if (availablevideosources.isempty()) { throw new illegalstateexception("no external video sources available"); } videosource webcamera = availablevideosources.get(0); system.out.println("webcamera = " + webcamera); videocapture.setvideosource(webcamera); java.util.list<codec> videocodecs = videocapture.getvideocodecs(); system.out.println("videocodecs = " + videocodecs); if (videocodecs.isempty()) { throw new illegalstateexception(&quo

python - Efficiently compute historical aggregates -

i have dataframe containing historical records, example sales. import pandas pd first_salesman = pd.series([1, 2, 3], index=[pd.to_datetime('2015-01-01'), pd.to_datetime('2015-01-02'), pd.to_datetime('2015-01-03')]) second_salesman = pd.series([2, 0, 5], index=[pd.to_datetime('2015-01-01'), pd.to_datetime('2015-01-02'), pd.to_datetime('2015-01-03')]) third_salesman = pd.series([6, 7, 1], index=[pd.to_datetime('2015-01-01'), pd.to_datetime('2015-01-02'), pd.to_datetime('2015-01-03')]) df = pd.concat([first_salesman, second_salesman, third_salesman], axis=1).reset_index() df = pd.melt(df, id_vars=['index'], value_vars=[0, 1, 2]) df.columns = ['date', 'salesman_id', 'sales'] df = df.set_index('date') i compute historical statistics each of salesmen: in other terms, each salesman , each day, know how mean, std, max, min, etc... looked until day. so focusing on salesma

Digest Authentication with CORS at Tomcat -

right building rest api running @ tomcat 8 using corsfilter of apache allow cross domain requests set @ web.xml that: <filter> <filter-name>corsfilter</filter-name> <filter-class>org.apache.catalina.filters.corsfilter</filter-class> </filter> <filter-mapping> <filter-name>corsfilter</filter-name> <url-pattern>/webapi/*</url-pattern> </filter-mapping> so far easy wanted add digest authentication rest-api, yes digest not basic! for simple usage wanted use security-constraints @ web.xml: <security-constraint> <web-resource-collection> <web-resource-name>all</web-resource-name> <url-pattern>/webapi/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>*</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>digest</au

c# - new MailAddress() Exits out of method -

i have weird issue can't wrap head around. here code: [httpget] [allowanonymous] public actionresult sendemail() { sendregisteremail("test", "testagain", "lasttest"); return view("index"); } public async task<bool> sendregisteremail(string subject, string message, string to) { var email = new email(); var mailaddress = new mailaddress(to); email.subject = subject; email.body = message; var mailaddresscollection = new mailaddresscollection(); mailaddresscollection.add(mailaddress); email.to = (mailaddresscollection); return await send(email); } now prove problem broke down code single lines can see on line breaks. here found: when debug , step sendregisteremail method, line says var mailaddress = new mailaddress(to); gets run , exits out function , runs line return view("index"); , page loads up. weird thing added logging method on send @ end , logging never gets hit. p

c# - combine predicates into expression -

i aiming use signature: ienumerable<t> searchfor(expression<func<t, bool>> expression); and , these 2 predicates: func<employee, bool> isactiveemployee = e => e.datefired == null; func<employee, bool> isnewemployee = e => e.datehired >= datetime.today.adddays(-90); into expression. how can achieve please? ps: basically, trying use this . line: var body = (binaryexpression) expression.body; in method getdynamicquery taken here throws exception: unable cast object of type 'system.linq.expressions.instancemethodcallexpressionn' type 'system.linq.expressions.binaryexpression'. using approach: expression<func<employee, bool>> isactiveemployee = e => e.datefired == null; expression<func<employee, bool>> isnewemployee = e => e.datehired >= datetime.today.adddays(-90); expression<func<employee, bool>> combined_expression = e => isactiveemployee.invoke(e) &