Skip to content

Instantly share code, notes, and snippets.

View theoretick's full-sized avatar

Lucas Charles theoretick

View GitHub Profile
@theoretick
theoretick / private_imports.ex
Last active March 2, 2016 18:40
Private imports in ruby versus elixir
iex(1)> defmodule Foo do
...(1)> defp bar do
...(1)> "bar"
...(1)> end
...(1)> end
iex:2: warning: function bar/0 is unused
{:module, Foo,
<<70, 79, 82, 49, 0, 0, 3, 168, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 94, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>,
{:bar, 0}}
iex(2)> defmodule Derp do
@theoretick
theoretick / upgrade_postgresql_9.3_to_9.4.sh
Last active March 2, 2016 19:03
shell script for upgrading postgres 9.3 to 9.4 with postGIS. RUN AS ROOT
#! /bin/bash
#
# Based on http://www.gab.lc/articles/migration_postgresql_9-3_to_9-4
#
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@theoretick
theoretick / etc init.d puma
Created January 30, 2016 18:50
puma init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: puma
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@theoretick
theoretick / exrm-conform-notes.md
Last active December 24, 2016 17:30
Notes on deploying elixir, erlang, and OTP apps with exrm and conform
@theoretick
theoretick / ruby_tap_in_elixir.ex
Last active January 23, 2020 05:56
ruby #tap in elixir
iex(1)> defmodule Util do
...(1)> def tap(input, func) do
...(1)> func.(input)
...(1)> input
...(1)> end
...(1)> end
{:module, Util,
<<70, 79, 82, 49, 0, 0, 4, 212, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 164, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>,
{:tap, 2}}
iex(2)> import Util
-- quiet outputs for setting these on psql start
\set QUIET 1
-- Custom Prompt
-- %M refers to the database server's hostname -- is "[local]" if the connection is over a Unix domain socket
-- %> refers to the listening port
-- %n refers to the session username
-- %/ refers the current database
-- %R refers to whether you're in single-line mode (^) or disconnected (!) but is normally =
10:21:48 $ irb
irb(main):001:0> module FooA
irb(main):002:1> BAR = "bar"
irb(main):003:1> end
=> "bar"
irb(main):004:0> FooA::BAR
=> "bar"
irb(main):005:0> module FooB
irb(main):006:1> class << self
irb(main):007:2> BAR = "bar"
@theoretick
theoretick / fml.sh
Last active August 16, 2018 17:17
just fix it, bash
#!/bin bash
function dammit_bundler() {
bundle clean
bundle install
}
function dammit_npm() {
rm -fr ./node_modules/
npm cache clean -f
@theoretick
theoretick / ruby_syntax_checker.sh
Created February 25, 2016 17:28
check all ruby files for syntax errors in current dir
#!/bin bash
function rbcheck() {
find . -name "*.rb" -exec ruby -wc {} \; 2>&1 | grep -v "Syntax OK\|: warning:"
}
@theoretick
theoretick / nginx_return_plaintext_200.sh
Last active December 24, 2016 17:31
How to return plaintext using just nginx
theoretick@li1316-219:/etc/nginx/sites-enabled$ cat discuss_it
server {
listen 80 default;
server_name www.discussitapp.com discussitapp.com;
location / {
#proxy_pass http://sinatra;
proxy_pass http://localhost:3000;
}