Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
require 'benchmark/ips'
numbers = (1..10000).to_a
numbers_as_string = "," + (1..10000).to_a.join(",") + ","
Benchmark.ips do |x|
x.report("binary search numbers") do |i|
while i > 0
as scraped by @cjlarose
5.0.0 - Spoony Bard
4.3.0 - Mysterious Traveller
4.2.0 - Distant Airhorns
4.1.0 - Fourth and One
4.0.0 - 4 Fast 4 Furious
3.12.0 - Llamas in Pajamas
3.11.0 - Love Song
3.10.0 - Russell's Teapot
$ benchmark-driver benchmark.yml --rbenv '2.0.0::2.0.0-p648 --disable-gems;2.5.3::2.5.3 --disable-gems;2.6.0-preview3::trunk --disable-gems;2.6.0-preview3+JIT::trunk --disable-gems --jit' -v --repeat-count 24
2.0.0: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
2.5.3: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
2.6.0-preview3: ruby 2.6.0dev (2018-10-31 trunk 65474) [x86_64-linux]
2.6.0-preview3+JIT: ruby 2.6.0dev (2018-10-31 trunk 65474) +JIT [x86_64-linux]
Calculating -------------------------------------
2.0.0 2.5.3 2.6.0-preview3 2.6.0-preview3+JIT
Optcarrot Lan_Master.nes 34.548 48.314 54.535 85.690 fps
Comparison:
@leemeichin
leemeichin / README.md
Last active December 18, 2019 08:29
CircleCI 2.0 - Merge parallel coverage results for CodeClimate

CircleCI 2.0 Parallel Builds and CodeClimate

Add the Ruby script to your repo, and add this snippet into your new circle.yml:

- deploy:
    name: Merge and copy coverage data
    command: bundle exec path/to/circle.rb
@erose
erose / decrypt_cookie.rb
Created April 24, 2017 02:50
Decrypt a Rails 5 session cookie
@mderazon
mderazon / .travis.yml
Last active April 13, 2020 11:05
Automatic deployment to Google Cloud Functions with Travis-ci
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
@taranda
taranda / dynamic-critical-path-css.md
Last active July 7, 2021 19:53
Dynamically Add Critical CSS to Your Rails App

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

@inscapist
inscapist / Dockerfile
Last active April 11, 2020 08:32
Docker + Rails configuration + Docker Sync
# This Dockerfile is intended to build a production-ready app image.
#
# This is not required for development environments
FROM sagittaros/rails-base:latest
MAINTAINER Felix Tioh <felix.tioh@crowdo.com>
COPY . /app
WORKDIR /app
EXPOSE 5000

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@danieleggert
danieleggert / GPG and git on macOS.md
Last active June 6, 2024 09:29
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys