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
require 'benchmark' | |
STRING = 'Haha hah hahaa ahah!!' | |
FIND = 'a' | |
REPLACE = 'o' | |
STRING.tr(FIND, REPLACE) == STRING.gsub(FIND, REPLACE) or abort | |
Benchmark.bmbm do |bm| | |
bm.report '.tr' do |
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
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Clean-Markup Line Numbers™</title> | |
<style> | |
body { | |
width: 800px; | |
margin: 0 auto; | |
} |
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
diff --git a/README.md b/README.md | |
index 97c0bfb..365acbd 100644 | |
--- a/README.md | |
+++ b/README.md | |
@@ -18,7 +18,7 @@ or install via gem | |
gem install pusher | |
``` | |
-After registering at <https://dashboard.pusher.com/>, configure your Pusher Channels app with the security credentials. | |
+After registering at <https://dashboard.pusher.com/>, configure your Channels app with the security credentials. |
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
require 'sinatra/base' | |
require 'sinatra/namespace' | |
class MyApp < Sinatra::Base | |
register Sinatra::Namespace | |
get '/' do | |
'Home' | |
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
def call | |
scope = base_relation.joins(:care_periods) | |
if params.care_provider_id.present? | |
scope = scope | |
.where(care_periods: { care_provider_id: params.care_provider_id }) | |
end | |
if params.hospital_id.present? | |
scope = scope |
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
/* | |
* Returns an array of jQuery objects, grouped by specified number of elements. | |
* | |
* Say you have 17 <frameset> tags on your page... | |
* | |
* $('frameset').inGroupsOf(7); // => [ jQuery[0..6], jQuery[7..13], jQuery[14..16] ] | |
* | |
*/ | |
$.fn.inGroupsOf = function( countPerGroup ) { | |
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
require 'benchmark' | |
require 'json' | |
str = '{"foo": "bar"}' | |
Benchmark.benchmark Benchmark::CAPTION, 11 do |bm| | |
bm.report 'JSON.load' do | |
500_000.times { JSON.load(str) } | |
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
# encoding: utf-8 | |
require 'minitest/autorun' | |
# `gem install unicode_utils` | |
require 'unicode_utils/downcase' | |
require 'unicode_utils/upcase' | |
module HumanName | |
def self.all_lower_case?(name) |
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 IncreaseDelayedJobsHandlerLength < ActiveRecord::Migration | |
def up | |
# Increase to MEDIUMTEXT (16,777,215 bytes) | |
change_column(:delayed_jobs, :handler, :text, limit: 16.megabytes - 1) | |
end | |
def down | |
# Back to default TEXT (65,535 bytes) | |
change_column(:delayed_jobs, :handler, :text) | |
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
irb(main):051:0> puts 'foo\bar' | |
foo\bar | |
nil | |
irb(main):052:0> puts 'foo\\bar' | |
foo\bar | |
nil | |
irb(main):053:0> puts 'foo\\\bar' | |
foo\\bar | |
nil | |
irb(main):054:0> puts 'foo\\\\bar' |
NewerOlder