tips on davidchua https://dchua.com/tags/tips/ Recent content in tips on davidchua Hugo -- gohugo.io en-us Thu, 21 Jan 2016 00:00:00 +0000 4 Tips to Supercharge your Jekyll Static Site Hosting https://dchua.com/posts/2016-01-21-proper-jekyll-deployment-workflow-to-s3-static-hosting/ Thu, 21 Jan 2016 00:00:00 +0000 https://dchua.com/posts/2016-01-21-proper-jekyll-deployment-workflow-to-s3-static-hosting/ Supercharge your Jekyll site with these 4 tips. Put your Jekyll into a Git Repository One of the best part of being in a command-line environment is that you have the full power of the tools available to you by your OS environment. Why not make sure you never lose track of your blog posts and revisions by using the power and flexibility of Git. By committing your blog posts and changes as individual commits, you can easily revert back or track changes you make easily at your own convenience. 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. Sum up array contents with a simple method https://dchua.com/posts/2014-02-23-sum-up-array-contents-with-a-simple-method/ Sun, 23 Feb 2014 00:00:00 +0000 https://dchua.com/posts/2014-02-23-sum-up-array-contents-with-a-simple-method/ With just: array.inject(:+) It will take an array and sum it up. >> [0,2,3,1] >> [0,2,3,1].inject(:+) => 6 Add text to end of multiple line - vim https://dchua.com/posts/2014-01-26-add-text-to-end-of-multiple-line-vim/ Sun, 26 Jan 2014 12:21:39 +0800 https://dchua.com/posts/2014-01-26-add-text-to-end-of-multiple-line-vim/ Suppose you have a whole list of text: Movies Travel Fashion (Men) Fashion (Women) Education Technology Clubbing Nightlife Fine Dining Food E-Commerce Beauty Wellness Gaming Performing Arts Sports Books Music Photography Fitness Gadgets And you want to make the whole thing an array in ruby. How do you do it in vim, quickly? First, we need to give everyone quotation marks. Using surround.vim, do: Surround the entire text using Ctrl-V In vim, type: :norm yss " This will give every single line in the selection a "" like: Discover Wireless Devices with Avahi https://dchua.com/posts/2013-11-16-discover-wireless-devices-with-avahi/ Sat, 16 Nov 2013 00:00:00 +0000 https://dchua.com/posts/2013-11-16-discover-wireless-devices-with-avahi/ Quick protip: If you’re having trouble finding the ip addresses of your devices that is connected to your local area network. Use Avahi $ avahi-browse -alr This returns you a list of all the devices connected to your network with the corresponding ip address.