Skip to content

Instantly share code, notes, and snippets.

View rupurt's full-sized avatar
🏠
Working from home

Alex Kwiatkowski rupurt

🏠
Working from home
View GitHub Profile
@rupurt
rupurt / .tmux.conf
Created June 22, 2016 14:45
tmux configuration
# remap prefix to Control + a
set -g prefix C-a
set -g default-terminal "xterm-256color"
set -s escape-time 0
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# Lines of history
<header class="school-website-header uk-z-4">
<div class="uk-padding-horizontal uk-container uk-container-center">
<nav class="uk-navbar" data-behavior="dropdown">
<a href="{{current_school.logo_navigation_url}}" class="uk-brand">
{{ if current_school.logo_url }}
<img src="{{current_school.logo_url}}" alt="{{current_school.name}}">
{{ else }}
<span class="uk-text-large uk-text-bold">{{ current_school.name }}</span>
{{ end }}
</a>
@rupurt
rupurt / gist:182a474bb9889b54fa50ec5bc0445014
Last active May 19, 2016 12:46
includes AR weirdness
# Should be 8 records
ActiveRecord::Base.connection.execute(MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_sql).count
# Should be 8 records but only returns 1
MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size
# 'joins' does what we want and returns 8 records. Maybe we can figure out how to get ransack to do a join instead of includes
MembershipSummary.joins(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size
@rupurt
rupurt / left_join_arel_example.rb
Created May 2, 2016 13:51 — forked from mildmojo/left_join_arel_example.rb
LEFT JOIN in ARel for ActiveRecord in Ruby on Rails
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of
# the mechanics, not a real-world use case.
# == DEFINITIONS
# - A Taxi is a car for hire. A taxi has_many :passengers.
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi.
class Taxi < ActiveRecord::Base
# This scope LEFT JOINs the Passenger table. You might use this if you wanted
# to select taxis by a set of taxi and passenger IDs (as with the
curl -o a425.dump `heroku pg:backups public-url a425 -r remote-name`
heroku pg:backups -r production # list existing backups
curl -o a123.dump `heroku pg:backups public-url a123 -r production` # pull the backup down locally
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d AppName_enviroment a123.dump
# Or even quicker
heroku pg:backups restore `heroku pg:backups public-url a123 -r sk-git-remote` DATABASE_URL -r sk-git-remote
@rupurt
rupurt / gist:09ec8f3f9ac9c4e6e180
Created February 24, 2016 17:03
Processing groups spike
module FileType
2 module ProcessingGroup
3 Box = [PDF, Word, Powerpoint]
4 Video = [Video]
5 end
@rupurt
rupurt / gist:455dd190f67b0a6195f8
Created June 1, 2015 21:01
Run update ssl cert
curl https://gist.githubusercontent.com/rupurt/a9e35c8c219a37eb90f6/raw/2397544c86ef149eedc3a3e9c645f3eb3c7319a7/update_ssl_cert.sh > /tmp/update_ssl_cert.sh && chmod 744 /tmp/update_ssl_cert.sh && /tmp/update_ssl_cert.sh
@rupurt
rupurt / update_ssl_cert.sh
Last active August 29, 2015 14:22
Update SSL cert
#!/bin/bash
cd /usr/local/etc/openssl/certs/
curl -O http://curl.haxx.se/ca/cacert.pem
mv cacert.pem cert.pem
echo "export SSL_CERT_FILE=/usr/local/etc/openssl/certs/cert.pem" >> ~/.bash_profile.local
source ~/.bash_profile
@rupurt
rupurt / custom_font_declaration.html
Created April 14, 2015 15:09
Custom font declaration
<style>
@font-face {
font-family: 'action_manbold_italic';
src: url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.eot');
src: url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.eot?#iefix') format('embedded-opentype'),
url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.woff2') format('woff2'),
url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.woff') format('woff'),
url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.ttf') format('truetype'),
url('https://youdomain.com/some_folder/action_man_bold_italic-webfont.svg#action_manbold_italic') format('svg');
font-weight: normal;