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
/*return iterations == DEPTH ? -1 : | |
iterations + 1 - log(log(sqrt(x*x + y*y))) / log(2);*/ | |
/* | |
* Coolt mönster:*/ | |
return (iterations == depth ? -1 : | |
(iterations << 4)) - log(sqrt(x*x - y*y)) / log(2); |
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.Number.CReal | |
piit accuracy = showCReal 100 (go 1 (1 / sqrt 2) (1 / 4) 1) | |
where go a b t p | (a - b) >= accuracy = let aa = (a + b) / 2 | |
bb = sqrt (a * b) | |
tt = t - p * (a - aa)^2 | |
pp = 2 * p | |
in go aa bb tt pp | |
| otherwise = (a + b)^2 / (4 * t) |
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 | |
import System.Random | |
import Data.List (intersect) | |
import Prelude hiding (words) | |
import Text.Printf | |
obscure word letters = map hide word | |
where hide c | |
| c `elem` (' ' : letters) = c |
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 | |
import Control.Monad (forever) | |
import System.Posix.Process (forkProcess, executeFile) | |
import System.Environment (getEnvironment) | |
import System.IO (hSetBuffering, stdout, BufferMode(NoBuffering)) | |
import Data.Text (Text, pack, unpack, split) | |
startProcess :: Text -> [Text] -> IO () |
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
def enum(varnames, start=0): | |
return dict(zip(varnames, range(start, start + len(varnames)))) |
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 | |
fizzbuzz x | |
| fizz x && buzz x = "FizzBuzz" | |
| fizz x = "Fizz" | |
| buzz x = "Buzz" | |
| otherwise = show x | |
where fizz = (== 0) . flip mod 3 | |
buzz = (== 0) . flip mod 5 |
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 argparse | |
import zmq | |
context = zmq.Context() | |
def bind_sockets(pub_port, pull_port): | |
pub = context.socket(zmq.PUB) | |
pub.bind('tcp://*:{}'.format(pub_port)) |
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 inspect | |
def curry(func): | |
return Currying(func) | |
class Currying: | |
def __init__(self, function, args=None): | |
self._function = function |
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
# This Makefile uses gcc's -MM-flag to scan your source tree for dependencies | |
# Other compilers may or may not have this feature. Adjust the DEPS | |
# definition accordingly. | |
CC := gcc | |
RM := rm | |
CFLAGS := -pedantic -Wall -Wextra -g | |
LIBS := |
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
from contextlib import contextmanager | |
from functools import update_wrapper | |
from django.db.models import signals | |
@contextmanager | |
def disable_signals(): | |
receiver_backups = {} | |
signals_list = [(signal_name, signal) for signal_name, signal in |
OlderNewer