Skip to content

Instantly share code, notes, and snippets.

View Rembane's full-sized avatar
🔥

Andreas Ekeroot Rembane

🔥
View GitHub Profile
@Rembane
Rembane / Magic.hs
Last active December 31, 2015 06:19
So, what happens when we wrap something in a monad? :D And what can we do with these endless possibilities?
{-# LANGUAGE NoMonomorphismRestriction #-}
-- If we aren't careful, the monomorphism restriction will bite our backs.
module Magic where
magic :: (Monad m) => Int -> Int -> m Int
magic a b = return $ a + b
main = magic 7 3
@Rembane
Rembane / exceptional_looping.py
Created January 7, 2014 12:28
The ugliness! :D
li = [...]
try:
while True:
c = li.next()
if condition(c):
break
except StopIteration:
# Not found...
@Rembane
Rembane / prime.hs
Last active January 2, 2016 18:29
A prime number generator, for fun!
import qualified Data.Vector as V
steppingPrimeGenerator :: (V.Vector Int, Int) -> (V.Vector Int, Int)
steppingPrimeGenerator (ps, x) | V.null $ V.filter ((==0) . (mod x)) ps = (V.snoc ps x, succ x)
| otherwise = (ps, succ x)
@Rembane
Rembane / f.md
Last active June 17, 2016 17:14
  • ffffff-ffff, fff f fffffff
  • ffff FFFF ffff FFFF ffff FFFF
  • FFFFFFFFFF
  • F
  • fF
  • fffff, fffff, fffff, F
  • #ffffff
  • #FFFFFF
  • #fff
  • #FFF
# encoding: utf-8
from bs4 import BeautifulSoup
from Cookie import SimpleCookie
import requests
url_template = u'http://wiki.sverok.se/w/index.php?title={}&action=edit'
with open('cookie.txt') as fh:
cookies = {k : v.value for k,v in SimpleCookie(fh.read()).items()}
void count_freq(int *number, int number_length) {
int *freqs[MAX], *p1;
// Nollställ först
for(p1=freqs; p1 < freqs + MAX; p1++) {
*p1 = 0;
}
for(p1=number; p1 < number + number_length; p1++) {
freqs[*p1-1]++;
module Main where
-- This one works, but is terribly slow.
-- Make it faster!!!
step (my, mx) (y, x) = if my == y && mx == x
then 1
else stepY + stepX
where
stepY | y < my = step (my, mx) (y+1, x)
import time
# http://docs.python.org/2/library/time.html#time.sleep
while True:
bla()
time.sleep(0.005)
,>, Input two bytes
[-<+>] While the second byte is greater than zero add it to the first byte
<. Print the first byte
#include<stdio.h>
int main() {
printf("1 == %i\n", 1);
printf("~1 == %i\n", ~1);
printf("~~1 == %i\n", ~~1);
return 0;
}