Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost | |
top = 49.3457868 # north lat | |
left = -124.7844079 # west long | |
right = -66.9513812 # east long | |
bottom = 24.7433195 # south lat | |
def cull(latlngs): | |
""" Accepts a list of lat/lng tuples. | |
returns the list of tuples that are within the bounding box for the US. | |
NB. THESE ARE NOT NECESSARILY WITHIN THE US BORDERS! |
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
# 2. Include Sweeping module in your controller(s) to have cache_sweeper | |
# method to be avaliable, or right in ApplicationController so it will be | |
# available in all controllers inheriting from it. | |
class ApplicationController < ActionController::Base | |
include ActionController::Caching::Sweeping | |
# ... | |
end |
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
class MP | |
class << self | |
def init_mixpanel | |
@mixpanel = Mixpanel.sharedInstance | |
self.identify(@mixpanel) | |
@mixpanel.people.set({"$last_login" => Time.now}) | |
MP.update_person(@mixpanel) | |
end |
Teacup::Stylesheet.new :create_screen do | |
# Input Fields | |
style :input_text_wrapper, | |
left: 24, | |
image: UIImage.imageNamed('ui-textfield-normal.png'), | |
userInteractionEnabled: true, | |
width: 249 | |
style :input_text_type, |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
# Migrate schema and data from Mongoid to MySQL ActiveRecord | |
class MongoidMysqlMigrator | |
def randomize_auto_increment_values(source_models, from=5500, to=10500) | |
source_models.each do |model| | |
value = rand(from-to)+from | |
sql = %(ALTER TABLE #{model.name.tableize} AUTO_INCREMENT=#{value}) | |
puts sql | |
ActiveRecord::Base.connection.execute(sql) | |
end |