Skip to content

Instantly share code, notes, and snippets.

@kirk
kirk / string_contains_emoji
Last active August 29, 2015 14:25 — forked from cihancimen/string_contains_emoji
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
module FormatHelper
def boolean_flag(bool, text = nil)
"<span class='flag #{bool.to_s}#{ ' labeled' unless text.nil?}'>#{text || bool.to_s}</span>"
end
def yes_or_no(bool)
bool ? 'Yes' : 'No'
end
@kirk
kirk / server.conf
Created December 24, 2011 03:17
NginX config for Rails 3.1 & Unicorn
upstream example_backend {
server unix:/var/www/example.com/shared/unicorn.sock;
}
server {
listen 80;
server_name example.com www.example.com;
access_log off;
error_log off;
client_max_body_size 20M;
@kirk
kirk / gist:995768
Created May 27, 2011 17:49
torquebox troubles..
(master)~/workspace/torquebox-current/share/rails/torquebox-tweetwatch $ rvm info
jruby-1.6.2@torquebox:
system:
uname: "Darwin edisons-MacBook-Pro.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
@kirk
kirk / gist:995483
Created May 27, 2011 15:28
torquebox troubles..
(master)~/workspace/torquebox-current/share/rails/torquebox-tweetwatch $ cat ~/.edisonnation.profile.torquebox
export TORQUEBOX_HOME=$HOME/workspace/torquebox-current
export JBOSS_HOME=$TORQUEBOX_HOME/jboss
export JRUBY_HOME=/Users/edison/Developer/.rvm/rubies/jruby-head
export PATH=$JRUBY_HOME/bin:$PATH
-----------------------
(master)~/workspace/torquebox-current/share/rails/torquebox-tweetwatch $ rvm info
## /etc/nginx/nginx.conf
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
##
# Node:
# Rackspace Cloud Server
# Ubuntu 10.04 LTS
# Hosted Chef Server
# Package install 10.04
# http://wiki.opscode.com/display/chef/Package+Installation+on+Debian+and+Ubuntu
# Using nginx for ssl
# http://warwickp.com/2010/10/hosting-chef-server-behind-nginx-proxy
##

Setup a Three Server HAPROXY/APACHE2 Setup

Demo Part One (Launch an Apache Server)

Start the demo by launching three EC2 instances then tell the audience that this will take about 3 minutes. Also explain that we not only starting the instances we are also bootstrapping it with the Chef client (Easy Peasy)...

./setupDemo.sh 

Sample Script

check process mongodb with pidfile /data/db/mongodb/mongod.lock
start program "/etc/init.d/mongodb start"
stop program "/etc/init.d/mongodb stop"
if failed port 27017 then restart
if 5 restarts within 5 cycles then timeout
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed port 80 protocol HTTP request / then restart
set daemon 60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: monit@example.comm }
set alert root@localhost
set httpd port 2812 and
allow admin:test
include /etc/monit.d/*