Skip to content

Instantly share code, notes, and snippets.

Hadrien Blanc hadrienblanc

Block or report user

Report or block hadrienblanc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cast_to_boolean.rb
ActiveModel::Type::Boolean.new.cast(ENV.fetch('MY_ENV_VARIABLE', false))
View increase_aws_volume_size.rb
lsblk # show the volume size
sudo file -s /dev/xvdf # know your filesystem type
sudo xfs_growfs -d /home/ubuntu/data/ # increase your mount folder
View auth.rb
require 'rest-client'
require 'json'
client_id = '42f5e************************'
client_secret = 'secret-b42-************************'
begin
response = RestClient.post('www.my_app.com/oauth/token', {
grant_type: 'client_credentials',
client_id: client_id,
View exists.mongo
{ "attribute_1": {$exists:true}, "attribute_2": "value_wanted"}
View mass_mv_change_filename.sh
#!/bin/bash
# mass change xml filename
for file in *.xml; do
mv "$file" "${file%.xml}_p.xml"
done
View prefix.sh
ls | xargs -I {} mv {} PREF_{}
View git_stats.sh
git diff --stat master
git log --stat
View screen_usage.sh
screeen -ls # list the screens
screen -S session_name # create a session
# how to detach ? : Ctrl+a d
screeen -ls # list the screens and find the ID
screen -r 42 # 42 is the ID of the screen
View attach_active_storage.rb
some_profile.avatar.attach(io: File.open('/path/to/file'), filename: 'avatar.png')
You can’t perform that action at this time.