Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
πŸ™€
πŸ›

Andrew Ekstedt magical

πŸ™€
πŸ›
View GitHub Profile
@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 (
#!/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 / 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)))]
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
#!/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()
@magical
magical / git-tips.txt
Created April 18, 2018 00:22
git tips & tricks
git tips & tricks
0. cloning
git clone ./repo ./clone # do a local clone
1. the index / patch mode
git add -p
@magical
magical / hangman.py
Last active April 25, 2018 06:32
LUG hangman, team 2
# Team 2
from __future__ import print_function
def prompt(question):
question = question.lstrip(' ') + ' '
answer = raw_input(question).strip()
while not answer:
answer = raw_input(question).strip()
return answer
@magical
magical / flim.lily
Last active September 13, 2018 20:02
\header {
title = "Flim"
composer = "Aphex Twin"
arranger = "The Bad Plus"
}
melody = \relative c'' {
d4 f a ais
d, f a ais
c, ees g d'
@magical
magical / matrix-irc.md
Created March 1, 2019 00:24
HOWTO connect to IRC with matrix (draft)

HOWTO connect to IRC with matrix

This guide explains how to connect to freenode channels via matrix, using riot.im.

  1. matrix.org runs a public freenode bridge.

  2. channels follow the pattern #freenode_#channel:matrix.org, so if you wanted to join #python on freenode, you'd type '#freenode_#python:matrix.org' into the join channel box in riot.im.