Skip to content

Instantly share code, notes, and snippets.

@M5RND
M5RND / Commit_Empty_Directory.md
Created March 3, 2026 23:29
[2026 : Git] #git

Commit Empty Directory Git

Using .gitkeep (Recommended Convention)

The most common and widely accepted method is to create a file named .gitkeep inside the empty directory:

mkdir your-directory
cd your-directory
touch .gitkeep
git add .
git commit -m "Add empty directory with .gitkeep"
@M5RND
M5RND / Deployment-Tools.md
Last active March 1, 2026 21:49
[2026 : Ruby Lang] notes #ruby #notes
@M5RND
M5RND / gist:e9af5fde2ccdd53dcdb47be37bb01bbe
Created March 21, 2017 17:35
ActiveRecord Preloading
# includes = preload
> User.includes(:merchants)
User Load (0.7ms) SELECT "users".* FROM "users"
HABTM_Merchants Load (0.9ms) SELECT "merchants_users".* FROM "merchants_users" WHERE "merchants_users"."user_id" IN (3, 1, 2)
Merchant Load (0.7ms) SELECT "merchants".* FROM "merchants" WHERE "merchants"."id" IN (2, 118, 1, 5)
> User.preload(:merchants)
User Load (0.8ms) SELECT "users".* FROM "users"
HABTM_Merchants Load (0.8ms) SELECT "merchants_users".* FROM "merchants_users" WHERE "merchants_users"."user_id" IN (3, 1, 2)
@M5RND
M5RND / jdk-manual-install
Last active November 2, 2018 01:08
Install Java Alternatives
#!/bin/sh
tar -xvf jdk-8*
sudo mkdir /usr/lib/jvm
sudo mv ./jdk1.8* /usr/lib/jvm/jdk1.8.0
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
# Singleton with ThreadSafe::Cache
require 'thread_safe'
module ActiveSupport
module Inflector
extend self
# A singleton instance of this class is yielded by Inflector.inflections,
# which can then be used to specify additional inflection rules. If passed
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.opentravel.org/OTA/2003/05" targetNamespace="http://www.opentravel.org/OTA/2003/05" elementFormDefault="qualified" version="1.008" id="OTA2007A">
<xs:include schemaLocation="OTA_VehicleCommonTypes.xsd"/>
<xs:annotation>
<xs:documentation xml:lang="en">All Schema files in the OTA specification are made available according to the terms defined by the OTA License Agreement at http://www.opentravel.org/ota_downloads_form.cfm</xs:documentation>
</xs:annotation>
@M5RND
M5RND / deep_struct.rb
Last active March 1, 2026 21:54
RUBY MISC
require 'ostruct'
# DeepStruct with some Array support
class DeepStruct < OpenStruct
def initialize(hash = nil)
@table = {}
@hash_table = {}
if hash && hash.is_a?(Hash)
hash.each do |k,v|
# gzipped json-stored hash unpack
require 'zlib'
data = Zlib::GzipReader.open("i18n.json.gz") {|gz| gz.read}
h = JSON.parse(data)
# rails console
ActiveRecord::Base.logger = Logger.new(STDOUT)
# one-line Postgres EXPLAIN (ANALYZE)
puts ActiveRecord::Base.connection.execute(%Q{ EXPLAIN (ANALYZE) SELECT ...; }).map{|x| x['QUERY PLAN']}.unshift('').join("\n")
@M5RND
M5RND / gist:a6df600c6dec867508fa
Last active November 2, 2018 01:00
Ruby one-time scripting
# Location names mapper
require 'json'
require 'csv'
# [0] "Location ID",
# [1] "Location Code",
# [2] "IATA",
# [3] "Location",
# [4] "City",
@M5RND
M5RND / bash.txt
Last active November 2, 2018 00:55
SYSTEM
# misc options
netstat -tnap | grep LIST
htop
iotop
ssh -f -N -L 9379:127.0.0.1:6379 {remote_user}@{remote_host} -p 22222
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock dockerui/dockerui
docker unpause dockerui/dockerui
docker ps