Skip to content

Instantly share code, notes, and snippets.

import Data.Bits
import Data.Word
base64Chars = zip [(0::Word8)..] "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
getFst ((b,c):xs) a = if a == b then c else getFst xs a
getBase64Char = getFst base64Chars
encodeTriple :: Word8 -> Word8 -> Word8 -> String
encodeTriple a b c =
map getBase64Char $ zipWith (.|.)
@rmalecki
rmalecki / Set2.md
Last active March 14, 2016 08:50
The Matasano Crypto Challenges - Set 2

Imports etc.

{-# LANGUAGE OverloadedStrings #-}

module Set2 where

import Set1
import Data.Bits
@rmalecki
rmalecki / Set1.hs
Last active February 29, 2016 08:56
The Matasano Crypto Challenges, Set 1 (http://cryptopals.com/sets/1)
module Set1 where
import qualified Data.Map.Strict as M
import Data.Bits
import Data.Word
import Data.Char (toLower)
import Data.List (transpose, sort, group)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C
import Crypto.Cipher.AES
@rmalecki
rmalecki / AutoSave.cs
Last active January 11, 2016 18:11
Unity Editor Autosave
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
[InitializeOnLoad]
public class AutoSave : ScriptableWizard
{
private static float autoSaveDelay = 15.0f;
private static double timeSinceAutoSave;
private static bool sEnabled;
@rmalecki
rmalecki / PlaceTreeShadowCasters.cs
Created September 11, 2015 16:06
Unity 5: Create stand-in geometry for Terrain trees to bake correct lightmaps
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
public class PlaceTreeShadowCasters
{
[@MenuItem ("Terrain/Place Tree Shadow Casters")]
static void Run()
{