Skip to content

Instantly share code, notes, and snippets.

@yuanotes
yuanotes / CommandTProject.vim
Last active December 19, 2015 01:19
A simple script that wrap CommandT for vim to quickly index current project.
function! MyGetProjectPath(path)
python << EOF
import os
import vim
def get_project_dir(path):
find_project_file = False
while not find_project_file:
files = os.listdir(path)
if ".vimproj" in files:
find_project_file = True
@yuanotes
yuanotes / blog.hs
Last active November 12, 2021 12:06
simple blog by haskell and yesod
{-# LANGUAGE OverloadedStrings, TypeFamilies, QuasiQuotes,
TemplateHaskell, GADTs, FlexibleContexts,
MultiParamTypeClasses, DeriveDataTypeable #-}
import Yesod
import Yesod.Auth
import Yesod.Form.Nic (YesodNic, nicHtmlField)
import Yesod.Auth.BrowserId (authBrowserId)
import Data.Text (Text)
import Network.HTTP.Conduit (Manager, newManager, def)
import Database.Persist.Sqlite
@yuanotes
yuanotes / bootstrap
Last active August 29, 2015 14:03
Setup Server on Debain
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc
export LC_ALL=en_US.UTF-8
apt-get update
apt-get install -y supervisor git subversion mercurial tmux
if [ ! -e ~/golang ]; then
mkdir ~/golang
fi
echo "export GOPATH=~/golang" >> ~/.bashrc
place holder.
@yuanotes
yuanotes / main.nim
Created June 24, 2015 12:54
Nim with IUP
from iup import nil
from os import nil
when isMainModule:
discard iup.open(nil, nil)
iup.show(iup.dialog(iup.label("Hello, world!")))
iup.mainLoop()
iup.close()
@yuanotes
yuanotes / png2svg.sh
Last active April 8, 2024 18:57
Convert png to svg.
#!/bin/bash
if [ "$1" == "" ]; then
echo Usage: $0 pngfile
exit 0
fi
FILE=`basename $1 .png`
if [ ! -e $FILE.png ]; then
@yuanotes
yuanotes / console.js
Created November 3, 2015 10:44
A helper script for playing http://minmaxia.com/basic/
function hackElement(el){
var priceText = el.getElementsByTagName("tr")[0].getElementsByTagName("td")[1].innerText.replace(/[,$]/g, "");
var tickText = el.getElementsByTagName("tr")[1].getElementsByTagName("td")[1].innerText.replace(/,/g, "");
if (priceText === "" || tickText === "") {
return;
}
var price = parseInt(priceText);
var tick = parseInt(/(\d+)\/tick/.exec(tickText)[1]);
var value = price/tick;
var tbody = el.getElementsByTagName("tbody")[0];
@yuanotes
yuanotes / hidpi.txt
Created January 9, 2016 14:57 — forked from simX/hidpi.txt
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@yuanotes
yuanotes / resp2csv.py
Created August 21, 2016 08:32
Process elastic search json result to csv.
# coding=utf-8
import re
import os.path
import sys
import json
PATH = os.path.dirname(os.path.abspath(__file__))
def get_file_name(name):
@yuanotes
yuanotes / min-char-rnn.py
Created June 12, 2017 15:25 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)