Skip to content

Instantly share code, notes, and snippets.

View ghiculescu's full-sized avatar

Alex Ghiculescu ghiculescu

View GitHub Profile
fetch("https://YOUR_DOMAIN.canny.io/api/users/get", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-GB,en;q=0.9,en-US;q=0.8","content-type":"application/json","sec-fetch-mode":"cors","sec-fetch-site":"same-origin"},"referrer":"https://YOUR_DOMAIN.canny.io/admin/users","referrerPolicy":"no-referrer-when-downgrade","body":"{\"__host\":\"YOUR_DOMAIN.canny.io\___LOTS_OF_OTHER_CRAP_HERE___\"limit\":1000}","method":"POST","mode":"cors"}).then(d => d.json().then(t => console.log(t.result.users.sort((a, b) => b.voteCount - a.voteCount))))
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
# srb rbi gems
# typed: false
#
# If you would like to make changes to this file, great! Please create the gem's shim here:
#
# https://github.com/sorbet/sorbet-typed/new/master?filename=lib/sorbet-rails/all/sorbet-rails.rbi
#
# sorbet-rails-0.5.7
def display_expected_hours_in_pay_period(user)
freq = user.next_pay_group.typed_frequency
case freq
when Frequency::Weekly
t("periods.week").downcase
when Frequency::Fortnightly
t("periods.fortnight").downcase
when Frequency::SemiMonthly
t("periods.period").downcase
@ghiculescu
ghiculescu / notes.md
Created June 2, 2021 14:08
Optimizing Rails fixtures

I had a thought while riding to work today: how much faster would CI and tests be if we had a lot less fixtures. I had a suspicion that cutting down on our fixtures load would make CI a lot faster.

Let's test this hypothesis:

Given this test class:

class SomethingTest < ActiveSupport::TestCase
  test "something" do
  end
"data-confirm: clicking on a link with data-confirm attribute. Confirm yes. (0, 6, 6)Rerun\n40 ms\ndata-confirm: clicking on a button with data-confirm attribute. Confirm yes. (0, 6, 6)Rerun\n26 ms\ndata-confirm: clicking on a link with data-confirm attribute. Confirm No. (0, 3, 3)Rerun\n66 ms\ndata-confirm: clicking on a button with data-confirm attribute. Confirm No. (0, 3, 3)Rerun\n70 ms\ndata-confirm: clicking on a button with data-confirm attribute. Confirm error. (0, 3, 3)Rerun\n68 ms\ndata-confirm: clicking on a submit button with form and data-confirm attributes. Confirm No. (0, 3, 3)Rerun\n71 ms\ndata-confirm: binding to confirm event of a link and returning false (0, 1, 1)Rerun\n69 ms\ndata-confirm: binding to confirm event of a button and returning false (0, 1, 1)Rerun\n66 ms\ndata-confirm: binding to confirm:complete event of a link and returning false (0, 2, 2)Rerun\n69 ms\ndata-confirm: binding to confirm:complete event of a button and returning false (0, 2, 2)Rerun\n66 ms\ndata-confirm: a butto
> @rails/[email protected] lint
> coffeelint app/assets/javascripts && eslint test/ujs/public/test
✓ app/assets/javascripts/rails-ujs.coffee
✓ app/assets/javascripts/rails-ujs/features/confirm.coffee
⚡ app/assets/javascripts/rails-ujs/features/disable.coffee
⚡ #93: Unnecessary double quotes are forbidden.
✓ app/assets/javascripts/rails-ujs/features/method.coffee
⚡ app/assets/javascripts/rails-ujs/features/remote.coffee
@ghiculescu
ghiculescu / test.rb
Last active June 17, 2021 14:39
#13071
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
require "json"
require "net/http"
image = "ruby"
uri = URI("https://registry.hub.docker.com/v1/repositories/#{image}/tags")
json = Net::HTTP.get(uri)
# json == ""
@ghiculescu
ghiculescu / keys.rb
Created January 31, 2022 19:48 — forked from archan937/keys.rb
List all Memcached keys using Ruby
# inspired by https://gist.github.com/archan937/f441146e1aeaa9da138e337514ee4000
require "net-telnet"
def keys(hosts, port, pattern = nil)
[hosts].flatten.each do |host|
slabs = {}
telnet = Net::Telnet::new("Host" => host, "Port" => port, "Timeout" => 30)
telnet.cmd("String" => "stats items", "Match" => /^END/) do |stats|
slabs = Hash[stats.scan(/STAT items:(\d+):number (\d+)/)]