This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
np.random.seed(123) | |
num_vals = 27 | |
index = pd.DatetimeIndex(start='jan 2 2018', periods=num_vals, freq='1D', name='date') | |
data = np.random.randn(num_vals) | |
dff = pd.DataFrame(data, index=index, columns=['val']) | |
dff.loc[:, 'weekday'] = dff.index.weekday | |
dff.loc[:, 'weekstart'] = dff.index - dff.index.weekday.astype('timedelta64[D]') | |
piv = dff.pivot(columns='weekday', values='val', index='weekstart') | |
piv.rename(inplace=True, columns={0: 'Mon', 1: 'Tue', 2: 'Wed', 3: 'Thu', 4: 'Fri', 5: 'Sat', 6: 'Sun'}) | |
piv.dropna(inplace=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config -l, --list // list config options from system, global and local config files | |
git config -l --show-origin | |
git config --global user.name "username" // set user.name in $HOME/.gitconfig | |
git config --system user.email [email protected] // set user.email in git/mingw/etc/gitconfig | |
git config --system --unset user.email // unset user.email in git/mingw/etc/gitconfig | |
git config --system --remove-section user | |
git config --global alias.lo "log --oneline --graph" | |
git init [<proj_dir>] // init repo in proj_dir or cwd (create $GIT_DIR=.git subdir) | |
git init --template <templ_dir> // templ_dir must be absolute path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As per http://wiki.commonjs.org/wiki/Modules/1.1 | |
// 1. In a module, there is a free variable "require", that is a Function. | |
// 2. In a module, there is a free variable called "exports", that is an object. | |
// 3. In a module, there must be a free variable "module", that is an Object. | |
//x3.1 The "module" object must have a read-only, don't delete "id" property. | |
// No check for 3.1 since nodejs's module.id is both writable and deletable. | |
//x2.1 modules must use the "exports" object as the only means of exporting. | |
// Export through "module.exports" is much simpler though. | |
myModule = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set "tool7z=%TOT_CORE%\7-Zip\7z" | |
set "jdk_exe=%1" | |
echo Extracting '.rsrc/1033/JAVA_CAB10/111' | |
%tool7z% e %jdk_exe% .rsrc/1033/JAVA_CAB10/111 | |
:: %tool7z% e %jdk_exe% .rsrc/1033/version.txt | |
echo Extracting '111' | |
extrac32 111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this function helps to avoid redrawing svg after map movement | |
//it has to be called after 'map.getPixelFromCoordinate' gets available | |
//returns scaleLonLat(lonlat) function that returns [x_px, y_px] for usage with d3 | |
//prevent lines thickness from getting scaled through css: .map .d3-layer path { vector-effect: non-scaling-stroke; } | |
//usage example: | |
//var s | |
//map.once('precompose', ()=>{ s=init_ol_d3(this); draw(); }) | |
//var draw_route = d3.line().x((lonlat)=>{return s(lonlat)[0]}).y(... | |
//TODO: postrender event is called for each tile render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Anatoly Grabovsky (https://github.com/grabantot) | |
var euler = function(p0, v0, a_f, dt) { //This method is here only for comparison | |
var a0 = a_f(p, v) //a=f(p0, v0) | |
p0.iadd(v0.mul(dt)) //p=p0+v*dt | |
v0.iadd(a0.imul(dt)) //v=p0+a*dt | |
} | |
var rk4 = function(p0, v0, a_f, dt) { | |
//p0 = new Vector(...), v0 = new Vector(...), a_f = function(p,v) { return new Vector(...) } } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ceils an absolute value of the number 'num' (so negative 'num' gets floored instead of being ceiled) | |
//so that its coefficient 'm' while 'num' is represented in scientific notation (num = m*10^n) | |
//is either a multiple of one of some number from 'to' array | |
//or exactly matches one of the numbers in 'to' array | |
//numbers to match exactly should be negative in 'to' array (to differ them from multiples) | |
var ceilAbs = function(num, to, bias) { // for example num = -165.4621 | |
if (!to) to = [-2, 5] // to = [-2, 5] (beautiful values are: ...0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10...) | |
if (!bias) bias = 0 // bias = 0 | |
var mults = to.filter(function(value) {return value > 0}) // mults = [5], m of the result should be eiter a multiple of 5 |