Skip to content

Instantly share code, notes, and snippets.

View nwxxb's full-sized avatar
😐

nzia nwxxb

😐
View GitHub Profile
@nwxxb
nwxxb / checking_ruby_or_rails_tz.sh
Last active March 5, 2025 07:19
checking ruby (&& on rails) timezone inside server
# get server's timezone
date +%Z
# if not empty, TZ env variable override server's timezone
echo $TZ
# checking ruby's timezone (which follows server's timezone)
echo 'puts Time.now.strftime("%Z")' | irb
# rails internally use two timezone: system timezone and application timezone
# WIP
# it currently can't detect suffix, prefix, and scope attribute provided to your enum invocation
# and if you use values that are reserved in ruby (like reject, create, etc...) you will get a problem using this script
# TL;DR you will end up need to filter it yourself/manually delete it
# I assume that you fill this array with the model's file name with extension omitted
["user", "product"].each.with_index(1) do |model_file_name, index|
model_constant = Object.const_get(model_file_name.camelize)
puts "#{index}. #{model_constant}"
@nwxxb
nwxxb / inversed_hello_world.rb
Created June 29, 2024 11:36
try to make this meme (I forget the origin) of hello world into reality
# basic hello world
puts "hello world"
# inversed hello world
def hello_world(method_sym)
if self.respond_to?(method_sym, true)
self.send(method_sym, 'hello world')
else
'hello world'.send(method_sym)
end
# https://stackoverflow.com/a/15852593
p ObjectSpace.each_object(Class){|ob| p ob}
@nwxxb
nwxxb / popup.vim
Created December 13, 2021 12:44
Vim Popup Penyemangat
function! CallRandomPenyemangat()
let messages = [
\'Persistent is the key',
\'Hello World!', 'Besok Mungkin Kita Sampai, Besok Mungkin Tercapai',
\'Never let the future disturb you. You will meet it, if you have to, with the same weapons of reason which today arm you against the present.'
\]
let seed = srand()
call popup_notification(messages[rand(seed) % len(messages)], #{ line: 5, col: 10, highlight: 'WildMenu', time: 5000, pos: 'center' } )
endfunction