Skip to content

Instantly share code, notes, and snippets.

@stwind
stwind / gist:1170278
Created August 25, 2011 08:59
Write string content to file
Write = fun(Content) ->
{ok, F1} = file:open("content.txt", [write]),
file:pwrite(F1, 0, unicode:characters_to_binary(Content)),
file:close(F1)
end.
Write("Hello Erlang").
@stwind
stwind / LICENSE.txt
Created September 6, 2011 06:12 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@stwind
stwind / gist:4371610
Last active December 10, 2015 02:58
Installing plyr 1.8 on OSX from cran

Install plyr on osx throws this error:


> install.packages("plyr", repos = "http://cran.r-project.org")


* installing *source* package ‘plyr’ ...
@stwind
stwind / uuid.py
Last active June 11, 2018 09:28
bash oneliner to print uuid with python
python -c "import uuid;print str(uuid.uuid4())" | tr -d '\n'
@stwind
stwind / kill-cassandra.sh
Last active December 17, 2015 05:59
kill cassandra
kill `ps -ef | grep cassandra | head -n 1 | awk '{print $2}'`
@stwind
stwind / erlzmq_usage.erl
Created July 7, 2013 02:28
Example req-rep usage of erlzmq
#!/usr/bin/env escript
%%! -pa ebin
%% -*- mode: erlang -*-
%% ex: ft=erlang ts=4 sw=4 et
-mode(compile).
-compile(export_all).
main(_) ->
{ok, Context} = erlzmq:context(1),
-module(ct_help).
-export([mock/2]).
-export([load_mocks/1]).
-export([unload_mocks/1]).
-include_lib("common_test/include/ct.hrl").
mock(Mocks, Config) ->
lists:foldl(fun do_mock/2, Config, Mocks).
@stwind
stwind / Makefile
Last active December 21, 2015 11:59
Common Erlang Makefile tasks
APP := erlang_awesome
include common.mk
include rebar.mk
include release.mk
include pkg.mk
  • fprof -- maybe helpful
fprof:start().
fprof:trace([start,{procs,processes()},{file,"/opt/fprof.trace"}]).
fprof:trace(stop).
fprof:profile([{file, "/opt/fprof.trace"}]).
fprof:analyse({dest,"fprof_result.analysis"}).
@stwind
stwind / sentry_createsuperuser.py
Created March 27, 2014 17:46
createsuperuser for sentry without password prompt
echo "from django.db import DEFAULT_DB_ALIAS as database; from sentry.models import User; User.objects.db_manager(database).create_superuser('<USER>', '<EMAIL>', '<PASSWORD>')" | sentry --config=/etc/sentry.conf.py shell