Skip to content

Instantly share code, notes, and snippets.

Trung Lê joneslee85

View GitHub Profile
@joneslee85
joneslee85 / codedeploy.md
Last active Feb 22, 2019
Where does AWS CodeDeploy agent store its scripts?
View codedeploy.md

/opt/codedeploy-agent/deployment-root/${DEPLOYMENT_GROUP_ID}/${DEPLOYMENT_ID}/deployment-archive/

@joneslee85
joneslee85 / gist:64ff44f7618e1c4ed1d57d470638c5e6
Created Aug 16, 2018
Link to download puppet learning VM
View gist:64ff44f7618e1c4ed1d57d470638c5e6
Original page: https://puppet.com/download-learning-vm/thank-you
Link: https://pe-education-vms.s3.amazonaws.com/learning/learning_puppet_vm-6.5.zip
Version: 6.5 (Quest Guide v2.3.0)
File Size: 3.2 GB
MD5: be3df9bc000b98b9aec6002f071968da
### Minimum requirements
* Internet-enabled Windows, OS X, or Linux computer with 10GB free space and a VT-x/AMD-V enabled processor.
* 4GB memory (8GB is recommended)
@joneslee85
joneslee85 / how_to_transfer_money_to_legame_with_transferwise.md
Last active Jun 19, 2018
How to transfer money to Legame with TransferWise?
View how_to_transfer_money_to_legame_with_transferwise.md
  • Name: カブシキガイシャ レガーメ
  • Bank: 1695
  • Branch: 004
  • No: 0680377
@joneslee85
joneslee85 / foreman_regex.rb
Last active Apr 5, 2018
A simple regex to match foreman log output
View foreman_regex.rb
message = %Q{3:54:04 worker.1 | main_message_is_here}
FOREMAN_REGEX = /^(?<TIME>([0-1]?[0-9]|[2][0-3]):([0-5][0-9])(:[0-5][0-9]))\s(?<PROGRAM>\S*)\s+\|(?<MESSAGE>.*)$/
match = FOREMAN_REGEX.match(message)
match["TIME"] #=> "3:54:04"
match["PROGRAM"] #=> "worker.1"
match["MESSAGE"] #=> "main_message_is_here"
@joneslee85
joneslee85 / unicorn_regex_ruby.md
Created Nov 12, 2017
Ruby Regex to match unicorn log output
View unicorn_regex_ruby.md

Input:

I, [2017-11-11T00:00:09.560827 #54806]  INFO -- : greedy message is here

Filter in Regex:

View gist:6486587d9c70f748d4e8a209ae2dc57a
Q: What is LTS status of NodeJS 4.x?
A: End of Life
B: Active
C: Maintenance <--
Q: What are the official supported languages for Android development?
A: Ruby
B: Cobol
C: Kotlin <--
D: Erlang
@joneslee85
joneslee85 / let_rails_router_handle_exception.md
Last active May 12, 2017
Rails way to let router to handle all exception
View let_rails_router_handle_exception.md

What people tend to do is to handle exception in controller with rescue_from, well it is totally fine. However there is also a different way by delegating the handling to router.

Configure the app to handle exception with Router

# config/application.rb

config.exceptions_app = self.routes
View gist:2a94deb92b13a10acc4c16e969fc60ff
Mentor list
@kimhieu - L - Android/Backend
@kiennt - M - Elixir/Backend
@codeaholicguy - L - JS
@joneslee85
joneslee85 / 00_pending_migrations.rb
Last active Nov 8, 2016
An initialiser to prevent app to bootstrap app on dev env if pending migrations - cover Rails 3 or newer
View 00_pending_migrations.rb
## Place in config/initializers/00_pending_migrations.rb
# Raise an error and abort the run there are any pending migrations:
if Rails.env.development?
# Rails 4 way ;)
if Rails.version >= '4'
ActiveRecord::Migration.check_pending!
else
# Rails 3 way - TODO: remove when we up to Rails 4
migrator = ActiveRecord::Migrator.new(
@joneslee85
joneslee85 / varnish_docker_log.md
Created Aug 30, 2016
How to get the log of varnish that runs under docker?
View varnish_docker_log.md

Well, you see varnishd does not output any log to STDOUT at all if run on foreground. In order to do so, Varnish provides different daemons for the job, that is varnishlog and its NCSA-format variant varnishncsa. Those logger daemon would pipe all outputs that varnish stores in memory fragments to a file, either /var/log/varnish/varnish.log or /var/log/varnish/varnishncsa.log respectively. Please remember that these log file can be re-configured. This tutorial is for the Varnish that is packaged for Ubuntu Trusty, in which default options of daemon are stored under /etc/default. You can peek into it to see what's the default for varnishlog or varnishncsa

In this quick tutorial, I am going to use varnishncsa instead. In your Dockerfile, you start varnishd first then varnishncsa and run tail -f /var/log/varnish/varnishncsa.log, I created a start.sh script:

You can’t perform that action at this time.