Skip to content

Instantly share code, notes, and snippets.

require 'midilib'
seq = MIDI::Sequence.new()
File.open(ARGV[0], 'rb') { |file| seq.read(file) }
events = [ ]
id = 0
seq.tracks.each do |track|
@floodsung
floodsung / CEM.py
Created June 2, 2016 08:02
This solution is mainly from John Schulman's Deep Reinforcement Learning Lab script in Machine Learning Summer School 2016
import numpy as np
import gym
from gym.spaces import Discrete,Box
# -------------------------------------------
# Policies
# -------------------------------------------
class DeterministicDiscreteActionLinearPolicy(object):
@snatchev
snatchev / gh.fish
Last active May 22, 2022 06:57
a fish-shell function to open the current git repo/branch in a browser
function gh --description 'Open the webpage for the current github repo/branch'
set -l fetch_url (command git remote --verbose show -n origin ^/dev/null | command grep Fetch | cut -c 14- )
#did we get an exit status?
if [ $status -gt 0 ]
echo 'Not a git repo.'
return 1
end
if [ -z $fetch_url ]
@duggan
duggan / cast.py
Last active December 5, 2024 20:30
Using pychromecast to headlessly stream youtube videos
#!/usr/bin/env python
"""
Requires pychromecast.
Install with `pip install pychromecast`
usage: cast.py [-h] -d DEVICE -v VIDEO
Cast YouTube videos headlessly.
@esehara
esehara / oogiri.py
Created April 25, 2015 04:40
メカ大喜利マン ver 0.1
# -*- coding: utf-8 -*-
from gensim.models import word2vec
import MeCab
import random
model = word2vec.Word2Vec.load("oogiri_gensim.model")
tagger = MeCab.Tagger("-Ochasen")
def word_and_kind_parse(line):
line_word = line.split("\t")
if len(line_word) < 2:
@akiym
akiym / online-ctf.md
Created September 11, 2014 15:55
オンラインCTFまとめ
@zk-phi
zk-phi / setup_description_ja.org
Last active October 16, 2022 13:54
[Emacs] setup.el で安全・爆速な init.el を書く

[Emacs] setup.el で安全・爆速な init.el を書く

Emacs プラグイン setup.el は、安全・爆速な設定ファイルを書くためのマク ロ集です。

ここでいう「安全」とは、「セットアップの途中でエラーが出て、ほとんどデ フォルトの Emacs が立ち上がる」ような悲劇が起きないことをいいます。

setup.el を使って書かれた設定ファイルがどれくらい爆速かというと、 5000 行以上の設定が入った Emacs が 0.29 秒でセットアップできるくらい爆速です。

@kohske
kohske / rmarkdown-to-html
Created February 21, 2014 03:02
emacsでknit2html
(defun rmarkdown-to-html ()
"Run knitr::knit2html on the current file"
(interactive)
(shell-command
(format "Rscript -e \"knitr::knit2html('%s')\""
(shell-quote-argument (buffer-file-name)))))

SWIM: スケーラブルな弱一貫性,伝染様式プロセスグループメンバーシッププロトコル[和訳]

update:2014-01-26
Version: 0.1

原題: SWIM: Scalable Weakly-consistent Infection-style Process Group Membership Protocol

@tsu-nera
tsu-nera / topcoder_define.h
Last active December 20, 2015 16:19
TopCoder Define
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;