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 RootScreen < ProMotion::Screen | |
title "Bienvenue" | |
def will_appear | |
UIBarButtonItem.configureFlatButtonsWithColor([89, 91, 91].uicolor, highlightedColor: [64, 65, 65].uicolor, cornerRadius: 2.0) | |
set_navigation_appearnce! | |
set_attributes self.view, { | |
backgroundColor: [222, 226, 225].uicolor | |
} | |
@label ||= UILabel.alloc.initWithFrame(CGRectZero) | |
@label.text = "Application" |
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
instances = Model.all | |
# If I try to perform this on all the instances, all return true but the changes are not persisted. | |
instances.each do |instance| | |
desc = instance.description | |
desc.gsub!(/some\swords/, '') | |
instance.update(:description => desc) # doesn't work | |
instance.description = desc | |
instance.save # doesn't work and returns true. |
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
# Let's say you have a collection of users you want to email once a week. | |
# Now using Sidekiq, it's easy to move this off the main thread, so that you're not blocking | |
# incoming requests to the Rails application. | |
# | |
#Chances are you have a worker that looks like the EmailUsersWorker below. | |
# | |
class EmailUsersWorker | |
include Sidekiq::Worker |
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 | |
unamestr=`uname` | |
platform_path='unknown' | |
if [[ "$unamestr" == "Linux" ]]; then | |
platform_path='/usr/bin' | |
if [[ $UID != 0 ]]; then | |
echo "Please run this script with sudo:" | |
echo "sudo $0 $*" | |
exit 1 |
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 String | |
def to_element | |
Element.find("#{self}") | |
end | |
alias :to_e :to_element | |
end | |
# Now you can do: | |
el = "#cool-stuff".to_e | |
# vs |
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
def make_stepped_gradient | |
@grad = NSGradient.alloc.initWithColorsAndLocations(start_color, 0.0, middle_color, 0.015, end_color, 1.0, nil) | |
# Explodes with: | |
# 2014-02-23 10:52:01.323 my_app[86365:303] -[__NSCFNumber colorUsingColorSpace:]: unrecognized selector sent to instance 0x7f8764169b20 | |
# 2014-02-23 10:52:01.416 my_app[86365:303] -[__NSCFNumber colorUsingColorSpace:]: unrecognized selector sent to instance 0x7f8764169b20 | |
end | |
def start_color | |
@start_color ||= BW.rgba_color(100,100,100,1.0) | |
end | |
def middle_color |
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
import scala.util._ | |
import java.security.SecureRandom | |
import java.security.MessageDigest | |
/* | |
* Generates a Bearer Token with a length of | |
* 32 characters (MD5) or 64 characters (SHA-256) according to the | |
* specification RFC6750 (http://tools.ietf.org/html/rfc6750) | |
* | |
* Uniqueness obtained by by hashing system time combined with a |
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
// | |
// GetOrElse.swift | |
// | |
// Requires Swift 2.0 for protocol extensions | |
// | |
import Foundation | |
protocol GetOrElse { | |
func getOrElse<T>(block block: () -> T) -> T |
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 OrElse | |
module ObjectImplementation | |
def or_else(_) | |
self | |
end | |
end | |
module NilClassImplementation | |
def or_else(val) | |
val | |
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
brew() { | |
local cmd=$1; shift | |
if test "$cmd" = 'upgrade' || test "$cmd" = 'update'; then | |
"__brew_update_or_upgrade" "$@" | |
else | |
command brew "$cmd" "$@" | |
fi | |
} | |
__brew_update_or_upgrade() { |