Skip to content

Instantly share code, notes, and snippets.

View stefl's full-sized avatar

Stef Lewandowski stefl

View GitHub Profile
@stefl
stefl / gist:1062414
Created July 3, 2011 17:45
How to get Padrino, Compass and Heroku working without checking in the resulting css to the git repo
# Enables support for Compass, a stylesheet authoring framework based on SASS.
# See http://compass-style.org/ for more details.
# Store Compass/SASS files (by default) within 'app/stylesheets'
module CompassInitializer
def self.registered(app)
require 'sass/plugin/rack'
Compass.configuration do |config|
config.project_path = Padrino.root
@stefl
stefl / gist:1154253
Created August 18, 2011 15:07
libmxf writeavidmxf options
Options: (options marked with * are required)
-h, --help display this usage message
* --prefix <filename> output filename prefix
--clip <name> clip (MaterialPackage) name.
--project <name> Avid project name.
--tape <name> tape name.
--ntsc NTSC framerate and frame size. Default is DV file frame rate or PAL
--film24 use framerate of 24 instead of default 25fps
--film23.976 use framerate of 23.976 (24000/1001) instead of default 25fps
--legacy use legacy DataDefs, for DV essence use legacy descriptor properties
@stefl
stefl / scrape_tweets.rb
Created March 25, 2012 14:47
Download all tweets from the twitter search API for a given search term (limited to their maximum of 1500)
#! /usr/bin/env ruby
require "fileutils"
search_term = ARGV[0]
if search_term
time = Time.now
directory_path = File.dirname(__FILE__) + "/tweets/" + search_term + "_" + time.to_i.to_s
FileUtils.mkdir_p(directory_path)
directory = Dir.new(directory_path)
(1..15).each do |i|
`curl "http://search.twitter.com/search.json?q=#{search_term}&rpp=100&page=#{i}&include_entities=true&result_type=mixed" > #{directory.path}/#{i}.json`
@stefl
stefl / gist:2385517
Created April 14, 2012 16:17
Rails button_to helper using a button tag rather than an input tag
def button_to_with_button_element(name, options = {}, html_options = {})
fragment = ::Nokogiri::HTML.fragment(button_to(name, options, html_options))
fragment.css("input[type=submit]").each do |input|
input.replace ::Nokogiri::HTML.fragment("<button class='#{input.attribute("class")} type='submit'>#{input.attribute("value")}</button>")
end
raw fragment.to_html
end
@stefl
stefl / gist:4540506
Created January 15, 2013 17:56
Contenteditable hover and focus states
[contenteditable]:hover:after {
content: ' click to edit';
font-style: italic;
font-size: 12px;
color: #ccc;
}
[contenteditable]:hover, [contenteditable]:focus {
background: #FFFFD3;
}
@stefl
stefl / foundation_paginate.rb
Last active December 13, 2015 20:48 — forked from mariszin/foundation_paginate.rb
Zurb Foundation now uses 'current' instead of 'active' for the active page.
# Based on https://gist.github.com/1182136 and https://gist.github.com/1586384
# Make the will_paginate generate markup for Zurb Foundation
# Put this in config/initializers/foundation_paginate.rb
module WillPaginate
module ViewHelpers
class LinkRenderer < LinkRendererBase
protected
def html_container(html)
tag(:ul, html, container_attributes)
@stefl
stefl / gist:5143269
Created March 12, 2013 14:24
Weird "localhost" oddness
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 lvh.me
@stefl
stefl / gist:5322519
Last active December 15, 2015 20:59
The names of the data sets that #nhtg13 have provided. All 9374 of them
["1-1-5m-scale-geology-through-climate-change-poster-map-covering-uk-mainland-northern-ireland-an",
"1-1056-scale-town-plans-1848-1939",
"1-50-000-scale-gazetteer",
"1-500-scale-town-plans-1848-1939",
"1-50000-scale-gazetteer",
"1-528-scale-town-plans-1848-1939",
"10k-sheet-data-files",
"13-butadiene-running-annual-mean-at-automatic-sites-comparison-with-health-objective-for-2003-u-2010",
"15th-percentile-house-prices-land-registry",
"1987-ongoing-met-office-marine-automatic-weather-station-maws-meteorological-observations",
@stefl
stefl / avatar-caching
Created May 10, 2013 11:21
Use memcache on repetitive avatar requests in Rails
def avatar(options = {})
key = "avatar-#{nickname}-#{options.map {|k,v| "#{k}:#{v}" }.join("-")}"
cached_avatar = Rails.cache.fetch(key)
return cached_avatar if cached_avatar
options.reverse_merge!({size: 48})
unless model.nil?
avatar = h.link_to(h.person_path(model)) do
h.image_tag(avatar_address,
class: 'avatar__img',
data: { src: avatar_address },
@stefl
stefl / Why hack.md
Last active December 18, 2015 12:28
Why Hack?

Why Hack?

At Makeshift we’re rapidly hacking on digital products that give a leg up to the little guy. We're a team of hackers, designers and product people who get out of bed each morning excited (okay, most mornings) to make new apps that bring our ideas to life.

We're kicking off our new blog series, "Why Hack?" featuring you. We want to know what gets you out of bed in the morning, or more specifically Why and How You Hack!

Over the next month, we will be posting these interviews on our blog + sending them out to our mailing list.

Thanks in advance for your thoughts!