Skip to content

Instantly share code, notes, and snippets.

@alexbaldwin
alexbaldwin / rounded-corners.css
Created December 18, 2015 20:39
Square with rounded corners
.photo img {
width: 230px;
border-radius: 20%;
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
}
@alexbaldwin
alexbaldwin / larger-visitor-photo.css
Created December 18, 2015 20:37
Make the visitor photo larger
.photo img {
width: 400px;
border-radius: 50%;
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
}
.visitor-info {
width: 100%;
text-align: center;
@alexbaldwin
alexbaldwin / gist:b5c21e281c590e9b8397
Created July 2, 2015 05:21
Soundcloud feed with HN
client.get('/me/activities').collection.each do |track|
favorites = track.origin['favoritings_count']
time_ago_in_hours = Time.diff(Time.now, Time.parse(track.created_at))[:hour]
score = (favorites / ((time_ago_in_hours + 2)**1.8)).ceil
p "#{track.origin['title']} - #{score}"
end
@alexbaldwin
alexbaldwin / gist:81fe0407368f9e6204aa
Created May 28, 2015 16:44
Dataclip for New Users Monthly
WITH monthrollup as (
select count(*) as signups,
date_trunc('month', created_at) as date
from users
WHERE created_at >= current_date - interval '24 months'
group by 2
)
SELECT date,
signups
00 9 * * * curl -F [email protected] [https://signwithenvoy.com/api/configuration/employee_list?api_key=YOUR_API_KEY_HERE](https://signwithenvoy.com/api/configuration/employee_list?api_key=YOUR_API_KEY_HERE)
get "/user_media_feed" do
client = Instagram.client(:access_token => session[:access_token])
user = client.user
html = "<h1>#{user.username}'s media feed</h1>"
page_1 = client.user_media_feed(777)
page_2_max_id = page_1.pagination.next_max_id
page_2 = client.user_recent_media(777, :max_id => page_2_max_id ) unless page_2_max_id.nil?
html << "<h2>Page 1</h2><br/>"
for media_item in page_1
@alexbaldwin
alexbaldwin / gist:cd41e4599398fd025841
Last active August 29, 2015 14:13
Rails User Queries
date = Date.parse('january 5 2013')
users = User.where(created_at: date..date.end_of_day)
@alexbaldwin
alexbaldwin / handbook.md
Last active June 27, 2019 09:04
thoughtbot Advisor Checklist

[ ] Put signed contact in Dropbox [ ] Create Freshbooks invoice for first 2 weeks [ ] Create Freshbooks recurring invoice to start after week 3 (weekly) [ ] Create Campfire room [ ] Create Github Repo [ ] Create Trello Board (for Product Design Sprints or Rails MVPs, use Trello template) [ ] Create recurring calendar invites for weekly planning, retros, and daily standups [ ] Create project in Team [ ] Share Team project page with client [ ] Schedule thirty minute meeting with client to go over systems

@alexbaldwin
alexbaldwin / config.ru
Last active December 28, 2015 12:59
When using Middleman http://middlemanapp.com and HF&J http://typography.com together, the production checks fail. Use this Rack middleware to fix it. Code via @croaky.
require 'lib/rack_typography'
use Rack::Typography
@alexbaldwin
alexbaldwin / basic_authenticate.rb
Created November 6, 2013 00:29
Rails 4 Basic Auth via ENV variable. Add this to your ApplicationController. Set the BASIC_AUTH ENV variable to enable.
before_filter :authenticate
protected
def authenticate
return true unless ENV['BASIC_AUTH']
authenticate_or_request_with_http_basic do |username, password|
username == "" && password == ENV['BASIC_AUTH']
end
end