Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
@czj
czj / download_attachments.sb
Created May 13, 2019 12:51
Download a Rails application's production attachements to your local machine
#!/usr/bin/env bash
APP_HOME=$( cd ${0%/*} && pwd -P )"/.."
REMOTE_SHARED="railsapp@host.domain.net:~/www/railsapp/shared"
SPEED_LIMIT=""
# Un-comment this line if you want to limit the download speed to un-clog your connexion
# SPEED_LIMIT="--bwlimit=500"
# -l forces copy of symlinks
#
@czj
czj / app_config.rb
Created May 6, 2019 14:50
Sample Rack::Attack configuration file
class AppConfig
class << self
# Lookup via
# https://www.ultratools.com/tools/ipWhoisLookupResult
# https://www.whatismyip.com/ip-whois-lookup/
BLOCKED_IPS = Set.new(
[
"6.5.4.3",
"5.4.3.2",
"4.3.2.1",
@czj
czj / config.yml
Created May 6, 2019 13:42
Circle CI 2.1 configuration step for Ruby / Rails / Redis / Postgres workflow with tests + system tests running in parallel
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2.1
executors:
my-executor:
docker:
# Main image to be used within this configuration

Keybase proof

I hereby claim:

  • I am czj on github.
  • I am czj (https://keybase.io/czj) on keybase.
  • I have a public key ASA-7J6_QjVmXe6nnNopADEypiIhM1vH2gbdW1hnns-hzAo

To claim this, I am signing this object:

@czj
czj / log_work_to_slack.rb
Created August 4, 2018 09:19
Work log output to local file + to Slack
#!/usr/bin/env ruby
require "bundler/inline"
gemfile { gem "slack-notifier" }
require "slack-notifier"
Slack::Notifier.new("https://hooks.slack.com/services/xxxxxxx").ping("• _#{query}_")
logs_dir = "~/Documents/work_logs"
query = ARGV[0].to_s.delete('\\')
@czj
czj / Gemfile
Last active August 28, 2022 09:06
Outputting Rails app logs to Logz.io via logstash
gem "lograge"
gem "logstash-event"
gem "logstash-logger"
@czj
czj / fake_name_generator.rb
Created June 9, 2018 19:44
Fake name generator (french/France)
#!/usr/bin/env ruby
require "json"
1000.times do
json = `curl --silent --insecure "https://api.namefake.com/french-france/random/"`
data = JSON.parse(json)
puts data["name"]
end
@czj
czj / simple_form.rb
Last active February 19, 2018 14:29
Bootstrap 4.0 compatible SimpleForm initializer
# frozen_string_literal: true
# Bootstrap 4 specific
# https://github.com/plataformatec/simple_form/pull/1476
SimpleForm::Inputs::Base.prepend(Module.new {
def merge_wrapper_options(options, wrapper_options)
if wrapper_options&.key?(:error_class)
wrapper_options = wrapper_options.dup
error_class = wrapper_options.delete(:error_class)
wrapper_options[:class] = "#{wrapper_options[:class]} #{error_class}" if has_errors?
#!/usr/bin/env ruby
if `brew --version`.include? 'Homebrew'
puts "Homebrew already installed."
else
puts "Installing Homebrew ..."
`/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
end
`brew upgrade`
@czj
czj / fix.fish
Created June 18, 2017 16:04
Fix for rbenv integration for fish shell
# 2017-06-06 : FIX RBENV / FISH
if not command -s rbenv > /dev/null
echo "rbenv: command not found. See https://github.com/rbenv/rbenv"
exit 1
end
set -l rbenv_root ''
if test -z "$RBENV_ROOT"
set rbenv_root "$HOME/.rbenv"