| Status Code | Status Message | Symbol |
|---|---|---|
| 100 | Continue | :continue |
| 101 | Switching Protocols | :switching_protocols |
| 102 | Processing | :processing |
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 'cgi' | |
| require 'uri' | |
| def get_section_id_from_url(url) | |
| query = URI.parse(url).query | |
| return nil if not query | |
| CGI.parse(query)['section'].first | |
| 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
| varnishncsa -F '{ | |
| "@source" => "unknown", | |
| "@type" => "varnish", | |
| "@fields" => { | |
| "remote_addr"=>"%h", | |
| "remote_user" => "%u", | |
| "x_forwarded_for" => "%{X-Forwarded-For}i", | |
| "hit_miss"=>" %{Varnish:hitmiss}x", | |
| "body_bytes_sent"=>"%b", | |
| "request_time"=>"%{Varnish:time_firstbyte}x", |
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
| <html> | |
| <body style="background: #333"> | |
| <script > | |
| var gui = require('nw.gui'); | |
| var win = gui.Window.get(); | |
| function takeSnapshot() { | |
| win.capturePage(function(img) { | |
| var popWindow = gui.Window.open('popup.html', | |
| {width: 420, height: 300}); | |
| popWindow.on('loaded', function() { |
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
| " Execute :CleanWhitespace to manually clean all trailing whitespace. | |
| command! CleanWhitespace call s:InPlace('%s/\s\+$//e') | |
| " Clean all useless whitespace automatically upon save. | |
| " | |
| " Do a 'let g:clean_whitespace = 0' if you need to avoid this for some reason. | |
| let g:clean_whitespace = 1 | |
| autocmd BufWritePre * | |
| \ if g:clean_whitespace | | |
| \ exe "CleanWhitespace" | |
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
| App = lambda do |env| | |
| [ | |
| 200, | |
| { "Content-Type" => "text/plain" }, | |
| [ | |
| "Hello!\n", | |
| "self in config.ru is: #{RACK_BUILDER.to_s}\n", | |
| "@use = #{RACK_BUILDER.instance_variable_get(:@use)}\n", | |
| "@map = #{RACK_BUILDER.instance_variable_get(:@map)}\n", | |
| ] |
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 Enum < Hash | |
| def initialize(*members) | |
| super() | |
| @rev = {} | |
| members.each_with_index {|m,i| self[i] = m } | |
| end | |
| def [](k) | |
| super || @rev[k] # || raise ArgumentError, "#{k} is not a member of this enum" | |
| end | |
| def []=(k,v) |
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
| #! /usr/bin/env ruby | |
| require 'bundler' | |
| paths = Bundler.load.specs.map(&:full_gem_path) | |
| system("ack '#{ARGV[0]}' #{paths.join(' ')}") |
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
| # | |
| # Slightly tighter CORS config for nginx | |
| # | |
| # A modification of https://gist.github.com/1064640/ to include a white-list of URLs | |
| # | |
| # Despite the W3C guidance suggesting that a list of origins can be passed as part of | |
| # Access-Control-Allow-Origin headers, several browsers (well, at least Firefox) | |
| # don't seem to play nicely with this. | |
| # |
the $query (aliased with $q) object exposes two methods: first() and all(). Both take a selector string as the first argument and, optionally, a context element as the second.
$q.first(".foo"); // => first element of class `foo`
$q.all(".foo"); // => array (yes, not NodeList) of all elements of class `foo`
var elem = $q.first("p");