This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# short_time_in_words(Time.now, 5.seconds.ago) # => "5s" | |
# short_time_in_words(Time.now, 5.minutes.ago) # => "5m" | |
# short_time_in_words(Time.now, 5.hours.ago) # => "5h" | |
# short_time_in_words(Time.now, 55.hours.ago) # => "2d" | |
# | |
def short_time_in_words(from_time, to_time) | |
from_time = from_time.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Wrote this for the Design Board at equilter.com almost 10 years ago. | |
* Can't believe it still works and it's still in use! | |
* Should work for any DHTML browser known to man. | |
* | |
* Not so fond memories of getting it to work on MSIE 4 for Mac. | |
* | |
* To experience: | |
* 1. Add items to shopping cart | |
* 2. Click the Design Board at the top right. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# controllers/shared/abstract_email_controller.rb | |
module Shared | |
class AbstractEmailController < AbstractController::Base | |
include AbstractController::Rendering | |
include AbstractController::Layouts | |
include AbstractController::Helpers | |
include AbstractController::Translation | |
include AbstractController::AssetPaths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FB = OmniAuth::Strategies::Facebook.new("nothing") | |
client = ::OAuth2::Client.new("nothing", "nothing", FB.client_options) | |
cached_token = "app_id_part|session_id_part|token_part" # or maybe you sent it from the iPhone | |
access_token = ::OAuth2::AccessToken.new(client, cached_token) | |
FB.instance_variable_set("@access_token", access_token) | |
FB.user_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
vlc="/Applications/VLC.app/Contents/MacOS/VLC" | |
ext="mp3" | |
dest="/Users/ryan/Desktop/mp3/" | |
for ARG in "$@"; do | |
NEWFILE="$dest$(basename "$ARG").$ext" | |
$vlc -I dummy -vvv "$ARG" --sout "#transcode{acodec=mp3,ab=128,channels=2,samplerate=44100}:std{mux=raw,dst=\"$NEWFILE\",access=file}" vlc://quit | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :facebook do | |
desc "Check if users have updated their Facebook verification status" | |
task :update_user_verifiation_status => :environment do | |
require 'omniauth' | |
# get all users who are not currently verified | |
@users = User.joins(:authentications, :profile).where(:"authentications.provider" => "facebook", :"user_profiles.facebook_verified" => 0).select("users.id AS id, authentications.uid, authentications.access_token, user_profiles.facebook_verified") | |
@users.each do |user| | |
FB = OmniAuth::Strategies::Facebook.new("nothing") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dragonfly' | |
app = Dragonfly[:images] | |
mconfig = Mongoid.load!("config/mongoid.yml", Rails.env) | |
app.datastore = Dragonfly::DataStorage::MongoDataStore.new | |
app.datastore.configure do |c| | |
cfg = mconfig['sessions']['default'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= stylesheet_link_tag "pikaday", :media => "all" %> | |
<%= form_for(@news) do |f| %> | |
<!-- Generate HTML --> | |
<%= form_datetime_selector_helper(:obj => f, | |
:field_name => :publish_date, | |
:label_name => 'Publish Date', | |
:date => @news.publish_date).html_safe %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SportStatistic | |
include Mongoid::Document | |
end | |
class AthleteStatistic < SportStatistic | |
end | |
class SoccerAthleteStatistic < AthleteStatistic | |
field: goals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/https" | |
require "uri" | |
require "date" | |
ACCOUNT_ID = "000000" | |
APP_ID = "000000000" | |
API_KEY = "0000000000000000000000000000000000000000" | |
yesterday = (Date.today.to_time - 1).strftime("%Y-%m-%d") |
OlderNewer