Skip to content

Instantly share code, notes, and snippets.

@mtabini
mtabini / gist:1178403
Created August 29, 2011 13:35
PNG representation of NSImage
//
// GRAppDelegate.m
// Testme
//
// Created by Marco Tabini on 11-08-29.
// Copyright (c) 2011 Marco Tabini. All rights reserved.
//
#import "GRAppDelegate.h"
@mtabini
mtabini / gist:900935
Created April 3, 2011 23:46
Marco's Bolognese recipe

Marco's Bolognese recipe

  • 300g ground skirt steak
  • 100g pancetta
  • 1/2 onion
  • 1/2 carrot
  • 1 celery stalk
  • 1/2 cup dry white wine
  • 1 cup milk
  • 1/2 cup tomato paste
BOOL colorSimilarToColor(UIColor *left, UIColor *right) {
float tolerance = 0.05; // 5%
CGColorRef leftColor = [left CGColor];
CGColorRef rightColor = [right CGColor];
if (CGColorGetColorSpace(leftColor) != CGColorGetColorSpace(rightColor)) {
return FALSE;
}
-(void)drawRect:(CGRect)rect {
CGFloat side = MIN(self.bounds.size.width, self.bounds.size.height);
NSInteger steps = 512;
float internalRadius = side * 0.0;
float externalRadius = side * 0.5;
float halfinteriorPerim = M_PI * internalRadius;
float halfexteriorPerim = M_PI * externalRadius;
On the psychology of freemium:
- Why do teens spend real money in virtual worlds? A consumption values and developmental psychology perspective on virtual consumption
http://www.sciencedirect.com/science/article/pii/S0268401214001030
- What Is a Variable-Ratio Schedule?
http://psychology.about.com/od/vindex/g/def_variablerat.htm
- The Psychology of “Freemium”
http://www.psychguides.com/interact/the-psychology-of-freemium/
@mtabini
mtabini / gist:3161449
Created July 23, 2012 00:19
I think I have successfully reverse engineered Interface Builder's layout algorithm when moving views between containers
- (void) layoutComponents {
// HAHAHHAHAHAHAAHAHAHAHA
}
<div class="swipe">
<img src="img/swipe-annotation.png" height="30" link="bookmark"><img src="img/swipe-favourite.png" height="30" link="favourite"><img src="img/swipe-pencil.png" height="30" link="annotate"><img src="img/swipe-email.png" height="30" link="email"><img src="img/swipe-tweet.png" height="30" link="tweet"><img src="img/swipe-facebook.png" height="30" link="facebook">
</div>
In your JS (assuming you have jQuery, otherwise will need to adjust accordingly):
$(".swipe img[link]").click(function() {
document.location.href = $(this).attr("link") + "://" + $(this).attr("link");
});
@mtabini
mtabini / gist:1197888
Created September 6, 2011 15:38
Catching PHP Warnings
<?php
error_reporting(E_ALL | E_STRICT);
function myHandler($errno, $errstr) {
throw new Exception($errstr, $errno);
}
set_error_handler('myHandler', E_ALL | E_STRICT);
@mtabini
mtabini / Shorten URL.scpt
Created April 30, 2011 19:04
Applescript script for shortening a URL
-- URLEncode routing from http://harvey.nu/applescript_url_encode_routine.html
on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
Travis Swicegood is a professional programmer and owner of Domain51, a web development company with a focus on non-profits, NGOs, and online activists. He doesn't change the world, he supports those who do.
He has personal a focus on web applications, performance, and stability; is author of Pragmatic Version Control using Git; and working on his second book. He has been using PHP; since '99 and still remembers how revolutionary PHP 4 was, but can't remember why. He's a TDD, open-source, and open government advocate—sometimes called a zealot—and lurker on many an open-source project mailing list when not learning other programming; languages; for fun, exploring his surroundings on bike, or tasting his latest kitchen and home-brew creations.