Skip to content

Instantly share code, notes, and snippets.

@vascoosx
vascoosx / .vimrc
Last active December 17, 2018 08:22
vimrc
execute pathogen#infect()
filetype plugin indent on " filetype detection and settings
syntax on " syntax highlighting
silent! runtime macros/matchit.vim " matchit comes with Vim
set nocompatible " not strictly necessary but useful in some scenarii
set backspace=indent,eol,start " let the backspace key work "normally"
set hidden " hide unsaved buffers
set incsearch " incremental search rules
set laststatus=2 " not strictly necessary but good for consistency
set ruler " shows line number in the status line
@vascoosx
vascoosx / .tmux
Last active April 12, 2016 01:42
tmux
set-option -g prefix C-j
unbind-key C-b
bind-key C-j send-prefix
bind-key C-j last-window
bind c new-window -c "#{pane_current_path}"
bind "\"" split-window -v -c "#{pane_current_path}"
set-window-option -g mode-keys vi
# list-keys -t vi-copy
@vascoosx
vascoosx / sort_xml.py
Last active September 17, 2021 15:04
custom sorting xml
# -*- coding: utf-8 -*-
"""
Created on Tue May 24 06:12:11 2016
@author: sh.otsuka
"""
# experiment based on http://stackoverflow.com/a/8387132/1635993
from lxml import etree
@vascoosx
vascoosx / item_item_prod.scala
Created May 30, 2016 08:24
calculate all combinations
import scala.collection.mutable
import org.apache.spark.mllib.linalg._
import org.apache.spark.mllib.rdd.MLPairRDDFunctions._
import org.apache.spark.rdd.RDD
def blockify(rank: Int,
features: RDD[(Int, Array[Double])]): RDD[(Array[Int], DenseMatrix)] = {
val blockSize = 4096 // TODO: tune the block size
val blockStorage = rank * blockSize
features.mapPartitions { iter =>
@vascoosx
vascoosx / changeName.ahk
Created June 29, 2016 00:40
autohotkey to change teraterm name
^1::
Send, !sw
Return
@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 / 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 / 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 / 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 / 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)