This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://stackoverflow.com/a/15852593 | |
| p ObjectSpace.each_object(Class){|ob| p ob} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |