Skip to content

Instantly share code, notes, and snippets.

@rondevera
rondevera / css-to-select-range-of-children.html
Last active February 8, 2023 11:29
CSS selector for a range of children
<!DOCTYPE html>
<html>
<head>
<style>
/* How to select a range of children
* (Here, 3rd-7th children, inclusive):
*/
ul li:nth-child(n+3):nth-child(-n+7) {
outline: 1px solid #0f0;
}
@rondevera
rondevera / gmail_bookmarklet.js
Created June 26, 2009 03:58
Gmail bookmarklet: For quickly e-mailing the current page's URL (and the selected text, if any) via Gmail.
/*
Gmail bookmarklet
rondevera.com
For quickly e-mailing the current page's URL (and the selected text, if any)
via Gmail.
Usage:
- Create a new item in your bookmark bar with the name "Gmail" (or just "Gm",
or your favorite Unicode character), and the code below as the location.
@rondevera
rondevera / gist:268213
Created January 4, 2010 00:53
Glossy text with CSS in WebKit
<style>
body {
background: #000;
}
p {
margin: 1em auto;
background: -webkit-gradient(
linear, left top, left bottom,
from(#fff), color-stop(50%, #777), color-stop(50%, #666), to(#111));
background: -webkit-linear-gradient(top, #fff, #777 50%, #666 50%, #111);
@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 / 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 / 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=()