Skip to content

Instantly share code, notes, and snippets.

@kevinlawler
kevinlawler / bcrypt.php
Created August 10, 2011 22:07 — forked from BaylorRae/bcrypt.php
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
// just an example; please use something more secure/random than sha1(microtime) :)
$salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22);
// 2a is the bcrypt algorithm selector, see http://php.net/crypt
@kevinlawler
kevinlawler / gist:1167117
Created August 24, 2011 01:48 — forked from todd1251/gist:1161262
Working with Core Plot trunk as at 22/08/2011
// Modified from: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
// NOTE: needs -load_all linker flag; might not be quite right - red/blue data line styles are not working
- (void)viewDidLoad
{
[super viewDidLoad];
graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds];
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
@kevinlawler
kevinlawler / hack.sh
Created March 31, 2012 17:49 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@kevinlawler
kevinlawler / .gitconfig
Created June 19, 2012 02:26 — forked from mbbx6spp/.gitconfig
Susan Potter's .gitconfig file from November 2007 blog post. Updated since November 2007 with new aliases or options.
# Migrating my old .gitconfig blog post from 2007 to here so I can update it easier.
# Original URL:
# http://geek.susanpotter.net/2007/11/my-gitconfig.html
[user]
name = Susan Potter # make sure you change this
email = me@susanpotter.net # make sure you change this
[color]
diff = auto
status = auto
branch = auto
@kevinlawler
kevinlawler / KVO + Singleton Example
Created July 7, 2012 06:18
Using KVO with NSSingleton
Bank *b = [Bank instance];
Person *p = [Person instance];
[b addObserver:p forKeyPath:@"accountBalance" options:NSKeyValueObservingOptionNew context:NULL];
b.accountBalance = [NSNumber numberWithInt:99];
#import "NSSingleton.h"
@interface Bank : NSSingleton
@property (nonatomic, strong) NSNumber *accountBalance;
@end

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param {number} r The red color value
* @param {number} g The green color value
* @param {number} b The blue color value
* @return {array} The HSL representation
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
@autoreleasepool {
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {
const char *bytes = [data bytes];
NSMutableString *profile = [NSMutableString new];

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@kevinlawler
kevinlawler / oK-bot.js
Created October 6, 2015 19:15 — forked from tangentstorm/oK-bot.js
K5 bot for #learnprogramming and #jsoftware on freenode
// An IRC bot for the k5 programming language,
// using oK from : https://github.com/JohnEarnest/ok
"use strict";
var irc = require('irc');
var ok = require('./ok/ok');
const MAXLINES = 8;
var client = new irc.Client('irc.freenode.net', 'oK-bot', {
channels: ['#jsoftware', '#learnprogramming']