-
This is a numbered list.
-
I'm going to include a fenced code block as part of this bullet:
Code More Code
| The regex patterns in this gist are intended to match any URLs, | |
| including "mailto:foo@example.com", "x-whatever://foo", etc. For a | |
| pattern that attempts only to match web URLs (http, https), see: | |
| https://gist.github.com/gruber/8891611 | |
| # Single-line version of pattern: | |
| (?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])) |
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| wdir="." | |
| else | |
| wdir=$1 | |
| fi | |
| for f in $( find . -name '*.erb' ); do | |
| out="${f%.erb}.haml" | |
| if [ -e $out ]; then |
| # here's a quick recipe to run a performance test | |
| # with this method, you can: | |
| #-> easily choose the examples you want included from your existing specs | |
| #-> define the target number of total iterations you'd like, no limit | |
| #-> tune the transaction mix by specifying frequency metadata for each example | |
| #-> be happy that the transaction mix is fairly homogeneous over the test interval | |
| # (ideally you'd run this with acceptance (webrat/capybara) specs, but you | |
| # could employ this technique for any rspec test) |
| { | |
| "use_simple_full_screen": false, | |
| // calculates indentation automatically when pressing enter | |
| "auto_indent": true, | |
| // sets the colors used within the text area (default) | |
| // see https://github.com/olivierlacan/monokaim to download | |
| // the customized Monokai I use. | |
| "color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme", |
| # ======================================================================================= # | |
| # NOTE: This is relatively outdated, you should use the DetectSyntax package | |
| # from Package Control instead: http://wbond.net/sublime_packages/community#sort-installs | |
| # ======================================================================================= # | |
| # Instructions: put this inside of the following folder on a Mac: | |
| # /Users/<yourusername>/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/ | |
| # ======================================================================================= # | |
| import sublime, sublime_plugin | |
| import os |
Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.
open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl
You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html
| require "rack/contrib/try_static" | |
| use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['index.html', '/index.html'] | |
| require "rack/contrib/static_cache" | |
| use Rack::StaticCache, :urls => ['/'], :root => 'build' |
| class Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
Fibur is a library that allows concurrency during Ruby I/O operations without needing to make use of callback systems. Traditionally in Ruby, to achieve concurrency during blocking I/O operations, programmers would make use of Fibers and callbacks. Fibur eliminates the need for wrapping your I/O calls with Fibers and a callback. It allows you to write your blocking I/O calls the way you normally would, and still have concurrent execution during those I/O calls.
Say you have a method that fetches data from a network resource: