Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
🙀
🐛

Andrew Ekstedt magical

🙀
🐛
View GitHub Profile
#!/usr/bin/env python2
# encoding: utf-8
from __future__ import print_function
import sqlalchemy as sqla
from sqlalchemy import orm, types
from sqlalchemy.sql.expression import bindparam
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
metadata = sqla.MetaData()
id │ identifier │ id │ identifier │ efficacy
───────┼───────────────────────┼────┼────────────┼──────────
1 │ bulbasaur │ 11 │ water │ 50
2 │ ivysaur │ 11 │ water │ 50
3 │ venusaur │ 11 │ water │ 50
10033 │ venusaur-mega │ 11 │ water │ 50
4 │ charmander │ 11 │ water │ 200
5 │ charmeleon │ 11 │ water │ 200
6 │ charizard │ 11 │ water │ 200
10034 │ charizard-mega-x │ 11 │ water │ 100
@magical
magical / s.hy
Created March 22, 2018 18:16
prime sieve
#!/usr/bin/env hy
(def N 999)
(def a (+ [1 1] (* [0] N)))
(let [(i 1) (j 0)]
(while (< i N)
(if (= i j) (print i))
(cond
[(> j N) (setv j 0)]
[(>= j i) (do (setv (get a j) 1)
(setv j (+ j i)))]
#!/usr/bin/env python3
N = 99999
a = [1,1] + [0]*N
i = 1
j = 0
while i < N:
if i == j:
print(i)
@magical
magical / gll.go
Last active January 21, 2018 23:54
package main
// Implementation of a GLL parser, from
//
// Elizabeth Scott and Adrian Johnstone. "GLL Parsing". LTDA 2009, pp 113-126
// http://ldta.info/2009/ldta2009proceedings.pdf
//
// ...with some modifications ;)
import (
@magical
magical / regexp.ml
Last active October 18, 2017 04:59
NFA -> Regular Expression conversion in OCaml
type node = { accept: bool; links: link list }
and link = Link of char * node
type nfa_type = NFA of node list * node
type regexp =
| Empty
| Epsilon
| Single of char
@magical
magical / pi14.go
Last active August 20, 2017 02:21
package main
import (
"flag"
"fmt"
"time"
)
type pair struct{ End, Start Point }
@magical
magical / quickmerge.py
Created August 4, 2017 19:27
quicksort + mergesort
def quicksort(list):
#print "quick>", list
if len(list) <= 1:
return list
pivot = list[len(list)//2]
a = mergesort([x for x in list if x <= pivot])
b = mergesort([x for x in list if not x <= pivot])
#print "quick<", a+b
return a + b
import Control.Monad (fail)
import Control.Monad.Trans (lift, liftIO)
import Text.Parsec ((<|>), (<?>))
import Text.Read (readMaybe)
import System.IO (hFlush, stdout)
import qualified Control.Monad.Trans.State.Strict as State
import qualified Data.HashMap.Strict as HashMap
import qualified Text.Parsec as P
Item Stats Structure
0x00 uint16 Purchase Price (in units of $10)
0x02 uint8 Held effect?
0x03 uint8 Effect argument
0x04 uint8 Natural Gift effect
0x05 uint8 Fling effect
0x06 uint8 Fling power
0x07 uint8 Natural Gift power
0x08 uint16 Bits 0-4: Natural Gift type (31=n/a)
Flags?