Skip to content

Instantly share code, notes, and snippets.

View erkattak's full-sized avatar

Erik Straub erkattak

View GitHub Profile
class Allocation < AR::Base
# allocations schema
# - line_item_id - indexed
# - type - string [ ‘CreditAllocation’, ‘DebitAllocation’ ] - indexed
# - allocatable_id - integer - indexed
# - amount - integer
belongs_to :line_item
belongs_to :allocatable, class_name: ‘LineItem’
end
@erkattak
erkattak / turbo_dev.rb
Created August 27, 2014 15:53
TurboDev - Speed up Rails development environment's asset serving
# from https://github.com/discourse/discourse/blob/21e08a423e8839c6bacb4ee688b924a4fb71113f/lib/middleware/turbo_dev.rb
# lib/middleware/turbo_dev.rb
module Middleware
# Cheat and bypass Rails in development mode if the client attempts to download a static asset
# that's already been downloaded.
#
\set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]%# '
\set PROMPT2 '[more] %R > '
-- By default, NULL displays as an empty space. Is it actually an empty
-- string, or is it null? This makes that distinction visible.
\pset null '[NULL]'
-- Use table format (with headers across the top) by default, but switch to
-- expanded table format when there's a lot of data, which makes it much
-- easier to read.
\x auto
-- Verbose error reports.
@erkattak
erkattak / gistbook.json
Last active August 29, 2015 14:11 — forked from anonymous/gistbook.json
Anonymous Gistbook
{"title":"Anonymous Gistbook","author":"Anonymous","pages":[{"pageName":"","sections":[{"type":"text","source":"Welcome to Gistbook!"},{"type":"html","source":"<h1>test</h1>"},{"type":"css","source":"h1 { color: red; }"},{"type":"javascript","source":"alert('welcome to the internet');"}]}],"public":true}
@erkattak
erkattak / instructions.md
Created January 22, 2015 14:59
Using opt+→ opt+← and opt+←delete in iTerm2 AND pry

iTerm2 > Preferences > Profiles > Keys

  • Left Option key acts as "Meta"
  • Right Option key acts as "Meta"
  • Opt+→ sends escape sequence of f
  • Opt+← sends escape sequence of b
  • Add Opt+←Delete sends hex code 17
export default React.createClass({
// ...
render () {
const style = {
WebkitTransform: 'translateY(' + this.state.translatedYPosition + ')'
}
let containerClassString = this.state.containerExpanded ? LeftNavConstants.CONTAINER_EXPANDED : LeftNavConstants.CONTAINER_COLLAPSED
if (this.state.containerHighlighted) containerClassString += ' ' + LeftNavConstants.CONTAINER_HIGHLIGHTED
vjs.MediaTechController.prototype.emulateTextTracks = function() {
var player = this.player_,
textTracksChanges,
tracks,
script;
if (!window['WebVTT']) {
script = document.createElement('script');
script.src = player.options()['vtt.js'] || '../node_modules/vtt.js/dist/vtt.js';
player.el().appendChild(script);
<?php
// controller
function wutangclan() {
$this->load->model('odb');
$data['killerbees'] = $this->odb->getThatPaper();
$data['main_content'] = 'report/dashboard'; // main body view, can be whatever
$this->load->view('includes/template', $data);
?>
============
@erkattak
erkattak / JR's CodeIgniter Image Thumb Helper
Created March 2, 2011 19:25
Image thumb helper that keeps the thumbnail once it's created. Must mod Image_lib to account for transparent PNGs.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('image_thumb_helper')){
function image_thumb($image_path, $filename, $height, $width){
$filename = preg_replace('/\.png/','_',$filename);
// Get the CodeIgniter super object
$CI =& get_instance();
// Path to image thumbnail
$image_thumb = dirname($image_path) . '/'.$filename . $height . '_' . $width . '.png';
if( ! file_exists($image_thumb)){
// LOAD LIBRARY
@erkattak
erkattak / RegExTimeRange
Created April 28, 2011 18:16
RegEx for Time Range (1-5pm, 11:45am-5pm, 1 - 5:15pm, etc.)
\b((?:(?<!:)(?:1?[0-9])(?::(?<!\d)[0-5]\d)?(?:\s?[ap][m]?)?)(?:\s?-\s?)(?<=-|\s)(?:(?:1?[0-9])(?::(?<!\d)[0-5]\d)?(?:\s?[ap][m]?)))\b