Skip to content

Instantly share code, notes, and snippets.

View jakeonrails's full-sized avatar

Jake Moffatt jakeonrails

View GitHub Profile
@jed
jed / rendering_templates_obsolete.md
Created October 19, 2012 05:07
Rendering templates obsolete

(tl;dr DOM builders like [domo][domo] trump HTML templates on the client.)

Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].

The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.

John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.

But I can't really see the value in client-side HTML templates anymore.

@ScottPhillips
ScottPhillips / detect-bot.php
Created June 10, 2012 08:15
Detects a few common Search Bots
<?php
/* Detects some common web bots */
function detectBot($USER_AGENT) {
$crawlers_agents = strtolower('Bloglines subscriber|Dumbot|Sosoimagespider|QihooBot|FAST-WebCrawler|Superdownloads Spiderman|LinkWalker|msnbot|ASPSeek|WebAlta Crawler|Lycos|FeedFetcher-Google|Yahoo|YoudaoBot|AdsBot-Google|Googlebot|Scooter|Gigabot|Charlotte|eStyle|AcioRobot|GeonaBot|msnbot-media|Baidu|CocoCrawler|Google|Charlotte t|Yahoo! Slurp China|Sogou web spider|YodaoBot|MSRBOT|AbachoBOT|Sogou head spider|AltaVista|IDBot|Sosospider|Yahoo! Slurp|Java VM|DotBot|LiteFinder|Yeti|Rambler|Scrubby|Baiduspider|accoona');
$crawlers = explode("|", $crawlers_agents);
if(is_array($crawlers) {
foreach($crawlers as $crawler) {
if (strpos(strtolower($USER_AGENT), trim($crawler)) !== false) {
return true;
}
@vieron
vieron / install.md
Created April 30, 2012 23:13 — forked from seamusjr/install.md
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, nvm

Setup new Mac with OSX Lion from scratch.

These commands are good as of 2012-03-18.

Install Xcode 4

The download/install takes a while so start it first. When it finishes downloading you will still need to run it to complete installation.

Note: Make sure you install the XCode Command Line Tools after XCode is done installing. To do this go to Xcodes -> Preferences -> Downloads -> Command Line Tools -> Install. If you don't you might not be able to install brew packages (i.e. brew install wget will fail).*

@seyyah
seyyah / gist:2366874
Created April 12, 2012 12:19 — forked from delano/gist:845643
Fix for "Errno::ETIMEDOUT: Operation timed out - connect(2)" when installing gems
# A DNS change to Rubygems.org is causing lingering issues. Namely,
# rubygems.org and production.s3.rubygems.org are still pointing to
# the old address. See:
# http://twitter.com/#!/gemcutter/status/30666857698557952
# The symptoms:
# $ gem install benelux --version 0.5.17
# ERROR: Could not find a valid gem 'benelux' (= 0.5.17) in any repository
# ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
@guyboltonking
guyboltonking / compressed_static_assets.rb
Created March 21, 2012 20:37
Slightly hacky rails middleware for serving up precompiled gzipped assets
require 'action_dispatch/middleware/static'
module Middleware
class FileHandler < ActionDispatch::FileHandler
def initialize(root, assets_path, cache_control)
@assets_path = assets_path.chomp('/') + '/'
super(root, cache_control)
end
def match?(path)
@Sjors
Sjors / robot_user_agents.rb
Created August 3, 2011 00:08
Recognize search engines and spammers using user-agents.org
require 'net/http'
require 'xmlsimple'
url = "http://www.user-agents.org/allagents.xml"
xml_data = Net::HTTP.get_response(URI.parse(url)).body
data = XmlSimple.xml_in(xml_data)
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
agent_names = agents.collect {|agent| agent["String"].first}
@schleg
schleg / 01. Gemfile
Created May 26, 2011 17:26
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'