Skip to content

Instantly share code, notes, and snippets.

View jrust's full-sized avatar

Jason Rust jrust

  • Seeq
  • Seattle, WA
View GitHub Profile
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
@jrust
jrust / self.rb
Last active December 8, 2016 17:12
An interactive tutorial on the self, singleton class, and method hierarchy in ruby.
# Resources:
# Method lookup diagram: http://phrogz.net/RubyLibs/RubyMethodLookupFlow.pdf
# Seeing metaclasses clearly: http://ruby-metaprogramming.rubylearning.com/html/seeingMetaclassesClearly.html
require 'rubygems'
require 'pry-debugger'
require 'awesome_print'
# Objects hold data, classes hold methods
# Just take a look at the source for Class
@jrust
jrust / convert_thumbs.rb
Created October 17, 2012 23:21
Resize thumbnails on S3 #amazon #scripts
require 'rubygems'
require 'aws-sdk'
require 'mini_magick'
aws_access_key_id = 'access-key'
aws_secret_access_key = 'secret'
bucket_name = 'bucket'
s3 = AWS::S3.new :access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key
@jrust
jrust / copy_s3_bucket.rb
Created August 30, 2012 18:10
Copy one S3 bucket to another
require 'rubygems'
require 'aws-sdk'
aws_access_key_id = 'key-id'
aws_secret_access_key = 'access-key'
s3 = AWS::S3.new :access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key
target_bucket = s3.buckets['old-bucket']
destination_bucket = s3.buckets['new-bucket']
@jrust
jrust / README.markdown
Created March 13, 2012 17:57 — forked from pezholio/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Ability to disable autoselect of first matched element.
  • Ability to automatically set the width of the dropdown to that of the text input.
  • Ability to fetch source element via AJAX
  • Ability to have a comma separated list of tags.

For the proper source, and other examples, please see the original gist.

Example showing off all the above features

@jrust
jrust / application.js
Created July 19, 2011 17:45
Binding events to both onload content and ajax-loaded content.
var Application = {
// @see attach_behaviors();
behaviors: {},
init: function() {
$('body').bind('ajaxSuccess', Application.attach_behaviors);
Lessonplanet.attach_behaviors();
},
/**
@jrust
jrust / gist:989391
Created May 24, 2011 18:57
Ruby & Rails & LP idioms
# @method LpConfig
# @desc Set variables for use by javascript files
# @file taxonomies/views/index.html.erb
# Non-idiom
=begin erb code
<% javascript_tag do %>
$.post('<%= new_taxonomy_path %>');
<% end %>
=end
@jrust
jrust / gist:704391
Created November 17, 2010 23:58
Optimiser Audit Questions
$content['type'] = array (
'name' => 'Optimiser Audit',
'type' => 'om_audit',
'description' => 'A web-based Optimiser audit.',
'title_label' => 'Please Enter a Description for This Audit',
'body_label' => '',
'min_word_count' => 0,
'help' => '',
'node_options' =>
array (
# Queries the Google spellcheck API to allow for determining misspelled words
# as well as providing corrective suggestions.
#
# Largely taken from the TinyMCE PHP Spellchecker plugin
module GoogleSpellchecker
require 'net/https'
require 'uri'
require 'builder'
def check_spelling(spell_check_text, lang='en')