Skip to content

Instantly share code, notes, and snippets.

@seoh
seoh / TreeUtil.scala
Created October 12, 2012 12:25
print CodeTree of Assignment4 (FPPiS)
def mkString(tree: CodeTree): String = {
def __mkString(tree: CodeTree, depth: Int): String =
List.fill(depth)('\t').mkString + "(" + chars(tree).mkString + ") " + weight(tree) + "\n" +
(tree match {
case Fork(left, right, chars, weight) =>
__mkString(left, depth + 1) + __mkString(right, depth + 1)
case Leaf(chars, weight) =>
""
})
__mkString(tree, 0)
@seoh
seoh / evernote.html
Created November 28, 2012 07:27
Evernote clipper
<script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>
<div class="evernote">
<a href="#" onclick="Evernote.doClip({providerName:'Dev the wild',contentId:'Evernote Clip'}); return false;"><img src="http://static.evernote.com/article-clipper.png" alt="Clip to Evernote" width="51" height="17" /></a>
</div>
@seoh
seoh / gist:7239983
Last active December 27, 2015 00:49
Synapsoft the second-half 2013 recruitment
function synap(number) {
var buff = [];
while( number >= 0 ) {
buff.push( String.fromCharCode(number%26 + 65) );
number = Math.floor(number/26)-1;
}
return buff.reverse().join('');
}
function fillZero(number, digit) {
@seoh
seoh / parse.js
Created June 10, 2016 05:14
JSON to QueryString
const prefixes = (prev, next) => prev ? `${prev}[${next}]` : next
const serialize = (key, value, prefix = '') => {
switch(value.constructor.name) {
case "Array": return value.map((obj, i) => serialize(i+ "", obj, prefixes(prefix, key))).join('&')
case "Object": return parse(value, prefixes(prefix, key))
default: return prefixes(prefix, key) + '=' + value
}
}

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a fish pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@seoh
seoh / .vimrc
Created January 21, 2019 09:43
call plug#begin('~/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/goyo.vim'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
@seoh
seoh / EitherT example.ipynb
Created March 4, 2019 13:32
EitherT example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seoh
seoh / eckey.js
Created April 15, 2019 11:30
address from pkey
// from https://etherworld.co/2017/11/17/understanding-the-concept-of-private-key-public-key-and-address-in-ethereum-blockchain/
const EC = require('elliptic').ec
const BN = require('bn.js')
const ec = new EC('secp256k1')
const keccak256 = require('js-sha3').keccak256
const G = ec.g
const privateKey = process.argv[2]
const pk = new BN(privateKey)
@seoh
seoh / slides.md
Last active May 25, 2020 22:22
Scala Night 2018
@seoh
seoh / inspect.js
Last active April 6, 2021 12:15
find key pathes contains keyword in value
function inspect(obj, keyword, curr) {
if(!obj) return []
const keys = Object.keys(obj)
let ret = []
for(let i=0; i<keys.length; i++) {
const value = obj[keys[i]]
if(typeof value == 'object') {