Skip to content

Instantly share code, notes, and snippets.

View armandfardeau's full-sized avatar
🏠
Working from home

Armand Fardeau armandfardeau

🏠
Working from home
  • Paris, France
View GitHub Profile
#!/usr/bin/env ruby
require 'easy_audio'
require 'open3'
# Configuration
TARGET = "google.com"
BASE_FREQUENCY = 1200.0 # Hz for High latency
MIN_FREQUENCY = 200.0 # Hz for low latency
SCALE = 0.001 # Adjust this for more/less sensitivity
UPDATE_INTERVAL = 0.25 # Fast update interval for smooth transitions
# example private key
private_key = ARGV[0]
# --------------------------
# Secp256k1 Curve Parameters
# --------------------------
# y^2 = x^3 + ax + b
$a = 0
$b = 7 # using global variables for convenience
#!/usr/bin/env ruby
top_level = `git rev-parse --show-toplevel`.chomp
file_paths = `git status --porcelain | cut -c4- | grep spec.rb`.freeze
@ruby_version = `ruby -v | cut -d" " -f2 | cut -c-5`.freeze
@project_ruby_version = `cat .ruby-version`
verbose = ARGV.include?('-v')
@unique_line = ARGV[1] if ARGV.include?('-l')
@armandfardeau
armandfardeau / How to drop all connections to a specific database without stopping the server?
Created July 2, 2019 15:27
How to drop all connections to a specific database without stopping the server?
select pg_terminate_backend(pid) from pg_stat_activity where datname='db';
RAILS_ENV=production bundle exec rails tmp:cache:clear assets:clobber assets:precompile && sudo service nginx restart && sudo service sidekiq restart
ls -1p | grep '/$' | sed 's/\/$//' | xargs -I {} bash -c "cd '{}' && pwd && echo $'\n' && bundle exec rake test" && echo $'\n' | xargs >> results.txt
/**
* CircleCI Incoming Webhook Script for Rocket.Chat
* @author <github.com/armandfardeau>
*/
class Script {
process_incoming_request({ request }) {
const statusMaps = {
'success': 'passed all tests ✅',
'no_tests': 'has no tests 🧐',
namespace :heroku do
desc "Deploy a test version on heroku"
task setup: :environment do
if ENV["SECRET_KEY_BASE"].nil?
puts "No SECRET_KEY_BASE found !"
puts "export SECRET_KEY_BASE first : "
puts "export SECRET_KEY_BASE=#{`bundle exe rake secret`}"
exit 1
end
#!/bin/bash
if [[ -z $1 ]];then
branch=$(git rev-parse --abbrev-ref HEAD)
branch_clean=${branch//_/-}
branch_clean_no_digit=$(printf '%s' "$branch_clean" | sed 's/[0-9.]//g')
app_name=$(printf '%s' "$branch_clean_no_digit" | sed 's/-//')
if [ ${#app_name} -ge 30 ]; then
echo "Branch name $app_name is too long, max is 30"
exit 1
@armandfardeau
armandfardeau / How to use
Last active July 13, 2018 17:12
Rails and Sidekiq post-receive deploy
git init --bare repo.git
vim hooks/post-receive
chmod ug+x hooks/post-receive