Skip to content

Instantly share code, notes, and snippets.

View fabdbt's full-sized avatar
👊
Working

Fabien Dobat fabdbt

👊
Working
  • Paris
View GitHub Profile
#!/usr/bin/env ruby
# Requirements :
# Be logged using Github CLI : https://github.com/cli/cli
# Place this script in a folder at same level than other repositories, i.e. :
# - ./Workspace/api-core
# - ./Workspace/mep/matera_mep.rb
# Usage :
# * ruby matera_mep.rb [repo]
@fabdbt
fabdbt / .gitlab-ci.yml
Created February 11, 2020 12:22
GitLab CI - ZIP Wordpress plugin and upload it to AWS S3
# DO NOT FORGET TO SET YOUR ENVIRONMENT VARIABLES : AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# ZIP stage is using shell runner (quick start), UPLOAD stage is using docker runner
# Usage on Wordpress : wp plugin install [S3_PATH]/xxx.zip --activate --force (update)
stages:
- zip
- upload
zip_plugin:
stage: zip
@fabdbt
fabdbt / bundler_version.rb
Last active January 24, 2020 10:49
Ruby script that returns version of a gem included in `Gemfile.lock` file
#!/usr/bin/env ruby
require 'bundler'
puts Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)).specs.find { |s| s.name == ARGV[0] }.version.version
# Requires `Gemfile.lock` file with required dependency included (eg: `bundle install rubocop`)
# Use case : gem install rubocop -v $(ruby bundler_version.rb rubocop) --no-document
# Can be useful in CI jobs (do not install all dependencies through `bundle install` when you only need to pass linter for example)
@fabdbt
fabdbt / .gitlab-ci.yml
Created September 12, 2018 09:30
GitLab CI - Minify JS / CSS and upload them to AWS S3
# DO NOT FORGET TO SET YOUR ENVIRONMENT VARIABLES : AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION (protected)
stages:
- minify
- upload
minify_js:
image: node:latest
stage: minify
before_script:
@fabdbt
fabdbt / server.py
Created April 21, 2017 10:44 — forked from dragermrb/server.py
Python 3 HTTP Server with Basic Authentication
import http.server
import cgi
import base64
import json
from urllib.parse import urlparse, parse_qs
class CustomServerHandler(http.server.BaseHTTPRequestHandler):
def do_HEAD(self):

Keybase proof

I hereby claim:

  • I am apokly on github.
  • I am apokly (https://keybase.io/apokly) on keybase.
  • I have a public key whose fingerprint is 3CAB 5BC1 0A6E F3DB 012F E2AC 2FDD CEBB 8124 C1EF

To claim this, I am signing this object:

@fabdbt
fabdbt / whybandit.rdoc
Created March 28, 2017 07:56
Bandit vs A/B Testing

From github.com/bmuller/bandit/blob/master/whybandit.rdoc

Bandit vs A/B Testing

In a typical A/B test, two alternatives are compared to see which produces the most “conversions” (that is, desired results). For instance, if you have a website with a big “Sign Up” button that you want visitors to click, you may wish to choose different background colors. Under typical A/B testing guildlines, you would pick a number (say, N) of users for a test and show half of them one color and half of them another color. After users are shown the button, you record the number of clicks that result from viewing each color. Once N users view one of the two alternatives, a statistical test (generally categorical, like a Chi-Square Test or a G-Test) is run to determine whether or not the number of clicks (aka, “conversions”) for one color were higher than the number of clicks for the other color. This test determines whether the difference you observed was likely due simply to chance or whether the difference

@fabdbt
fabdbt / tmux-cheatsheet.markdown
Created March 7, 2017 17:10 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@fabdbt
fabdbt / paginate_helper.rb
Created December 21, 2015 08:51
Bootstrap 4 will paginate
module PaginateHelper
class BootstrapRenderer < WillPaginate::ActionView::LinkRenderer
def prepare collection, options, template
options[:params] ||= Hash.new
options[:params]['_'] = nil
super(collection, options, template)
end
protected
@fabdbt
fabdbt / convert_model_table_utf8.rb
Created November 19, 2015 16:21
Convert the table associated to a model into 'utf8_general_ci' (string columns + table)
class ConvertToUtf8
DEFAULT_CONVERT_CHARACTER = 'utf8'
DEFAULT_CONVERT_COLLATE = 'utf8_general_ci'
DEFAULT_CONVERT_COLUMNS = {
# ActiveRecord: SQL
string: 'varchar(255)',
text: 'text'
}