Skip to content

Instantly share code, notes, and snippets.

View milesmatthias's full-sized avatar

Miles Matthias milesmatthias

View GitHub Profile
@milesmatthias
milesmatthias / Outline of Meteor Intro Screencast.txt
Last active December 11, 2015 06:58
This is the outline / notes I took while listening to the Meteor introductory screencast. I wanted to be able to reference their main selling points later. Maybe this will save you some time too.
http://www.meteor.com/screencast
1. Download Meteor
2. Create new project
3. Create HTML file
4. Run Meteor / go to localhost in browser
5. Live Update Demo (changed HTML file)
6. Pasted in simple app (made it clear that this app uses handlebars and mongodb, but meteor lets you use whatever you want.
The app uses Templates and Collections)
@milesmatthias
milesmatthias / action.rb
Last active December 20, 2015 18:19 — forked from ahoward/action.rb
# it's not critical for understanding
# but here is the associated server-side action
#
def version
@program = load_program!
@version = @program.versions.find(params[:version_id])
if stale?(:last_modified => @version.updated_at, :etag => @version.cache_key)
render
@milesmatthias
milesmatthias / a.md
Last active January 2, 2016 09:58 — forked from ahoward/a.md

recently our team had an exchange about lazy evaluation of ORM queries in ruby ( https://gist.github.com/ahoward/8285529 ) - this prompted me to think about how deep rails has really become and just how hard good MVC organization for the web really is. back in the day it took a special kind of developer to understand how to not kill a db when it was used in a web app - now it's pretty easy and, while this seems good on the outside, in the inside i think today's developers understand less and less about why web programming is really the hardest kind there is.

that's the motivation for today's quiz. to take it fork and keep your answer under 142 LOC total

given a model, Post, write code which will

  • load the 2nd set of 5 results (page 2 of 5 each)
  • access them in the view
@milesmatthias
milesmatthias / static.rake
Created April 29, 2014 20:17
part of a rake task to create an index and thank you page from given title and primary color
desc "given a name and primary color, build static index and thank you pages, returning directory path of files"
task :build, :site_id, :name, :primary_color do |t, args|
dirname = DateTime.now.to_s
dirname += '_' + args[:site_id] if args[:site_id].length > 0
dirpath = Rails.root.join("tmp/static_builds", dirname)
system("mkdir -p #{ dirpath.to_path }")
system("cp -r #{ Rails.root }/static/* #{ dirpath.to_path }")
puts("name = #{ args[:name] }")
@milesmatthias
milesmatthias / a.rb
Created May 16, 2014 20:10 — forked from ahoward/a.rb
# make this script run, update your gist with the running script, and it's
# output in a separate gist. the entire quzi should take 1-3 minutes, but you
# get 5.
#
# the meat - take < 5 minutes to do this
#
assert :hash do
x = {}
@milesmatthias
milesmatthias / headline_service.js.erb
Created June 10, 2014 13:52
AngularJS with Rails JSONP API
angular.module('app')
.factory('HeadlineService', ['$http',
function($http) {
'use strict';
var BASE_URL = "<%= [App.settings.api_base_url, '/services/headlines'].join %>",
CALLBACK_STRING = "?callback=JSON_CALLBACK";
return {
getHeadlines: function(){
@milesmatthias
milesmatthias / application.html.slim
Created July 18, 2014 01:23
Mobile detection on CloudFront
doctype html
head
= render partial: 'shared/mobile_detection'
javascript:
var device_cookie = cookie.get('device'),
cookiesEnabled = cookie.enabled();
@milesmatthias
milesmatthias / directory_upload.rb
Created September 1, 2014 00:57
S3 directory upload in ruby. Switched http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively to use the official aws ruby sdk.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
@milesmatthias
milesmatthias / number_episodes.rb
Created October 5, 2014 23:22
A short ruby script I wrote to quicken the process of prefixing episodes with numbers on an external hard drive.
#!/usr/bin/env ruby
require 'pry'
require 'fileutils'
EPISODES = [
nil,
nil,
nil,
"My Happy Place.mov",
@milesmatthias
milesmatthias / mv_contents_up.rb
Created October 6, 2014 00:02
short ruby script used to move movies in a file structure created by itunes into a flat structure
#!/usr/bin/env ruby
# for each directory in the current directory:
#
# 1. move its contents up one directory (out of its current directory)
# 2. remove the (now empty) directory
#
# ( note: skips hidden files and . and .. )
require 'pry'