Skip to content

Instantly share code, notes, and snippets.

Avatar
🦆
🦆 🦆 🦆 🦆

Henrik Nyh henrik

🦆
🦆 🦆 🦆 🦆
View GitHub Profile
@tgodfrey
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
ventsislaf / phoenix_heroku_reset_db.md
Last active Mar 8, 2021
Reset database on Heroku running Phoenix app
View phoenix_heroku_reset_db.md

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 Oct 14, 2015
Why do .env files exist?
View post.md

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 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
alanpeabody / my_app.ex
Last active Apr 12, 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(
'div',
{style: style, children: this.props.children}
);
}
View generate_personal_podcast.rb
#!/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 Jun 14, 2018
Create and switch sessions in tmux quickly
View tm.sh
#!/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