Skip to content

Instantly share code, notes, and snippets.

@SteveBenner
SteveBenner / sass-convert-dir.rb
Created March 23, 2014 01:51
Recursively convert a directory of SASS files from one syntax to the alternate one
DIR = '<project-root>'
files = Dir.glob("#{DIR}/**/*.scss")
files.each { |f| `sass-convert #{f} #{f.sub(/\.scss/, '.sass')}` unless File.exist?(f.sub(/\.scss/, '.sass')) }
# one-liner for CLI use
# ruby -e "Dir.glob('<project-root>/**/*.scss').each { |f| `sass-convert #{f} #{f.sub(/\.scss/, '.sass')}` unless File.exist?(f.sub(/\.scss/, '.sass')) }"
@SteveBenner
SteveBenner / github-readme-markdown-styles.sass
Last active August 29, 2015 13:59
Github Readme SASS styles
// Github markdown styles
$h1-grey: #dddddd
$h2-grey: #eeeeee
$header-black: #333333
// placeholders
%hover-link
background: url(data:image/png) no-repeat 10px center
text-decoration: none
@SteveBenner
SteveBenner / _disqus.slim
Last active August 29, 2015 13:59 — forked from voigt/disqus.js
Slim partial - Disqus comments widget
/ Integrate Disqus comments into your site with this widget (adheres to official API and config spec)
/
/ @see https://help.disqus.com/customer/portal/articles/1104788-web-integration Official web integration docs
/ @see https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables Configuration docs
/
/ @local [Hash{Symbol => String}] disqus Key/value pairs corresponding to the Disqus JS configuration variables
/ @option disqus [String] shortname Unique identifier for your forum website registered on Disqus.com (REQUIRED)
/ @option disqus [String] identifier A String or Integer value which identifies the current web page thread
/ @option disqus [String] title Title of the current page; defaults to value of HTML `title` element
/ @option disqus [String] url URL of the current page; defaults to `window.location.href`
@SteveBenner
SteveBenner / ghost-upgrade.rake
Last active August 29, 2015 13:59
Rake - upgrade a Ghost blog installation
require 'bundler'
require 'fileutils'
Bundler.require
GHOST_DIR = ENV['GHOST_HOME'] || '<your_ghost_folder>'
THEME = 'casper'
namespace :blog do
desc 'Upgrades Ghost using given file'
@SteveBenner
SteveBenner / shortcuttr.rb
Last active August 29, 2015 14:00
Simple script that generates executable shortcuts from the command line
#!/usr/bin/env ruby
#
# Shortcuttr - generates executable shortcuts
#
require 'fileutils'
SCRIPT = File.join ENV['HOME'], 'github/ruby-scripts/system/bin', ARGV.first.to_s
File.open SCRIPT, 'w', 0755 do |f|
f.puts '#!/usr/bin/bash'
f.puts '# This executable shortcut was generated by Stephen Benner, a truly lazy programmer'
@SteveBenner
SteveBenner / fname_incr.rb
Created May 6, 2014 03:26
Function which returns a given filename or the incremented version thereof
def fname_incr(fname)
!File.exists?(fname) ?
fname :
/([0-9]+)\./.match(fname) ?
fname_incr(fname.sub(/([0-9]+)/) { |m| (m.to_i+1).to_s }) :
fname_incr(fname.sub(/[^\.]*/) { |m| m+'1' })
end
@SteveBenner
SteveBenner / nuke-ruby.bash
Created July 17, 2014 13:35
When there is just too much Ruby in yo OS
# Nuke Ruby!
rm -rf ~/.gem
rm -rf ~/.rubies
# Prerequisites for Mac OSX installation
#
# Make sure Xcode or the command line tools are installed
# This one's up to you: https://github.com/kennethreitz/osx-gcc-installer#readme
#
# Install Homebrew if not installed
@SteveBenner
SteveBenner / .bowerrc.yml
Created August 15, 2014 07:20
Bower - configuration file
# Bower configuration
#
# Official docs at: http://bower.io/docs/config/
# Last updated at: 2014-08-14
#
# Config is obtained by merging the following, in given order:
# - CLI args via -config
# - Environment variables
# - Local .bowerrc located in the current working directory
# - All .bowerrc files upwards the directory tree
@SteveBenner
SteveBenner / _google-analytics.slim
Created September 26, 2014 05:43
Slim partial - Google analytics
/ Official Google Analytics tracking code (updated 2014-10-23)
/
/ @option [String] google_analytics_key GA key in a format similar to: 'UA-XXXXXXXX-X'
/
- if google_analytics_key
javascript:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
body.loading:after {
/* with no content, nothing is rendered */
content: "";
position: fixed;
/* element stretched to cover during rotation an aspect ratio up to 1/10 */
top: -500%;
left: -500%;
right: -500%;
bottom: -500%;
z-index: 9999;