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
- (BOOL) string2bool: (NSString*) aString { | |
NSString *normalizedString = [self normalize: aString]; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: @"(yes|true|tak|ok|right)" | |
options: NSRegularExpressionCaseInsensitive | |
error: NULL]; | |
return [regex firstMatchInString: normalizedString options: 0 range: NSMakeRange(0, normalizedString.length)]; | |
} | |
// [aString boolValue]; |
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
class Hash | |
def symbolize_keys | |
inject({}) do |result, (key, value)| | |
new_key = case key | |
when String then | |
key.to_sym | |
else | |
key | |
end | |
new_value = case value |
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
-- DOCUMENTATION: http://www.postgresql.org/docs/9.3/static/queries-with.html | |
/* | |
WITH - defines auxilary stetments for larger query. Also called as 'Common Table Expressions' (CTE). | |
It can create temporary tables just for one query. | |
It is a basic CRUD statement atatched to another CRUD query. | |
*/ | |
-- SYNTAX: |
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
namespace :deploy do | |
after :publishing, :restart do | |
on roles(:app) do | |
within release_path do | |
execute :sudo, "cp -f #{release_path}/my_config.conf /etc/init/" | |
execute :sudo, 'initctl restart my_service' | |
end | |
end | |
end | |
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/bash | |
echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)" | |
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 | |
echo "Enable subpixel font rendering on non-Apple LCDs" | |
defaults write NSGlobalDomain AppleFontSmoothing -int 2 | |
echo "Enable the 2D Dock" | |
defaults write com.apple.dock no-glass -bool true |
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
(env) -> | |
if env.ENV is 'production' | |
{ | |
API_ENDPOINT: '' | |
FACEBOOK_ID: '' | |
FACEBOOK_NAMESPACE: '' | |
FACEBOOK_OBJECT: '' | |
} | |
else | |
{ |
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
root = 'public' | |
use Rack::Static, | |
urls: Dir["#{root}/*"].map { |file| file.sub(root, '')}, | |
root: root, | |
index: 'index.html', | |
header_rules: [[:all, { 'Cache-Control' => 'public, max-age=3600' }]] | |
run -> env { | |
[ |
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
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'ostruct' | |
class CookbookCreator | |
COMPANY_NAME = 'COMPANY_NAME' | |
EMAIL = 'email@example.com' | |
COOKBOOK_NAME = 'COOKBOOK_NAME' | |
class << self |
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
def isPrime(number: Int) = (2 until number) forall (divider => number % divider != 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
document.querySelector("a").addEventListener("mousedown", function(e) { | |
if (e.which === 2) { | |
this.style.pointerEvents = "none"; | |
} | |
}); | |
document.body.addEventListener("mouseup", function(e) { | |
if (e.which === 2) { | |
document.querySelector("a").style.pointerEvents = ""; | |
} |
OlderNewer