Skip to content

Instantly share code, notes, and snippets.

@rev087
rev087 / BootstrapFormBuilder.rb
Created September 6, 2011 02:09
Rails FormBuilder to be used with Bootstrap from Twitter
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
['text_field', 'text_area'].each do |helper|
define_method helper do |field, *args|
options = args.detect{ |a| a.is_a?(Hash) } || {}
if @object.errors[field].any?
'<div class="clearfix error">'.html_safe +
(self.label field) +
'<div class="input">'.html_safe +
(super field, *args) +
@rev087
rev087 / ass.sh
Created September 24, 2011 22:02
ass - JavaScript assets download for lazy asses
#!/bin/sh
label() {
printf '\033[1;30;43m %s \033[0m\n' $1
}
# jQuery
label jquery-1.6.4.min.js
curl http://code.jquery.com/jquery-1.6.4.min.js > jquery-1.6.4.min.js
# Backbone.js
@rev087
rev087 / style.css
Created October 26, 2011 22:01
Exemplo de LESS
body {
padding-top: 60px;
}
.hero-unit img {
margin: -50px -30px 0px 0px;
float: right;
}
.btn.tiny {
padding: 2px 4px;
font-size: 11px;
<?php
// Prepare the API call
$search_string = urlencode("City of God");
$API_KEY = "<redacted>";
$URL = "http://api.themoviedb.org/2.1/Movie.search/en/xml/{$API_KEY}/{$search_string}";
// Perform the API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@rev087
rev087 / json.js
Created June 29, 2012 16:51
Simple JSON parsing command line tool
#!/usr/local/bin/node
/**
* Example usage:
*
* curl https://api.twitter.com/1/statuses/public_timeline.json | json 2.text
* curl https://api.twitter.com/1/statuses/public_timeline.json | json 0.user
*
*/
@rev087
rev087 / fontprep.sh
Last active December 14, 2015 03:29
Start the FontPrep server and open it in Google Chrome's app mode
fontprep ()
{
# Move to the server folder
cd /Applications/FontPrep.app/Contents/Resources/fontprep_server
# Start the FontPrep server, fork the process and store it's pid
ruby src/main.rb & pid_server=$!
# Give some time for the server to start, then open the URL in Google Chrome's app mode
sleep 2
@rev087
rev087 / gulpfile.js
Last active September 29, 2017 14:59
Gulp task to bump semver
// This gulpfile adds three tasks to bump the semver release: bump:major, bump:minor, bump:patch.
// First, it checks if the git repository is clean, and fails with an alert otherwise, then:
// - Update manifests (in this example, package.json and Info.plist)
// - Add manifests to the git stage
// - Commit changes in the manifests with the message "Prepare for vX.Y.Z"
// - Tag the release
// All that is left for the user to do is push the commit/tag to the remote repo with `git push --tags`
var gulp = require('gulp');
var semver = require('semver');
@rev087
rev087 / redsearch.sh
Created May 27, 2014 17:19
Command-line reddit search via jq
# Search reddit for a string
redsearch() {
curl "http://www.reddit.com/search.json?q=$1" | jq '[.data.children[].data | {created_utc, permalink, num_comments, ups, author, subreddit, url, title} | select(.title | contains("'$1'"))] | sort_by(.created_utc)'
}
function find_git_branch {
local dir=. head
until [ "$dir" -ef / ]; do
if [ -f "$dir/.git/HEAD" ]; then
head=$(< "$dir/.git/HEAD")
if [[ $head == ref:\ refs/heads/* ]]; then
git_branch="${head#*/*/}"
elif [[ $head != '' ]]; then
git_branch='(detached)'
else
@rev087
rev087 / Info.plist
Created May 1, 2015 01:33
Safari extension to display viewport width as a toolbar
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Author</key>
<string>Bruno Daniel</string>
<key>Builder Version</key>
<string>10600.5.17</string>
<key>CFBundleDisplayName</key>
<string>Viewport Width</string>