Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@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 / main.js
Created December 12, 2014 12:50
firefox addon adding a button which shows whether the current url has been added into Delicious.com
var buttons = require('sdk/ui/button/action');
var tabs = require("sdk/tabs");
var prefs = require('sdk/simple-prefs');
var Request = require("sdk/request").Request;
var button = buttons.ActionButton({
id: "delicious-check",
label: "delicious-check",
icon: "./tagOff.png",
onClick: check
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scturtle
scturtle / 0hh1.py
Last active August 29, 2015 14:12
play 0hh1.com with pyautogui
import pyautogui
# constants
O, R, B = -1, 1, 0
width = 50
# global variables
topy, topx = None, None
mat = []
@scturtle
scturtle / flight_mon.py
Created January 3, 2015 06:57
show flight price on OS X system status bar
# coding: utf8
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
import os
import re
start_time = NSDate.date()
@scturtle
scturtle / output.txt
Last active August 29, 2015 14:12
Trampolined-style (workaround of tail recursion) http://lifegoo.pluskid.org/?p=327
calling tramp_fac(n=5, k=1)
bouncer: ('bounce', 'tramp_fac', (4, 5))
calling tramp_fac(n=4, k=5)
bouncer: ('bounce', 'tramp_fac', (3, 20))
calling tramp_fac(n=3, k=20)
bouncer: ('bounce', 'tramp_fac', (2, 60))
calling tramp_fac(n=2, k=60)
bouncer: ('bounce', 'tramp_fac', (1, 120))
calling tramp_fac(n=1, k=120)
bouncer: ('bounce', 'tramp_fac', (0, 120))