Skip to content

Instantly share code, notes, and snippets.

@uri
uri / action_controller_gem.rb
Created April 16, 2018 16:06
Test case for confusing default_headers initialization
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do

Keybase proof

I hereby claim:

  • I am uri on github.
  • I am urigorelik (https://keybase.io/urigorelik) on keybase.
  • I have a public key ASDEHGnt1RSfY-SIysyW8mRw4ajygprYOFJrT5ng_MLmbQo

To claim this, I am signing this object:

@uri
uri / actor_tutorial.exs
Created October 25, 2017 03:02
An example of the actor pattern in Elixir.
@moduledoc """
This file showcases how the actor pattern works in elixir by using send/receive
to pass messages and spawn to create a separate state for an actor.
import ActorTutorial
Create a tally actor and send a message
tally = start_tally()
send tally, {:add, 5}
RabbitMQ 3.5.7. Copyright (C) 2007-2015 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /var/log/rabbitmq/[email protected]
###### ## /var/log/rabbitmq/[email protected]
##########
Starting broker... completed with 0 plugins.
=WARNING REPORT==== 15-Aug-2017::11:53:14 ===
@uri
uri / po_box_regex.rb
Created June 27, 2016 21:11
PO Box (Post office box) regular expression in ruby.
po_box_regex = /\A\b(?:p[.\s]?o?[.\s]?b?[.\s]?)\b(?:box)?|post{1}\s(?:office)?\s?(:?box|bin){1}\z/i
# Matches
#
# P. O. Box
# P.O.Box
# Post Box
# Post Office Box
# P.O.B
# P.O.B.
@uri
uri / Makefile
Last active June 17, 2016 14:16
Useful Makefile for development convenience
start:
mysql.server start
redis-server &
stop:
mysql.server stop
redis-cli shutdown
clone-db:
bundle exec rake dev:db:branch_dup
@uri
uri / stack.exs
Last active October 30, 2017 14:12
Two implementations of a stack in Elixir; one using GenServer and the other with send, receive, and pids.
defmodule StackGenServer do
use GenServer
def start, do: GenServer.start(__MODULE__, [], name: __MODULE__)
def query, do: GenServer.call(__MODULE__, :query)
def pop, do: GenServer.call(__MODULE__, :pop)
def push(element), do: GenServer.call(__MODULE__, { :push, element })
def handle_call(:query, _from, stack), do: {:reply, stack, stack}
def handle_call(:pop, _from, [h|t]), do: {:reply, h, t}
def handle_call(:pop, _from, []), do: {:reply, nil, []}
def handle_call({ :push, element }, _from, stack), do: {:reply, [element | stack], [element | stack]}
@uri
uri / post-commit
Last active December 14, 2015 19:29
A post-commit hook that will check for changed assets and ask if they should be compiled.
#!/bin/bash
ASSET_FILES="$(git diff-index --name-only HEAD~ | egrep '.+\.(?:js|css|jpg|jpeg|png|gif)' | grep -v 'public/')"
if [[ ! -z $ASSET_FILES ]] ; then
echo 'You have changed the following assets that need to be compiled:'
echo $ASSET_FILES
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
@uri
uri / vim-ruby-syntime.txt
Created June 18, 2015 17:59
syntime for ruby syntax
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
4.678966 1003 0 0.006825 0.004665 rubySymbol []})\"':]\@<!\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@=
4.085646 584726 0 0.000114 0.000007 rubyString \\\\\|\\\"
2.570973 1003 0 0.004286 0.002563 rubySymbol \%([{(,]\_s*\)\@<=\l\w*[!?]\=::\@!
2.078462 294332 294332 0.000106 0.000007 rubyArrayLiteral ]
@uri
uri / _readme.md
Last active August 29, 2015 14:17 — forked from mislav/_readme.md

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work: