This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# http://docs.python.org/2/library/time.html#time.sleep | |
while True: | |
bla() | |
time.sleep(0.005) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
,>, Input two bytes | |
[-<+>] While the second byte is greater than zero add it to the first byte | |
<. Print the first byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
printf("1 == %i\n", 1); | |
printf("~1 == %i\n", ~1); | |
printf("~~1 == %i\n", ~~1); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer