Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile

Keybase proof

I hereby claim:

  • I am scturtle on github.
  • I am scturtle (https://keybase.io/scturtle) on keybase.
  • I have a public key whose fingerprint is C781 C6A7 A71A FFBA D1CD 08DA 899C 7671 AF1A 9565

To claim this, I am signing this object:

@scturtle
scturtle / avl.hs
Last active August 29, 2015 14:02
AVL tree in haskell (insert and select)
data AVL a = Null | Branch a (AVL a) (AVL a) Int Int -- height size
deriving Show
height :: AVL a -> Int
height Null = 0
height (Branch _ _ _ h _) = h
size :: AVL a -> Int
size Null = 0
size (Branch _ _ _ _ s) = s
@scturtle
scturtle / yanwenzi
Last active August 29, 2015 14:03
颜文字
🎵
「」
╮( ̄▽ ̄")╭
┐(・ิL_・ิ)┌
ˊ_>ˋ
(#°Д°)
_(:3」∠)_
→_→
﹁ ﹁
눈_눈
@scturtle
scturtle / ocr.py
Created August 27, 2014 03:06
OCR with CV
import cv2
import cv2.cv as cv
import tesseract
def show(im):
msg = 'press any key to continue'
cv2.namedWindow(msg, cv2.WINDOW_NORMAL)
cv2.imshow(msg, im)
cv2.waitKey(0)
cv2.destroyAllWindows()
@scturtle
scturtle / valid.hs
Last active August 29, 2015 14:06
Propositional formulae validity checker in CPS style (port from http://www.ps.uni-saarland.de/~duchier/python/continuations.html)
import qualified Data.Map as Map
data Formula = Variable String
| Negation Formula
| Conjunction Formula Formula
| Disjunction Formula Formula
instance Show Formula where
show (Variable v) = v
show (Negation f) = "!" ++ show f
@scturtle
scturtle / h20.hs
Created September 4, 2014 14:19
my solutions of '20 Intermediate Haskell Exercises' http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/
import Data.Maybe (fromMaybe)
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
-- Relative Difficulty: 1
instance Fluffy [] where
furry = map
@scturtle
scturtle / user.css
Created October 14, 2014 02:25
weibo v6 fix
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("www.weibo.com") {
#v6_pl_content_publishertop {
display: none
}
#v6_pl_content_homefeed .WB_tab_a {
display: none
}
@scturtle
scturtle / main.rs
Created October 14, 2014 14:53
hello rust
use std::iter;
fn primes(maxn: uint) -> (Vec<bool>, Vec<uint>) {
let mut primes : Vec<uint> = Vec::new();
let mut is_prime : Vec<bool> = Vec::from_elem(maxn + 1, true);
*is_prime.get_mut(0) = false;
*is_prime.get_mut(1) = false;
primes.push(2);
for i in iter::range_step_inclusive(4, maxn, 2) {
*is_prime.get_mut(i) = false;
#!/bin/env python
''' L-BFGS algorithm http://aria42.com/blog/2014/12/understanding-lbfgs/ '''
import numpy as np
from numpy import linalg
from collections import deque
class LineSearch:
''' backtracing line search algorithm '''
@scturtle
scturtle / lr_sgd.ipynb
Last active October 27, 2015 23:26
Logistic Regression with Stochastic Gradient Descent http://nbviewer.ipython.org/gist/scturtle/8a42262dc8b3841a4a80
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.