Skip to content

Instantly share code, notes, and snippets.

@vascoosx
vascoosx / ansible_limit_trick.sh
Created January 5, 2017 15:06
limit by multiple patterns
#!/usr/bin/env bash
ansible-playbook -i inventory playbooks/test_single.yml --limit '!*apattern*:!special:*anotherpattern' --list-hosts
from math import exp
def theta(k):
return 1.0/(1 + exp(-k))
def ht(wx, xt, uh, ht_m1, bh): return theta(wx * xt + uh * ht_m1 + bh)
val numKey = (num: Int) => (0 to 500 by 50).toStream.dropWhile(_ < num).headOption.getOrElse(600)
@vascoosx
vascoosx / profile.ps1
Last active February 1, 2017 11:41
emacs bindings, for unix users
Set-PSReadlineOption -EditMode Emacs
sal -Name ls -Value C:\cygwin64\bin\ls.exe -Option AllScope
Set-PSReadLineOption -TokenKind Parameter -ForegroundColor Gray -BackgroundColor 0
Set-Alias find "C:\cygwin64\bin\find.exe"
[Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", '/tmp/.ssh-pageant-sh.otsuka', "Process")
$agentPid=ssh-pageant -r -a '/tmp/.ssh-pageant-sh.otsuka' | grep "PID"
if( -not $?) {
$agentPid=$agentPid -replace '[A-Z,_,=,a-z,;]',''
[Environment]::SetEnvironmentVariable("SSH_PAGEANT_PID", $agentPid, "Process")
}
@vascoosx
vascoosx / parallelsum.scala
Last active October 28, 2016 02:35
parallel programs comparisons
import org.scalameter._
import common._
import scala.math.pow
val standardConfig = config(
Key.exec.minWarmupRuns -> 40,
Key.exec.maxWarmupRuns -> 80,
Key.exec.benchRuns -> 100,
Key.verbose -> false
) withWarmer(new Warmer.Default)
@vascoosx
vascoosx / connectionTest.scala
Created September 23, 2016 09:32
test connection
import $ivy.`org.scalikejdbc::scalikejdbc:2.4.2`, scalikejdbc.ConnectionPool, scalikejdbc._
import $ivy.`mysql::mysql-connector-java:5.1.32`
Class.forName("com.mysql.jdbc.Driver").newInstance()
val (url,
user,
password,
driver) = ("jdbc:mysql://172.17.0.2:3306/test_database",
"root",
"foo",
"com.mysql.jdbc.Driver")
@vascoosx
vascoosx / pval_calculator.py
Last active August 31, 2016 14:30
hypothesis testing
# -*- coding: utf-8 -*-
from functools import reduce
from sys import argv
def partial_fact(tries, success):
m = range(tries - success + 1, tries + 1)
return reduce((lambda x,y: x*y), m)
def fact(n):
return reduce((lambda x,y: x*y), range(1, n+1))
@vascoosx
vascoosx / json_highlight_format.vim
Last active August 16, 2016 14:00
vim json prettyfier
" Inspired by https://github.com/chaosong
vmap <f6> :FormatJson <cr>
command -range FormatJson :call FormatJson()
function! FormatJson() range
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
python << EOF
import vim
@vascoosx
vascoosx / shorcuts.js
Created July 6, 2016 00:51
shortcut manager
// ==UserScript==
// @ShortcutManager
// @name open url in new window
// @namespace NIEQCKdtMwoR
// @key Ctrl+]
// @include *
// ==/UserScript==
javascript:window.open(window.location.href)
@vascoosx
vascoosx / changeName.ahk
Created June 29, 2016 00:40
autohotkey to change teraterm name
^1::
Send, !sw
Return