This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSString (Collate) | |
- (NSString *)collateWithOtherString:(NSString *)otherString; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set the strict mode | |
set -e | |
if [ -d "/Volumes/Thumbdrive" ]; then | |
if [ ! -d "/Volumes/Thumbdrive/Backups" ]; then | |
mkdir "/Volumes/Thumbdrive/Backups" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "precise64.box" | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
# config.vm.box = "opscode-ubuntu-12.04_chef-11.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Based On: https://github.com/chovy/node-startup/blob/master/init.d/node-app | |
# strict | |
set -e | |
NODE_ENV="development" | |
NODE_APP='app.js' | |
APP_DIR='.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- See Magnus Hagander: Secure Your Web Webapp passwords in PostgreSQL | |
-- YouTube: http://youtu.be/MuLMIQBB4Ew | |
-- Below the SECURITY DEFINER directive makes the query run as the user which | |
-- created the stored procedure which is the only user which has access to the | |
-- user table. The app which uses this database would connect with a user which | |
-- does not have access to this table, preventing queries from pulling all of | |
-- the data in the table. | |
CREATE OR REPLACE FUNCTION login(_userid text, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('promise'); | |
// Always return a promise for immediate or delayed responses | |
var doAsync = function(nbr) { | |
if (nbr === 1) { | |
// use static function to resolve with data immediately | |
return Promise.resolve('Success already!'); | |
} | |
else if (nbr === 2) { | |
// use static function to reject with an error immediately |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('promise'); | |
var limit = 3; | |
var doAsync = function(nbr) { | |
var promise = new Promise(function (resolve, reject) { | |
setTimeout(function() { | |
if (nbr <= limit) { | |
// increment the given value by 1 | |
resolve(nbr+1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "promise-sample", | |
"description": "Promise Sample", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"promise": "~4.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGFloat)heightForAttributedString:(NSAttributedString *)text maxWidth:(CGFloat)maxWidth { | |
if ([text isKindOfClass:[NSString class]] && !text.length) { | |
// no text means no height | |
return 0; | |
} | |
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading; | |
CGSize size = [text boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:options context:nil].size; |
OlderNewer