This file contains hidden or 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
class Singleton | |
@get: -> @instance ?= new @ | |
class Test extends Singleton | |
constructor: -> alert "Test constructed" | |
run: -> alert "Test run" | |
class OtherTest extends Singleton | |
constructor: -> alert "OtherTest constructed" | |
run: -> alert "OtherTest run" |
This file contains hidden or 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
require 'zmq' | |
context = ZMQ::Context.new | |
pub = context.socket ZMQ::PUB | |
pub.setsockopt ZMQ::IDENTITY, 'ping-pinger' | |
pub.bind 'tcp://*:5555' | |
i=0 | |
loop do | |
pub.send "ping pinger #{i+=1}" ; sleep 1 | |
end |
This file contains hidden or 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/bash | |
# | |
# MYSQL CONFIG | |
# ============ | |
# <UDF name="db_password" Label="Choose a MySQL Root Password" /> | |
# <UDF name="db_name" Label="MySQL - Database Name" default="" example="Optionally create this database." /> | |
# <UDF name="db_user" Label="MySQL - Username" default="" example="Optionally create this user." /> | |
# <UDF name="db_user_password" Label="MySQL - Password" default="" example="The user password." /> | |
# | |
# OPTIONAL LIBRARIES TO INSTALL |
This file contains hidden or 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
- (void)resizeTableViewWithHeightOffset:(CGFloat)offsetHeight | |
animationDuration:(double)animationDuration | |
completion:(void (^)(BOOL))completionHandler | |
{ | |
[UIView animateWithDuration:animationDuration animations:^{ | |
CGRect frame = self.tableView.frame; | |
frame.size.height += offsetHeight; | |
self.tableView.frame = frame; | |
} completion:completionHandler]; | |
} |
This file contains hidden or 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
// | |
// BPPrivateWebView.h | |
// BPUI | |
// | |
// Created by akisute on 11/09/11. | |
// | |
/* | |
Copyright (c) 2011 Masashi Ono. | |
Permission is hereby granted, free of charge, to any person obtaining a copy of |
This file contains hidden or 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
# Update, upgrade and install development tools: | |
apt-get update | |
apt-get -y upgrade | |
apt-get -y install build-essential | |
apt-get -y install git-core | |
# Install rbenv | |
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv | |
# Add rbenv to the path: |
This file contains hidden or 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
require 'benchmark' | |
class Proc | |
def slow_callback(callable, *args) | |
self === Class.new do | |
method_name = callable.to_sym | |
define_method(method_name) { |&block| block.nil? ? true : block.call(*args) } | |
define_method("#{method_name}?") { true } | |
def method_missing(method_name, *args, &block) false; end | |
end.new |
This file contains hidden or 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
module Rayo | |
module Aws | |
AWS = Fog::Compute.new({ | |
:provider => 'AWS', | |
:aws_access_key_id => CONFIG.aws.access_key_id, | |
:aws_secret_access_key => CONFIG.aws.secret_access_key | |
}) | |
def create_server(opts={}) | |
hostname=opts[:hostname] |
This file contains hidden or 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
#include <sys/xattr.h> | |
/// Set a flag that the files shouldn't be backuped to iCloud. | |
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath { | |
u_int8_t b = 1; | |
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0); | |
} | |
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available. | |
+ (NSString *)legacyStoragePath { |
This file contains hidden or 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
# A sample Gemfile | |
source "http://rubygems.org" | |
gem "redis" | |
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git' | |
gem "em-hiredis" | |
# gem "em-synchrony" | |
gem "em-websocket" |