Skip to content

Instantly share code, notes, and snippets.

@amcgregor
amcgregor / BDHost.m
Created October 5, 2011 18:35
Useful Objective-C methods, classes, objects, and categories. Basically a snippit collection.
// From: http://www.bdunagan.com/2009/11/28/iphone-tip-no-nshost/
// MIT license
// Remember to add CFNetwork.framework to your project using Add=>Existing Frameworks.
#import "BDHost.h"
#import <CFNetwork/CFNetwork.h>
#import <netinet/in.h>
#import <netdb.h>
#import <ifaddrs.h>
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@rodrigomanhaes
rodrigomanhaes / capitulo1.rst
Created June 17, 2012 17:46
Resumo do livro Agile Estimating and Planning, de Mike Cohn

AGILE ESTIMATING AND PLANNING

Mike Cohn

CHAPTER 1. The Purpose of Planning

Plans help to guide investment decisions (this project is worth to begin?), know who needs to be available to work on a project during a given period and know if a project is on track.

@renehuber
renehuber / gist:2959472
Created June 20, 2012 11:38
Plaintext contentEditable DIVs
/**
* Event handler to prevent richtext and linebreaks in contentEditable DIVs
*/
$('body').on('keydown paste', 'div.editfield', function(e) {
var $field = $(e.currentTarget);
if (e.keyCode===13 && $field.hasClass('multiline')) {
return true;
} else if (e.keyCode===13 || e.type==='paste') {
setTimeout(function() {
$field.html($field.text());
@letanure
letanure / estados-cidades.json
Last active April 30, 2024 23:07
JSON estados cidades do brasil, dividido por estados. segunda lista atualizada em 2020, dados do IBGE
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@mbinna
mbinna / podforceupdate.sh
Created December 4, 2012 09:43
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@antonio
antonio / delete_branches_older_than.sh
Created January 21, 2013 14:29
Script to delete branches older than a certain date
#!/bin/sh
date=$1
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since $date | wc -l)" -eq 0 ]]; then
if [[ "$branch" =~ "origin/" ]]; then
local_branch_name=$(echo "$branch" | sed 's/^origin\///')
if [[ "$DRY_RUN" -eq 1 ]]; then
echo "git push origin :$local_branch_name"
@justinHowlett
justinHowlett / gist:4611988
Last active July 24, 2018 06:13
Determine if a UIImage is generally dark or generally light
BOOL isDarkImage(UIImage* inputImage){
BOOL isDark = FALSE;
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage));
const UInt8 *pixels = CFDataGetBytePtr(imageData);
int darkPixels = 0;
int length = CFDataGetLength(imageData);
@cbosco
cbosco / all_my_facebook_photos.html
Last active November 9, 2023 23:34
Simple "get all of my facebook photos" facebook JS SDK + Graph API example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Photos with Friends!</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
/**
* This is the getPhoto library
*/
@rbreve
rbreve / gist:5127070
Created March 10, 2013 04:01
merge video
if (firstAsset !=nil && secondAsset!=nil) {
[activityView startAnimating];
// 1 - Create AVMutableComposition object. This object will hold your AVMutableCompositionTrack instances.
AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];
// 2 - Video track
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration)
ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration)