Skip to content

Instantly share code, notes, and snippets.

@rondevera
rondevera / git-changelog
Created November 4, 2014 02:56 — forked from jfsiii/git-changelog
Generates a Markdown changelog for a npm/bower repo
#!/usr/bin/env bash
function printCommitLine(){
local FROM=$1
local TO=$2
if [ TO ]; then
git log $GIT_LOG_OPTS --format="$LOG_FORMAT_OPTS" $FROM..$TO
else
git log $GIT_LOG_OPTS --format="$LOG_FORMAT_OPTS" $FROM
fi
@rondevera
rondevera / gist:2482368
Created April 24, 2012 18:28
Array push vs concatenation
Benchmark.bmbm do |x|
x.report('<<:') do
arr = []
50_000.times do |i|
arr2 = [i]
arr << arr2
end
end
x.report('+=:') do
@rondevera
rondevera / amazon-short-url-bookmarklet.js
Created October 23, 2011 06:43 — forked from nathos/amznshortener.js
Amazon short URL bookmarklet
(function(d){
var asin = d.getElementById('ASIN'), url;
if (asin) {
url = 'http://' + d.domain + '/dp/' + asin.value;
if (prompt('Short Amazon URL (hit OK to load):', url)) {
window.location.href = url;
}
} else {
alert("Can't find an Amazon product ID.");
@rondevera
rondevera / asset_hat_extensions.rake
Created August 3, 2011 18:54
AssetHat workaround for a media query bug in the `cssmin` gem
# rails_app/lib/tasks/asset_hat_extensions.rake
# AssetHat: http://mintdigital.github.com/asset_hat/
namespace :asset_hat_extensions do
namespace :css do
task :fix_media_queries do
# The `cssmin` gem has a bug in which it shortens
# `@media screen and (max-width:800px)` to
# `@media screen and(max-width:800px)` -- the missing space breaks it.
# This task re-adds the space.
@rondevera
rondevera / detect-box-shadow-inset-support.js
Created May 23, 2011 19:53
JS to detect whether the browser supports `box-shadow: inset [...]`
// Detect whether the browser supports `box-shadow: inset [...]`:
(function(e,s,k,u){s=e[s];s[k]=s[k]==u?0:'inset 0 0 0 red';return!!s[k]}(document.createElement('test'),'style','webkitBoxShadow'));
// Replace `webkitBoxShadow` as needed, e.g., `MozBoxShadow`.
// For use when Modernizr doesn't provide such fine-grained coverage:
// https://github.com/Modernizr/Modernizr/issues/109
@rondevera
rondevera / results.txt
Created May 10, 2011 14:49
#define_method vs ActiveSupport::StringInquirer
Rehearsal ----------------------------------------------
#one? 0.000000 0.000000 0.000000 ( 0.001843)
#one? 0.000000 0.000000 0.000000 ( 0.002105)
#kind.one? 0.010000 0.000000 0.010000 ( 0.005502)
------------------------------------- total: 0.010000sec
user system total real
#one? 0.000000 0.000000 0.000000 ( 0.002660)
#one? 0.000000 0.000000 0.000000 ( 0.002275)
#kind.one? 0.000000 0.000000 0.000000 ( 0.003826)
@rondevera
rondevera / gist:957820
Created May 5, 2011 20:11
Shrink Campfire images
/* Useful when Campfire chat images are
being used more for noise than signal.
To use in Propane, add to
~/Library/Application Support/Propane/styles/cf_chat.css
and restart the app:
*/
table.chat tr.message a.loaded img {
max-width: 100px !important;
@rondevera
rondevera / gist:935626
Created April 21, 2011 22:34
project_completion.bash
cdp(){
# For changing directly to a specific project's directory.
# Usage: `cdp bloombox`
local proj=$1
c "/Users/ron/Documents/Projects/$proj/"
settabtitle $proj
}
_cdp(){
# Tab completion routine for `cdp`:
COMPREPLY=()
var Carl = (function(){
var C = {},
drops = []; // private
C.eavesdrops = function(pattern){
drops.push(pattern);
};
return C;
}());
<html lang="en">
<head>
<style>
div {
position: relative;
display: inline-block;
margin: 2em;
padding: 5em;
background: #fcfcfc;
background: -webkit-gradient(linear, left top, left bottom,