howto on davidchua https://dchua.com/tags/howto/ Recent content in howto on davidchua Hugo -- gohugo.io en-us Fri, 17 Jun 2016 15:24:00 +0800 Painless ECR authentication for Docker https://dchua.com/posts/2016-06-17-painless-ecr-authentication-for-docker/ Fri, 17 Jun 2016 15:24:00 +0800 https://dchua.com/posts/2016-06-17-painless-ecr-authentication-for-docker/ I’ve been playing around with Jenkins lately and one of the problems I’ve been facing is that it gets tedious manually doing a aws ecr get-login every 12 hours on the Jenkins instances so that my builds can push docker images into ECR. You may be thinking, why not just add the authentication into the build step before the push. Tried that but for some reason, I’m never able to get it to eval correctly. Hooking up Jekyll to Facebook Instant Articles https://dchua.com/posts/2016-04-24-hooking-up-jekyll-to-facebook-instant-articles/ Sun, 24 Apr 2016 10:57:56 +0800 https://dchua.com/posts/2016-04-24-hooking-up-jekyll-to-facebook-instant-articles/ Run a Jekyll site? Want to get into the whole Facebook Instant Articles Action? Prerequisite Install Jekyll Last Modified Plugin Plugin Install jekyll-last-modified-at gem by adding it onto your Gemfile or installing it into your system-wide gem. $ gem install jekyll-last-modified-at In your Jekyll site’s _config.yml file: # Add this under gems gems: - jekyll-last-modified-at Write your special RSS feed In /path/to/jekyll/feed/instant-articles.xml, copy the following snippet into it. Enjoy! Now when you access http://jekyll-site/feed/instant-articles. Installing pyenv - RVM for Python https://dchua.com/posts/2016-03-25-installing-pyenv-rvm-for-python/ Fri, 25 Mar 2016 11:02:06 +0800 https://dchua.com/posts/2016-03-25-installing-pyenv-rvm-for-python/ One of the things I’ve missed while learning python, is the ability to manage and switch between python versions. In Ruby, we often use tools like RVM or rbenv to handle the different ruby versions. This is particularly useful when you have projects that have to rely on an older version of ruby and you don’t want to mess up your local environment. In python, there’s pyenv. To set it up, its really quite simple. Debugging Redis and its Memory https://dchua.com/posts/2015-04-28-debugging-redis-and-its-memory/ Tue, 28 Apr 2015 00:00:00 +0000 https://dchua.com/posts/2015-04-28-debugging-redis-and-its-memory/ To determine the size of a key redis-cli> DEBUG OBJECT <keyname> Value at:0x7ffc8f8eb330 refcount:1 encoding:linkedlist serializedlength:1175841791 lru:416416 lru_seconds_idle:30 serializedlength is in bytes. To print out the size of each key in your redis-database Checkout this script To tweak Redis from overloading your memory Add vm.overcommit_memory = 1 to /etc/sysctl.conf and then reboot or run the command sysctl vm.overcommit_memory=1 for this to take effect immediately. To limit the size of your redis database # /etc/redis/redis. Carrierwave Fog - Need a local file? Use Cache! https://dchua.com/posts/2014-02-27-carrierwave-fog-need-a-local-file-use-cache-/ Thu, 27 Feb 2014 20:40:50 +0800 https://dchua.com/posts/2014-02-27-carrierwave-fog-need-a-local-file-use-cache-/ If you’re like me, using carrierwave + fog to hook up your Model witih Amazon S3, you may encounter this problem where you need to reprocess an image and you can’t do so without downloading the file locally. In my case, I need a to_file() method done on one of my assets but using Carrierwave/Fog(S3) and in order for that to happen the file needs to be a Carrierwave::SanitizedFile. So what can I do?