Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1B
- Decimal:
27
Copy and paste the swift code below into a playground to experiment.
This is a very close emulation of Functor and Monad typeclasses in swift. However, it is very fragile (i.e. easy to crash the compiler).
For example, instance methods of fmap
will run fine, but attempting to use a globally defined fmap
that acts on Functor
types will cause a crash. Similarly for bind
. Unfortunately this means we cannot define the nice infix operator versions of these functions.
Demonstrates the d3.geo.tile plug-in used in conjunction with the d3.geo.mercator projection to clip MapBox Natural Earth II raster tiles. The outline of the United States is loaded in TopoJSON format.
# | |
# Ideas stolen from lograge and brought to Rails 2.3 | |
# https://github.com/mattmatt/lograge/blob/master/lib/lograge/log_subscriber.rb | |
# | |
module ImprovedControllerLogging | |
def self.included(base) | |
base.alias_method_chain :log_processing, :fixup | |
base.inject_alias_method_chain :perform_action, | |
:perform_action_with_benchmark, |
module Deployinator | |
module Stacks | |
module Boilerplate | |
def boilerplate_production_version | |
# %x{curl http://my-app.com/version.txt} | |
"cf44aab-20110729-230910-UTC" | |
end | |
def boilerplate_head_build | |
# the build version you're about to push |
/** | |
* Smokescreen v0.1.2 - Chris Smoak <[email protected]> | |
* A Flash player written in JavaScript. | |
* | |
* Copyright 2010, RevShock | |
* | |
* Date: 2010-05-27 | |
*/ | |
var Smokescreen = function(url, element, width, height, name, params) { | |
goog = {}; |
# sometimes you really _do_ want a global... | |
# alternately, stick it as a method on a Module somewhere, App.logger or whatever, but it's still just as much of a smell. | |
# replace STDERR with your filename of choice. | |
$logger = Logger.new(STDERR) | |
$logger.formatter = proc { |severity, datetime, progname, msg| | |
"#{severity} - #{progname} - [#{datetime.strftime("%d/%m/%Y %H:%M:%S")}] #{msg}\n" | |
} | |
run(Rack::Builder.new { |
def test_something_for_real | |
flunk <<-ABBOT_AND_COSTELLO | |
hey buddy, you should probably rename this file and start testing for real. | |
For Rael? | |
No real... | |
What's real? Rael? | |
Rael? You mean Rails? | |
Who's talking about Rails, all I want to know is if the test is for Rael... | |
ABBOT_AND_COSTELLO | |
end |
# This is how you can get a user's location using MacRuby and CoreLocation | |
framework 'CoreLocation' | |
def locationManager(manager, didUpdateToLocation: new_location, fromLocation: old_location) | |
puts "location: #{new_location.description}" | |
exit | |
end | |
loc = CLLocationManager.alloc.init | |
loc.delegate = self |
class Class | |
def memoize(*methods) | |
methods.each do |method_name| | |
safe_method_name = method_name.to_s.gsub(/(\!|\?)/, '_') | |
class_eval(" | |
alias :'#{safe_method_name}_without_memo' :'#{method_name}' | |
def #{method_name} | |
if defined?(@#{safe_method_name}) | |
@#{safe_method_name} |