Skip to content

Instantly share code, notes, and snippets.

View kylefox's full-sized avatar
🥊
programming

Kyle Fox kylefox

🥊
programming
View GitHub Profile
@kylefox
kylefox / gist:4582967
Last active December 11, 2015 09:58
Example CORS configuration for allowing direct uploads to Amazon S3.
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<MaxAgeSeconds>3000</MaxAgeSeconds>
</CORSRule>
@kylefox
kylefox / gist:4512777
Created January 11, 2013 18:15
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
@kylefox
kylefox / gist:4333153
Created December 18, 2012 23:45
Twitter Bootstrap download from http://twitter.github.com/bootstrap/customize.html contains this error (error.txt, formatted as JS for readability).
/*
A less error occured trying to build your bundle.
You've likely entered an invalid input into the less variable field.
Check your syntax and try again!
thanks!
*/
{
####################################################################################
# Awesome prompt with git branch name & dirty flag.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\033[0;35m\]\w\[\033[0;36m\]$(parse_git_branch)\[\e[0m\]: '
@kylefox
kylefox / fileseq.rb
Created September 27, 2012 04:16
Sequentially renames files in a directory.
#!/usr/bin/env ruby -wKU
# encoding: UTF-8
#
# Sequentially renames *all* files in a directory.
# You'll be prompted for a filename prefix (ex: "image-") and will
# be shown a preview of the new filenames before the rename is performed.
#
# Installation:
# 1) Symlink this script somewhere on your $PATH, ex: `ln -s fileseq.rb /usr/local/bin/fileseq`
# 2) Make it executable: `chmod +x /usr/local/bin/fileseq`
@kylefox
kylefox / chomper.rb
Created September 21, 2012 06:05
A little Goliath proof-of-concept for a dynamic custom origin for images in Amazon CloudFront
# This is a hack. Just playing around.
#
# Original image:
# http://media.photobattle.me.s3.amazonaws.com/images/5417/original.jpg
#
# To resize, use ImageMagick geometry strings (http://www.imagemagick.org/script/command-line-processing.php#geometry) in place of `original` in the URL.
#
# -- Examples --
#
# Proxies an existing image:
// Sass mixins for columns
.features div:first-child,
.features div:last-child,
+column(3)
.features div:nth-child(2)
+column(6)
// Start fading in slowly...
jQuery('.alert').fadeIn("slow", function() {
// This callback gets run once the fadeIn has finished.
jQuery('.alert').fadeOut("slow");
});
_captionLabelContainer.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
-(void)realAuthenticate {
NSURLRequest *request = [self getURLRequest];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^( NSURLRequest *request , NSHTTPURLResponse *response , id JSON ) {
NSString *domain = [[(NSArray *)[JSON objectForKey:@"sites"] lastObject] objectForKey:@"domain"];
Portfolio *portfolio = [[Portfolio alloc] init];
portfolio.domain = domain;
self.portfolio = portfolio;
[self finishAuth:YES];