Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / gist:5374240
Last active December 16, 2015 03:59
Scale an image (Objective-C)
- (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 / git-diff-paste
Created January 28, 2013 18:15
extract two git commit hashes out of the pasteboard and do a git diff on them
#!/usr/bin/perl
# extract two git commit hashes out of the pasteboard and do a git diff on them.
#
# no need to clean up any extra stuff in the paste -- this will do a diff of the
# top-most and bottom-most hashes found in the paste.
#
# requires pbpaste command line utility
use strict;
@carlosmcevilly
carlosmcevilly / cat-clean.pl
Created December 27, 2012 00:37
cat a file, removing leading and trailing space, removing empty lines, and ensuring every line is followed by a newline.
#!/usr/local/bin/perl
# cat a file, removing leading and trailing space, removing
# empty lines, and ensuring every line is followed by a newline.
use strict;
use warnings;
my $line;
while (defined($line=<>)) {
@carlosmcevilly
carlosmcevilly / cat-notin.pl
Created December 27, 2012 00:33
given a reference file, output every line from STDIN that does not appear in the reference file, preserving the order of the lines in STDIN.
#!/usr/bin/perl
use strict;
use warnings;
my $in = shift || die "usage: $0 <ref-file>\n\n";
my %unwanted = %{&load_words($in)};
my $line;
@carlosmcevilly
carlosmcevilly / expand-bitly
Created December 27, 2012 00:28
expand a bit.ly URL to its original URL. Need a bit.ly developer account to use this.
#!/bin/bash
# change these to your own
export userid=<user_id_string_from_bitly_account>
export key=<key string_from_bitly_account>
export link=$1
if [[ "$link" == '' ]]
then
@carlosmcevilly
carlosmcevilly / fget
Created December 27, 2012 00:25
fetch a URL using wget and sending Firefox as the user agent, with an optional referer URL
#!/bin/bash
export url="$1"
export referer="$2"
export uagent='Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11';
if [[ "$referer" == '' ]]; then
wget --user-agent="$uagent" "$url"
else
@carlosmcevilly
carlosmcevilly / multiple_ssh_setting.md
Created October 18, 2012 13:20 — forked from fanwaze-dev/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github accounts

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@carlosmcevilly
carlosmcevilly / gist:3865987
Created October 10, 2012 14:30 — forked from codeincontext/gist:3862543
Photo capture, manipulation, and upload in iOS6 Safari
<!DOCTYPE html>
<html>
<head>
<title>iOS6 Safari Photo Capture Demo</title>
<script type="text/javascript">
window.onload = function() {
var input = document.getElementById("input");
input.addEventListener("change", handleFile);
}
@carlosmcevilly
carlosmcevilly / gist:3850496
Created October 8, 2012 03:03
How to allow unsigned Eclipse to run on Mountain Lion without opening Gatekeeper entirely
xattr -d com.apple.quarantine /path/to/Eclipse.app
@carlosmcevilly
carlosmcevilly / flush-dns.sh
Created October 7, 2012 07:11
flush the DNS cache
#!/bin/bash
dscacheutil -flushcache