This file contains hidden or 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
[user] | |
name = SengMing Tan | |
email = email@example.com | |
[alias] | |
b = branch | |
c = commit . | |
co = checkout | |
stat = status | |
s = status | |
h = log --pretty=format:'%Cblue%h %Cgreen %ar%Creset %s' |
This file contains hidden or 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
# How Clearance / Hoptoad does it | |
module Clearance | |
class << self | |
attr_accessor :configuration | |
end | |
def self.configure | |
self.configuration ||= Configuration.new | |
yield(configuration) | |
end |
This file contains hidden or 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
# This file is copied to spec/ when you run 'rails generate rspec:install' | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} |
This file contains hidden or 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
# Copy and paste this to the rails console to test your email settings | |
class MyMailer < ActionMailer::Base | |
def test_email | |
@recipients = "someone@somewhere.com" | |
@from = "must_be_same_as_smpt_account_login@gmail.com" | |
@subject = "test from the Rails Console" | |
@body = "This is a test email" | |
end | |
end |
This file contains hidden or 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 'irb' | |
require 'pathname' | |
require 'json' | |
require 'rake/clean' | |
require 'time' | |
class Tweet | |
attr_reader :tweet_id, :created_at | |
def initialize(row) |
This file contains hidden or 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
# joins with time range | |
time_range = (Time.now.midnight - 1.day)..Time.now.midnight | |
Client.joins(:orders).where(orders: { created_at: time_range }) |
This file contains hidden or 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
# Use this to look for broken links in your app. | |
# crawls the development server http://localhost:3000 | |
# Suggestion: Also check to make sure that intentional 404s | |
# are handled gracefully by app. | |
task :crawl => :environment do | |
require 'anemone' | |
root = 'http://localhost:3000' | |
options = {:discard_page_bodies => true, :verbose => true} |
This file contains hidden or 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
curl --silent https://raw.githubusercontent.com/cmusphinx/cmudict/master/cmudict.dict | | |
egrep '[a-z]+\s+[^AEIOU]*[AEIOU]+[^AEIOU]+[AEIOU]+[^AEIOU]*$' | | |
perl -pe 's/([a-z]+).*/\1/' | | |
comm --nocheck-order -12 - /usr/share/dict/words | | |
shuf -n 2 |
This file contains hidden or 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
commnunity.users.each do |recipient| | |
sms_credits = community.sms_credits | |
if sms_credits > 0 | |
# this chucks the job into a queue and returns immediately! | |
SmsSenderJob.perform_later recipient, 'Everything is fine.' | |
# take off a credit | |
community.sms_credits = sms_credits - 1 | |
community.save |
This file contains hidden or 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
# Job 1 | |
sms_credits = community.sms_credits # start with 100 credits | |
# Switch! ------------------------------------------------------------------- | |
# Job 2 | |
sms_credits = community.sms_credits # still 100 credits!! | |
if sms_credits > 0 | |
send_sms recipient, message | |
# take off a credit | |
community.sms_credits = sms_credits - 1 |
NewerOlder