Skip to content

Instantly share code, notes, and snippets.

View endofunky's full-sized avatar
☎️
NO CARRIER

ef. endofunky

☎️
NO CARRIER
  • /dev/ttyS0
View GitHub Profile
@steve-jansen
steve-jansen / git-update
Created March 8, 2013 16:29
A custom script for git to stash any working changes, checkout master, pull origin master, checkout your working branch, rebase master, and unstash your working changes
#!/bin/bash
stash() {
# check if we have uncommited changes to stash
git status --porcelain | grep "^." >/dev/null;
if [ $? -eq 0 ]
then
if git stash save -u "git-update on `date`";
then
@timcowlishaw
timcowlishaw / monads.rb
Created April 26, 2013 16:19
A Ruby approximation of the Continuation Monad from Haskell, inspired by Dan Piponi's FPComplete tutorial, "The Mother of All Monads": https://www.fpcomplete.com/user/dpiponi/the-mother-of-all-monads
# Inspired by https://www.fpcomplete.com/user/dpiponi/the-mother-of-all-monads, A ruby port of Haskell's continuation monad, using fibers for lazily-evaluated giggles:
#
# For reference, The continuation monad instance definition from haskell:
# instance Monad (Cont r) where
# return a = Cont ($ a)
# m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c
#HI THERE, I AM THE CONTINUATION MONAD
class Cont
def self.unit(x)
@dleavitt
dleavitt / changelog.rake
Created May 4, 2013 20:38
Rake task for generating a change log based on git tags
desc "Outputs a change log based on git tags"
task :changelog do
tags = Dir['.git/refs/tags/*'].each.with_object({}) do |path, hsh|
hsh[File.basename(path)] = File.read(path).chomp
end
tag_outputs = []
tags.reduce(nil) do |(_, commit1), (name, commit2)|
tag_date = `git log -1 --format="%ci" #{commit2}`.chomp
lines = [ "## #{name} - #{tag_date}\n" ]
@cstorey
cstorey / logger_proxy.rb
Last active December 17, 2015 12:19
Lock free Proxy class for the ruby stdlib Logger that can be used from within a signal handler. Not 100% ready for production use, as it cannot currently recover from failures of the logger thread. Lock free queue implementation based on http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue
require_relative 'mpsc'
class LoggerProxy
def initialize target
@target = target
@queue = MpscQueue.new
end
def start!
@reader, @writer = IO.pipe
@htr
htr / xmonad.hs
Last active February 22, 2021 18:23
spotify from xmonad
{-# LANGUAGE OverloadedStrings #-}
import DBus
import DBus.Client
spotifyCtrl :: Client -> MemberName -> X ()
spotifyCtrl client command = liftIO $ do
call_ client
(methodCall "/org/mpris/MediaPlayer2" "org.mpris.MediaPlayer2.Player" command) {
@itsderek23
itsderek23 / Dockerfile
Created August 27, 2013 02:09
Example Docker File to start a Rails app located in a local ./docker-rails directory.
# docker build -t="rails" .
FROM ubuntu:12.04
RUN apt-get update
## MYSQL
RUN apt-get install -y -q mysql-client libmysqlclient-dev
## RUBY
@barrysteyn
barrysteyn / Base64.md
Last active September 24, 2024 04:37
OpenSSL Base64 En/Decode: Portable and binary safe.

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn

@bnyeggen
bnyeggen / upgradablelock.go
Last active July 25, 2019 03:31
Upgradable read -> write locks in Go
package main
import (
"fmt"
"runtime"
"sync"
)
type UpgradableLock struct {
uglMutex sync.RWMutex
@joyrexus
joyrexus / README.md
Last active February 12, 2024 19:59
The Stable Marriage Problem

My implementation of the Gale/Shapley algorithm in Python. This algorithm is designed to address the Stable Marriage Problem.

Compare this recursive variant with the implementations on Rosetta Code.

Problem description

Given an equal number of men and women to be paired for marriage, each man ranks all the women in order of his preference and each women ranks all the men in order of her preference.

A stable set of engagements for marriage is one where no man prefers a women over the one he is engaged to, where that other woman also prefers that man over the one she is engaged to. I.e. with consulting marriages, there would be no reason for the engagements between the people to change.

@gorsuch
gorsuch / gist:5aed15e45c90c9ad7d2d
Last active September 13, 2017 08:40
Example Serf client in go
package main
import (
"fmt"
"strconv"
"time"
"github.com/hashicorp/serf/client"
)