Skip to content

Instantly share code, notes, and snippets.

@lafka
lafka / messsage_channel.exs
Last active October 7, 2015 12:44
Simple pub/sub with elixir and erlang/otp pg2 module
defmodule DBL.Message.Channel do
def subscribe([]), do: :ok
def subscribe([chan | rest]) do
case :pg2.join "stream/" <> chan, self do
{:error, {:no_such_group, _}} ->
:ok = :pg2.create "stream/" <> chan
:ok = :pg2.join "stream/" <> chan, self
:ok ->
:ok
@Jursdotme
Jursdotme / block-grid.scss
Last active January 21, 2021 17:03
Foundation 5 style Block-Grid for Bootstrap 3 (SASS Version)
// Block Grid
// Technique adapted from Foundation 5 for Bootstrap 3.
// https://github.com/zurb/foundation/blob/f755d8704123f86c281ede0b171881e2672f150d/scss/foundation/components/_block-grid.scss
// Original LESS Version by Christopher Mitchell (https://gist.github.com/ChrisTM)
// Converted to SCSS by Rasmus Jürs (https://github.com/Jursdotme)
[class*="block-grid-"] {
display: block;
margin: -($grid-gutter-width/2);
padding: 0;
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@lpgauth
lpgauth / gist:3789152
Created September 26, 2012 16:53
basic auth with Cowboy
-module(auth_handler).
-compile({parse_transform, seqbind}).
-export([init/3, handle/2, terminate/2]).
-define(USERNAME, <<"admin">>).
-define(PASSWORD, <<"password">>).
%% public
init(_Transport, Req, []) ->
@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@alloy
alloy / Instructions.md
Created June 28, 2012 12:56
Run iOS unit tests (in a Xcode workspace) when a file changes and *only* those tests related to the changed file. Also trims otest output and colors test results.
@nikolaykasyanov
nikolaykasyanov / NULevelDB.podspec
Created June 17, 2012 14:30
Podspec for NULevelDB
Pod::Spec.new do |s|
s.name = 'NULevelDB'
s.version = '0.0.1'
s.license = 'New BSD and custom BSD-like'
s.summary = 'NULevelDB is a Objective-C wrapper for Google\'s LevelDB.'
s.homepage = 'https://github.com/nulayer/NULevelDB'
s.author = { 'Brent Gulanowski' => 'FILL IN' }
s.source = { :git => 'https://github.com/nulayer/NULevelDB.git', :commit => '08b6d4c7a67bfd5fb58b4658d5d5da6ba821b0e0' }
@rolandoam
rolandoam / gist:2440784
Created April 22, 2012 01:58
enable webgl on embedded WebViews
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitWebGLEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
@skeeet
skeeet / xcode_ramdisk.sh
Created April 12, 2012 13:35 — forked from MaximKeegan/xcode_ramdisk.sh
Create a RAM disk for using with XCode
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
% snippet from pubsub_srv.erl
%-----------
start_link() ->
{ok,PID} = eredis_sub:start_link(),
register(eredispid,PID),
_Receiver = spawn_link(fun () ->
eredis_sub:controlling_process(PID),
receiver(PID)
end),
io:format("Eredis server started~n"),