Skip to content

Instantly share code, notes, and snippets.

View theoretick's full-sized avatar

Lucas Charles theoretick

View GitHub Profile
@theoretick
theoretick / 01-activerecord.rb
Created December 9, 2016 22:25 — forked from janko/01-activerecord.rb
PostgreSQL JSON querying in Sequel (my presentation from our local Ruby meetup)
require "active_record"
ActiveRecord::Base.establish_connection('postgres:///testing')
ActiveRecord::Migration.verbose = false
ActiveRecord::Migration.class_eval do
create_table :played_quizzes, force: true do |t|
t.integer :player_ids, array: true
t.json :quiz_snapshot
end
module RQueue
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
#set the queue name some as the model name
@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;
}
@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 / 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
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"
-- 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 =
@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
@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 / 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