Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
loop do
puts (" " * (rand() * 80).floor) + "(╯°□°)╯︵ ┻━┻"
end
@sw17ch
sw17ch / Mu.hs
Last active August 29, 2015 13:56
-- | For reference, see http://en.wikipedia.org/wiki/MU_puzzle.
module Main where
import Control.Monad ((>=>))
import Data.Maybe (mapMaybe)
-- | The base language primitives.
data MuVal = U | I | M deriving (Show, Eq)
-- | Names for the MU rules.
sequences :: [a] -> [[a]]
sequences ls = ls' ++ [i ++ [a] | i <- sequences ls, a <- ls]
where
ls' = map (:[]) ls
main :: IO ()
main = do
let syms = ["a","e","i","o","u","y"]
mapM_ (print . concat) (sequences syms)
use std::io::net::ip::SocketAddr;
use std::io::net::tcp::{TcpListener, TcpStream};
use std::io::{IoResult, Acceptor, Listener};
fn main() {
let addr = from_str::<SocketAddr>("127.0.0.1:7123").unwrap();
match TcpListener::bind(addr) {
Err(e) => fail!("Unable to bind to {}: {}", addr, e),
Ok(l) => listen(l),
/*
* http://en.wikipedia.org/wiki/Single_precision_floating-point_format
*/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
static const uint32_t SIGN_MASK = 0x80000000;
static const uint32_t EXP_MASK = 0x7f800000;
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
static const uint32_t SIGN_MASK = 0x80000000;
static const uint32_t EXP_MASK = 0x7f800000;
static const uint32_t FRA_MASK = 0x007fffff;
int main(int argc, char * argv[]) {
if (argc < 2) {
#!/bin/sh
CORE="cauterize-core"
OTHER="cauterize cauterize-test caut-c11-synchronous caut-hs2010-synchronous"
REPOS="$CORE $OTHER"
PREFIX="git@gitlab.com:cauterize/"
POSTFIX=".git"
mkdir -p cauterize-env/sandbox
#define _POSIX_C_SOURCE 199309L
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <signal.h>
#define GTCHECK(EXP) \
@sw17ch
sw17ch / quaternions.txt
Created August 30, 2014 00:38
An IRC conversation between me and fishcorn about quaternions and my lack of understanding thereof.
sw17ch: today i'm trying to figure out quaternions and if they are different from a normal vector and a rotation around that normal...
[3:53pm] jcaudle_ is now known as jcaudle.
[3:53pm] oliffia: ive made maybe a dozen games before, none particularly big
[3:53pm] oliffia: or good :)
[3:53pm] vanila: sw17ch, I know a nice way to think about them with analogy to normal complex numbers if you like
[3:54pm] sw17ch: vanila: i think part of my problem is the complex numbers
[3:54pm] sw17ch: euler angles seem to work well for me
[3:54pm] sw17ch: and i'm trying to figure out the advantage in quaternions
[3:54pm] sw17ch: or why complex numbers come into play
[3:54pm] vanila: the main advantage of quaternions is that they don't suffer from gimbal lock, which the axis-angle approach does
class IntervalSquelch
# Accepts an `interval` in fractional seconds and a `max_runs` as an integer.
# Will ensure that `go` calls its block no more than `max_runs` times per
# `interval`.
#
# By default, `max_runs` is 1.
def initialize(interval, max_runs = 1)
@max_runs = max_runs.to_i
@interval = interval.to_f