Skip to content

Instantly share code, notes, and snippets.

@Bhacaz
Bhacaz / string_modifier.rb
Created January 20, 2022 14:09
Detect files with methods that may modify string
# frozen_string_literal: true
files_path = `git diff --name-only origin/master..`
files_path = files_path.split("\n").select { |f| f.end_with?('.rb') }
METHODS = %w(
<<
.push
.gsub!
.concat
@Bhacaz
Bhacaz / docker-compose.yml
Created January 21, 2021 20:11
Docker compose to run ElasticSearch and Kibana with Docker.
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
environment:
- node.name=elasticsearch
- discovery.type=single-node
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- bootstrap.memory_lock=true
# Fur Elise
# Note by note
use_bpm 40
use_synth :piano
# Partie 1 >>
play :E5, amp: 4
sleep 1/8.0
play :Ds5
@Bhacaz
Bhacaz / main.rb
Created May 7, 2019 19:00
[Ruby] Example of using class attributes
require_relative 'user'
require_relative 'user_serializer'
user = User.new('Hello', 'World', '21')
puts UserSerializer.new(user).serialize
# => {:display_name=>"Hello World", :age=>"21 years old"}
@Bhacaz
Bhacaz / .gitconfig
Last active February 28, 2024 14:39
Personal Git alias
[alias]
s = status
branch-name = "!git rev-parse --abbrev-ref HEAD"
uncommit = !git reset --soft HEAD~1 && git s
discard-all = !git add . && git reset --hard
publish = !git push --set-upstream origin $(git branch-name)
chb = !sh -c \"git branch -a | grep $1 | head -n 1 | cut -d/ -f3- | xargs git checkout\"
nb = checkout -b
c = checkout
cm = !git add . && git commit -m
@Bhacaz
Bhacaz / Add frozen_string_literal on top of a file .rb
Created June 4, 2018 17:53
Script to add `# frozen_string_literal: true` on top of a file. Useful to add has a external tool in RubyMine
#!/usr/bin/env ruby
file_path = ARGV.first
puts ''
unless file_path
puts 'You must provide a file path'
puts ' Ex: ruby add_frozen_string.rb /path/to/file.rb'
exit 1
end
@Bhacaz
Bhacaz / my-agnoster.zsh-theme.diff
Last active September 8, 2017 13:06
Change the prompt to be more like Shell and only display the current folder.
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 07546fd..e6dec73 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -80,7 +80,7 @@ prompt_end() {
# Context: user@hostname (who am I and where am I)
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
- prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
+ prompt_segment black default "%(!.%{%F{yellow}%}.)$USER:"
@Bhacaz
Bhacaz / Create Git alias checkout with ticket number.sh
Last active September 6, 2017 14:51
I'm working with JIRA and ticket number and to change branch without tapping the board name, the numbre and press TAB a couple of times I create this alias to only write the number.
git config --global alias.chb 'chb = !sh -c "git branch -a | grep $1 | head -n 1 | cut -d/ -f3- | xargs git checkout"'
git chb 1085 # Example
@Bhacaz
Bhacaz / shp2png.py
Created June 25, 2017 19:28
Generate image (PNG) preview of a Shapefile
'''
Big thanks and inspiration from : https://github.com/mfurlend/shp2png
Addapted to have:
- random fill color
- shapeType = Points to pentagone
'''
import shapefile, math
import Image, ImageDraw