Skip to content

Instantly share code, notes, and snippets.

@mbajur
mbajur / nil.rb
Created February 11, 2021 10:19
Ruby `#to_s` vs `|| ''` benchmark
require 'benchmark'
n = 100_000
Benchmark.bm do |benchmark|
benchmark.report("#to_s") do
n.times do
nil.to_s
end
end
@mbajur
mbajur / Gemfile
Last active January 4, 2022 11:16
Liquid, Handlebars, Erb and gsub benchmarks
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'liquid'
gem 'ruby-handlebars'
@mbajur
mbajur / update_production
Created November 13, 2018 10:18
Prismo updating script
echo '== Stoping the app =='
docker-compose down
echo '== Pulling changes =='
git pull
echo '== Building the image =='
docker-compose build
echo '== Removing old assets'
█▬█ █ ▀█▀
@mbajur
mbajur / affix.vue
Created July 20, 2017 07:57
vue-affix with option to delay the initialization
<template>
<div>
<slot></slot>
</div>
</template>
<script>
export default {
props: {
/**
module Api::Views::V1::Events
class Index
include Api::View
end
@mbajur
mbajur / alt-action-listeners.js.es6
Last active June 28, 2017 18:06
alt.js - listening for events outside of the store
/**
* ActionListeners(alt: AltInstance): ActionListenersInstance
*
* > Globally listen to individual actions
*
* If you need to listen to an action but don't want the weight of a store
* then this util is what you can use.
*
* Usage:
*
@mbajur
mbajur / letsencrypt.md
Created May 9, 2016 13:25 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@mbajur
mbajur / .md
Created April 29, 2016 07:16
How to create small, unique tokens in Ruby

How to create small, unique tokens in Ruby

That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:

My choice: Dave Bass’s rand().to_s() trick

Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):

@mbajur
mbajur / gist:d65c92445f48603424e7
Created March 12, 2015 16:43
Install drone.io

(important) Setup ubuntu to use aufs driver for drone

sudo apt-get install linux-image-extra-$(uname -r)
sudo reboot

Install docker

curl -s https://get.docker.io/ubuntu/ | sudo sh

Install drone.io