Skip to content

Instantly share code, notes, and snippets.

@waynehoover
waynehoover / layout.haml
Created October 20, 2010 01:34
Sinatra S3 Direct Upload application
!!! 5
%html
%head
%title Sinatra AWS Upload Example
%link{:rel => "stylesheet", :href => "/css/swfupload.css", :type => "text/css", :media => "all"}
%link{:rel => "stylesheet", :href => "http://cachedcommons.org/cache/blueprint/0.9.1/stylesheets/screen-min.css", :type => "text/css", :media =>"all"}
%script{:src => "http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"}
%body
= yield
@waynehoover
waynehoover / main.rb
Created October 20, 2010 03:04
Sinatra S3 Direct Upload with jQuery SWFObject
require 'rubygems'
require 'sinatra'
require 'active_support/core_ext'
require "base64"
get '/upload' do
bucket = 'bucket name here'
access_key_id = 'access key id here'
secret_access_key = 'Enter secret access key here'
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false" />
</cross-domain-policy>
irb(main):004:0> Teacher.find_by_id(49)
Teacher Load (0.3ms) SELECT "teachers".* FROM "teachers" WHERE "teachers"."id" = 49 LIMIT 1
=> #<Teacher id: 49, name: "Sam Rice", bio: nil, email: nil, created_at: "2011-06-22 21:03:41", updated_at: "2011-06-22 21:03:41", pic_file_name: nil, pic_content_type: nil, pic_file_size: nil, pic_updated_at: nil>
irb(main):007:0> Teacher.find_by_name("Sam Rice")
Teacher Load (0.3ms) SELECT "teachers".* FROM "teachers" WHERE "teachers"."name" = 'Sam Rice' LIMIT 1
=> nil
@waynehoover
waynehoover / gist:1172733
Created August 26, 2011 04:57
new hypem downloader GM script working aug 25th 2011
// ==UserScript==
// @name Hype Machine direct download links v3
// @author tonyskn_at_gmail.com and wayne@blissofbeing.com
// @description Add download links next to tracks on The Hype Machine.
// @include http://hypem.com/*
// ==/UserScript==
// Modified by @blissofbeing
// Fixed jQuery conflict issue
// Modified by @obmas
// I got rid of the hot keys and the embeded icon. This now adds (Download) next to the track and attributes to work with the DownThemAll plugin.
(function () {
var a, b, c, d;
if (typeof $ == "undefined" || $ === null) return;
d = !1, b = function () {
d = !0
}, a = function () {
d = !1
}, "onpagehide" in window ? ($(window).on("pageshow", a), $(window).on("pagehide", b)) : ($(window).on("load", a), $(window).on("beforeunload", b), $(window).on("unload", b)), c = function () {
return $.browser != null && ($.browser.webkit || $.browser.opera || $.browser.msie && parseInt($.browser.version) >= 8 || $.browser.mozilla && parseInt($.browser.version) >= 4) && $.browser.version != null && $.browser.version !== "0"
}();
(jQuery), function (a) {
a.fn.autosaveField = function (b) {
var c = a.extend({}, a.fn.autosaveField.defaults, b);
return this.each(function () {
var b = a(this);
if (b.data("autosaved-init")) return;
var d = b.attr("data-field-type") || ":text",
e = b.find(d),
f = b.attr("data-action"),
g = b.attr("data-name"),
DOM:
<div ng-repeat="post in posts">
...
abbr.created-at.arial.timeago title="{{post.created_at}}"
</div>
Script:
.directive('postTile', function($timeout){
angular.module('hyveServices', ['ngResource']).
factory('HyvePost', function($resource){
return $resource('/hyves/'+gon.current_hyve.id+'/posts/:id', {}, {
update: { method: 'PUT'},
query: {method: 'GET', isArray:true}
});
}).factory('Comment', function($resource){
return $resource('/posts/:post_id', {}, {
update: { method: 'PUT'},
query: {method: 'GET', isArray:true}
"SELECT \"worksheets\".* FROM \"worksheets\" INNER JOIN \"plans\" ON \"plans\".\"id\" = \"worksheets\".\"plan_id\" WHERE \"plan\".\"student_id\" IS NULL"