Skip to content

Instantly share code, notes, and snippets.

View lailsonbm's full-sized avatar

Lailson Bandeira lailsonbm

View GitHub Profile
@Dagnan
Dagnan / application.html.erb
Last active November 21, 2020 19:10 — forked from averyvery/application.rb
Inline CSS or JS in Rails 5
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>
@janko
janko / 1-activerecord.rb
Last active June 13, 2023 20:00
INSERTing 50,000 records into a database in ActiveRecord, Arel, SQL, activerecord-import and Sequel.
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}"] }
@mergulhao
mergulhao / gist:6269789
Last active April 6, 2017 13:33
How to convert a PFX ssl certificate to PEM? If you are in Brazil and buy an A1 (e-CNPJ) certificate from CertSign it comes as a PFX. We need to convert it to PEM format so we can use the certificate to sign documents electronically and use it to access a lot of APIs, incluing NFe.
### 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
@fred
fred / clockwork_celluloid.rb
Created June 28, 2013 17:16
Running clockwork inside a Sidekiq Thread using Celluloid
###
### Rails.root/lib/scheduler.rb
###
require 'celluloid/autostart'
module AwesomeRailsApp
class ClockworkScheduler
include Celluloid
include Clockwork
def run
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
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"
# 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
@ejucovy
ejucovy / graphael-linechart-legend.js
Created June 24, 2010 16:15
manually building a legend for a g.raphael linechart
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)