Skip to content

Instantly share code, notes, and snippets.

View chriszarate's full-sized avatar
👋
hi

Chris Zarate chriszarate

👋
hi
View GitHub Profile
@chriszarate
chriszarate / repeated-character-domains.txt
Created May 8, 2012 20:25
Repeated-character .com domain name availability
======== REPEATED-CHARACTER .COM DOMAIN NAME AVAILABILITY =======
1 10 20 30 40 50 63
a ..............................#.......#...........#..#..##..#..
b ............#.....#..#...###########.########.#########.######.
c .............#..#....######.#.#######...######################.
d .....................##.##.###########.############.##########.
e ...................###.#######################################.
f ...........#.#.....#.#...####.#.##.###..#############.########.
g .......................#.#.#.....##.####.####.################.
h ..................#.#...#.#.##################################.
@chriszarate
chriszarate / imgcat.sh
Created June 8, 2012 13:12
Concatenate images with ImageMagick
# If you want to append images horizontally, use this command
convert image1.jpg image2.jpg image3.jpg +append result.jpg
# If you want to append them vertically, change the + to a -
convert image1.jpg image2.jpg image3.jpg -append result.jpg
# Source: http://snipplr.com/view/10360/
@chriszarate
chriszarate / ip-report.sh
Created June 8, 2012 13:16
Show IP addresses in standard Apache log files
awk '{ print $1}' /path/to/access.log | sort | uniq -c | sort -nr
zip -X my.epub mimetype
zip -rg my.epub META-INF -X \*.DS_Store
zip -rg my.epub OEBPS -x \*.DS_Store
@chriszarate
chriszarate / sort.php
Last active October 5, 2015 23:37
Fake good sorting for en-US
<?php
/*
* In 2013, locale-based sort is still broken or headache-inducing on many machines, and
* POSIX or C locales are the unassailable default in a shocking number of places. (For a
* fun exercise, try relying on LC_COLLATE for sorting in OS X.)
*
* This is a shameful PHP-based hack that mimics proper sorting for English using iconv
* transliteration. If doing things the WRONG WAY offends you, avert your eyes. However,
* this has worked for me in a pinch when I don’t have time to track down a box that has
@chriszarate
chriszarate / bp-custom.php
Last active December 12, 2015 01:58
BuddyPress 1.6 custom site avatars.
<?php
/*
BuddyPress 1.6 custom site avatars.
Add to (or create) /wp-content/plugins/bp-custom.php.
Or place in theme's functions.php.
*/
/*
Use a specific user's avatar for a site.
@chriszarate
chriszarate / upgrade-trac-1.0.sh
Created February 25, 2013 22:50
Upgrade to Trac 1.0
# as root
/etc/init.d/apache2 stop
easy_install --upgrade Trac==1.0
trac-admin /var/trac/sites/my-trac upgrade
trac-admin /var/trac/sites/my-trac wiki upgrade
/etc/init.d/apache2 start
@chriszarate
chriszarate / getTextNodesBetween.js
Last active April 1, 2023 13:45
Native JavaScript function to get all *text* nodes contained in a selection object.
// Get all *text* nodes contained in a selection object.
// Adapted from code by Tim Down.
// http://stackoverflow.com/questions/4398526/how-can-i-find-all-text-nodes-between-to-element-nodes-with-javascript-jquery
function getTextNodesBetween(selection) {
var range = selection.getRangeAt(0), rootNode = range.commonAncestorContainer,
startNode = range.startContainer, endNode = range.endContainer,
startOffset = range.startOffset, endOffset = range.endOffset,
pastStartNode = false, reachedEndNode = false, textNodes = [];
function getTextNodes(node) {
var val = node.nodeValue;

September 29 2010, 9:23 PM

Amazon’s EC2 service now allows you to boot from persistent EBS volumes—a boon to those of us who like to run the occasional server-hour but don’t want to mess with bundling AMIs and other atrocities. The [AWS Management Console][1] automates most tasks, but you might find yourself quickly running into a two-part annoyance: (1) if you use public AMIs, the size of your EBS volume is chosen for you; and (2) EBS volumes are not resizable—at least, [not downwards][2]. Since Amazon charges you for allotted space on EBS volumes, this “annoyance” can literally cost you [tens of cents][3] per month!

Luckily, there is a workaround, and it has the side benefit of allowing you to boot one EBS volume on different instance types—that is, boot up your volume on an “m1.small” instance one day, a “c1.medium” the next, and so on. What follows assumes familiarity with Amazon Web Services and EC2, UNIX/Linux, the command-line, computers, typing, pants-wearing, etc.

Ok: Launch an EC2 instance fr

@chriszarate
chriszarate / flickr-biggest.js
Created May 23, 2013 17:06
Bookmarklet to get largest available photo from a Flickr photo page. Fits in a tweet! (82 characters)
javascript:P=FLICKR.photo.getSizes();window.location=P[Object.keys(P).pop()].url;