Skip to content

Instantly share code, notes, and snippets.

View Yoshyn's full-sized avatar
🇫🇷
Graou

Sylvestre Antoine Yoshyn

🇫🇷
Graou
View GitHub Profile
@Yoshyn
Yoshyn / stylish.css
Created January 28, 2015 14:18
Stylish CSS for production domain.
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("my-domain.com") {
body {
border-top: 2px solid orange;
}
body:before {
background-color: orange;
content: "PROD";
start_time_record = window.performance.now();
MY CODE TO PERFORM
end_time_record = window.performance.now();
function_as_string = arguments.callee.toString()
console.log(function_as_string.substr(0, function_as_string.indexOf('{')) + '(+' + (end_time_record - start_time_record) + ' ms)');
@Yoshyn
Yoshyn / .Manage Postgres
Last active March 2, 2018 09:06
Manage Postgres : Several script in order to manage Postgres
# Contains :
# * find_duplicated_index.sql
# * find_missing_index.sql
# * find_unused_index.sql
# * generate_data.sql : Generate a big dummy set of data
# * update_PG_varchar_to_string.rb : Update all field in varchar to string into a database
# * mass_export_and_delete.sql
# * remove_update_duplicate.sql
# * sharding_table_stats.sql : Get avg, percentile & co for a table over sharding
@Yoshyn
Yoshyn / wrapper_poc.rb
Created October 21, 2016 10:36
Rails wrapper for string like simple_form, tested implementation.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '~> 4.2' #, github: 'rails/rails'
GEMFILE
system 'bundle'
end
require 'bundler'
@Yoshyn
Yoshyn / active_record_log_subscriber.rb
Created November 15, 2016 13:28
Give the backtrace for all the SQL query performed in development mode. (into config/initializers/)
unless Rails.env.production?
module LogQuerySources
LOG_QUERY_LINES = ENV.fetch('LOG_QUERY_LINES', 3).to_i
def debug(*args, &block)
return unless super
backtrace = Rails.backtrace_cleaner.clean(caller)
@Yoshyn
Yoshyn / Capistrano.rb
Last active February 20, 2017 11:43
Capistrano : Set of task/script that can be add to deploy.rb
# Contains :
# * deploy_git_sync.rb : stop deployment if git is not synchronized remote branch.
# * deploy_lock_per_user.rb : stop deployment if somebody is already deploying the application.
# * deploy_smart_asset.rb : Avoid compiling asset if not needed.
# * passenger_restart.rb : Restart passenger after deploy.
# * sidekiq_restart.rb : Restart sidekiq after deploy.
# Question? Why this and not use gem ?
# -> Answer : Why use a gem for this? :)
@Yoshyn
Yoshyn / .Manage Sidekiq.rb
Last active January 31, 2017 13:47
Sidekiq : Set of task/script to manage sidekiq
# Contains :
# * deploy_git_sync.rb : Check if a job is running
# * identify_errno_EMFILE.sh : identify a Errno::EMFILE over sidekiq
@Yoshyn
Yoshyn / .ruby_rails_snippet.rb
Last active November 14, 2019 13:13
Ruby & Rails : Set of snippet
# Contains :
# * replace_task.rb
# * convert_date.rb
# * detect_leaks.rb
# * trace_point_logger.rb : Display all function path, parameter and return to a file (a logger) POC
# * profile_gem_on_boot.rb : Loading time per gem
# * crow_flies_sqlite.rb : An implementation of crow flies for sqlite & rails
# * openssl.rb : Asyn & sync encryption with openssl
# Convert from ipaddr to netaddr:cidr type
@Yoshyn
Yoshyn / .Manage Dtrace
Last active March 14, 2019 15:15
Script & help reminded for Dtrace & ruby
# Contains :
# * ruby_glob_analysis.d
Amazing quicksheet : http://www.tablespace.net/quicksheet/dtrace-quickstart.html
Amasome one-liner : https://wiki.freebsd.org/DTrace/One-Liners
Adding Probe dynamicly for ruby : https://github.com/kevinykchan/ruby-usdt
IP tracking : https://docs.oracle.com/cd/E36784_01/html/E36846/glhhr.html
# Main exemple :
ruby*:::method-entry
@Yoshyn
Yoshyn / readme.md
Created July 17, 2017 14:08 — forked from shime/readme.md
bake your own code reloader for rails

Let's build our own code reloader for Rails, shall we?

Require dependency problems

Run this inside rails/railties:

$ grep -rn "eager_load_paths" .

You should get the results from Rails::Engine::Configuration and Rails::Engine. As you know, each Rails application is actually a Rails::Engine and Rails::Engine::Configuration is that thing wrapped inside Rails.application.config block.