Skip to content

Instantly share code, notes, and snippets.

View nicolas-brousse's full-sized avatar
🚲

Nicolas Brousse nicolas-brousse

🚲
View GitHub Profile

Usage

$ ruby fake_smtp_server
require "net/smtp"
@nicolas-brousse
nicolas-brousse / _alert.html.slim
Created March 29, 2018 12:42
Komponent gem usage example
= content_tag(:div, html_attributes) do
= yield_or_property(:message)
@nicolas-brousse
nicolas-brousse / active_admin.js
Last active May 14, 2021 18:45
Formtastic PostgreSQL Array input (inspered from https://gist.github.com/franks921/44509c65da3bea99bc49)
$('form .input.array').each(function() {
var $wrapper = $('.array-inputs', this);
var $insertArea = $(".array-input button[data-action=add]").closest(".array-input");
$(".array-input button[data-action=add]", $(this)).click(function(e) {
$('.array-input:first-child', $wrapper).clone(true).insertBefore($insertArea).find('input').val('').focus();
});
$('.array-input button[data-action=remove]', $wrapper).click(function() {
if ($('.array-input', $wrapper).length > 2) {
$(this).parent('.array-input').remove();
}
class Gemstash < Formula
desc "A RubyGems.org cache and private gem server."
homepage "https://github.com/bundler/gemstash/"
url "https://github.com/bundler/gemstash/archive/v1.0.4.tar.gz"
sha256 "d3479b692a3a14844b703e0be033e29e9fca99899cf0b887d77c8759dcfbebd5"
def install
ENV["GEM_HOME"] = libexec
system "gem", "build", "gemstash.gemspec"
system "gem", "install", "gemstash-#{version}.gem"
require "benchmark"
require "securerandom"
n = 1_000_000
Benchmark.bm(7) do |x|
x.report("uuid:") { n.times do; SecureRandom.uuid; end }
end
@nicolas-brousse
nicolas-brousse / pg.md
Created February 10, 2017 11:51 — forked from benschwarz/pg.md
Awesome postgres
@nicolas-brousse
nicolas-brousse / postgres_uuid_primary_key_benchmark.rb
Last active June 26, 2023 22:31
PostgreSQL Serial/UUID as primary key benchmark
require "pg"
require "benchmark"
require "faker"
def say(msg)
puts msg
end
conn = PG.connect(dbname: "postgres")

Usage

@title = "Example title"

v = View.new("./view.erb", layout: "./layout.erb")
puts v.render(binding)
FROM gliderlabs/alpine:3.2
RUN apk-install curl
Clicking this number<sup>[1](#note-1)</sup> will lead you to a footnote.

---

<sup name="note-1">1</sup>: Handy! Now click the return link to go back.