Skip to content

Instantly share code, notes, and snippets.

🦆 🦆 🦆 🦆

Henrik Nyh henrik

🦆 🦆 🦆 🦆
View GitHub Profile
tgodfrey / redix.ex
Last active Jun 5, 2020
Elixir Module for working with MessageBus
View redix.ex
defmodule MyApp.Redix do
@pool_size 5
# How long, in seconds, to keep messages in the backlog
@max_backlog_age 604800
# How many messages may be kept in the global backlog
@max_global_backlog_size 2000
# How many messages may be kep in the per-channel backlog
@max_backlog_size 1000
ventsislaf /
Last active Mar 8, 2021
Reset database on Heroku running Phoenix app

Note: Don't do this on a production evniroment!

Get the heroku database name:

heroku pg:info

Name can be found in the reponse from the command above. For example: Add-on: soaring-newly-1337.

jnicklas /
Last active Oct 14, 2015
Why do .env files exist?

Why do .env files exist?

Lately I've seen a lot of projects use .env files to store application configuration, files which look something like this:

CrowdHailer / user.exs
Created Sep 18, 2015
Creating stateful module in elixir
View user.exs
# Using the erlang mechanism of tuple modules it is possible to create a "stateful module".
# This concept of a stateful module is discussed in "Programming erlang" Second edition.
defmodule User do
defstruct name: nil, admin: false, internal: "kinda private"
def new(name, options \\ []) do
dependencies = struct(%__MODULE__{name: name}, options)
{__MODULE__, dependencies}
View dev.exs
config :my_app, :twitter_api,
client: Twitter.SandboxClient
alanpeabody / my_app.ex
Last active Aug 25, 2021
Websockets in Elixir with Cowboy and Plug
View my_app.ex
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
View gist:bd5fa62610f80b6ec087
function makeStyle(defaults, tagName) {
tagName = tagName || 'div';
var Style = React.createClass({
getDefaultProps: function() {
return assign({}, defaults);
render: function() {
var style = assign({}, this.props);
delete style.children;
View gist:63096ce46439a686548e
var Style = React.createClass({
render: function() {
var style = assign({}, this.props);
delete style.children;
return React.createElement(
{style: style, children: this.props.children}
View generate_personal_podcast.rb
#!/usr/bin/env ruby -wKU
# by Kelan Champagne
# A script to generate a personal podcast feed, hosted on Dropbox
# Inspired by
# Simply put this, and some .mp3 or .m4a files in a sub-dir under your Dropbox
jyurek /
Last active Jul 14, 2021
Create and switch sessions in tmux quickly
tm() {
if [ -z $1 ]; then
tmux switch-client -l
if [ -z "$TMUX" ]; then
tmux new-session -As $1
if ! tmux has-session -t $1 2>/dev/null; then
TMUX= tmux new-session -ds $1