Skip to content

Instantly share code, notes, and snippets.

@jocke-l
jocke-l / secure_jump.sh
Last active February 12, 2020 21:55
SSH to a machine protected by SSH jumpbox without the need to forward your SSH-agent.
#!/bin/sh
set -eo pipefail
usage () {
echo "Usage:"
echo -e "\t${0} <jumpbox> <target>"
echo -e "\tJUMP_BOX=<jumpbox> ${0} <target>"
}
@jocke-l
jocke-l / HaskellTest.hs
Last active September 19, 2018 11:48
Java vs Python vs Haskell
module Main where
import System.IO
type Logger = String -> IO ()
fileLogger :: Handle -> Logger
fileLogger file string = do
hPutStrLn file string
hFlush file
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jocke-l
jocke-l / disable_signals.py
Last active January 12, 2017 16:09
Signal disabler context manager
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
@jocke-l
jocke-l / utils.py
Created August 21, 2016 14:34
Currying functions in python
import inspect
def curry(func):
return Currying(func)
class Currying:
def __init__(self, function, args=None):
self._function = function
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))
@jocke-l
jocke-l / Main.hs
Created December 18, 2015 08:32
hazel
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 ()
@jocke-l
jocke-l / gist:4b3fdef28d8eeda7acdb
Created January 25, 2015 22:50
mandelbrot colour
/*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);
@jocke-l
jocke-l / Makefile
Last active December 5, 2016 05:03
Makefile
# 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 :=
@jocke-l
jocke-l / fizzbuzz.hs
Last active December 27, 2015 13:09
Functional FizzBuzz
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