Skip to content

Instantly share code, notes, and snippets.

View AlvaroFranco's full-sized avatar

Álvaro Franco AlvaroFranco

View GitHub Profile
@orta
orta / remove_headers.rb
Last active October 31, 2015 23:28
Remove all project headers
def should_crop(lines)
(0..6).each do |n|
return false unless lines[n].start_with? "//"
end
return false unless lines[7] = ""
true
end
all_objc = Dir.glob("Classes/**/**/**/**.{m,h}")
all_objc.each do |path|
@b3ll
b3ll / MaybeRevolutionary.swift
Created July 3, 2014 23:14
Revolutionizing YES / NO
import Cocoa
var MAYBE: Bool {
get {
return Bool(Int(arc4random_uniform(2)))
}
}
var thisIsTotallyAGoodIdea = MAYBE
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@mattt
mattt / UTTypeForImageData.m
Created March 27, 2014 23:19
A quick function for determining an image's file type by its first couple of bytes
@import MobileCoreServices;
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
@greghelton
greghelton / node-mysql-recipes.js
Created February 6, 2012 03:57
MySQL Results in node.js
var http = require('http')
, mysql = require('mysql');
var client = mysql.createClient({
user: 'root',
password: ''
});
client.useDatabase('cookbook');
@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to