Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / gists-for-user.js
Created October 19, 2014 21:50
bookmarklet that takes you to the gists page for the user whose github pages you are viewing
javascript:void(window.location=window.location.toString().replace(/%5Ehttps:%5C/%5C/(?:www%5C.)?github%5C.com%5C/(%5Cw+)(?:%5C/.*)?$/,'https://gists.github.com/$1'))
@carlosmcevilly
carlosmcevilly / pbclean
Created September 24, 2014 22:06
pbclean
#!/bin/bash
pbpaste | pbcopy
@carlosmcevilly
carlosmcevilly / gist:dfe8824daf219433a0be
Created May 28, 2014 07:22
python3 http server in current directory
python3 -m http.server
@carlosmcevilly
carlosmcevilly / bloom.py
Last active August 30, 2018 08:00
A bloom filter implementation with auto-resizing buckets, and the ability to also store histograms.
#!/usr/local/bin/python3
"""
store and check items in a bloom filter
limitations:
- not optimized for speed.
- data structures on disk are not protected from multiple writers... so, use accordingly.
- some other rough edges... under development. example: no quiet option.
- mixing conventional bloom filter and vector treatment complicates things somewhat.
@carlosmcevilly
carlosmcevilly / nuke-yadda.pl
Created March 25, 2014 22:26
Remove most legal boilerplate from an Apple sample project. For testing/research purposes only.
#!/usr/bin/perl
use strict;
use warnings;
my $path = $ENV{'XcodeProjectPath'};
$path =~ s{(.*)/\w+\.xcodeproj}{"$1"};
my $cmd = "/usr/bin/find $path -type f -name \"*.[mh]\" -print";
my $files = qx($cmd);
@carlosmcevilly
carlosmcevilly / tagthis.py
Last active August 29, 2015 13:56
Add tags to a set of comment lines in notes.txt in the current directory
#!/usr/bin/env python3
"""
Add tags to a set of comment lines in notes.txt
This opens a file called notes.txt in the current
working directory (creating the file if it does not
exist) and prepends lines to it containing the tags
that are passed in on the command line. Tags are
only added once. Can be run again any time to add
@carlosmcevilly
carlosmcevilly / gist:8960812
Created February 12, 2014 17:49
Scaling a UIImage. Use in a category on UIImage.
/* from Bill Dudney's Practical Drawing session at 2011 WWDC */
+ (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, YES, 0.0);
CGRect imageRect = {{0.0, 0.0}, newSize};
[image drawInRect:imageRect];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
@carlosmcevilly
carlosmcevilly / update-hashes.sh
Created February 6, 2014 02:04
make hashes of the ls -lR output for each directory and its subdirectories (one level down) in a ~/work/ directory
#!/bin/bash
export index=~/work/indexes
mkdir -p $index
cd ~/work
for dir in `ls -d *`
do
if [[ -d "$dir" ]]; then
echo doing $dir
@carlosmcevilly
carlosmcevilly / gist:7720494
Created November 30, 2013 15:35
tell OS X where to store screen captures
defaults write com.apple.screencapture location ~/path/
killall SystemUIServer
@carlosmcevilly
carlosmcevilly / gist:7637145
Created November 25, 2013 06:28
check whether Nagle's algorithm is on or off
#!/usr/bin/perl
# modified from the broken 'perldoc perlfunc' getsockopt example by adding one line (see comment below)
use strict;
use warnings;
use Socket qw(:all);
defined(my $tcp = getprotobyname("tcp"))