Skip to content

Instantly share code, notes, and snippets.

scturtle

Block or report user

Report or block scturtle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hack.py
# http://five.flash-gear.com/npuz/puz.php?c=z&o=2&id=4349105&k=17041499&s=15&w=420&h=555&f_dm=five
data = open('puz.swf', 'rb').read()
mark = '\xff\xd8\xff\xe0\x00\x10JFIF'
t=data.split(mark)
for i, d in enumerate(t):
if 'CREATOR' in d:
open('%d.jpeg'%i, 'wb').write(mark + d)
@scturtle
scturtle / calc.hs
Last active Aug 29, 2015
calc with parsec
View calc.hs
import Text.Parsec
import Text.Parsec.Expr
import Text.Parsec.Language (emptyDef)
import Text.Parsec.String (Parser)
import qualified Text.Parsec.Token as P
lexer = P.makeTokenParser emptyDef
parens = P.parens lexer
number :: Parser Double
@scturtle
scturtle / tree.hs
Last active Aug 29, 2015
plot binary tree like a boss
View tree.hs
import Data.Maybe (fromMaybe)
import Data.List (intercalate)
data Tree a = Tree {left :: Tree a, right :: Tree a, val :: a}
| Nil deriving (Eq)
instance (Eq a, Show a) => Show (Tree a) where
show = toString
genPosTree :: (Show a, Eq a) => Tree a -> Int -> Tree (a, Int, Int, Maybe Int, Maybe Int)
View get163book.py
import requests
import base64
from bs4 import BeautifulSoup
cookie = open('cookie163.txt').read().strip()
bookid = '23c816b98303491ab82e898d349f6154_4&tradeId='
bookinfo = requests.get('http://yuedu.163.com/getBook.do?id='+bookid).json()
content = ''
for p in bookinfo['portions']:
@scturtle
scturtle / evol.py
Created Apr 18, 2014
generic algorithm using DEAP
View evol.py
from deap import base, creator, tools, algorithms
from random import randint, random, gauss
from PIL import Image, ImageDraw
from functools import partial
from math import sqrt
import numpy
PIC = Image.open('head.jpg')
SIZE = 100
View mandelbrot.py
''' http://nbviewer.ipython.org/gist/anonymous/f5707335f40af9463c43 '''
try:
import numpy as np
except:
import numpypy as np
def mandel(x, y, max_iters):
c = complex(x, y)
z = 0.0j
@scturtle
scturtle / bf.hs
Created Apr 28, 2014
Brainfuck Intepreter
View bf.hs
{-# OPTIONS_GHC -O2 -optc-O2 #-}
import Control.Monad
import Text.ParserCombinators.Parsec
import Control.Monad.State
import Data.Array.IO
import Data.Char
import Debug.Trace
data Stmt = INCPNT | DECPNT | INC | DEC | OUTPUT | READ
| Loop [Stmt]
@scturtle
scturtle / test.bf
Created Apr 30, 2014
print 0 to 99 in brainfuck
View test.bf
ref: http://www'iwriteiam'nl/Ha_bf_intro'html
>++++++++++[<++++++++++>-] (#0=100)
>+++++++[<+++++++>-]+++++++++++<--< (#1=47 #2=11)
[ (loop #0)
>+ (inc #1)
>- (dec #2)
(test if #2 is 0 using #3 #4)
[>+>+<<-] >[<+>-] (move #2 to #3 #4; move #3 to #2)
View keybase.md

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 Aug 29, 2015
AVL tree in haskell (insert and select)
View avl.hs
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
You can’t perform that action at this time.