Skip to content

Instantly share code, notes, and snippets.

View henrik's full-sized avatar

Henrik Nyh henrik

View GitHub Profile
@tgodfrey
tgodfrey / redix.ex
Last active June 5, 2020 15:30
Elixir Module for working with MessageBus
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
ventsislaf / phoenix_heroku_reset_db.md
Last active May 18, 2023 14:14
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
jnicklas / post.md
Last active October 14, 2015 20:30
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:

FOO=bar
Bar=baz
@CrowdHailer
CrowdHailer / user.exs
Created September 18, 2015 14:20
Creating stateful module in elixir
# 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}
config :my_app, :twitter_api,
client: Twitter.SandboxClient
@alanpeabody
alanpeabody / my_app.ex
Last active March 9, 2024 19:15
Websockets in Elixir with Cowboy and Plug
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
])
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;
var Style = React.createClass({
render: function() {
var style = assign({}, this.props);
delete style.children;
return React.createElement(
'div',
{style: style, children: this.props.children}
);
}
#!/usr/bin/env ruby -wKU
#
# by Kelan Champagne
# http://yeahrightkeller.com
#
# A script to generate a personal podcast feed, hosted on Dropbox
#
# Inspired by http://hints.macworld.com/article.php?story=20100421153627718
#
# Simply put this, and some .mp3 or .m4a files in a sub-dir under your Dropbox
@jyurek
jyurek / tm.sh
Last active February 12, 2024 10:37
Create and switch sessions in tmux quickly
#!/bin/sh
tm() {
if [ -z $1 ]; then
tmux switch-client -l
else
if [ -z "$TMUX" ]; then
tmux new-session -As $1
else
if ! tmux has-session -t $1 2>/dev/null; then
TMUX= tmux new-session -ds $1