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
<!DOCTYPE html> | |
<html> | |
<head> | |
<%= inline_js 'application.js' %> | |
<%= inline_css 'application.css' %> | |
</head> | |
<body> | |
</body> | |
</html> |
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 "active_record" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Migration.class_eval do | |
create_table(:records) do |t| | |
t.string :column | |
end | |
end | |
data = 50_000.times.map { |i| Hash[column: "Column #{i}"] } |
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
### pfx to pem, complete edition: | |
$ openssl pkcs12 -in filename.pfx -nocerts -out key.pem | |
$ openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem | |
$ openssl pkcs12 -in filename.pfx -cacerts -out ca_cert.pem |
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
### | |
### Rails.root/lib/scheduler.rb | |
### | |
require 'celluloid/autostart' | |
module AwesomeRailsApp | |
class ClockworkScheduler | |
include Celluloid | |
include Clockwork | |
def run |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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
# Adapted for Rspec2. This won't work in RSpec 1. | |
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb | |
Rspec.configure do |config| | |
config.before(:each) do | |
Capybara.current_driver = :selenium if example.metadata[:js] | |
end | |
config.after(:each) 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
raph = Raphael([..]); | |
chart = raph.g.linechart([..]); | |
var labels = ["first variable", "second variable", "third variable"]; | |
chart.labels = raph.set(); | |
var x = 15; var h = 5; | |
for( var i = 0; i < labels.length; ++i ) { | |
var clr = chart.lines[i].attr("stroke"); | |
chart.labels.push(raph.set()); | |
chart.labels[i].push(raph.g["disc"](x + 5, h, 5) |