Skip to content

Instantly share code, notes, and snippets.

Avatar
⚗️
Elixiring

Tonći Galić Tuxified

⚗️
Elixiring
View GitHub Profile
View up.completion.bash
#!/bin/bash
# Bash completion for `up` <http://brettterpstra.com/2014/05/14/up-fuzzy-navigation-up-a-directory-tree/>
_up_complete()
{
local rx
local token=${COMP_WORDS[$COMP_CWORD]}
local IFS=$'\t'
local words=$(dirname `pwd` | tr / " ")
local nocasematchWasOff=0
@JEG2
JEG2 / counter.rb
Created Jan 25, 2017
A wannabe GenServer.
View counter.rb
class Counter
def initialize(initial_count = 0)
@mailbox = Queue.new
@replies = Queue.new
@state = initial_count
@server = process_messages
end
def increment
mailbox.push([:handle_increment, 1])
@darkphnx
darkphnx / super_simple_service.rb
Last active Mar 23, 2017
Simple, hot-restartable Ruby service
View super_simple_service.rb
require 'socket'
class SuperSimpleService
attr_reader :bind_address, :bind_port
def initialize
@bind_address = 'localhost'
@bind_port = 12345
end
@michaelfairley
michaelfairley / stuff.md
Last active Jun 11, 2017
Makin' Games with Ruby
@coreyhaines
coreyhaines / Animation.elm
Last active Jun 19, 2017
Animation support library
View Animation.elm
module Animation exposing (..)
import Task
import Process
import Time exposing (Time, millisecond)
type Animation state
= Setup state
| Animate state
@gnarmis
gnarmis / experiments.rb
Created Sep 21, 2012
Experimenting with bastardized functional-ness in Ruby
View experiments.rb
#ruby1.9.3
def defn name, &b
Object.send :define_method, name, &b
end
# this also works (surprisingly), albeit with a warning
# def defn name
# Object.send(:define_method, name)
# end
@pcreux
pcreux / pipable.rb
Last active Jun 12, 2018
*nix has pipes, Elixir has pipes, Ruby deserves pipes.
View pipable.rb
# Elixir has pipes `|>`. Let's try to implement those in Ruby.
#
# I want to write this:
#
# email.body | RemoveSignature | HighlightMentions | :html_safe
#
# instead of:
#
# HighlightMentions.call(RemoveSignature.call(email.body)).html_safe
#
View gist:222607
#!/bin/bash
# A simple script which will name a tab in iTerm
# usage:
# $ nametab New tab name
echo -ne "\033]0;"$@"\007"
@vic
vic / ex14parens.rb
Created Dec 9, 2016
Add missing parentheses to avoid Elixir 1.4 warnings on function calls.
View ex14parens.rb
#!/usr/bin/env ruby
###
# This utility adds missing parentheses to single word function calls
# that are now treated as warnings on Elixir 1.4.
#
# Download this file on your project repo and execute
# ruby ex14parens.rb --help
####
require('fileutils')
@yonkeltron
yonkeltron / mix.exs
Last active Feb 22, 2019
OpenTracing in Elixir with Otter
View mix.exs
defmodule Ot.Mixfile do
use Mix.Project
def project do
[app: :ot,
version: "0.1.0",
elixir: "~> 1.4",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]