Skip to content

Instantly share code, notes, and snippets.

View Rembane's full-sized avatar
🔥

Andreas Ekeroot Rembane

🔥
View GitHub Profile
# 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;
}
@Rembane
Rembane / PrintCompile.hs
Created April 24, 2014 20:44
Det kan vara så att jag blev lite ivrig efter dagens Perlande...
import Control.Monad
import Data.Char
import Data.List
color s c = "\x1b[38;5;" ++ show c ++ "m" ++ s ++ "\x1b[0m"
txt = map chr $ foldr (\a (b:bs) -> (a+b):(b:bs)) [32] [(-12),2,(-3),7,(-3),7,69]
main = sequence_ $ cycle $ map (\c -> putStr $ color txt c) [0..256]
@Rembane
Rembane / restore_firewall.sh
Created June 6, 2014 14:34
This is my firewall restoration script.
#!/bin/bash
iptables -F # Flush all!
iptables -X # Delete all custom chains!
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
@Rembane
Rembane / ssnLab.hs
Created June 26, 2014 23:13
Just fooling around with personnummer-validation.
import Data.Char
import Data.List
type Personnummer = [Int]
mod10 x = mod x 10
cleanAndConvert :: String -> Maybe Personnummer
cleanAndConvert cs = return $ map digitToInt $ filter isDigit cs
@Rembane
Rembane / FizzBuzz3.hs
Created August 18, 2014 23:00
More Fizzbuzz!
import Data.Maybe
mrd n x | mod n x == 0 = Just n
| otherwise = Nothing
lp = map (\n -> head . catMaybes $ zipWith (\f v -> v >> return f) ["FizzBuzz", "Fizz", "Buzz", show n] (map (mrd n) [15, 3, 5, 1])) [1..]
main :: IO ()
main = putStr $ unlines $ take 100 lp