[{"content":"About Me Welcome to my personal website.\nThis is where I\u0026rsquo;ll share articles, photos, projects, and other interesting things.\n","permalink":"http://uly.me/about/","summary":"\u003ch1 id=\"about-me\"\u003eAbout Me\u003c/h1\u003e\n\u003cp\u003eWelcome to my personal website.\u003c/p\u003e\n\u003cp\u003eThis is where I\u0026rsquo;ll share articles, photos,\nprojects, and other interesting things.\u003c/p\u003e","title":"About"},{"content":"An Ansible script that makes multiple machines reservations in a GCP project based on machine type, zone and number of running instances.\nThe script \u0026hellip;\nCreates new reservations if it\u0026rsquo;s non-existent with count. Update an existing reservation by increasing or decreasing count. Delete a reservation if no instances are present or none are running. Print a summary at end of the script. ","permalink":"http://uly.me/posts/making-machine-reservations/","summary":"\u003cp\u003eAn Ansible script that makes multiple machines reservations in a GCP project based on machine type, zone and number of running instances.\u003c/p\u003e\n\u003cp\u003eThe script \u0026hellip;\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCreates new reservations if it\u0026rsquo;s non-existent with count.\u003c/li\u003e\n\u003cli\u003eUpdate an existing reservation by increasing or decreasing count.\u003c/li\u003e\n\u003cli\u003eDelete a reservation if no instances are present or none are running.\u003c/li\u003e\n\u003cli\u003ePrint a summary at end of the script.\u003c/li\u003e\n\u003c/ul\u003e","title":"making machine reservations"},{"content":"If you have a text file with multiple columns, you can use column to align the output vertically.\ncat output.txt | column -t ","permalink":"http://uly.me/posts/column-t/","summary":"\u003cp\u003eIf you have a text file with multiple columns, you can use column to align the output vertically.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat output.txt | column -t \n\u003c/code\u003e\u003c/pre\u003e","title":"column t"},{"content":"Here\u0026rsquo;s the script that will the dos2unix command recursively in the current directory.\nIt doesn\u0026rsquo;t have to be dos2unix but can be any command.\nRun it on all files.\nfind . -type f -exec dos2unix {} + Run it on all shell files only.\nfind . -type f -name \u0026#34;*.sh\u0026#34; -exec dos2unix {} + ","permalink":"http://uly.me/posts/run-command-recursively-directory/","summary":"\u003cp\u003eHere\u0026rsquo;s the script that will the dos2unix command recursively in the current directory.\u003c/p\u003e\n\u003cp\u003eIt doesn\u0026rsquo;t have to be dos2unix but can be any command.\u003c/p\u003e\n\u003cp\u003eRun it on all files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efind . -type f -exec dos2unix {} +\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun it on all shell files only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efind . -type f -name \u0026#34;*.sh\u0026#34; -exec dos2unix {} +\n\u003c/code\u003e\u003c/pre\u003e","title":"run command recursively directory"},{"content":"Here\u0026rsquo;s my $0.13 cent cloud bill.\nBack in the day, my cloud bill was anywhere between $10-20 per month because I was hosting a VM.\nI converted from WordPress site to Jekyll, a static site generator hosted for free at GitHub.\nMy photo gallery is hosted in AWS S3. I use node.js programs to generate the galleries.\nMy total bill this month is $0.13. It will climb a few cents as I upload more photos.\n","permalink":"http://uly.me/posts/13-cent-cloud-bill/","summary":"\u003cp\u003eHere\u0026rsquo;s my $0.13 cent cloud bill.\u003c/p\u003e\n\u003cp\u003eBack in the day, my cloud bill was anywhere between $10-20 per month because I was hosting a VM.\u003c/p\u003e\n\u003cp\u003eI converted from WordPress site to Jekyll, a static site generator hosted for free at GitHub.\u003c/p\u003e\n\u003cp\u003eMy photo gallery is hosted in AWS S3. I use node.js programs to generate the galleries.\u003c/p\u003e\n\u003cp\u003eMy total bill this month is $0.13. It will climb a few cents as I upload more photos.\u003c/p\u003e","title":"13 cent cloud bill"},{"content":"This is the command to display system memory in GB in Linux.\ngrep -E \u0026#39;MemTotal|MemAvailable\u0026#39; /proc/meminfo | awk \u0026#39;{printf \u0026#34;%s %.2f GB\\n\u0026#34;, $1, $2/1024^2}\u0026#39; ","permalink":"http://uly.me/posts/linux-gb-memory/","summary":"\u003cp\u003eThis is the command to display system memory in GB in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egrep -E \u0026#39;MemTotal|MemAvailable\u0026#39; /proc/meminfo | awk \u0026#39;{printf \u0026#34;%s %.2f GB\\n\u0026#34;, $1, $2/1024^2}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"linux gb memory"},{"content":"Here\u0026rsquo;s a nice little script that generates a random string.\nUser is asked to match the string. If there\u0026rsquo;s a match, it continues.\nIf there\u0026rsquo;s no match, it will exit.\nconfirm() { CHARNUM=6 CHARSET=\u0026#39;A-Za-z0-9\u0026#39; # Generate random string RANDOM_STRING=$(LC_ALL=C tr -dc $CHARSET \u0026lt;/dev/urandom | head -c $CHARNUM) printf \u0026#34;%s\\n\u0026#34; \u0026#34;Please confirm Code to continue: $RANDOM_STRING\u0026#34; read -r -p \u0026#34;Code: \u0026#34; USER_INPUT if [[ \u0026#34;$USER_INPUT\u0026#34; != \u0026#34;$RANDOM_STRING\u0026#34; ]]; then echo \u0026#34;❌ Code does not match! Exiting!\u0026#34; exit 1 fi echo \u0026#34;✅ Code matched!\u0026#34; echo \u0026#34;Shutting down server!\u0026#34; } ","permalink":"http://uly.me/posts/confirm-random-string/","summary":"\u003cp\u003eHere\u0026rsquo;s a nice little script that generates a random string.\u003c/p\u003e\n\u003cp\u003eUser is asked to match the string. If there\u0026rsquo;s a match, it continues.\u003c/p\u003e\n\u003cp\u003eIf there\u0026rsquo;s no match, it will exit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003econfirm() {\n  CHARNUM=6\n  CHARSET=\u0026#39;A-Za-z0-9\u0026#39;\n  # Generate random string\n  RANDOM_STRING=$(LC_ALL=C tr -dc $CHARSET \u0026lt;/dev/urandom | head -c $CHARNUM)\n  printf \u0026#34;%s\\n\u0026#34; \u0026#34;Please confirm Code to continue: $RANDOM_STRING\u0026#34;\n  read -r -p \u0026#34;Code: \u0026#34; USER_INPUT\n  if [[ \u0026#34;$USER_INPUT\u0026#34; != \u0026#34;$RANDOM_STRING\u0026#34; ]]; then\n    echo \u0026#34;❌ Code does not match! Exiting!\u0026#34;\n    exit 1\n  fi\n  echo \u0026#34;✅ Code matched!\u0026#34;\n  echo \u0026#34;Shutting down server!\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"confirm random string"},{"content":"Here\u0026rsquo;s my new git push script.\n#!/bin/bash comment=$1 if [[ -z $comment ]]; then echo \u0026#34;Usage: $0 \u0026#39;put your comment here\u0026#39;\u0026#34; exit fi git add . git commit -am \u0026#34;$comment\u0026#34; git push To use the script, simply execute ./gitPush.sh \u0026lsquo;put your git comment here\u0026rsquo;\nThe script will add, commit and push it to your remote repository.\n","permalink":"http://uly.me/posts/git-push-script/","summary":"\u003cp\u003eHere\u0026rsquo;s my new git push script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\ncomment=$1\nif [[ -z $comment ]]; then\n  echo \u0026#34;Usage: $0 \u0026#39;put your comment here\u0026#39;\u0026#34;\n  exit\nfi\n\ngit add .\ngit commit -am \u0026#34;$comment\u0026#34;\ngit push\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo use the script, simply execute ./gitPush.sh \u0026lsquo;put your git comment here\u0026rsquo;\u003c/p\u003e\n\u003cp\u003eThe script will add, commit and push it to your remote repository.\u003c/p\u003e","title":"git push script"},{"content":"I run Gitea on my desktop. Recently my desktop IP address changed.\nI should really set it to a static IP address, but that\u0026rsquo;s another story.\nDoing a git pull and a git push no longer works since the remote URL changed.\nTo update to a new remote location, simply run the command below.\ngit remote set-url origin http://192.168.68.105:3000/ulysses/scripts.git If you use SSH, use the SSH remote link instead of HTTP.\n","permalink":"http://uly.me/posts/git-remote-set-url/","summary":"\u003cp\u003eI run Gitea on my desktop. Recently my desktop IP address changed.\u003c/p\u003e\n\u003cp\u003eI should really set it to a static IP address, but that\u0026rsquo;s another story.\u003c/p\u003e\n\u003cp\u003eDoing a git pull and a git push no longer works since the remote URL changed.\u003c/p\u003e\n\u003cp\u003eTo update to a new remote location, simply run the command below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit remote set-url origin http://192.168.68.105:3000/ulysses/scripts.git\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you use SSH, use the SSH remote link instead of HTTP.\u003c/p\u003e","title":"git remote set url"},{"content":"Here\u0026rsquo;s a neat script that will edit crontab without creating duplicates.\n#!/usr/bin/env bash CRON_ENTRY=\u0026#34;0 2 * * * /path/to/script.sh\u0026#34; EXISTING=$(crontab -l 2\u0026gt;/dev/null || true) if ! echo \u0026#34;$EXISTING\u0026#34; | grep -Fxq \u0026#34;$CRON_ENTRY\u0026#34;; then printf \u0026#34;%s\\n%s\\n\u0026#34; \u0026#34;$EXISTING\u0026#34; \u0026#34;$CRON_ENTRY\u0026#34; | crontab - fi ","permalink":"http://uly.me/posts/editing-crontab-without-duplicates/","summary":"\u003cp\u003eHere\u0026rsquo;s a neat script that will edit crontab without creating duplicates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/usr/bin/env bash\n\nCRON_ENTRY=\u0026#34;0 2 * * * /path/to/script.sh\u0026#34;\n\nEXISTING=$(crontab -l 2\u0026gt;/dev/null || true)\n\nif ! echo \u0026#34;$EXISTING\u0026#34; | grep -Fxq \u0026#34;$CRON_ENTRY\u0026#34;; then\n  printf \u0026#34;%s\\n%s\\n\u0026#34; \u0026#34;$EXISTING\u0026#34; \u0026#34;$CRON_ENTRY\u0026#34; | crontab -\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"editing crontab without duplicates"},{"content":"Here are the baggage limits for international travel for the following airlines.\nBaggage Limits Delta Airlines Baggage Carry On Korean Airlines Baggage Carry On Philippine Airlines (domestic) Baggage Carry On ","permalink":"http://uly.me/posts/baggage-limits/","summary":"\u003cp\u003eHere are the baggage limits for international travel for the following airlines.\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003eBaggage Limits\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eDelta Airlines\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eBaggage\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCarry On\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKorean Airlines\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eBaggage\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCarry On\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003ePhilippine Airlines (domestic)\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eBaggage\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCarry On\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e","title":"baggage limits"},{"content":"Another potential fix to my keyboard freezing problem on Linux Mint 22.1 after going to sleep.\nEdit Grub.\nsudo vi /etc/default/grub Add i8042.dubkdbd=1 to the GRUB_CMDLINE_LINUX_DEFAULT.\nGRUB_CMDLINE_LINUX_DEFAULT=\u0026#34;usbcore.autosuspend=-1 quiet splash i8042.dumbkbd=1\u0026#34; Update Grub and reboot.\nsudo update-grub reboot Hopefully that fixes it.\n","permalink":"http://uly.me/posts/keyboard-freeze/","summary":"\u003cp\u003eAnother potential fix to my keyboard freezing problem on Linux Mint 22.1 after going to sleep.\u003c/p\u003e\n\u003cp\u003eEdit Grub.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo vi /etc/default/grub\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd i8042.dubkdbd=1 to the GRUB_CMDLINE_LINUX_DEFAULT.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eGRUB_CMDLINE_LINUX_DEFAULT=\u0026#34;usbcore.autosuspend=-1 quiet splash i8042.dumbkbd=1\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUpdate Grub and reboot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo update-grub\nreboot\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHopefully that fixes it.\u003c/p\u003e","title":"keyboard freeze"},{"content":"Here\u0026rsquo;s a couple of USB command line tools if you having issues with your USB peripherals.\nlsusb xinput I have issues with my keyboard and this helps.\n","permalink":"http://uly.me/posts/usb-commands/","summary":"\u003cp\u003eHere\u0026rsquo;s a couple of USB command line tools if you having issues with your USB peripherals.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsusb\nxinput\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI have issues with my keyboard and this helps.\u003c/p\u003e","title":"usb commands"},{"content":"I use a single keyboard between 2 computer systems (MacOS and Linux). I disconnect my USB keyboard on one system and plug it to another whenever I switch computers. When my keyboard is disconnected from Linux for a very long time, the system no longer recognizes the keyboard when I plugged it back in unless I reboot the system. After a little bit of a research, I found a potential solution to the issue. Essentially the fix is to disable the USB autosuspend option which will need to be added to grub.\nHere are the steps:\nsudo sed -i \u0026#39;s/GRUB_CMDLINE_LINUX_DEFAULT=\u0026#34;/\u0026amp;usbcore.autosuspend=-1 /\u0026#39; /etc/default/grub sudo update-grub sudo systemctl reboot Hopefully it fixes the issue.\n","permalink":"http://uly.me/posts/disable-usb-autosuspend/","summary":"\u003cp\u003eI use a single keyboard between 2 computer systems (MacOS and Linux). I disconnect my USB keyboard on one system and plug it to another whenever I switch computers. When my keyboard is disconnected from Linux for a very long time, the system no longer recognizes the keyboard when I plugged it back in unless I reboot the system. After a little bit of a research, I found a potential solution to the issue. Essentially the fix is to disable the USB autosuspend option which will need to be added to grub.\u003c/p\u003e","title":"disable usb autosuspend"},{"content":"tmux controls\n| leader key | ` | | switching windows | | move to left window | shift + left arrow | | move to right window | shift + right arrow | | swapping windows | | swap windows to left | ctrl + shift + left | | swap window to right | ctrl + shift + right | | switching panes | | move to next pane | leader o | | move between panes | leader left, leader right, leader up or leader down | | delete pane | leader x | | sync \u0026amp; unsync panes | | sync \u0026amp; unsync panes | leader y | | convert pane into window | leader ! | | reload configuration | | reload tmux config | leader r |\n","permalink":"http://uly.me/posts/tmux-controls/","summary":"\u003cp\u003etmux controls\u003c/p\u003e\n\u003cp\u003e| leader key | ` |\n| switching windows |\n| move to left window | shift + left arrow |\n| move to right window | shift + right arrow |\n| swapping windows |\n| swap windows to left | ctrl + shift + left |\n| swap window to right | ctrl + shift + right |\n| switching panes |\n| move to next pane | leader o |\n| move between panes | leader left, leader right, leader up or leader down |\n| delete pane | leader x |\n| sync \u0026amp; unsync panes |\n| sync \u0026amp; unsync panes | leader y |\n| convert pane into window | leader ! |\n| reload configuration |\n| reload tmux config | leader r |\u003c/p\u003e","title":"tmux controls"},{"content":"The last year or so, I have been using different tools on my terminal.\nIt started with the oh-my-posh prompt, then I switched to using tmux.\nNow I\u0026rsquo;m messing around with lazyVim editor which is a tweak of neovim.\nSo, here\u0026rsquo;s my configuration so far.\nTool Program Terminal Tmux Prompt Oh My Posh Editor Neovim (LazyVim) I still use VSCode, but it\u0026rsquo;s less and less.\nLazyVim still has many plugins to explore.\nStay tuned.\n","permalink":"http://uly.me/posts/terminal-configuration/","summary":"\u003cp\u003eThe last year or so, I have been using different tools on my terminal.\u003c/p\u003e\n\u003cp\u003eIt started with the oh-my-posh prompt, then I switched to using tmux.\u003c/p\u003e\n\u003cp\u003eNow I\u0026rsquo;m messing around with lazyVim editor which is a tweak of neovim.\u003c/p\u003e\n\u003cp\u003eSo, here\u0026rsquo;s my configuration so far.\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth style=\"text-align: left\"\u003eTool\u003c/th\u003e\n\t\t\t\t\t\u003cth style=\"text-align: left\"\u003eProgram\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eTerminal\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eTmux\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003ePrompt\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eOh My Posh\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eEditor\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eNeovim (LazyVim)\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eI still use VSCode, but it\u0026rsquo;s less and less.\u003c/p\u003e\n\u003cp\u003eLazyVim still has many plugins to explore.\u003c/p\u003e","title":"terminal configuration"},{"content":"How to comment multiple lines in nvim.\nGo to the first line you want to start to comment. Place cursor at the beginning. Enter Visual Block mode by pressing Ctrl+v. Use arrow keys or j to select multiple lines. Shift+I to enter insert mode. Choose a character (#) to use. Esc to comment multiple lines. Ctrl+v Use cursor or j Shift+I # Esc To uncomment\nPlace cursor on the first comment. Enter Visual Block or Ctrl+v. Select columns using cursor or j,k. Press x or d to delete on selected lines. Ctrl+v Use cursor or j x or d ","permalink":"http://uly.me/posts/comment-multiple-lines/","summary":"\u003cp\u003eHow to comment multiple lines in nvim.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eGo to the first line you want to start to comment. Place cursor at the beginning.\u003c/li\u003e\n\u003cli\u003eEnter Visual Block mode by pressing Ctrl+v.\u003c/li\u003e\n\u003cli\u003eUse arrow keys or j to select multiple lines.\u003c/li\u003e\n\u003cli\u003eShift+I to enter insert mode.\u003c/li\u003e\n\u003cli\u003eChoose a character (#) to use.\u003c/li\u003e\n\u003cli\u003eEsc to comment multiple lines.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCtrl+v\nUse cursor or j\nShift+I\n#\nEsc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo uncomment\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003ePlace cursor on the first comment.\u003c/li\u003e\n\u003cli\u003eEnter Visual Block or Ctrl+v.\u003c/li\u003e\n\u003cli\u003eSelect columns using cursor or j,k.\u003c/li\u003e\n\u003cli\u003ePress x or d to delete on selected lines.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCtrl+v\nUse cursor or j\nx or d\n\u003c/code\u003e\u003c/pre\u003e","title":"comment multiple lines"},{"content":"How to copy and paste in vim or nvim.\nLet\u0026rsquo;s say you have 10 rows of code that you want to copy somewhere else like at the bottom of your code.\nPress Esc to enter Normal mode. Move the cursor to the first line. Enter Visual Line mode. Shift+V. Move cursor or letter j or k. Press y to yank the selected lines. Move the cursor to your target location. Press p to paste after the current line. Or P to paste before the current line. Esc Move cursor Shift+V Move cursor y Move cursor p or P u If you want to undo, press u.\n","permalink":"http://uly.me/posts/copy-paste-nvim/","summary":"\u003cp\u003eHow to copy and paste in vim or nvim.\u003c/p\u003e\n\u003cp\u003eLet\u0026rsquo;s say you have 10 rows of code that you want to copy somewhere else like at the bottom of your code.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003ePress Esc to enter Normal mode.\u003c/li\u003e\n\u003cli\u003eMove the cursor to the first line.\u003c/li\u003e\n\u003cli\u003eEnter Visual Line mode. Shift+V.\u003c/li\u003e\n\u003cli\u003eMove cursor or letter j or k.\u003c/li\u003e\n\u003cli\u003ePress y to yank the selected lines.\u003c/li\u003e\n\u003cli\u003eMove the cursor to your target location.\u003c/li\u003e\n\u003cli\u003ePress p to paste after the current line.\u003c/li\u003e\n\u003cli\u003eOr P to paste before the current line.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eEsc\nMove cursor\nShift+V\nMove cursor\ny\nMove cursor\np or P\nu\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want to undo, press u.\u003c/p\u003e","title":"copy paste nvim"},{"content":"Run your node script from anywhere by switching to a specific directory by changing to a working directory.\nPlace this code at the top of your node script.\n#!/usr/bin/env node process.chdir(\u0026#39;/absolute/path/to/your/directory\u0026#39;); console.log(\u0026#39;Now running in:\u0026#39;, process.cwd()); In addition, you can also add your node directory to your PATH so you can run it anywhere.\nexport PATH=$PATH:/absolute/path/to/your/directory If you want it to be more permanent, add the export command to your ~/.bashrc in Linux or ~/.zshrc on a Mac.\n","permalink":"http://uly.me/posts/run-node-anywhere/","summary":"\u003cp\u003eRun your node script from anywhere by switching to a specific directory by changing to a working directory.\u003c/p\u003e\n\u003cp\u003ePlace this code at the top of your node script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/usr/bin/env node \n\nprocess.chdir(\u0026#39;/absolute/path/to/your/directory\u0026#39;);\nconsole.log(\u0026#39;Now running in:\u0026#39;, process.cwd());\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn addition, you can also add your node directory to your PATH so you can run it anywhere.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport PATH=$PATH:/absolute/path/to/your/directory\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want it to be more permanent, add the export command to your ~/.bashrc in Linux or ~/.zshrc on a Mac.\u003c/p\u003e","title":"run node anywhere"},{"content":"Feeding the sourdough starter (the beast).\nTake out 80% of the starter and throw it away or use it on other breads.\nAdd 50 grams of flour to the starter.\nAdd 50 grams of filtered water to the starter.\nMix it thoroughly for 30 seconds or so.\nPlace in the fridge until the next feeding or use.\nFeed your starter at least once a week.\n","permalink":"http://uly.me/posts/feeding-the-starter/","summary":"\u003cp\u003eFeeding the sourdough starter (the beast).\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003e\n\u003cp\u003eTake out 80% of the starter and throw it away or use it on other breads.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAdd 50 grams of flour to the starter.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAdd 50 grams of filtered water to the starter.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eMix it thoroughly for 30 seconds or so.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003ePlace in the fridge until the next feeding or use.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eFeed your starter at least once a week.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e","title":"feeding the starter"},{"content":"Beginner\u0026rsquo;s Sourdough\nIngredients\n50g of bubbly active starter 350g of filtered water 500g of unbleached all-purpose flour 10g fine salt (1) Make the dough.\nWe’re going to use a mixer to mix our dough.\nAdd flour to the mixing bowl.\nAdd water to the mixing bowl.\nSet mixer to level 2 and mix for 2 minutes.\nAfter mix, let it rest for 30 minutes.\nAdd salt to the mix.\nAdd starter to the mix.\nSet mixer to level 2 and mix for 5 minutes.\nAfter mix, let it rest for 30 minutes.\n(2) Stretch and Fold (3 times)\nAfter dough has rested Wet hands to prevent dough from sticking. Remove dough from mixer and place it on mat. Grab the right side and stretch it, fold it over to the left, and over the dough. Grab the left side and stretch it, fold it over to the left, and over the dough. Grab the top side and stretch it, fold it down over the dough. Place the dough in a glass bowl. Let it rest for 30 minutes Repeat 3 times (3) Bulk Ferment\nCover the bowl with a damp towel Let it rise overnight for 8-10 hours at 70 F The dough is ready when it no longer looks dense and doubled in size (4) Pre-shape\nCoax the dough in a lightly floured work surface Grab the far right of the dough and fold over to cover 2/3 of the dough. Grab the left side of the dough and fold over to the remaining dough. Grab the bottom edge of the dough and roll up until you have a ball of dough with a smooth top. After shaping, gently cup and pull it towards you in a circular motion to tighten its shape. Set the dough aside and let it rest for 15-30 minutes. (5) Final Shape\nLine your proofing basket with a cheesecloth towel or lightly dust with flour. With floured hands, flip the dough over and shape it again. After shaping, gently cup it and pull toward in a circular motion to tighten its shape. Lightly flour the top and flip the dough into the bowl. Seam side up. (6) Second Rise\nCover the bowl and let it rest for 1-2 hours The dough is ready when it looks puffy and has risen slightly at about 30%. Optional (Most recommended)\nPlace the dough in the fridge for a cold proof. The dough can be kept in the fridge for up to 2-3 days before baking. Always do a cold proof. (7) Preheat\nPreheat your oven to 425F for at least 45 minutes. Place your dutch oven in the oven while preheating. Cut a sheet of parchment paper to fit the size of the baking pot leaving excess around the sides. (8) Score\nOnce your oven is preheated, place the parchment paper over the dough and invert bowl to release. Using the tip of the serrated knife, score the dough with and expansion core. Use fun score pattern for optional decorative score. Use the parchment paper to transfer the dough to the baking pot. (9) Bake\nBake the dough in the center rack for 20 minutes. It’s important to keep the lid on for the first 20 minutes so the water inside creates steam. The steam helps create the signature artisan crust of the sourdough bread. After 20 minutes, remove the lid, and continue to bake for 25-30 minutes until golden brown. Transfer bread to a wire rack and it cool for 1-2 hours before slicing. (10) Enjoy\nToast a slice of sourdough bread. Add butter and jelly spread if you like. Enjoy with a cup of cappuccino coffee. ","permalink":"http://uly.me/posts/sourdough-bread/","summary":"\u003cp\u003eBeginner\u0026rsquo;s Sourdough\u003c/p\u003e\n\u003cp\u003eIngredients\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e50g of bubbly active starter\u003c/li\u003e\n\u003cli\u003e350g of filtered water\u003c/li\u003e\n\u003cli\u003e500g of unbleached all-purpose flour\u003c/li\u003e\n\u003cli\u003e10g fine salt\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e(1) Make the dough.\u003c/p\u003e\n\u003cp\u003eWe’re going to use a mixer to mix our dough.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eAdd flour to the mixing bowl.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAdd water to the mixing bowl.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eSet mixer to level 2 and mix for 2 minutes.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAfter mix, let it rest for 30 minutes.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAdd salt to the mix.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAdd starter to the mix.\u003c/p\u003e","title":"sourdough bread"},{"content":"If you want to host Git repositories on your desktop or server, then give Gitea a try.\nCreate a new directory.\nmkdir gitea cd gitea To install, just use Docker Compose to keep it simple.\nCreate a docker-compose.yml file and add the following code below.\nnetworks: gitea: external: false services: server: image: docker.gitea.com/gitea:1.25.3 container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 restart: always networks: - gitea volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - \u0026#34;3000:3000\u0026#34; - \u0026#34;222:22\u0026#34; Start Gitea. You will be asked to create a new Gitea account and password.\ndocker compose up -d Once Gitea is up and running, access it using a web browser via link below.\nhttp://localhost:3000 If you have a port conflict, you can modify the port to another.\nCreate a new repository. Clone it or perform a remote add origin.\n","permalink":"http://uly.me/posts/gitea/","summary":"\u003cp\u003eIf you want to host Git repositories on your desktop or server, then give Gitea a try.\u003c/p\u003e\n\u003cp\u003eCreate a new directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir gitea\ncd gitea\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo install, just use Docker Compose to keep it simple.\u003c/p\u003e\n\u003cp\u003eCreate a docker-compose.yml file and add the following code below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enetworks:\n  gitea:\n    external: false\n\nservices:\n  server:\n    image: docker.gitea.com/gitea:1.25.3\n    container_name: gitea\n    environment:\n      - USER_UID=1000\n      - USER_GID=1000\n    restart: always\n    networks:\n      - gitea\n    volumes:\n      - ./gitea:/data\n      - /etc/timezone:/etc/timezone:ro\n      - /etc/localtime:/etc/localtime:ro\n    ports:\n      - \u0026#34;3000:3000\u0026#34;\n      - \u0026#34;222:22\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart Gitea. You will be asked to create a new Gitea account and password.\u003c/p\u003e","title":"gitea"},{"content":"Here\u0026rsquo;s another great Terminal or CLI tool for navigating files and directories.\nTo install, just use your package manager. In this case, it\u0026rsquo;s apt.\napt install yazi brew install yazi To run, just type yazi.\n$ yazi If text is not readable, search online for catppuccin yazi theme.\nDownload the file and paste it to ~/.config/yazi/theme.toml.\nmkdir ~/.config/yazi touch ~/.config/yazi/theme.toml vi ~/.config/yazi/theme.toml Rerun yazi. The new theme should be activated.\n$ yazi ","permalink":"http://uly.me/posts/yazi-file-manager/","summary":"\u003cp\u003eHere\u0026rsquo;s another great Terminal or CLI tool for navigating files and directories.\u003c/p\u003e\n\u003cp\u003eTo install, just use your package manager. In this case, it\u0026rsquo;s apt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install yazi\nbrew install yazi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo run, just type yazi.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ yazi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf text is not readable, search online for catppuccin yazi theme.\u003c/p\u003e\n\u003cp\u003eDownload the file and paste it to ~/.config/yazi/theme.toml.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir ~/.config/yazi\ntouch ~/.config/yazi/theme.toml\nvi ~/.config/yazi/theme.toml\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRerun yazi. The new theme should be activated.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ yazi\n\u003c/code\u003e\u003c/pre\u003e","title":"yazi file manager"},{"content":"Convert is an awesome program.\nHere\u0026rsquo;s another way of converting JPG to PDF.\nconvert input.jpg output.pdf If you don\u0026rsquo;t have it installed, run:\napt install imagemagick Just run convert thereafter.\nThat is all.\n","permalink":"http://uly.me/posts/convert-jpg-pdf/","summary":"\u003cp\u003eConvert is an awesome program.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s another way of converting JPG to PDF.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003econvert input.jpg output.pdf\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you don\u0026rsquo;t have it installed, run:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install imagemagick\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eJust run convert thereafter.\u003c/p\u003e\n\u003cp\u003eThat is all.\u003c/p\u003e","title":"convert jpg pdf"},{"content":"If you like hosting a photo gallery on your own desktop or server, give Immich a try.\nI installed mine on my Linux Mint desktop using docker compose.\n(1). Create a directory.\nmkdir immich; cd immich (2). Download a couple of files.\nwget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env (3). Customize the .env file with your custom values.\nUPLOAD_LOCATION= DB_DATA_LOCATION= DB_PASSWORD= (4). Start the container.\ndocker compose up -d (5). Finally, access the gallery from your browser.\nhttp://localhost:2283 # or via ip address http://xxx.xxx.xxx.xxx:2283 ","permalink":"http://uly.me/posts/immich-gallery/","summary":"\u003cp\u003eIf you like hosting a photo gallery on your own desktop or server, give Immich a try.\u003c/p\u003e\n\u003cp\u003eI installed mine on my Linux Mint desktop using docker compose.\u003c/p\u003e\n\u003cp\u003e(1). Create a directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir immich; cd immich\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(2). Download a couple of files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml\nwget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(3). Customize the .env file with your custom values.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eUPLOAD_LOCATION=\nDB_DATA_LOCATION=\nDB_PASSWORD=\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(4). Start the container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker compose up -d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(5). Finally, access the gallery from your browser.\u003c/p\u003e","title":"immich gallery"},{"content":"Portainer is an enterpise container management platform to deploy, troubleshoot and secure Kubernetes, Docker and Podman environments.\nI run several containers using docker-compose. I was curious installing Portainer to see if there\u0026rsquo;s any value to this tool.\nI\u0026rsquo;m using docker-compose again to install Portainer.\n(1). Setup Portainer\nmkdir ~/code/docker/portainer cd ~/code/docker/portainer vi docker-compose.yml (2). Paste content into docker-compose.yml file.\nversion: \u0026#34;3\u0026#34; services: portainer: image: portainer/portainer-ce:latest container_name: portainer ports: - 9000:9000 volumes: - portainer_data:/data - /var/run/docker.sock:/var/run/docker.sock restart: unless-stopped volumes: portainer_data: (3). Run Portainer.\ndocker-compose up -d (4). Open your browser and open the web interface on port 9000.\n","permalink":"http://uly.me/posts/portainer/","summary":"\u003cp\u003ePortainer is an enterpise container management platform to deploy, troubleshoot and secure Kubernetes, Docker and Podman environments.\u003c/p\u003e\n\u003cp\u003eI run several containers using docker-compose. I was curious installing Portainer to see if there\u0026rsquo;s any value to this tool.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m using docker-compose again to install Portainer.\u003c/p\u003e\n\u003cp\u003e(1). Setup Portainer\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir ~/code/docker/portainer\ncd ~/code/docker/portainer\nvi docker-compose.yml\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(2). Paste content into docker-compose.yml file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eversion: \u0026#34;3\u0026#34;\nservices:\n  portainer:\n    image: portainer/portainer-ce:latest\n    container_name: portainer\n    ports:\n      - 9000:9000\n    volumes:\n      - portainer_data:/data\n      - /var/run/docker.sock:/var/run/docker.sock\n    restart: unless-stopped\nvolumes:\n  portainer_data:\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e(3). Run Portainer.\u003c/p\u003e","title":"portainer"},{"content":"There are times you need to get a list of subdirectories in Shell/Bash.\nHere\u0026rsquo;s a simple script that reads a certain directory and then lists then.\n# Function to get subdirectories in a given directory get_subdirectories() { dir=\u0026#34;/home/ulysses/code11\u0026#34; # Initialize an empty array to store subdirectories local subdirectories=() # Check if the given path is a directory if [ -d \u0026#34;$dir\u0026#34; ]; then # Loop through the contents of the directory for item in \u0026#34;$dir\u0026#34;/*; do # Check if the item is a directory if [ -d \u0026#34;$item\u0026#34; ]; then subdirectories+=(\u0026#34;$item\u0026#34;) fi done else # not a valid directory return 1 fi # Return the array of subdirectories echo \u0026#34;${subdirectories[@]}\u0026#34; } # Example usage subdirs=$(get_subdirectories) if [[ $? -eq 0 ]]; then for source_dir in $subdirs; do srcDir=$(basename \u0026#34;$source_dir\u0026#34;) echo $srcDir done else echo \u0026#34;The path is not a valid directory.\u0026#34; fi The script checks if directory is available or mounted. List subdirectories on directory that\u0026rsquo;s given. ","permalink":"http://uly.me/posts/list-directories-bash/","summary":"\u003cp\u003eThere are times you need to get a list of subdirectories in Shell/Bash.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s a simple script that reads a certain directory and then lists then.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Function to get subdirectories in a given directory\nget_subdirectories() {\n  dir=\u0026#34;/home/ulysses/code11\u0026#34;\n  # Initialize an empty array to store subdirectories\n  local subdirectories=()\n  # Check if the given path is a directory\n  if [ -d \u0026#34;$dir\u0026#34; ]; then\n    # Loop through the contents of the directory\n    for item in \u0026#34;$dir\u0026#34;/*; do\n      # Check if the item is a directory\n      if [ -d \u0026#34;$item\u0026#34; ]; then\n        subdirectories+=(\u0026#34;$item\u0026#34;)\n      fi\n    done\n  else\n    # not a valid directory\n    return 1\n  fi\n  # Return the array of subdirectories\n  echo \u0026#34;${subdirectories[@]}\u0026#34;\n}\n\n# Example usage\nsubdirs=$(get_subdirectories)\n\nif [[ $? -eq 0 ]]; then\n  for source_dir in $subdirs; do\n    srcDir=$(basename \u0026#34;$source_dir\u0026#34;)\n    echo $srcDir\n  done\nelse\n  echo \u0026#34;The path is not a valid directory.\u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003col\u003e\n\u003cli\u003eThe script checks if directory is available or mounted.\u003c/li\u003e\n\u003cli\u003eList subdirectories on directory that\u0026rsquo;s given.\u003c/li\u003e\n\u003c/ol\u003e","title":"list directories bash"},{"content":"Ever since Microsoft acquired Github, many developers are re-evaluating their use of GitHub.\nReasons why developers are leaving GitHub.\nOpposition to AI practices. Major point of contention is GitHub\u0026rsquo;s use of public code to train AI models like Copilot. Risk of Single-Point Control. GitHub has been known to unilaterally ban repositories or accounts at any time. Performance and UI Issues. Users report that GitHub\u0026rsquo;s web interface has become slow, resource-hungry and requires JavaScript. Intrusive Community Management. The platform is criticized for constantly pushing new, often unwanted features, etc. Inadequate Community Management. Project maintainers find GitHub\u0026rsquo;s tools insufficient for managing large communities. Reasons why developers are moving to Codeberg.\nIt\u0026rsquo;s non-profit and community-driven. Future and direction are determined by members through a democratic voting process. It\u0026rsquo;s privacy-friendly and ethical. The platform does not engage in user tracking, third-party cookies, or selling your data. It\u0026rsquo;s build on FOSS (free and open source software) specifically the Forgejo platform which is a fork of Gitea. No vendor lock-in. By using a self-hosting platform like Forgejo, users avoid lock-in to proprietary ecosystems. Simple and focused interface. Many users find Codeberg\u0026rsquo;s interface more minimal and less cluttered than other platforms. European Digital Sovereignty. Codeberg operates under EU data protection regulations which is significantly prioritizes privacy. Integrated Services. Codeberg offers other FOSS-based services like static website hosting, CI/CD using Woodpecker and CI/Forgejo Actions. Mission Alignment. For many using Codeberg is an ethical choice to support and contribute to the open-source ecosystem. Less Scrutiny. Some users report that the atmosphere feels more freeing with less pressure on larger and more visible platforms. ","permalink":"http://uly.me/posts/reasons-for-leaving-github/","summary":"\u003cp\u003eEver since Microsoft acquired Github, many developers are re-evaluating their use of GitHub.\u003c/p\u003e\n\u003cp\u003eReasons why developers are leaving \u003ca href=\"https://github.com\"\u003eGitHub\u003c/a\u003e.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eOpposition to AI practices. Major point of contention is GitHub\u0026rsquo;s use of public code to train AI models like Copilot.\u003c/li\u003e\n\u003cli\u003eRisk of Single-Point Control. GitHub has been known to unilaterally ban repositories or accounts at any time.\u003c/li\u003e\n\u003cli\u003ePerformance and UI Issues. Users report that GitHub\u0026rsquo;s web interface has become slow, resource-hungry and requires JavaScript.\u003c/li\u003e\n\u003cli\u003eIntrusive Community Management. The platform is criticized for constantly pushing new, often unwanted features, etc.\u003c/li\u003e\n\u003cli\u003eInadequate Community Management. Project maintainers find GitHub\u0026rsquo;s tools insufficient for managing large communities.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eReasons why developers are moving to \u003ca href=\"https://codeberg.org\"\u003eCodeberg\u003c/a\u003e.\u003c/p\u003e","title":"reasons for leaving github"},{"content":"If you find yourself scratching your head as to why your Jekyll site is not working, pay attention to the errors when you run \u0026lsquo;build.\u0026rsquo;\nMost likely the errors you see will give you clues to what\u0026rsquo;s going on during the rebuild. In my case it was a simple CSS error.\nIt is surprising that a small syntax CSS error can bring down Jekyll.\nPerform the following steps to troubleshoot your Jekyll site.\n(1) Check if docker container is running. If it\u0026rsquo;s restarting every 5 seconds, then there\u0026rsquo;s definitely a problem.\ndocker ps -a (2) Stop the container.\ndocker-compose stop (3) Rebuild Jekyll.\ndocker-compose up --build (4) Check for errors. They are usually highlighted in red.\n(5) Once you fixed the errors, restart Jekyll.\ndocker stop ulyme_jekyll_1 docker rm ulyme_jekyll_1 docker-compose up -d Hopefully, you\u0026rsquo;ll find this helpful.\n","permalink":"http://uly.me/posts/troubleshooting-jekyll/","summary":"\u003cp\u003eIf you find yourself scratching your head as to why your Jekyll site is not working, pay attention to the errors when you run \u0026lsquo;build.\u0026rsquo;\u003c/p\u003e\n\u003cp\u003eMost likely the errors you see will give you clues to what\u0026rsquo;s going on during the rebuild. In my case it was a simple CSS error.\u003c/p\u003e\n\u003cp\u003eIt is surprising that a small syntax CSS error can bring down Jekyll.\u003c/p\u003e\n\u003cp\u003ePerform the following steps to troubleshoot your Jekyll site.\u003c/p\u003e","title":"troubleshooting jekyll"},{"content":"Here are just a few quality choices between $100-$600 range.\nManufacturer Features TLB Mallorca Goodyear welted, refined craftmanship Bridlen Goodyear welted, box calf full grain leather Blkbrd Hand-welted footwear, artisan craftmanship Meermin Goodyear welted, elegance and versatility CNES Hand-welted crafted shoes Skolyx Goodyear welted, box calf full grain leather These are legacy shoes - which were once the standard, but quality is no longer the same as it once was.\nJohnston \u0026amp; Murphy Beckett Simonon Allen Edmonds Florsheim Alden Enjoy.\n","permalink":"http://uly.me/posts/best-dress-shoes/","summary":"\u003cp\u003eHere are just a few quality choices between $100-$600 range.\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003eManufacturer\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eFeatures\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://www.tlbmallorca.com/\"\u003eTLB Mallorca\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eGoodyear welted, refined craftmanship\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://bridlen.com/\"\u003eBridlen\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eGoodyear welted, box calf full grain leather\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://us.blkbrdshoemaker.com/collections/oxfords\"\u003eBlkbrd\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eHand-welted footwear, artisan craftmanship\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://meermin.com/collections/mens-oxfords\"\u003eMeermin\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eGoodyear welted, elegance and versatility\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://cnes.co\"\u003eCNES\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eHand-welted crafted shoes\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://www.skolyx.com/c/shoes/oxfords\"\u003eSkolyx\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eGoodyear welted, box calf full grain leather\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eThese are legacy shoes - which were once the standard, but quality is no longer the same as it once was.\u003c/p\u003e","title":"best dress shoes"},{"content":"There\u0026rsquo;s a command to close a browser tab or window from zsh on a Mac OS.\nYou have to specify which browser you\u0026rsquo;re using.\nAs well as the current URL of the tab.\nosascript -e \u0026#39;tell application \u0026#34;Google Chrome\u0026#34; to close (tabs of windows whose URL contains \u0026#34;uly.me\u0026#34;)\u0026#39; Give it a try.\n","permalink":"http://uly.me/posts/close-browser-from-zsh/","summary":"\u003cp\u003eThere\u0026rsquo;s a command to close a browser tab or window from zsh on a Mac OS.\u003c/p\u003e\n\u003cp\u003eYou have to specify which browser you\u0026rsquo;re using.\u003c/p\u003e\n\u003cp\u003eAs well as the current URL of the tab.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eosascript -e \u0026#39;tell application \u0026#34;Google Chrome\u0026#34; to close (tabs of windows whose URL contains \u0026#34;uly.me\u0026#34;)\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGive it a try.\u003c/p\u003e","title":"close browser from zsh"},{"content":"I recently added snowfall on this site with some help from Javascript.\nYou can download snowstorm.js from online.\nJust add the lines to your HTML template.\n\u0026lt;script src=\u0026#34;/snowstorm.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script\u0026gt; ``` snowStorm.snowColor = \u0026#39;#ffffff\u0026#39;; // white snow snowStorm.flakesMaxActive = 50; // show more snow on screen at once snowStorm.useTwinkleEffect = true; // let the snow flicker in and out of view \u0026lt;/script\u0026gt; Lastly, you can modify the options and tailor it to your site.\nOff you go.\n","permalink":"http://uly.me/posts/let-it-snow/","summary":"\u003cp\u003eI recently added snowfall on this site with some help from Javascript.\u003c/p\u003e\n\u003cp\u003eYou can \u003ca href=\"https://www.schillmania.com/projects/snowstorm/\"\u003edownload snowstorm.js\u003c/a\u003e from online.\u003c/p\u003e\n\u003cp\u003eJust add the lines to your HTML template.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;script src=\u0026#34;/snowstorm.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;                                             \n\u0026lt;script\u0026gt;                                                                          ```\nsnowStorm.snowColor = \u0026#39;#ffffff\u0026#39;;   // white snow                                  \nsnowStorm.flakesMaxActive = 50;    // show more snow on screen at once            \nsnowStorm.useTwinkleEffect = true; // let the snow flicker in and out of view     \n\u0026lt;/script\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLastly, you can modify the options and tailor it to your site.\u003c/p\u003e","title":"let it snow"},{"content":"I\u0026rsquo;ve been using Openshot video editor to edit or stitch video files.\nWhen exporting to the H.264 format, I\u0026rsquo;ve been getting a black screen.\nI tried other formats, but it\u0026rsquo;s working only with theora ogg format.\nUntil I find a fix, I may have to use HandBrake to convert ogg to mp4.\nThe theora ogg export is super slow. I think I\u0026rsquo;m have missing codecs.\nUpdate: I was able to fix it. I reinstalled openshot-qt via ppa.\nHere are the steps:\nUninstall openshot-qt sudo apt purge openshot-qt Install missing codecs sudo apt install libx264-dev libmp3lame-dev Install openshot-qt via ppa sudo add-apt-repository ppa:openshot.developers/ppa sudo apt update sudo apt install openshot-qt python3-openshot After reinstalling, I\u0026rsquo;m now able to export to a mp4 format successfully.\nNo more black screen. However, the exported mp4 file is 1400MB.\nI ran it through HandBrake on Fast 720p30. It\u0026rsquo;s down to 105MB.\nThat is all.\n","permalink":"http://uly.me/posts/openshot-black-screen/","summary":"\u003cp\u003eI\u0026rsquo;ve been using Openshot video editor to edit or stitch video files.\u003c/p\u003e\n\u003cp\u003eWhen exporting to the H.264 format, I\u0026rsquo;ve been getting a black screen.\u003c/p\u003e\n\u003cp\u003eI tried other formats, but it\u0026rsquo;s working only with theora ogg format.\u003c/p\u003e\n\u003cp\u003eUntil I find a fix, I may have to use HandBrake to convert ogg to mp4.\u003c/p\u003e\n\u003cp\u003eThe theora ogg export is super slow. I think I\u0026rsquo;m have missing codecs.\u003c/p\u003e\n\u003cp\u003eUpdate: I was able to fix it. I reinstalled openshot-qt via ppa.\u003c/p\u003e","title":"openshot black screen"},{"content":"Code-server runs Visual Studio Code (VS Code) on a remote server making it accessible via a web browser.\nI use docker-compose to host code-server on a container.\nHere\u0026rsquo;s my docker-compose.yml.\nservices: code-server: image: lscr.io/linuxserver/code-server:latest container_name: code-server environment: - PUID=1000 - PGID=1000 - TZ=Etc/UTC - PASSWORD=xxxxxxxx #optional - HASHED_PASSWORD= #optional - SUDO_PASSWORD=xxxxxxxx #optional - SUDO_PASSWORD_HASH= #optional - PROXY_DOMAIN=code-server.my.domain #optional - DEFAULT_WORKSPACE=/config/workspace #optional - PWA_APPNAME=code-server #optional volumes: - /home/ulysses/Code:/config ports: - 8443:8443 restart: unless-stopped There are a few things that are optional and can be skipped.\nBring it up.\ndocker-compose up -d Access the code-server from a browser.\nhttp://localhost:8443 # OR http://192.168.168.10:8443 It looks just like VSCode, but only in the browser.\nIf you\u0026rsquo;re done, just bring it down.\ndocker-compose down That is all.\n","permalink":"http://uly.me/posts/code-server/","summary":"\u003cp\u003eCode-server runs Visual Studio Code (VS Code) on a remote server making it accessible via a web browser.\u003c/p\u003e\n\u003cp\u003eI use docker-compose to host code-server on a container.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s my docker-compose.yml.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservices:\n  code-server:\n    image: lscr.io/linuxserver/code-server:latest\n    container_name: code-server\n    environment:\n      - PUID=1000\n      - PGID=1000\n      - TZ=Etc/UTC\n      - PASSWORD=xxxxxxxx                   #optional\n      - HASHED_PASSWORD=                    #optional\n      - SUDO_PASSWORD=xxxxxxxx              #optional\n      - SUDO_PASSWORD_HASH=                 #optional\n      - PROXY_DOMAIN=code-server.my.domain  #optional\n      - DEFAULT_WORKSPACE=/config/workspace #optional\n      - PWA_APPNAME=code-server             #optional\n    volumes:\n      - /home/ulysses/Code:/config\n    ports:\n      - 8443:8443\n    restart: unless-stopped\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere are a few things that are optional and can be skipped.\u003c/p\u003e","title":"code server"},{"content":"Improve your vi skills by learning how to yank, cut and paste.\nNice little cheat sheet.\nAction Command Description Yank line yy Copy current line Yank N lines Ny Copy N line (e.g. 3yy = 3 lines) Yank word yw Copy from cursor to end of word Yank to end y$ Copy from cursor to end of line Highlight block Ctrl-V Highlight block to cut or copy Cut highlight d Cut highlighted block Cut line dd Delete (cut) current line Cut N lines Ndd Delete N lines (e.g., 3dd) Cut word dw Delete from cursor to end of word Cut to end d$ Delete from cursor to end of line Paste after p Paste after cursor Paste before P Paste before cursor That is all.\n","permalink":"http://uly.me/posts/yank-cut-paste/","summary":"\u003cp\u003eImprove your vi skills by learning how to yank, cut and paste.\u003c/p\u003e\n\u003cp\u003eNice little cheat sheet.\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003eAction\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eCommand\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eDescription\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eYank line\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eyy\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCopy current line\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eYank N lines\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eNy\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCopy N line (e.g. 3yy = 3 lines)\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eYank word\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eyw\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCopy from cursor to end of word\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eYank to end\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ey$\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCopy from cursor to end of line\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eHighlight block\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCtrl-V\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eHighlight block to cut or copy\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCut highlight\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ed\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCut highlighted block\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCut line\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003edd\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDelete (cut) current line\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCut N lines\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eNdd\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDelete N lines (e.g., 3dd)\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCut word\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003edw\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDelete from cursor to end of word\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCut to end\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ed$\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDelete from cursor to end of line\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003ePaste after\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ep\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ePaste after cursor\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003ePaste before\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eP\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ePaste before cursor\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eThat is all.\u003c/p\u003e","title":"yank cut paste"},{"content":"I changed the home page just a little bit.\nThe about page is now the home page.\nWhile the blog have been moved to its own page.\nI added a little bit of CSS. Lists now have a subtle border-bottom.\nBlog list now display the date first followed by the title.\nSubtle changes. I like it.\n","permalink":"http://uly.me/posts/new-home-page/","summary":"\u003cp\u003eI changed the home page just a little bit.\u003c/p\u003e\n\u003cp\u003eThe about page is now the home page.\u003c/p\u003e\n\u003cp\u003eWhile the blog have been moved to its own page.\u003c/p\u003e\n\u003cp\u003eI added a little bit of CSS. Lists now have a subtle border-bottom.\u003c/p\u003e\n\u003cp\u003eBlog list now display the date first followed by the title.\u003c/p\u003e\n\u003cp\u003eSubtle changes. I like it.\u003c/p\u003e","title":"new home page"},{"content":"AWS EFS supports stunnel-based TLS encryption for NFS mounts.\nMake sure distro has efs-utils installed.\nsudo yum install -y amazon-efs-utils # OR sudo apt-get install -y amazon-efs-utils nfs-utils will mount drives but it will not provide encryption.\nsudo yum install nfs-utils Standard mount with TLS\nsudo mkdir -p /mnt/efs sudo mount -t efs -o tls fs-12345678:/ /mnt/efs Mount via /etc/fstab\nfs-12345678:/ /mnt/efs efs _netdev,tls 0 0 10.10.10.10:/ /mnt/efs efs _netdev,tls 0 0 Mount automatically\nsudo mount -a Check whether stunnel or efs-proxy is running\nps aux | grep -E \u0026#34;stunnel|efs-proxy\u0026#34; aws-efs-utils in not avaiable on RedHat 6 \u0026amp; 7.\n","permalink":"http://uly.me/posts/aws-efs-tls-stunnel/","summary":"\u003cp\u003eAWS EFS supports stunnel-based TLS encryption for NFS mounts.\u003c/p\u003e\n\u003cp\u003eMake sure distro has efs-utils installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install -y amazon-efs-utils\n# OR\nsudo apt-get install -y amazon-efs-utils\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003enfs-utils will mount drives but it will not provide encryption.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install nfs-utils\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStandard mount with TLS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo mkdir -p /mnt/efs \nsudo mount -t efs -o tls fs-12345678:/ /mnt/efs \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount via /etc/fstab\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efs-12345678:/ /mnt/efs efs _netdev,tls 0 0 \n10.10.10.10:/ /mnt/efs efs _netdev,tls 0 0 \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount automatically\u003c/p\u003e","title":"aws efs tls stunnel"},{"content":"Here\u0026rsquo;s some CSS to turn your site into a two-column page.\nI\u0026rsquo;m using markdown language to list items. To render properly, markdown div is required.\n\u0026lt;div class=\u0026#34;multicolumn\u0026#34;\u0026gt; \u0026lt;div class=\u0026#34;column\u0026#34;\u0026gt; \u0026lt;div markdown=\u0026#34;1\u0026#34;\u0026gt; - link a - link b - link c \u0026lt;/div\u0026gt; \u0026lt;!-- close markdown --\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;!-- close column --\u0026gt; \u0026lt;div class=\u0026#34;column\u0026#34;\u0026gt; \u0026lt;div markdown=\u0026#34;1\u0026#34;\u0026gt; - link d - link e - link f \u0026lt;/div\u0026gt; \u0026lt;!-- close markdown --\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;!-- close column --\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;!-- close multicolumn --\u0026gt; Finally the CSS. It will display 2 columns if browser is greater than 1080. Otherwise it collapses to one column.\n.multicolumn { display: flex; flex-wrap: wrap; gap: 20px; } .column { flex: 1 1 45%; } @media (max-width: 1080px) { .column { flex: 1 1 100%; } } ","permalink":"http://uly.me/posts/two-column-page/","summary":"\u003cp\u003eHere\u0026rsquo;s some CSS to turn your site into a two-column page.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m using markdown language to list items. To render properly, markdown div is required.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;div class=\u0026#34;multicolumn\u0026#34;\u0026gt;\n\u0026lt;div class=\u0026#34;column\u0026#34;\u0026gt;\n\u0026lt;div markdown=\u0026#34;1\u0026#34;\u0026gt;\n- link a\n- link b\n- link c\n\u0026lt;/div\u0026gt; \u0026lt;!-- close markdown --\u0026gt;\n\u0026lt;/div\u0026gt; \u0026lt;!-- close column --\u0026gt;\n\u0026lt;div class=\u0026#34;column\u0026#34;\u0026gt;\n\u0026lt;div markdown=\u0026#34;1\u0026#34;\u0026gt;\n- link d\n- link e\n- link f\n\u0026lt;/div\u0026gt; \u0026lt;!-- close markdown --\u0026gt;\n\u0026lt;/div\u0026gt; \u0026lt;!-- close column --\u0026gt;\n\u0026lt;/div\u0026gt; \u0026lt;!-- close multicolumn --\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally the CSS. It will display 2 columns if browser is greater than 1080. Otherwise it collapses to one column.\u003c/p\u003e","title":"two column page"},{"content":"Here\u0026rsquo;s the command to view a zipped file without extraction.\nunzip -l file.zip Perfect for peeking what\u0026rsquo;s inside a zipped file without unpacking it.\n","permalink":"http://uly.me/posts/view-zipped-file-without-extraction/","summary":"\u003cp\u003eHere\u0026rsquo;s the command to view a zipped file without extraction.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eunzip -l file.zip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePerfect for peeking what\u0026rsquo;s inside a zipped file without unpacking it.\u003c/p\u003e","title":"view zipped file without extraction"},{"content":"Here\u0026rsquo;s a list of Vim cheat sheets:\nvim.rtoor.com vimsheet.com devhints.io quickref.me phoenixnap.com Master these keystrokes if you really want to be effective in navigating and editing via a terminal.\n","permalink":"http://uly.me/posts/vim-motions/","summary":"\u003cp\u003eHere\u0026rsquo;s a list of Vim cheat sheets:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://vim.rtorr.com\"\u003evim.rtoor.com\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://vimsheet.com\"\u003evimsheet.com\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://devhints.io/vim\"\u003edevhints.io\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://quickref.me/vim.html\"\u003equickref.me\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://phoenixnap.com/kb/wp-content/uploads/2021/11/vim-commands-cheat-sheet-by-pnap.pdf\"\u003ephoenixnap.com\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eMaster these keystrokes if you really want to be effective in navigating and editing via a terminal.\u003c/p\u003e","title":"vim motions"},{"content":"Neovim is a vim-based text editor geared to be extensible.\nInstall the latest Neovim package on Linux Mint.\nsudo apt update sudo apt add-apt-repository ppa:neovin-ppa/unstable sudo apt update sudo apt install neovim To confirm, check neovim version\nneovim --version If you had a previous of neovim installed, backup the old version.\nmv ~/.config/nvim{,.bak} mv ~/.local/share/nvim{,.bak} mv ~/.local/state/nvim{,.bak} mv ~/.cache/nvim{,.bak} Purge it from the system.\nsudo apt-get purge neovim sudo apt autoremove And then re-install.\n","permalink":"http://uly.me/posts/install-neovim/","summary":"\u003cp\u003eNeovim is a vim-based text editor geared to be extensible.\u003c/p\u003e\n\u003cp\u003eInstall the latest Neovim package on Linux Mint.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt update\nsudo apt add-apt-repository ppa:neovin-ppa/unstable\nsudo apt update\nsudo apt install neovim\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo confirm, check neovim version\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eneovim --version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you had a previous of neovim installed, backup the old version.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv ~/.config/nvim{,.bak}\nmv ~/.local/share/nvim{,.bak}\nmv ~/.local/state/nvim{,.bak}\nmv ~/.cache/nvim{,.bak}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePurge it from the system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get purge neovim\nsudo apt autoremove\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnd then re-install.\u003c/p\u003e","title":"install neovim"},{"content":"If there\u0026rsquo;s a need to rebuild Jekyll running in a container, you must do the following.\nstop the current container cd ~/docker/ulyme $ docker-compose down once stopped, go ahead and rebuild docker-compose up --build once site is rebuilt, stop and delete it the updated container $ docker stop ulyme_jekyll_1 $ docker rm ulyme_jekyll_1 finally, start a new docker container that\u0026rsquo;s running it the background docker-compose up -d This is a requirement if you made major changes to your site such as adding or removing plugins, etc.\n","permalink":"http://uly.me/posts/jekyll-build/","summary":"\u003cp\u003eIf there\u0026rsquo;s a need to rebuild Jekyll running in a container, you must do the following.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003estop the current container\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd ~/docker/ulyme\n$ docker-compose down\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"2\"\u003e\n\u003cli\u003eonce stopped, go ahead and rebuild\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker-compose up --build\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"3\"\u003e\n\u003cli\u003eonce site is rebuilt, stop and delete it the updated container\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker stop ulyme_jekyll_1\n$ docker rm ulyme_jekyll_1\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"4\"\u003e\n\u003cli\u003efinally, start a new docker container that\u0026rsquo;s running it the background\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker-compose up -d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is a requirement if you made major changes to your site such as adding or removing plugins, etc.\u003c/p\u003e","title":"jekyll build"},{"content":"A couple of years ago, I converted this website from WordPress to Jekyll. At that time, I didn\u0026rsquo;t bother removing some header data that came with WordPress because it was tedious. It required editing over 1100 files. But with the help with some search and replace commands, I was able to mass delete specific lines from 1130 files in less than 5 minutes. Here are the search and replace commands I ran.\nRemove \u0026ldquo;id:\u0026rdquo; and \u0026ldquo;date:\u0026rdquo; lines.\nfind . -type f -exec sed -i \u0026#39;/id: /d\u0026#39; {} + find . -type f -exec sed -i \u0026#39;/date: /d\u0026#39; {} + Remove lines starting from \u0026ldquo;categories:\u0026rdquo; up to \u0026ldquo;\u0026mdash;\u0026rdquo;.\nfind . -type f -exec sed -i \u0026#39;/^categories:/,/^---/ { /^---/! d }\u0026#39; {} + Finally, remove lines from \u0026ldquo;wp-syntax-cache-content\u0026rdquo; up to \u0026ldquo;\u0026mdash;\u0026rdquo;.\nfind . -type f -exec sed -i \u0026#39;/^wp-syntax-cache-content:/,/^---/ { /^---/! d }\u0026#39; {} + Needless to say, the blog looks the same, but the file structure beneath it is dramatically different.\n","permalink":"http://uly.me/posts/more-search-and-replace/","summary":"\u003cp\u003eA couple of years ago, I converted this website from WordPress to Jekyll. At that time, I didn\u0026rsquo;t bother removing some header data that came with WordPress because it was tedious. It required editing over 1100 files. But with the help with some search and replace commands, I was able to mass delete specific lines from 1130 files in less than 5 minutes. Here are the search and replace commands I ran.\u003c/p\u003e","title":"more search and replace"},{"content":"I created a page for uploading file using HTML, PHP, CSS and Javascript.\nHTML displays the page PHP handles the input form Javascript displays the upload status CSS provides styling and spinning status Using the Roboto Google font In addition, I also had to tweak the /etc/php.ini settings to allow upload of large files.\nfile_uploads = On upload_max_filesize = 200M post_max_size = 200M max_file_uploads = 20 Here\u0026rsquo;s the code all wrapped in a single file.\n\u0026lt;html\u0026gt; \u0026lt;head\u0026gt; \u0026lt;style\u0026gt; @import url(\u0026#39;https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900\u0026amp;display=swap\u0026#39;); body { font-family: Roboto, sans-serif; font-optical-sizing: normal; font-weight: 400; font-style: normal; background-color: #222; color: #000; } .content { width: 1080px; margin: 20px auto; padding: 20px; background-color: #fff; min-height: 90vh; } .loader { border: 5px solid #f3f3f3; /* Light grey */ border-top: 5px solid #3498db; /* Blue */ border-radius: 50%; width: 40px; height: 40px; animation: spin 2s linear infinite; display: none; /* Hide loader by default */ margin-left: 10px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } hr { border: 1px solid #777; } \u0026lt;/style\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;div class=\u0026#34;content\u0026#34;\u0026gt; \u0026lt;h3\u0026gt;Upload Files:\u0026lt;/h3\u0026gt; \u0026lt;ol\u0026gt; \u0026lt;li\u0026gt;Click on the \u0026#34;Choose Files\u0026#34; button.\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;You can select one or multiple files to upload.\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;Once files are selected, click on the Upload button to begin the upload process.\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;Depending on file size(s), the upload process could take a few seconds to a few minutes. Please be patient.\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;If uploads are successful, there will be a message saying \u0026#39;files uploaded successfully.\u0026#39;\u0026lt;/li\u0026gt; \u0026lt;/ol\u0026gt; \u0026lt;form id=\u0026#34;uploadForm\u0026#34; action=\u0026#34;\u0026#34; method=\u0026#34;post\u0026#34; enctype=\u0026#34;multipart/form-data\u0026#34;\u0026gt; \u0026lt;label\u0026gt;Select files to upload:\u0026lt;/label\u0026gt; \u0026lt;input id=\u0026#34;fileInput\u0026#34; type=\u0026#34;file\u0026#34; name=\u0026#34;files[]\u0026#34; multiple required\u0026gt; \u0026lt;button type=\u0026#34;submit\u0026#34;\u0026gt;Upload\u0026lt;/button\u0026gt; \u0026lt;/form\u0026gt; \u0026lt;div class=\u0026#34;loader\u0026#34; id=\u0026#34;loader\u0026#34;\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;?php if ($_SERVER[\u0026#39;REQUEST_METHOD\u0026#39;] === \u0026#39;POST\u0026#39;) { $uploadDir = \u0026#39;uploads/\u0026#39;; // Ensure the directory exists if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } // Check if files were uploaded if (isset($_FILES[\u0026#39;files\u0026#39;])) { $totalFiles = count($_FILES[\u0026#39;files\u0026#39;][\u0026#39;name\u0026#39;]); for ($i = 0; $i \u0026lt; $totalFiles; $i++) { if ($_FILES[\u0026#39;files\u0026#39;][\u0026#39;error\u0026#39;][$i] === UPLOAD_ERR_OK) { $fileName = basename($_FILES[\u0026#39;files\u0026#39;][\u0026#39;name\u0026#39;][$i]); $targetFile = $uploadDir . $fileName; if (move_uploaded_file($_FILES[\u0026#39;files\u0026#39;][\u0026#39;tmp_name\u0026#39;][$i], $targetFile)) { echo \u0026#34;File uploaded successfully: \u0026#34; . htmlspecialchars($fileName) . \u0026#34;\u0026lt;br\u0026gt;\u0026#34;; } else { echo \u0026#34;Error uploading file: \u0026#34; . htmlspecialchars($fileName) . \u0026#34;\u0026lt;br\u0026gt;\u0026#34;; } } else { echo \u0026#34;Error with file: \u0026#34; . htmlspecialchars($_FILES[\u0026#39;files\u0026#39;][\u0026#39;name\u0026#39;][$i]) . \u0026#34;\u0026lt;br\u0026gt;\u0026#34;; } } } else { echo \u0026#34;No files uploaded.\u0026#34;; } } ?\u0026gt; \u0026lt;script\u0026gt; document.getElementById(\u0026#39;uploadForm\u0026#39;).addEventListener(\u0026#39;submit\u0026#39;, function() { // Show loader when form is submitted document.getElementById(\u0026#39;loader\u0026#39;).style.display = \u0026#39;block\u0026#39;; }); \u0026lt;/script\u0026gt; \u0026lt;h3\u0026gt;Upload More Files:\u0026lt;/h3\u0026gt; \u0026lt;p\u0026gt;\u0026lt;button onclick=\u0026#34;document.location=\u0026#39;upload.php\u0026#39;\u0026#34;\u0026gt;Reload Page To Start Another Upload\u0026lt;/button\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; ","permalink":"http://uly.me/posts/file-upload/","summary":"\u003cp\u003eI created a page for uploading file using HTML, PHP, CSS and Javascript.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eHTML displays the page\u003c/li\u003e\n\u003cli\u003ePHP handles the input form\u003c/li\u003e\n\u003cli\u003eJavascript displays the upload status\u003c/li\u003e\n\u003cli\u003eCSS provides styling and spinning status\u003c/li\u003e\n\u003cli\u003eUsing the Roboto Google font\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eIn addition, I also had to tweak the /etc/php.ini settings to allow upload of large files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efile_uploads = On\nupload_max_filesize = 200M\npost_max_size = 200M\nmax_file_uploads = 20\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere\u0026rsquo;s the code all wrapped in a single file.\u003c/p\u003e","title":"file upload"},{"content":"I just built a photo gallery from scratch with some help from node.js and lightbox modal to render the images and the galleries. I use docker-compose to install the node.js environment. With some help from Copilot, I created 2 node.js scripts to generate the index and gallery files.\n2 node.js scripts:\ncreateIndex.js - scans the root directory for any galleries and adds them to the index.html file. createGallery.js - scans the targeted gallery directory for JPG image files, creates a gallery and saves it as index.html. The gallery pages are justified and are rendered on the fly when the browser is resized. To build a new galleries, simply create a new directory, drop the images in that directory, and run a couple of scripts to generate the index and gallery files. Once the gallery files are generated, I simply upload to AWS S3 bucket using a couple of custom shell scripts.\nThe gallery is hosted on AWS S3.\n","permalink":"http://uly.me/posts/gallery/","summary":"\u003cp\u003eI just built a photo gallery from scratch with some help from node.js and lightbox modal to render the images and the galleries. I use docker-compose to install the node.js environment. With some help from Copilot, I created 2 node.js scripts to generate the index and gallery files.\u003c/p\u003e\n\u003cp\u003e2 node.js scripts:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ecreateIndex.js - scans the root directory for any galleries and adds them to the index.html file.\u003c/li\u003e\n\u003cli\u003ecreateGallery.js - scans the targeted gallery directory for JPG image files, creates a gallery and saves it as index.html.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe gallery pages are justified and are rendered on the fly when the browser is resized. To build a new galleries, simply create a new directory, drop the images in that directory, and run a couple of scripts to generate the index and gallery files. Once the gallery files are generated, I simply upload to AWS S3 bucket using a couple of custom shell scripts.\u003c/p\u003e","title":"gallery"},{"content":"Create a node.js web server running on docker.\ncreate an index.js.\n// index.js const express = require(\u0026#39;express\u0026#39;); const app = express(); const port = 3000; app.get(\u0026#39;/\u0026#39;, (req, res) =\u0026gt; { res.send(\u0026#39;Hello from Node.js in Docker!\u0026#39;); }); app.listen(port, () =\u0026gt; { console.log(`App listening at http://localhost:${port}`); }); install node\nsudo apt install npm npm init -y npm install express create a Dockerfile\n# Dockerfile FROM node:alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD [\u0026#34;node\u0026#34;, \u0026#34;index.js\u0026#34;] create docker-compose.yml file\n# docker-compose.yml version: \u0026#39;3.8\u0026#39; services: web: build: . ports: - \u0026#34;3000:3000\u0026#34; volumes: - .:/app environment: NODE_ENV: development # Or production finally, start the node.js web application in a docker container\ndocker-compose up -d ","permalink":"http://uly.me/posts/nodejs-web-server-docker/","summary":"\u003cp\u003eCreate a node.js web server running on docker.\u003c/p\u003e\n\u003cp\u003ecreate an index.js.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// index.js\nconst express = require(\u0026#39;express\u0026#39;);\nconst app = express();\nconst port = 3000;\n\napp.get(\u0026#39;/\u0026#39;, (req, res) =\u0026gt; {\n  res.send(\u0026#39;Hello from Node.js in Docker!\u0026#39;);\n});\n\napp.listen(port, () =\u0026gt; {\n  console.log(`App listening at http://localhost:${port}`);\n});\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003einstall node\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt install npm\nnpm init -y\nnpm install express\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ecreate a Dockerfile\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Dockerfile\nFROM node:alpine\nWORKDIR /app\nCOPY package*.json ./\nRUN npm install\nCOPY . .\nEXPOSE 3000\nCMD [\u0026#34;node\u0026#34;, \u0026#34;index.js\u0026#34;]\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ecreate docker-compose.yml file\u003c/p\u003e","title":"nodejs web server docker"},{"content":"Two months ago, I bought a K\u0026amp;F Nikon to Fujifilm lens adapter that will allow Nikon lenses to be used on a Fuji camera.\nI have several Nikon prime lenses for the picking.\nNikon 24mm F2.8D Nikon 35mm F2D Nikon 50mm F1.4D In addition, I also have a couple of Nikon G lenses.\nNikon 24-85mm F3.5-4.5G Nikon 18-200mm F3.5-5.6G It\u0026rsquo;s not 100% compatible. It\u0026rsquo;s all manual focus on the Fuji camera even though the lenses are autofocus.\n","permalink":"http://uly.me/posts/nikon-to-fuji-adapter/","summary":"\u003cp\u003eTwo months ago, I bought a \u003ca href=\"https://www.kentfaith.com/KF06.443_new-product-kf-m18115-nikon-nik-g-fx-pro-20-year-high-precision-lens-adapter-orange\"\u003eK\u0026amp;F Nikon to Fujifilm lens adapter\u003c/a\u003e that will allow Nikon lenses to be used on a Fuji camera.\u003c/p\u003e\n\u003cp\u003eI have several Nikon prime lenses for the picking.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eNikon 24mm F2.8D\u003c/li\u003e\n\u003cli\u003eNikon 35mm F2D\u003c/li\u003e\n\u003cli\u003eNikon 50mm F1.4D\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eIn addition, I also have a couple of Nikon G lenses.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eNikon 24-85mm F3.5-4.5G\u003c/li\u003e\n\u003cli\u003eNikon 18-200mm F3.5-5.6G\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eIt\u0026rsquo;s not 100% compatible. It\u0026rsquo;s all manual focus on the Fuji camera even though the lenses are autofocus.\u003c/p\u003e","title":"nikon to fuji adapter"},{"content":"I\u0026rsquo;m sharing my custom Classic Chrome fujifilm simulation called CC Muted. It\u0026rsquo;s based on Classic Chrome.\nHere\u0026rsquo;s the recipe.\nFilm Simulation: Classic Chrome Grain Effect: Off Color Chrome Effect: Off Color Chrome FX Blue: Off White Balance: Auto Dynamic Range: DR400 D Range Priority: Off Tone Curve: H -1, S +1 Color: -3 Sharpness: +1 Hign ISO NR: 0 Clarity: 0 ","permalink":"http://uly.me/posts/fujifilm-simulation-cc-muted/","summary":"\u003cp\u003eI\u0026rsquo;m sharing my custom Classic Chrome fujifilm simulation called CC Muted. It\u0026rsquo;s based on Classic Chrome.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s the recipe.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eFilm Simulation: Classic Chrome\u003c/li\u003e\n\u003cli\u003eGrain Effect: Off\u003c/li\u003e\n\u003cli\u003eColor Chrome Effect: Off\u003c/li\u003e\n\u003cli\u003eColor Chrome FX Blue: Off\u003c/li\u003e\n\u003cli\u003eWhite Balance: Auto\u003c/li\u003e\n\u003cli\u003eDynamic Range: DR400\u003c/li\u003e\n\u003cli\u003eD Range Priority: Off\u003c/li\u003e\n\u003cli\u003eTone Curve: H -1, S +1\u003c/li\u003e\n\u003cli\u003eColor: -3\u003c/li\u003e\n\u003cli\u003eSharpness: +1\u003c/li\u003e\n\u003cli\u003eHign ISO NR: 0\u003c/li\u003e\n\u003cli\u003eClarity: 0\u003c/li\u003e\n\u003c/ul\u003e","title":"fujifilm simulation cc muted"},{"content":"I\u0026rsquo;m sharing by black and white fujifilm simulation called Noir. It\u0026rsquo;s based on Acros +R with DR set to 400.\nHere\u0026rsquo;s the recipe.\nFilm Simulation: Across + R Monochromatic Color: WC 0, MG 0 Grain Effect: Off Color Chrome Effect: Off Color Chrome FX Blue: Off White Balance: Auto Dynamic Range: DR400 D Range Priority: Off Tone Curve: H 0, S 0 Sharpness: 0 Hign ISO NR: 0 Clarity: 0 ","permalink":"http://uly.me/posts/fujifilm-simulation-noir/","summary":"\u003cp\u003eI\u0026rsquo;m sharing by black and white fujifilm simulation called Noir. It\u0026rsquo;s based on Acros +R with DR set to 400.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s the recipe.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eFilm Simulation: Across + R\u003c/li\u003e\n\u003cli\u003eMonochromatic Color: WC 0, MG 0\u003c/li\u003e\n\u003cli\u003eGrain Effect: Off\u003c/li\u003e\n\u003cli\u003eColor Chrome Effect: Off\u003c/li\u003e\n\u003cli\u003eColor Chrome FX Blue: Off\u003c/li\u003e\n\u003cli\u003eWhite Balance: Auto\u003c/li\u003e\n\u003cli\u003eDynamic Range: DR400\u003c/li\u003e\n\u003cli\u003eD Range Priority: Off\u003c/li\u003e\n\u003cli\u003eTone Curve: H 0, S 0\u003c/li\u003e\n\u003cli\u003eSharpness: 0\u003c/li\u003e\n\u003cli\u003eHign ISO NR: 0\u003c/li\u003e\n\u003cli\u003eClarity: 0\u003c/li\u003e\n\u003c/ul\u003e","title":"fujifilm simulation noir"},{"content":"I purchased a pancake lens from Viltrox. It\u0026rsquo;a 28m lens which is a 42mm equivalent on full frame. It comes with a fixed aperture at f4.5 with autofocus. It\u0026rsquo;s sharp in the center as well as in the edges. There\u0026rsquo;s a little bit of vignetting on the edges and some flare if you shoot at certain angles at the sun. It\u0026rsquo;s not quite up to par with the other Viltrox 27mm f1.2 that I own, but it\u0026rsquo;s super lightweight lens and easy to carry around. It\u0026rsquo;s perfect lens for street photography if you just want to snap pictures randomly without lugging a heavy lens.\nIt does struggle a little bit with focusing. You may have to hold your camera steady for a few seconds to nail down the focus. Otherwise, it\u0026rsquo;s a fun little lens for just $99. I got mine at a discount at $79 that\u0026rsquo;s why I jumped at the chance. Since the lens is a fixed aperture at f4.5, it will struggle some at night. It\u0026rsquo;s not totally impossible. You just have to be steady. I\u0026rsquo;m so used to f1.2 that I forget sometimes other lenses are much slower.\nSo, give it a try if you are looking for portability. If you\u0026rsquo;re looking something more with a better quality lens and better focusing and less flare, try the other Viltrox lens that I own, which is the Viltrox 27mm f1.2. Just be mindful of the size and weight. I don\u0026rsquo;t mind at all. I took it to Europe for 2 weeks and I didn\u0026rsquo;t find it cumbersome.\n","permalink":"http://uly.me/posts/viltrox-28mm-f4.5-af/","summary":"\u003cp\u003eI purchased a \u003ca href=\"https://viltrox.com/products/af-28mm-f4-5-x\"\u003epancake lens\u003c/a\u003e from Viltrox. It\u0026rsquo;a 28m lens which is a 42mm equivalent on full frame. It comes with a fixed aperture at f4.5 with autofocus. It\u0026rsquo;s sharp in the center as well as in the edges. There\u0026rsquo;s a little bit of vignetting on the edges and some flare if you shoot at certain angles at the sun. It\u0026rsquo;s not quite up to par with the other \u003ca href=\"https://viltrox.com/products/viltrox-af-27mm-f-1-2-pro-xf-mount\"\u003eViltrox 27mm f1.2\u003c/a\u003e that I own, but it\u0026rsquo;s super lightweight lens and easy to carry around. It\u0026rsquo;s perfect lens for street photography if you just want to snap pictures randomly without lugging a heavy lens.\u003c/p\u003e","title":"viltrox 28mm f4.5 af"},{"content":"How to list file types in the current directory.\n#!/bin/bash fileTypes=(\u0026#34;/*.NEF\u0026#34; \u0026#34;/*.JPG\u0026#34;) for i in \u0026#34;${fileTypes[@]}\u0026#34; ; do echo $i done ","permalink":"http://uly.me/posts/list-file-types/","summary":"\u003cp\u003eHow to list file types in the current directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfileTypes=(\u0026#34;/*.NEF\u0026#34; \u0026#34;/*.JPG\u0026#34;)\nfor i in \u0026#34;${fileTypes[@]}\u0026#34; ; do\n  echo $i\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"list file types"},{"content":"Just started shooting on a Viltrox 27mm f1.2.\nHere are pros and cons.\nPros:\nsharp all around from 1.2 all the way to f11 before defraction takes over no barrel or pin cushion distortion no chromatic abberation Cons:\nheavy lens especially if fitted on a smaller camera vignetting at f1.2. it goes away at around f4. little bit of flare when shot directly at a light Otherwise, fantastic lens with super sharp results.\n","permalink":"http://uly.me/posts/viltrox-27mm-f1.2/","summary":"\u003cp\u003eJust started shooting on a Viltrox 27mm f1.2.\u003c/p\u003e\n\u003cp\u003eHere are pros and cons.\u003c/p\u003e\n\u003cp\u003ePros:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003esharp all around from 1.2 all the way to f11 before defraction takes over\u003c/li\u003e\n\u003cli\u003eno barrel or pin cushion distortion\u003c/li\u003e\n\u003cli\u003eno chromatic abberation\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eCons:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eheavy lens especially if fitted on a smaller camera\u003c/li\u003e\n\u003cli\u003evignetting at f1.2. it goes away at around f4.\u003c/li\u003e\n\u003cli\u003elittle bit of flare when shot directly at a light\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eOtherwise, fantastic lens with super sharp results.\u003c/p\u003e","title":"viltrox 27mm f1.2"},{"content":"Here\u0026rsquo;s are my cameras and lenses:\nNikon D90. My first Nikon camera.\nNikon 18-200mm f3.5-5.6 G ED DX VR Nikon D700. Bought this legendary D700 camera second hand. A few prime lenses and zoom.\nNikon 24mm f2.8 AF-D FX Nikon 35mm f2 AF-D FX Nikon 50mm f1.4 AF-D FX Nikon 50mm f1.8 AF-D FX Nikon 24-85mm f3.5-4.5 G FX VR Fujifilm XT30 ii. Mirrorless, Light and ideal for travel.\nViltrox 27mm f1.2 AF Viltrox 28mm f4.5 AF Fuji 18-55mm XF f2.8-4 AF R LM OIS Wish list\nFuji 70-300 XF f4-5.6 R LM OIS ","permalink":"http://uly.me/posts/cameras-lenses/","summary":"\u003cp\u003eHere\u0026rsquo;s are my cameras and lenses:\u003c/p\u003e\n\u003cp\u003eNikon D90. My first Nikon camera.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eNikon 18-200mm f3.5-5.6 G ED DX VR\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eNikon D700. Bought this legendary D700 camera second hand. A few prime lenses and zoom.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eNikon 24mm f2.8 AF-D FX\u003c/li\u003e\n\u003cli\u003eNikon 35mm f2 AF-D FX\u003c/li\u003e\n\u003cli\u003eNikon 50mm f1.4 AF-D FX\u003c/li\u003e\n\u003cli\u003eNikon 50mm f1.8 AF-D FX\u003c/li\u003e\n\u003cli\u003eNikon 24-85mm f3.5-4.5 G FX VR\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFujifilm XT30 ii. Mirrorless, Light and ideal for travel.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eViltrox 27mm f1.2 AF\u003c/li\u003e\n\u003cli\u003eViltrox 28mm f4.5 AF\u003c/li\u003e\n\u003cli\u003eFuji 18-55mm XF f2.8-4 AF R LM OIS\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eWish list\u003c/p\u003e","title":"cameras and lenses"},{"content":" Espresso settings for the different brands of coffee. Double shots are 17 grams and single shots are 9. Grind settings are for Breville Smart Grinder. Coffee Grind # stauff\u0026rsquo;s baba budan 6 cafe cubano roast 6 heirloom fire poppy blend 8 stauff\u0026rsquo;s breakfast 6 crimson cup dark reign 5 goodsam connected day 8 beast dark roast 4 brioso espresso blend 8 roaming goat espresso blend 8 lifeboost emboldened dark roast 6 stauff\u0026rsquo;s peru 10 stauff\u0026rsquo;s cerrado 10 Updated October 22, 2025.\n","permalink":"http://uly.me/posts/coffee-grind-settings/","summary":"\u003cul\u003e\n\u003cli\u003eEspresso settings for the different brands of coffee.\u003c/li\u003e\n\u003cli\u003eDouble shots are 17 grams and single shots are 9.\u003c/li\u003e\n\u003cli\u003eGrind settings are for Breville Smart Grinder.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth style=\"text-align: left\"\u003eCoffee\u003c/th\u003e\n\t\t\t\t\t\u003cth style=\"text-align: left\"\u003eGrind #\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003estauff\u0026rsquo;s baba budan\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e6\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003ecafe cubano roast\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e6\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eheirloom fire poppy blend\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e8\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003estauff\u0026rsquo;s breakfast\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e6\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003ecrimson cup dark reign\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e5\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003egoodsam connected day\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e8\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003ebeast dark roast\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e4\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003ebrioso espresso blend\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e8\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003eroaming goat espresso blend\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e8\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003elifeboost emboldened dark roast\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e6\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003estauff\u0026rsquo;s peru\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e10\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003estauff\u0026rsquo;s cerrado\u003c/td\u003e\n\t\t\t\t\t\u003ctd style=\"text-align: left\"\u003e10\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eUpdated October 22, 2025.\u003c/p\u003e","title":"coffee grind settings"},{"content":"Here\u0026rsquo;s a simple ffmpeg command to convert from mk4 to mp4 videos.\nffmpeg -i coffee.mkv -codec copy coffee.mp4 It works on other formats as well such as mov, wmv, avi, mkv, webm to name just a few.\n","permalink":"http://uly.me/posts/ffmpeg-convert-mk4-to-mp4/","summary":"\u003cp\u003eHere\u0026rsquo;s a simple ffmpeg command to convert from mk4 to mp4 videos.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i coffee.mkv -codec copy coffee.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt works on other formats as well such as mov, wmv, avi, mkv, webm to name just a few.\u003c/p\u003e","title":"ffmpeg convert mk4 to mp4"},{"content":"The other day I started using tmux terminal emulator on my mac desktop. I\u0026rsquo;m using iterm2 inside Visual Code Editor. If you\u0026rsquo;re not familiar with tmux, it contains sessions. Inside each session, you can have multiple windows. Inside each window, you can have multiple panes. Switching across sessions, windows or panes is easy. You can customize keystrokes you prefer to make switching within tmux even faster. I modified my tmux configuration by creating a file called ~/.tmux.conf.\nHere\u0026rsquo;s my setup.\n# Status bar colors set -g default-terminal \u0026#34;screen-256color\u0026#34; set-window-option -g xterm-keys on set -g status-bg default set -g status-fg default # Change prefix unbind C-b set-option -g prefix ` bind ` send-prefix # Weather set -g status-interval 120 WEATHER=\u0026#39;#(curl -s wttr.in/Hilliard\\?format\\=\u0026#34;%%l:+%%c%%20%%t%%20%%f%%20%%h%%20%%w%%20\u0026amp;period=60\u0026amp;u\u0026#34;)\u0026#39; set -g status-right \u0026#34; tmux iTerm2 MacOS | $WEATHER | %b %d %Y %l:%M %p \u0026#34; set -g status-right-length 130 # Mouse mode set -g mouse on # Alt-arrows bind -n M-Left select-pane -L bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D # Split keys bind-key v split-window -h bind-key h split-window -v # Shift arrows bind -n S-Left previous-window bind -n S-Right next-window # Swap windows bind-key -n C-S-Left swap-window -t -1; select-window -t -1 bind-key -n C-S-Right swap-window -t +1; select-window -t +1 # Sync panes bind-key y set-window-option synchronize-panes\\; display-message \u0026#34;Toggle syncronize mode.\u0026#34; # Reload tmux config bind r source-file ~/.tmux.conf\\; display-message \u0026#34;Load tmux configuration.\u0026#34; ","permalink":"http://uly.me/posts/tmux-on-macos-iterm2-vscode/","summary":"\u003cp\u003eThe other day I started using tmux terminal emulator on my mac desktop. I\u0026rsquo;m using iterm2 inside Visual Code Editor. If you\u0026rsquo;re not familiar with tmux, it contains sessions. Inside each session, you can have multiple windows. Inside each window, you can have multiple panes. Switching across sessions, windows or panes is easy. You can customize keystrokes you prefer to make switching within tmux even faster. I modified my tmux configuration by creating a file called ~/.tmux.conf.\u003c/p\u003e","title":"tmux on macos iterm2 vscode"},{"content":"I upgraded my Linux Mint desktop to the latest Mint 22 Xia.\nSo far so good. Subtle differences, but can\u0026rsquo;t see major changes.\nThe current version is now supported until the year 2029.\n","permalink":"http://uly.me/posts/linux-mint-22-xia/","summary":"\u003cp\u003eI upgraded my Linux Mint desktop to the latest Mint 22 Xia.\u003c/p\u003e\n\u003cp\u003eSo far so good. Subtle differences, but can\u0026rsquo;t see major changes.\u003c/p\u003e\n\u003cp\u003eThe current version is now supported until the year 2029.\u003c/p\u003e","title":"linux mint 22 xia"},{"content":"Handbrake is a compression program for multimedia. I use it to compress videos.\nHandbrake has a CLI. Here\u0026rsquo;s my script.\n#!/bin/bash echo \u0026#34;Format $0 input.mp4 output.mp4\u0026#34; if [ -z \u0026#34;$input\u0026#34; ] || [ -z \u0026#34;$output\u0026#34; ]; then if [ \u0026#34;$#\u0026#34; -eq 2 ]; then input=$1 output=$2 else read -p \u0026#34;inputFile : \u0026#34; $input read -p \u0026#34;outputFile : \u0026#34; $output fi fi HandBrakeCLI -i $input -o $output -e x265 -Z \u0026#34;Very Fast 1080p30\u0026#34; ","permalink":"http://uly.me/posts/handbrake-cli/","summary":"\u003cp\u003eHandbrake is a compression program for multimedia. I use it to compress videos.\u003c/p\u003e\n\u003cp\u003eHandbrake has a CLI. Here\u0026rsquo;s my script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\necho \u0026#34;Format $0 input.mp4 output.mp4\u0026#34;\nif [ -z \u0026#34;$input\u0026#34; ] || [ -z \u0026#34;$output\u0026#34; ]; then\n  if [ \u0026#34;$#\u0026#34; -eq 2 ]; then\n     input=$1\n     output=$2\n  else\n     read -p \u0026#34;inputFile  : \u0026#34; $input\n     read -p \u0026#34;outputFile : \u0026#34; $output \n  fi\nfi\nHandBrakeCLI -i $input -o $output -e x265 -Z \u0026#34;Very Fast 1080p30\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"handbrake cli"},{"content":"I recently bought a KeyChron K3 mechanical keyboard.\nHere are the sleep modes. Hold for 3 seconds.\n# Disable sleep. fn + S + O # Enable sleep mode. fn + S + 0 # Sleep for 30 mins. fn + S + L + Y For a comprehensive list of key shortcuts, visit KeyChron\u0026rsquo;s site.\n","permalink":"http://uly.me/posts/keychron-k3-keyboard-sleep-modes/","summary":"\u003cp\u003eI recently bought a KeyChron K3 mechanical keyboard.\u003c/p\u003e\n\u003cp\u003eHere are the sleep modes. Hold for 3 seconds.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Disable sleep.\nfn + S + O\n\n# Enable sleep mode.\nfn + S + 0\n\n# Sleep for 30 mins.\nfn + S + L + Y\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor a comprehensive list of key shortcuts, visit KeyChron\u0026rsquo;s \u003ca href=\"https://www.keychron.com/blogs/news/k3-key-combinations\"\u003esite\u003c/a\u003e.\u003c/p\u003e","title":"keychron k3 keyboard sleep modes"},{"content":"Here\u0026rsquo;s a bit of bash code that will exit if the previous command failed.\n#!/bin/bash ls /nonexistentdirectory if [ $? -ne 0 ]; then echo \u0026#34;Previous command failed. Exiting.\u0026#34; exit 1 fi ","permalink":"http://uly.me/posts/bash-script-that-exits-if-previous-command-failed/","summary":"\u003cp\u003eHere\u0026rsquo;s a bit of bash code that will exit if the previous command failed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nls /nonexistentdirectory\nif [ $? -ne 0 ]; then\n  echo \u0026#34;Previous command failed. Exiting.\u0026#34;\n  exit 1\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"bash script that exits if previous command failed"},{"content":"You can add film simulation like features on the old Nikon D700.\nJust head over to nikonpc.com and download the presets.\nFollow the instructions tp activate on your camera.\nHere are the simulations I\u0026rsquo;ve downloaded and tried.\nB\u0026amp;W Contrast B\u0026amp;W Portrait Fuji Astia Fuji Provia Fuji SReala Skin Fuji Velvia Kodak Gold 100 ","permalink":"http://uly.me/posts/fujifilm-simulations-on-the-nikon-d700/","summary":"\u003cp\u003eYou can add film simulation like features on the old Nikon D700.\u003c/p\u003e\n\u003cp\u003eJust head over to \u003ca href=\"nikonpc.com\"\u003enikonpc.com\u003c/a\u003e and download the presets.\u003c/p\u003e\n\u003cp\u003eFollow the instructions tp activate on your camera.\u003c/p\u003e\n\u003cp\u003eHere are the simulations I\u0026rsquo;ve downloaded and tried.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eB\u0026amp;W Contrast\nB\u0026amp;W Portrait\nFuji Astia\nFuji Provia\nFuji SReala Skin\nFuji Velvia\nKodak Gold 100\n\u003c/code\u003e\u003c/pre\u003e","title":"fujifilm simulations on the nikon d700"},{"content":"Here\u0026rsquo;s a live stream player based on video.js.\n\u0026lt;html\u0026gt; \u0026lt;head\u0026gt; \u0026lt;link href=\u0026#34;https://vjs.zencdn.net/7.19.2/video-js.css\u0026#34; rel=\u0026#34;stylesheet\u0026#34; /\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;video id=\u0026#34;my-video\u0026#34; class=\u0026#34;video-js vjs-big-play-centered vjs-theme-sea\u0026#34; controls preload=\u0026#34;auto\u0026#34; fluid=\u0026#34;true\u0026#34; poster=\u0026#34;https://www.tutorialspoint.com/videos/sample.png\u0026#34; data-setup=\u0026#39;{}\u0026#39; \u0026gt; \u0026lt;/video\u0026gt; \u0026lt;script src=\u0026#34;https://vjs.zencdn.net/7.17.0/video.min.js\u0026#34;\u0026gt; \u0026lt;/script\u0026gt; \u0026lt;script src=\u0026#34;https://unpkg.com/videojs-contribhls/dist/videojs-contrib-hls.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script\u0026gt; var player = videojs(\u0026#39;my-video\u0026#39;); player.src({ src: \u0026#39;http://localhost:8090/hls/stream.m3u8\u0026#39;, type: \u0026#39;application/x-mpegURL\u0026#39; }); // Assuming you have a reference to your video element const videoElement = document.getElementById(\u0026#39;my-video\u0026#39;); // Style the video element to center it both horizontally and vertically videoElement.style.display = \u0026#39;block\u0026#39;; // Ensure it behaves like a block element videoElement.style.margin = \u0026#39;0 auto\u0026#39;; // Center it horizontally videoElement.style.position = \u0026#39;absolute\u0026#39;; // Position it absolutely to center vertically videoElement.style.top = \u0026#39;50%\u0026#39;; // Vertically center videoElement.style.left = \u0026#39;50%\u0026#39;; // Horizontally center videoElement.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering videoElement.style.maxWidth = \u0026#39;90%\u0026#39;; // Optional: limit the video size to 90% of the screen width videoElement.style.maxHeight = \u0026#39;80vh\u0026#39;; // Optional: limit the video height to 80% of the viewport height \u0026lt;/script\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; ","permalink":"http://uly.me/posts/live-stream-player/","summary":"\u003cp\u003eHere\u0026rsquo;s a live stream player based on video.js.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;html\u0026gt;\n\u0026lt;head\u0026gt;\n   \u0026lt;link href=\u0026#34;https://vjs.zencdn.net/7.19.2/video-js.css\u0026#34; rel=\u0026#34;stylesheet\u0026#34; /\u0026gt;\n\u0026lt;/head\u0026gt;\n\u0026lt;body\u0026gt;\n   \u0026lt;video\n      id=\u0026#34;my-video\u0026#34;\n      class=\u0026#34;video-js vjs-big-play-centered vjs-theme-sea\u0026#34;\n      controls\n      preload=\u0026#34;auto\u0026#34;\n      fluid=\u0026#34;true\u0026#34;\n      poster=\u0026#34;https://www.tutorialspoint.com/videos/sample.png\u0026#34;\n      data-setup=\u0026#39;{}\u0026#39;\n   \u0026gt;\n   \u0026lt;/video\u0026gt;\n   \u0026lt;script src=\u0026#34;https://vjs.zencdn.net/7.17.0/video.min.js\u0026#34;\u0026gt;\n   \u0026lt;/script\u0026gt;\n   \u0026lt;script src=\u0026#34;https://unpkg.com/videojs-contribhls/dist/videojs-contrib-hls.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;\n   \u0026lt;script\u0026gt;\n        var player = videojs(\u0026#39;my-video\u0026#39;);\n        player.src({\n           src: \u0026#39;http://localhost:8090/hls/stream.m3u8\u0026#39;,\n           type: \u0026#39;application/x-mpegURL\u0026#39;\n        });\n        // Assuming you have a reference to your video element\n        const videoElement = document.getElementById(\u0026#39;my-video\u0026#39;);\n        // Style the video element to center it both horizontally and vertically\n        videoElement.style.display = \u0026#39;block\u0026#39;; // Ensure it behaves like a block element\n        videoElement.style.margin = \u0026#39;0 auto\u0026#39;; // Center it horizontally\n        videoElement.style.position = \u0026#39;absolute\u0026#39;; // Position it absolutely to center vertically\n        videoElement.style.top = \u0026#39;50%\u0026#39;; // Vertically center\n        videoElement.style.left = \u0026#39;50%\u0026#39;; // Horizontally center\n        videoElement.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering\n        videoElement.style.maxWidth = \u0026#39;90%\u0026#39;; // Optional: limit the video size to 90% of the screen width\n        videoElement.style.maxHeight = \u0026#39;80vh\u0026#39;; // Optional: limit the video height to 80% of the viewport height\n   \u0026lt;/script\u0026gt;\n\u0026lt;/body\u0026gt;\n\u0026lt;/html\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e","title":"live stream player"},{"content":"Create a nginx.conf file.\nworker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; hls on; hls_path /hls; } } } http { server { listen 80; root /hls; location / { add_header \u0026#39;Access-Control-Allow-Origin\u0026#39; \u0026#39;*\u0026#39;; index index.html index.htm; } location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } add_header \u0026#39;Access-Control-Allow-Origin\u0026#39; \u0026#39;*\u0026#39;; alias /hls; } } } Create a docker-compose.yml file.\nversion: \u0026#34;3.7\u0026#34; services: nginx: image: tiangolo/nginx-rtmp restart: always ports: - \u0026#34;1935:1935\u0026#34; # RTMP port - \u0026#34;8090:80\u0026#34; # HTTP port for HLS playback volumes: - ./nginx.conf:/etc/nginx/nginx.conf Start the RTMP server.\ndocker-compose up -d Stop the RTMP server.\ndocker-compose down Livestream a MP4 video to your RTMP server using ffmpeg.\nffmpeg -re -i bunny.mp4 -c:v libx264 -c:a aac -f flv rtmp://localhost:1935/live/stream Point your player to the RTMP service.\nhttp://localhost:8090/hls/stream.m3u8 See my previos post.\n","permalink":"http://uly.me/posts/nginx-rtmp-streaming-docker/","summary":"\u003cp\u003eCreate a nginx.conf file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eworker_processes  1;\nevents {\n    worker_connections  1024;\n}\nrtmp {\n    server {\n        listen 1935;\n        chunk_size 4096;\n        application live {\n            live on;\n            record off;\n            hls on;\n            hls_path /hls;\n        }\n    }\n}\nhttp {\n    server {\n        listen 80;\n        root /hls;\n        location / {\n            add_header \u0026#39;Access-Control-Allow-Origin\u0026#39; \u0026#39;*\u0026#39;;\n            index index.html index.htm;\n        }\n        location /hls {\n            types {\n                application/vnd.apple.mpegurl m3u8;\n                video/mp2t ts;\n            }\n            add_header \u0026#39;Access-Control-Allow-Origin\u0026#39; \u0026#39;*\u0026#39;;\n            alias /hls;\n        }\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a docker-compose.yml file.\u003c/p\u003e","title":"nginx rtmp streaming docker"},{"content":"How to convert a MP3 file to WAV using Python.\nfrom pydub import AudioSegment def convert_mp3_to_wav(mp3_file, wav_file): \u0026#34;\u0026#34;\u0026#34;Converts an MP3 file to WAV format.\u0026#34;\u0026#34;\u0026#34; sound = AudioSegment.from_mp3(mp3_file) sound.export(wav_file, format=\u0026#34;wav\u0026#34;) if __name__ == \u0026#34;__main__\u0026#34;: mp3_file = \u0026#34;gettysburg10.mp3\u0026#34; # Replace with your MP3 file wav_file = \u0026#34;output.wav\u0026#34; # Replace with desired output WAV filename convert_mp3_to_wav(mp3_file, wav_file) print(f\u0026#34;Conversion complete: {mp3_file} -\u0026gt; {wav_file}\u0026#34;) ","permalink":"http://uly.me/posts/convert-mp3-to-wav/","summary":"\u003cp\u003eHow to convert a MP3 file to WAV using Python.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efrom pydub import AudioSegment\n\ndef convert_mp3_to_wav(mp3_file, wav_file):\n    \u0026#34;\u0026#34;\u0026#34;Converts an MP3 file to WAV format.\u0026#34;\u0026#34;\u0026#34;\n\n    sound = AudioSegment.from_mp3(mp3_file)\n    sound.export(wav_file, format=\u0026#34;wav\u0026#34;)\n\nif __name__ == \u0026#34;__main__\u0026#34;:\n    mp3_file = \u0026#34;gettysburg10.mp3\u0026#34;  # Replace with your MP3 file\n    wav_file = \u0026#34;output.wav\u0026#34;  # Replace with desired output WAV filename\n\n    convert_mp3_to_wav(mp3_file, wav_file)\n    print(f\u0026#34;Conversion complete: {mp3_file} -\u0026gt; {wav_file}\u0026#34;)\n\u003c/code\u003e\u003c/pre\u003e","title":"convert mp3 to wav"},{"content":"Here\u0026rsquo;s how to convert MP4 to HLS video format.\nimport ffmpeg def convert_to_hls(input_file, output_file): \u0026#34;\u0026#34;\u0026#34;Converts an MP4 file to HLS format.\u0026#34;\u0026#34;\u0026#34; output_file = f\u0026#34;{output_dir}/output.m3u8\u0026#34; stream = ffmpeg.input(input_file) stream = ffmpeg.output(stream, output_file, format=\u0026#39;hls\u0026#39;, hls_time=10, hls_list_size=0, start_number=0) ffmpeg.run(stream) if __name__ == \u0026#34;__main__\u0026#34;: input_file = \u0026#34;bunny.mp4\u0026#34; output_dir = \u0026#34;files\u0026#34; convert_to_hls(input_file, output_dir) ","permalink":"http://uly.me/posts/convert-mp4-to-hls/","summary":"\u003cp\u003eHere\u0026rsquo;s how to convert MP4 to HLS video format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport ffmpeg\n\ndef convert_to_hls(input_file, output_file):\n    \u0026#34;\u0026#34;\u0026#34;Converts an MP4 file to HLS format.\u0026#34;\u0026#34;\u0026#34;\n\n    output_file = f\u0026#34;{output_dir}/output.m3u8\u0026#34;\n\n    stream = ffmpeg.input(input_file)\n    stream = ffmpeg.output(stream, output_file, format=\u0026#39;hls\u0026#39;, \n                           hls_time=10, hls_list_size=0, \n                           start_number=0) \n    ffmpeg.run(stream)\n\nif __name__ == \u0026#34;__main__\u0026#34;:\n    input_file = \u0026#34;bunny.mp4\u0026#34;  \n    output_dir = \u0026#34;files\u0026#34;   \n    convert_to_hls(input_file, output_dir)\n\u003c/code\u003e\u003c/pre\u003e","title":"convert mp4 to hls"},{"content":"Here\u0026rsquo;s how to convert a WAV file to MP3 in Python.\nfrom pydub import AudioSegment def convert_wav_to_mp3(wav_file, mp3_file): \u0026#34;\u0026#34;\u0026#34;Converts a WAV file to MP3.\u0026#34;\u0026#34;\u0026#34; sound = AudioSegment.from_wav(wav_file) sound.export(mp3_file, format=\u0026#34;mp3\u0026#34;) if __name__ == \u0026#34;__main__\u0026#34;: wav_file = \u0026#34;gettysburg10.wav\u0026#34; mp3_file = \u0026#34;output.mp3\u0026#34; convert_wav_to_mp3(wav_file, mp3_file) print(f\u0026#34;Converted {wav_file} to {mp3_file}\u0026#34;) ","permalink":"http://uly.me/posts/convert-wav-mp3/","summary":"\u003cp\u003eHere\u0026rsquo;s how to convert a WAV file to MP3 in Python.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efrom pydub import AudioSegment\n\ndef convert_wav_to_mp3(wav_file, mp3_file):\n    \u0026#34;\u0026#34;\u0026#34;Converts a WAV file to MP3.\u0026#34;\u0026#34;\u0026#34;\n\n    sound = AudioSegment.from_wav(wav_file)\n    sound.export(mp3_file, format=\u0026#34;mp3\u0026#34;)\n\nif __name__ == \u0026#34;__main__\u0026#34;:\n    wav_file = \u0026#34;gettysburg10.wav\u0026#34;\n    mp3_file = \u0026#34;output.mp3\u0026#34;\n    convert_wav_to_mp3(wav_file, mp3_file)\n    print(f\u0026#34;Converted {wav_file} to {mp3_file}\u0026#34;)\n\u003c/code\u003e\u003c/pre\u003e","title":"convert wav mp3"},{"content":"I was getting this error whenever Apache runs a gcloud command.\nWARNING: Could not setup log file in /usr/share/httpd/.config/gcloud/logs, (Error: Could not create directory [/usr/share/httpd/.config/gcloud/logs/2025.01.06]: Permission denied. Please verify that you have permissions to write to the parent directory.. The configuration directory may not be writable. To learn more, see https://cloud.google.com/sdk/docs/configurations#creating_a_configuration ERROR: (gcloud.compute.disks.list) Could not create directory [/usr/share/httpd/.config/gcloud]: Permission denied. Please verify that you have permissions to write to the parent directory. So, here\u0026rsquo;s the fix. The .config directory under /usr/share/httpd/ is missing.\nmkdir /usr/share/httpd/.config chown -R apache:apache /usr/share/httpd/.config Create the directory and change ownership to apache:apache.\n","permalink":"http://uly.me/posts/gcloud-could-not-setup-log-file/","summary":"\u003cp\u003eI was getting this error whenever Apache runs a gcloud command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eWARNING: Could not setup log file in /usr/share/httpd/.config/gcloud/logs, \n(Error: Could not create directory [/usr/share/httpd/.config/gcloud/logs/2025.01.06]: Permission denied.\n\nPlease verify that you have permissions to write to the parent directory..\nThe configuration directory may not be writable. To learn more, see https://cloud.google.com/sdk/docs/configurations#creating_a_configuration\nERROR: (gcloud.compute.disks.list) Could not create directory [/usr/share/httpd/.config/gcloud]: Permission denied.\n\nPlease verify that you have permissions to write to the parent directory.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSo, here\u0026rsquo;s the fix. The .config directory under /usr/share/httpd/ is missing.\u003c/p\u003e","title":"gcloud could not setup log file"},{"content":"Here\u0026rsquo;s an HLS video player using hls.js.\n\u0026lt;html\u0026gt; \u0026lt;head\u0026gt; \u0026lt;script src=\u0026#34;https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.5.14/hls.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;p\u0026gt;\u0026lt;video id=\u0026#34;video\u0026#34; controls muted autoplay style=\u0026#34;width: 80%\u0026#34;\u0026gt;\u0026lt;/video\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;script\u0026gt; var video = document.getElementById(\u0026#39;video\u0026#39;); var videoSrc = \u0026#39;/bunny/output.m3u8\u0026#39;; // Initialize HLS.js if supported if (Hls.isSupported()) { var hls = new Hls(); hls.loadSource(videoSrc); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED, function () { video.muted = true; video.play(); }); } else if (video.canPlayType(\u0026#39;application/vnd.apple.mpegurl\u0026#39;)) { video.src = videoSrc; } // Assuming you have a reference to your video element const videoElement = document.getElementById(\u0026#39;video\u0026#39;); // Style the video element to center it both horizontally and vertically videoElement.style.display = \u0026#39;block\u0026#39;; // Ensure it behaves like a block element videoElement.style.margin = \u0026#39;0 auto\u0026#39;; // Center it horizontally videoElement.style.position = \u0026#39;absolute\u0026#39;; // Position it absolutely to center vertically videoElement.style.top = \u0026#39;50%\u0026#39;; // Vertically center videoElement.style.left = \u0026#39;50%\u0026#39;; // Horizontally center videoElement.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering videoElement.style.maxWidth = \u0026#39;90%\u0026#39;; // Optional: limit the video size to 90% of the screen width videoElement.style.maxHeight = \u0026#39;80vh\u0026#39;; // Optional: limit the video height to 80% of the viewport height // Create a button to unmute the player const unmuteButton = document.createElement(\u0026#39;button\u0026#39;); unmuteButton.textContent = \u0026#39;Unmute\u0026#39;; // Style the button to make it bigger unmuteButton.style.fontSize = \u0026#39;30px\u0026#39;; // Larger font size unmuteButton.style.padding = \u0026#39;20px 40px\u0026#39;; // Larger button size unmuteButton.style.backgroundColor = \u0026#39;#007BFF\u0026#39;; // Button color unmuteButton.style.color = \u0026#39;white\u0026#39;; // Text color unmuteButton.style.border = \u0026#39;none\u0026#39;; // Remove border unmuteButton.style.borderRadius = \u0026#39;10px\u0026#39;; // Rounded corners unmuteButton.style.cursor = \u0026#39;pointer\u0026#39;; // Pointer cursor on hover unmuteButton.style.position = \u0026#39;absolute\u0026#39;; // Absolute positioning unmuteButton.style.top = \u0026#39;50%\u0026#39;; // Vertically center unmuteButton.style.left = \u0026#39;50%\u0026#39;; // Horizontally center unmuteButton.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering // Add an event listener to the button unmuteButton.addEventListener(\u0026#39;click\u0026#39;, () =\u0026gt; { videoElement.muted = false; // Unmute the video unmuteButton.remove(); // Remove the button once clicked }); // Add the button to the DOM document.body.appendChild(unmuteButton); \u0026lt;/script\u0026gt; \u0026lt;/body\u0026gt; ","permalink":"http://uly.me/posts/hls-player/","summary":"\u003cp\u003eHere\u0026rsquo;s an HLS video player using hls.js.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;html\u0026gt;\n  \u0026lt;head\u0026gt;\n    \u0026lt;script src=\u0026#34;https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.5.14/hls.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;\n  \u0026lt;/head\u0026gt;\n  \u0026lt;body\u0026gt;\n    \u0026lt;p\u0026gt;\u0026lt;video id=\u0026#34;video\u0026#34; controls muted autoplay style=\u0026#34;width: 80%\u0026#34;\u0026gt;\u0026lt;/video\u0026gt;\u0026lt;/p\u0026gt;\n\n    \u0026lt;script\u0026gt;\n        var video = document.getElementById(\u0026#39;video\u0026#39;);\n        var videoSrc = \u0026#39;/bunny/output.m3u8\u0026#39;;\n    \n        // Initialize HLS.js if supported\n        if (Hls.isSupported()) {\n            var hls = new Hls();\n            hls.loadSource(videoSrc);\n            hls.attachMedia(video);\n            hls.on(Hls.Events.MANIFEST_PARSED, function () {\n                video.muted = true;\n                video.play();\n            });\n        } else if (video.canPlayType(\u0026#39;application/vnd.apple.mpegurl\u0026#39;)) {\n            video.src = videoSrc;\n        }\n    \n        // Assuming you have a reference to your video element\n        const videoElement = document.getElementById(\u0026#39;video\u0026#39;);\n    \n        // Style the video element to center it both horizontally and vertically\n        videoElement.style.display = \u0026#39;block\u0026#39;; // Ensure it behaves like a block element\n        videoElement.style.margin = \u0026#39;0 auto\u0026#39;; // Center it horizontally\n        videoElement.style.position = \u0026#39;absolute\u0026#39;; // Position it absolutely to center vertically\n        videoElement.style.top = \u0026#39;50%\u0026#39;; // Vertically center\n        videoElement.style.left = \u0026#39;50%\u0026#39;; // Horizontally center\n        videoElement.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering\n        videoElement.style.maxWidth = \u0026#39;90%\u0026#39;; // Optional: limit the video size to 90% of the screen width\n        videoElement.style.maxHeight = \u0026#39;80vh\u0026#39;; // Optional: limit the video height to 80% of the viewport height\n    \n        // Create a button to unmute the player\n        const unmuteButton = document.createElement(\u0026#39;button\u0026#39;);\n        unmuteButton.textContent = \u0026#39;Unmute\u0026#39;;\n    \n        // Style the button to make it bigger\n        unmuteButton.style.fontSize = \u0026#39;30px\u0026#39;; // Larger font size\n        unmuteButton.style.padding = \u0026#39;20px 40px\u0026#39;; // Larger button size\n        unmuteButton.style.backgroundColor = \u0026#39;#007BFF\u0026#39;; // Button color\n        unmuteButton.style.color = \u0026#39;white\u0026#39;; // Text color\n        unmuteButton.style.border = \u0026#39;none\u0026#39;; // Remove border\n        unmuteButton.style.borderRadius = \u0026#39;10px\u0026#39;; // Rounded corners\n        unmuteButton.style.cursor = \u0026#39;pointer\u0026#39;; // Pointer cursor on hover\n        unmuteButton.style.position = \u0026#39;absolute\u0026#39;; // Absolute positioning\n        unmuteButton.style.top = \u0026#39;50%\u0026#39;; // Vertically center\n        unmuteButton.style.left = \u0026#39;50%\u0026#39;; // Horizontally center\n        unmuteButton.style.transform = \u0026#39;translate(-50%, -50%)\u0026#39;; // Adjust for exact centering\n    \n        // Add an event listener to the button\n        unmuteButton.addEventListener(\u0026#39;click\u0026#39;, () =\u0026gt; {\n            videoElement.muted = false; // Unmute the video\n            unmuteButton.remove(); // Remove the button once clicked\n        });\n \n        // Add the button to the DOM\n        document.body.appendChild(unmuteButton);\n \n   \u0026lt;/script\u0026gt;\n  \u0026lt;/body\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e","title":"hls player"},{"content":"This is a Python code that generates QR Codes. Save file as qrcode.py. Provide a URL and you\u0026rsquo;re good to go.\nimport pyqrcode from pyqrcode import QRCode # String which represent the QR code s = \u0026#34;https://uly.me\u0026#34; # Generate QR code url = pyqrcode.create(s) # Create and save the png file naming \u0026#34;myqr.png\u0026#34; url.svg(\u0026#34;site.svg\u0026#34;, scale = 8) I use Python\u0026rsquo;s virtual environment for my programs so each one is isolated. Here\u0026rsquo;s the command to start one.\npython3 -m venv qrcode Activate\ncd qrcode source bin/activate You\u0026rsquo;ll need the pyqrcode module before running the program.\npip install pyqrcode Finally, run it.\npython3 qrcode.py Output is site.svg.\n![qrcode]({{ site.baseurl }}/wp-content/uploads/2025/01/site.svg)\n","permalink":"http://uly.me/posts/generate-qrcode/","summary":"\u003cp\u003eThis is a Python code that generates QR Codes. Save file as qrcode.py. Provide a URL and you\u0026rsquo;re good to go.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport pyqrcode \nfrom pyqrcode import QRCode \n  \n# String which represent the QR code \ns = \u0026#34;https://uly.me\u0026#34;\n  \n# Generate QR code \nurl = pyqrcode.create(s) \n  \n# Create and save the png file naming \u0026#34;myqr.png\u0026#34; \nurl.svg(\u0026#34;site.svg\u0026#34;, scale = 8)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI use Python\u0026rsquo;s virtual environment for my programs so each one is isolated. Here\u0026rsquo;s the command to start one.\u003c/p\u003e","title":"generate qrcode"},{"content":"Here\u0026rsquo;s one way to delete files recursively in the current directory in Linux.\ncd /home/ulysses/photos/ find . -name \u0026#34;*.pp3\u0026#34; -type f -delete The run command with delete is fast. The files are gone in seconds.\n","permalink":"http://uly.me/posts/delete-files-recursively/","summary":"\u003cp\u003eHere\u0026rsquo;s one way to delete files recursively in the current directory in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /home/ulysses/photos/\nfind . -name \u0026#34;*.pp3\u0026#34; -type f -delete\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe run command with delete is fast. The files are gone in seconds.\u003c/p\u003e","title":"delete files recursively"},{"content":"Install the Azure CLI on a Linux Desktop. This one of 2 options, but this is by far the easiest.\ncurl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash Validate Azure CLI is installed\naz --version To upgrade\naz upgrade ","permalink":"http://uly.me/posts/install-azure-cli/","summary":"\u003cp\u003eInstall the Azure CLI on a Linux Desktop. This one of 2 options, but this is by far the easiest.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eValidate Azure CLI is installed\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaz --version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo upgrade\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaz upgrade\n\u003c/code\u003e\u003c/pre\u003e","title":"install azure cli"},{"content":"These are the steps taken to make my Logitech K811 keyboard to connect via Bluetooth in Linux Mint.\nRun bluetoothctl\nbluetoothctl In the bluetoothctl command line run these commands. Replace with your own device number.\nremove 00:XX:XX:XX:XX:1F scan on pair 00:XX:XX:XX:XX:1F connect 00:XX:XX:XX:XX:1F trust 00:XX:XX:XX:XX:1F You may be asked to type a six digit code to pair the device.\n","permalink":"http://uly.me/posts/logitech-keyboard-bluetooth-linux/","summary":"\u003cp\u003eThese are the steps taken to make my Logitech K811 keyboard to connect via Bluetooth in Linux Mint.\u003c/p\u003e\n\u003cp\u003eRun bluetoothctl\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebluetoothctl\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn the bluetoothctl command line run these commands. Replace with your own device number.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eremove 00:XX:XX:XX:XX:1F\nscan on\npair 00:XX:XX:XX:XX:1F\nconnect 00:XX:XX:XX:XX:1F\ntrust 00:XX:XX:XX:XX:1F\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may be asked to type a six digit code to pair the device.\u003c/p\u003e","title":"logitech keyboard bluetooth linux"},{"content":"How to split a file into multiple files. In this example, it\u0026rsquo;s split in lines of 100.\n#!/bin/bash # Input file name input_file=\u0026#34;$1\u0026#34; # Lines per file lines_per_file=100 # Check if input file exists if [ ! -f \u0026#34;$input_file\u0026#34; ]; then echo \u0026#34;Error: Input file \u0026#39;$input_file\u0026#39; not found.\u0026#34; exit 1 fi # Get the number of lines in the input file total_lines=$(wc -l \u0026lt; \u0026#34;$input_file\u0026#34;) # Calculate the number of output files needed num_files=$(( (total_lines + lines_per_file - 1) / lines_per_file )) # Loop through the input file and split it into multiple files for ((i=1; i\u0026lt;=num_files; i++)); do # Output file name output_file=\u0026#34;${input_file}_part${i}\u0026#34; # Extract lines from the input file head -n \u0026#34;$((i * lines_per_file))\u0026#34; \u0026#34;$input_file\u0026#34; | tail -n \u0026#34;$lines_per_file\u0026#34; \u0026gt; \u0026#34;$output_file\u0026#34; done echo \u0026#34;File \u0026#39;$input_file\u0026#39; split into $num_files files.\u0026#34; exit 0 ","permalink":"http://uly.me/posts/split-file-into-multiple-files/","summary":"\u003cp\u003eHow to split a file into multiple files. In this example, it\u0026rsquo;s split in lines of 100.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# Input file name\ninput_file=\u0026#34;$1\u0026#34;\n\n# Lines per file\nlines_per_file=100\n\n# Check if input file exists\nif [ ! -f \u0026#34;$input_file\u0026#34; ]; then\n  echo \u0026#34;Error: Input file \u0026#39;$input_file\u0026#39; not found.\u0026#34;\n  exit 1\nfi\n\n# Get the number of lines in the input file\ntotal_lines=$(wc -l \u0026lt; \u0026#34;$input_file\u0026#34;)\n\n# Calculate the number of output files needed\nnum_files=$(( (total_lines + lines_per_file - 1) / lines_per_file ))\n\n# Loop through the input file and split it into multiple files\nfor ((i=1; i\u0026lt;=num_files; i++)); do\n  # Output file name\n  output_file=\u0026#34;${input_file}_part${i}\u0026#34;\n\n  # Extract lines from the input file\n  head -n \u0026#34;$((i * lines_per_file))\u0026#34; \u0026#34;$input_file\u0026#34; | tail -n \u0026#34;$lines_per_file\u0026#34; \u0026gt; \u0026#34;$output_file\u0026#34;\ndone\n\necho \u0026#34;File \u0026#39;$input_file\u0026#39; split into $num_files files.\u0026#34;\n\nexit 0\n\u003c/code\u003e\u003c/pre\u003e","title":"split file into multiple files"},{"content":"How to copy files from source to the target directory. Copy only if file is not present in the target.\n#!/bin/bash source=\u0026#34;/home/ulysses/Cameras/fujifilm\u0026#34; target=\u0026#34;/home/ulysses/Cameras/Fujifilm\u0026#34; output=\u0026#34;output.txt\u0026#34; \u0026gt; $output # Check if source directory exists if [ ! -d \u0026#34;$source\u0026#34; ]; then echo \u0026#34;Error: Directory \u0026#39;$source\u0026#39; does not exist.\u0026#34; exit 1 fi # Find all JPG files in the source directory find \u0026#34;$source\u0026#34; -type f -iname \u0026#34;*.JPG\u0026#34; | while read -r file; do # Get the basename. filename=$(basename \u0026#34;$file\u0026#34;) # Check if filename is in target directory. if find \u0026#34;$target\u0026#34; -type f -name \u0026#34;$filename\u0026#34; -print -quit | grep -q .; then true else # Copy file from source to target. cp $source/$filename $target/100_FUJI/ echo \u0026#34;Copying $file to $target/100_FUJI.\u0026#34; | tee -a $output fi done ","permalink":"http://uly.me/posts/copy-files-from-directory-to-directory/","summary":"\u003cp\u003eHow to copy files from source to the target directory. Copy only if file is not present in the target.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\nsource=\u0026#34;/home/ulysses/Cameras/fujifilm\u0026#34;\ntarget=\u0026#34;/home/ulysses/Cameras/Fujifilm\u0026#34;\n\noutput=\u0026#34;output.txt\u0026#34;\n\u0026gt; $output\n\n# Check if source directory exists\nif [ ! -d \u0026#34;$source\u0026#34; ]; then\n    echo \u0026#34;Error: Directory \u0026#39;$source\u0026#39; does not exist.\u0026#34;\n    exit 1\nfi\n\n# Find all JPG files in the source directory\nfind \u0026#34;$source\u0026#34; -type f -iname \u0026#34;*.JPG\u0026#34; | while read -r file; do\n\n    # Get the basename.\n    filename=$(basename \u0026#34;$file\u0026#34;)\n\n    # Check if filename is in target directory.\n    if find \u0026#34;$target\u0026#34; -type f -name \u0026#34;$filename\u0026#34; -print -quit | grep -q .; then\n        true\n    else\n        # Copy file from source to target.\n        cp $source/$filename $target/100_FUJI/\n        echo \u0026#34;Copying $file to $target/100_FUJI.\u0026#34; | tee -a $output\n    fi\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"copy files from directory to directory"},{"content":"Tar multiple directories to a single tar.gz file.\ntar -czvf /home/ulysses/Code/backup.tar.gz ~/Documents/ ~/Downloads ~/Git/gcloud/ ~/Pictures ~/Videos To list files inside the tar.gz file, run this.\ntar -tzvf /home/ulysses/Code/backup.tar.gz ","permalink":"http://uly.me/posts/tar-multiple-directories-to-targz/","summary":"\u003cp\u003eTar multiple directories to a single tar.gz file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -czvf /home/ulysses/Code/backup.tar.gz ~/Documents/ ~/Downloads ~/Git/gcloud/ ~/Pictures ~/Videos\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo list files inside the tar.gz file, run this.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -tzvf /home/ulysses/Code/backup.tar.gz\n\u003c/code\u003e\u003c/pre\u003e","title":"tar multiple directories to targz"},{"content":"Here\u0026rsquo;s the gcloud command to create a new image with an extended license with an option to add family type.\ngcloud beta compute images create new-image-with-license \\ --source-image=this-is-the-source-image \\ --family rocky-9 \\ --project your-project-id \\ --user-licenses=https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/licenses/rhel-7-els Any VM provisioned using this image will now have the extended license.\n","permalink":"http://uly.me/posts/gcp-create-image-with-license/","summary":"\u003cp\u003eHere\u0026rsquo;s the gcloud command to create a new image with an extended license with an option to add family type.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta compute images create new-image-with-license \\\n--source-image=this-is-the-source-image \\\n--family rocky-9 \\\n--project your-project-id \\\n--user-licenses=https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/licenses/rhel-7-els\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAny VM provisioned using this image will now have the extended license.\u003c/p\u003e","title":"gcp create image with license"},{"content":"Here\u0026rsquo;s a gsutil command to copy a directory recursively to a GCS bucket via parallel uploads.\n# Define source and destination SOURCE_DIR=\u0026#34;/path/to/local/directory\u0026#34; DEST_BUCKET=\u0026#34;gs://your-bucket-name\u0026#34; # Use gsutil with the -m flag for parallel uploads gsutil -m cp -r \u0026#34;$SOURCE_DIR\u0026#34; \u0026#34;$DEST_BUCKET\u0026#34; ","permalink":"http://uly.me/posts/gsutil-copy-local-recursively-to-bucket/","summary":"\u003cp\u003eHere\u0026rsquo;s a gsutil command to copy a directory recursively to a GCS bucket via parallel uploads.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Define source and destination\nSOURCE_DIR=\u0026#34;/path/to/local/directory\u0026#34;\nDEST_BUCKET=\u0026#34;gs://your-bucket-name\u0026#34;\n\n# Use gsutil with the -m flag for parallel uploads\ngsutil -m cp -r \u0026#34;$SOURCE_DIR\u0026#34; \u0026#34;$DEST_BUCKET\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gsutil copy local recursively to bucket"},{"content":"I fixed my Bluetooth issues with my Logitech K811 keyboard on Linux Mint\nTake note of your device ID in a similar format as a MAC Address.\nHere are the steps I took to fix the pairing issue.\nRun bluetoothctl, you will get a special prompt.\nbluetoothctl Perform a scan. Copy the device ID.\nscan on Remove the device.\nremove ID Finally reconnect device.\nconnect ID trust ID pair ID You may be prompted to enter the pairing code.\nSimply enter the numbers.\nThat\u0026rsquo;s it.\n","permalink":"http://uly.me/posts/logitech-keyboard-bluetooth-issues/","summary":"\u003cp\u003eI fixed my Bluetooth issues with my Logitech K811 keyboard on Linux Mint\u003c/p\u003e\n\u003cp\u003eTake note of your device ID in a similar format as a MAC Address.\u003c/p\u003e\n\u003cp\u003eHere are the steps I took to fix the pairing issue.\u003c/p\u003e\n\u003cp\u003eRun bluetoothctl, you will get a special prompt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebluetoothctl \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePerform a scan. Copy the device ID.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escan on\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove the device.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eremove ID\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally reconnect device.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003econnect ID\ntrust ID\npair ID\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may be prompted to enter the pairing code.\u003c/p\u003e","title":"logitech keyboard bluetooth issues"},{"content":"I have a Python script that copies files from a local directory to a GCS bucket and down a couple of directories.\nThe script was tested in a Python virtual environment. Google Cloud Storage module is required which can be installed via pip.\npip install google-cloud-storage If you have trouble running pip, you may have to run this on Linux Mint (Ubuntu) to update the virtual environment.\napt install python3.12-venv For authentication, you will need to download the service account credentials key that has write access to the GCS bucket.\nexport GOOGLE_APPLICATION_CREDENTIALS=\u0026#34;key.json\u0026#34; Finally, here\u0026rsquo;s the Python script \u0026hellip;\n#!bin/python from google.cloud import storage import os def upload_files_to_gcs(bucket_name, directory, destination_directory): \u0026#34;\u0026#34;\u0026#34;Uploads files from a local directory to a GCS bucket. Args: bucket_name: The name of the GCS bucket. directory: The local directory containing the files to upload. destination_directory: The directory in the GCS bucket where the files will be uploaded. \u0026#34;\u0026#34;\u0026#34; storage_client = storage.Client() bucket = storage_client.bucket(bucket_name) for file_name in os.listdir(directory): file_path = os.path.join(directory, file_name) if os.path.isfile(file_path): blob = bucket.blob(os.path.join(destination_directory, file_name)) blob.upload_from_filename(file_path) print(f\u0026#34;Uploaded {file_name} to {bucket_name}/{destination_directory}\u0026#34;) if __name__ == \u0026#34;__main__\u0026#34;: bucket_name = \u0026#34;ulysses-test-bucket\u0026#34; directory = \u0026#34;/home/ulysses/Code/python/gcs/upload\u0026#34; destination_directory = \u0026#34;upload/test/\u0026#34; upload_files_to_gcs(bucket_name, directory, destination_directory) ","permalink":"http://uly.me/posts/python-copy-files-gcs-bucket/","summary":"\u003cp\u003eI have a Python script that copies files from a local directory to a GCS bucket and down a couple of directories.\u003c/p\u003e\n\u003cp\u003eThe script was tested in a Python virtual environment. Google Cloud Storage module is required which can be installed via pip.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epip install google-cloud-storage\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have trouble running pip, you may have to run this on Linux Mint (Ubuntu) to update the virtual environment.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install python3.12-venv\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor authentication, you will need to download the service account credentials key that has write access to the GCS bucket.\u003c/p\u003e","title":"python copy files gcs bucket"},{"content":"Here\u0026rsquo;s the code for a bash script that generates another bash script and then executes it, as well as deletes it in the end.\n#!/bin/bash # Define the script content script_content=\u0026#39;#!/bin/bash echo \u0026#34;Hello, this is the generated script!\u0026#34; echo \u0026#34;The current date and time is: $(date)\u0026#34; \u0026#39; # Define the name of the new script new_script=\u0026#34;generated_script.sh\u0026#34; # Write the content to the new script file echo \u0026#34;$script_content\u0026#34; \u0026gt; \u0026#34;$new_script\u0026#34; # Make the new script executable chmod +x \u0026#34;$new_script\u0026#34; # Execute the new script ./\u0026#34;$new_script\u0026#34; rm -f $new_script ","permalink":"http://uly.me/posts/generating-a-bash-script/","summary":"\u003cp\u003eHere\u0026rsquo;s the code for a bash script that generates another bash script and then executes it, as well as deletes it in the end.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# Define the script content\nscript_content=\u0026#39;#!/bin/bash\necho \u0026#34;Hello, this is the generated script!\u0026#34;\necho \u0026#34;The current date and time is: $(date)\u0026#34;\n\u0026#39;\n\n# Define the name of the new script\nnew_script=\u0026#34;generated_script.sh\u0026#34;\n\n# Write the content to the new script file\necho \u0026#34;$script_content\u0026#34; \u0026gt; \u0026#34;$new_script\u0026#34;\n\n# Make the new script executable\nchmod +x \u0026#34;$new_script\u0026#34;\n\n# Execute the new script\n./\u0026#34;$new_script\u0026#34;\n\nrm -f $new_script\n\u003c/code\u003e\u003c/pre\u003e","title":"generating a bash script"},{"content":"How to convert uppercase to lowercase and vice versa.\nupper_project=$(echo \u0026#34;$project\u0026#34; | tr \u0026#39;[:lower:]\u0026#39; \u0026#39;[:upper:]\u0026#39;) Vice versa\nlower_project=$(echo \u0026#34;$project\u0026#34; | tr \u0026#39;[:upper:]\u0026#39; \u0026#39;[:lower:]\u0026#39;) Display output\necho $upper_project echo $lower_project ","permalink":"http://uly.me/posts/lower-to-upper-vice-versa/","summary":"\u003cp\u003eHow to convert uppercase to lowercase and vice versa.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eupper_project=$(echo \u0026#34;$project\u0026#34; | tr \u0026#39;[:lower:]\u0026#39; \u0026#39;[:upper:]\u0026#39;)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVice versa\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elower_project=$(echo \u0026#34;$project\u0026#34; | tr \u0026#39;[:upper:]\u0026#39; \u0026#39;[:lower:]\u0026#39;)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay output\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $upper_project\necho $lower_project\n\u003c/code\u003e\u003c/pre\u003e","title":"lower to upper vice versa"},{"content":"I was getting an Apache error on startup and during a restart after upgrading to Linux Mint 22.\nAs it turned out, the module that\u0026rsquo;s enabled is php8.1. It should be 8.3.\nHere\u0026rsquo;s the fix:\nsudo a2dismod php8.1 sudo systemctl restart apache2 This did the trick, but I was getting another error during restarting services.\nThe error says \u0026ldquo;could not reliably determin the server fully qualified domain.\u0026rdquo;\nHere\u0026rsquo;s the fix for that.\nsudo vi /etc/apache2/apache2.conf Insert\nServerName localhost Restart Apache\nsudo systemctl restart apache2 ","permalink":"http://uly.me/posts/fixing-apache-errors/","summary":"\u003cp\u003eI was getting an Apache error on startup and during a restart after upgrading to Linux Mint 22.\u003c/p\u003e\n\u003cp\u003eAs it turned out, the module that\u0026rsquo;s enabled is php8.1. It should be 8.3.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s the fix:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo a2dismod php8.1\nsudo systemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis did the trick, but I was getting another error during restarting services.\u003c/p\u003e\n\u003cp\u003eThe error says \u0026ldquo;could not reliably determin the server fully qualified domain.\u0026rdquo;\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s the fix for that.\u003c/p\u003e","title":"fixing apache errors"},{"content":"How to undo git\u0026rsquo;s last commit.\ngit reset --soft HEAD~ Undo the last 2 commits.\ngit reset --soft HEAD~2 Undo local changes.\ngit reset --hard abcd543 ","permalink":"http://uly.me/posts/git-undo-last-commit/","summary":"\u003cp\u003eHow to undo git\u0026rsquo;s last commit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit reset --soft HEAD~\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUndo the last 2 commits.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit reset --soft HEAD~2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUndo local changes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit reset --hard abcd543\n\u003c/code\u003e\u003c/pre\u003e","title":"git undo last commit"},{"content":"I\u0026rsquo;m trying to figure out why my audio is not automatically starting on Linux.\nAfter some trial and error, here\u0026rsquo;s the fix.\nEdit the /etc/pulse/client.conf file.\nvi /etc/pulse/client.conf Change \u0026ldquo;autospawn=no\u0026rdquo; to \u0026ldquo;autospawn=yes.\u0026rdquo;\nautospawn=yes Make sure to take out \u0026lsquo;;\u0026rsquo; or \u0026lsquo;#\u0026quot; to remove the comment.\npulseaudio --start Once you modified the file, restart pulseaudio.\npulseaudio --start Reboot your machine to check if audio is working on boot.\nIf that doesn\u0026rsquo;t work, delete the cookie.\nrm -f ~/.config/pulse/cookie You can restart the service.\nsystemctl --user restart pulseaudio In addition, running this command worked if audio does not load automatically.\npulseaudio -k In my case, I added the following to my Startup Applications because it wasn\u0026rsquo;t loading properly.\nsystemctl --user restart pulseaudio Enjoy.\n","permalink":"http://uly.me/posts/pulseaudio-auto-start/","summary":"\u003cp\u003eI\u0026rsquo;m trying to figure out why my audio is not automatically starting on Linux.\u003c/p\u003e\n\u003cp\u003eAfter some trial and error, here\u0026rsquo;s the fix.\u003c/p\u003e\n\u003cp\u003eEdit the /etc/pulse/client.conf file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evi /etc/pulse/client.conf\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange \u0026ldquo;autospawn=no\u0026rdquo; to \u0026ldquo;autospawn=yes.\u0026rdquo;\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eautospawn=yes\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake sure to take out \u0026lsquo;;\u0026rsquo; or \u0026lsquo;#\u0026quot; to remove the comment.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epulseaudio --start \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce you modified the file, restart pulseaudio.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epulseaudio --start\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot your machine to check if audio is working on boot.\u003c/p\u003e\n\u003cp\u003eIf that doesn\u0026rsquo;t work, delete the cookie.\u003c/p\u003e","title":"pulseaudio auto start"},{"content":"Somehow I lost my audio devices in Linux Mint. Instead, the only audio device present in the system is the \u0026lsquo;dummy output.\u0026rsquo; Googling for answers was not clear cut. After many trials and errors I was able to get my sound fixed. Here are the commands I took to get my audio devices back in the fold in Linux Mint. Your mileage may vary.\nFirst, validate your sound devices are still present or being recognized on your system.\naplay -l You can try also Alsa. You may have to install it first.\nsudo apt install alsa-utils alsamixer -c 1 Then remove and purge pulseaudio and start fresh.\nrm -r ~/.config/pulse/ pulseaudio -k killall pulseaudio apt remove pulseaudio apt purge pulseaudio reboot After reboot, reinstall pulseaudio.\napt install pulseaudio Make sure to enable and to start pulseaudio on bootup.\nsystemctl --user enable pulseaudio systemctl --user start pulseaudio systemctl --user status pulseaudio Your sound devices should load. You should be able to hear again.\n","permalink":"http://uly.me/posts/linux-mint-dummy-output/","summary":"\u003cp\u003eSomehow I lost my audio devices in Linux Mint. Instead, the only audio device present in the system is the \u0026lsquo;dummy output.\u0026rsquo; Googling for answers was not clear cut. After many trials and errors I was able to get my sound fixed. Here are the commands I took to get my audio devices back in the fold in Linux Mint. Your mileage may vary.\u003c/p\u003e\n\u003cp\u003eFirst, validate your sound devices are still present or being recognized on your system.\u003c/p\u003e","title":"linux mint dummy output"},{"content":"How to exit gracefully from GCP\u0026rsquo;s serial console.\nType on the keyboard tilde followed by dot.\n~. That would be tilde followed by a dot.\n","permalink":"http://uly.me/posts/gcp-exit-serial-console/","summary":"\u003cp\u003eHow to exit gracefully from GCP\u0026rsquo;s serial console.\u003c/p\u003e\n\u003cp\u003eType on the keyboard tilde followed by dot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e~.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThat would be tilde followed by a dot.\u003c/p\u003e","title":"gcp exit serial console"},{"content":"Here\u0026rsquo;s a good way to add comments to a Bash function.\n############################################################ # Function : calculate_average # Description : Calculates the average of a list of numbers. # Parameters : List of numbers separated by spaces # Returns : The average value of the input numbers ############################################################ calculate_average() { ... } ############################################################ # Function : calculate_sum # Description : Calculates the sum of a list of numbers. # Parameters : List of numbers separated by spaces # Returns : The sum value of the input numbers ############################################################ calculate_sum() { ... } ","permalink":"http://uly.me/posts/bash-function-comments/","summary":"\u003cp\u003eHere\u0026rsquo;s a good way to add comments to a Bash function.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e############################################################\n# Function    : calculate_average\n# Description : Calculates the average of a list of numbers.\n# Parameters  : List of numbers separated by spaces\n# Returns     : The average value of the input numbers\n############################################################\ncalculate_average() {\n  ...\n}\n\n############################################################\n# Function    : calculate_sum\n# Description : Calculates the sum of a list of numbers.\n# Parameters  : List of numbers separated by spaces\n# Returns     : The sum value of the input numbers\n############################################################\ncalculate_sum() {\n  ...\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"bash function comments"},{"content":"How to add to a crontab without creating duplicates.\ncrontab -l | grep \u0026#39;myscript.sh\u0026#39; || (crontab -l 2\u0026gt;/dev/null; echo \u0026#34;45 10 * * * /path/to/myscript.sh\u0026#34;) | crontab - ","permalink":"http://uly.me/posts/add-to-crontab-with-no-duplicate/","summary":"\u003cp\u003eHow to add to a crontab without creating duplicates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab -l | grep \u0026#39;myscript.sh\u0026#39; || (crontab -l 2\u0026gt;/dev/null; echo \u0026#34;45 10 * * * /path/to/myscript.sh\u0026#34;) | crontab -\n\u003c/code\u003e\u003c/pre\u003e","title":"add to crontab with no duplicate"},{"content":"Here\u0026rsquo;s a good way to compare two directories to see if both directories contain similar files.\nThis is essential if you want to combine two directories into one.\ndiff -qr dir1 dir2 | sort ","permalink":"http://uly.me/posts/diff-files-in-two-directories/","summary":"\u003cp\u003eHere\u0026rsquo;s a good way to compare two directories to see if both directories contain similar files.\u003c/p\u003e\n\u003cp\u003eThis is essential if you want to combine two directories into one.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ediff -qr dir1 dir2 | sort\n\u003c/code\u003e\u003c/pre\u003e","title":"diff files in two directories"},{"content":"Here\u0026rsquo;s a function that will convert a timestamp from one timezone to another, in this case from UTC to ET timezone.\nGet a list of snapshots\nlist_snapshots() { volume_name=\u0026#34;$1\u0026#34; snapshots=$(gcloud compute snapshots list --filter=\u0026#34;sourceDisk=$volume_name\u0026#34; --format=\u0026#34;value(name,creationTimestamp.date(\u0026#39;%s\u0026#39;))\u0026#34;) while read -r snapshot; do snapshot_name=$(echo \u0026#34;$snapshot\u0026#34; | cut -d\u0026#39; \u0026#39; -f1) creation_timestamp=$(echo \u0026#34;$snapshot\u0026#34; | cut -d\u0026#39; \u0026#39; -f2) et_creation_timestamp=$(convert_to_et \u0026#34;$creation_timestamp\u0026#34;) echo \u0026#34;Snapshot: $snapshot_name, Creation Time (ET): $et_creation_timestamp\u0026#34; done \u0026lt;\u0026lt;\u0026lt; \u0026#34;$snapshots\u0026#34; } The function to convert to ET timezone.\nconvert_to_et() { timestamp=\u0026#34;$1\u0026#34; et_timestamp=$(date --date=\u0026#34;@${timestamp}\u0026#34; +\u0026#34;%Y-%m-%d %H:%M:%S %Z\u0026#34; -u) echo \u0026#34;$et_timestamp\u0026#34; } Finally, call the function.\nvolume_name=\u0026#34;$1\u0026#34; list_snapshots \u0026#34;$volume_name\u0026#34; ","permalink":"http://uly.me/posts/timestamp-timezone-conversion/","summary":"\u003cp\u003eHere\u0026rsquo;s a function that will convert a timestamp from one timezone to another, in this case from UTC to ET timezone.\u003c/p\u003e\n\u003cp\u003eGet a list of snapshots\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elist_snapshots() {\n    volume_name=\u0026#34;$1\u0026#34;\n    snapshots=$(gcloud compute snapshots list --filter=\u0026#34;sourceDisk=$volume_name\u0026#34; --format=\u0026#34;value(name,creationTimestamp.date(\u0026#39;%s\u0026#39;))\u0026#34;)\n    while read -r snapshot; do\n        snapshot_name=$(echo \u0026#34;$snapshot\u0026#34; | cut -d\u0026#39; \u0026#39; -f1)\n        creation_timestamp=$(echo \u0026#34;$snapshot\u0026#34; | cut -d\u0026#39; \u0026#39; -f2)\n        et_creation_timestamp=$(convert_to_et \u0026#34;$creation_timestamp\u0026#34;)\n        echo \u0026#34;Snapshot: $snapshot_name, Creation Time (ET): $et_creation_timestamp\u0026#34;\n    done \u0026lt;\u0026lt;\u0026lt; \u0026#34;$snapshots\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe function to convert to ET timezone.\u003c/p\u003e","title":"timestamp timezone conversion"},{"content":"After a few weeks with OpenWRT, I decided to switch over to DDWRT. There is nothing wrong with OpenWRT. DDWRT is a much simpler interface.\nIt seems to be very stable as well. I don\u0026rsquo;t recall any reboots other than service provider having an internet issue.\nI think that was a great decision while still using old router hardware, a Linksys E4200 circa 2011 (release date).\nOne of these days I will have to purchase a new router, but why fix something that not broken.\n","permalink":"http://uly.me/posts/ddwrt/","summary":"\u003cp\u003eAfter a few weeks with OpenWRT, I decided to switch over to DDWRT. There is nothing wrong with OpenWRT. DDWRT is a much simpler interface.\u003c/p\u003e\n\u003cp\u003eIt seems to be very stable as well. I don\u0026rsquo;t recall any reboots other than service provider having an internet issue.\u003c/p\u003e\n\u003cp\u003eI think that was a great decision while still using old router hardware, a Linksys E4200 circa 2011 (release date).\u003c/p\u003e\n\u003cp\u003eOne of these days I will have to purchase a new router, but why fix something that not broken.\u003c/p\u003e","title":"ddwrt"},{"content":"A little Python script to brighten an image.\nimport os from PIL import ImageEnhance, Image def brightenImage(input_dir, output_dir): os.makedirs(output_dir, exist_ok=True) # output directory for filename in os.listdir(input_dir): # loop through files if filename.lower().endswith(\u0026#39;.jpg\u0026#39;): # check if jpg with Image.open(os.path.join(input_dir, filename)) as img: # open jpg enhanced_img = ImageEnhance.Contrast(img).enhance(1.25) # enhance contrast enhanced_img = ImageEnhance.Brightness(enhanced_img).enhance(1.5) # enhance brightness enhanced_img.save(os.path.join(output_dir, filename)) # save output if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory brightenImage(input_directory, output_directory) # brighten image ","permalink":"http://uly.me/posts/brigthen/","summary":"\u003cp\u003eA little Python script to brighten an image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import ImageEnhance, Image\n\ndef brightenImage(input_dir, output_dir):\n    os.makedirs(output_dir, exist_ok=True)                                          # output directory\n    for filename in os.listdir(input_dir):                                          # loop through files\n        if filename.lower().endswith(\u0026#39;.jpg\u0026#39;):                                       # check if jpg\n            with Image.open(os.path.join(input_dir, filename)) as img:              # open jpg  \n                enhanced_img = ImageEnhance.Contrast(img).enhance(1.25)             # enhance contrast\n                enhanced_img = ImageEnhance.Brightness(enhanced_img).enhance(1.5)   # enhance brightness\n                enhanced_img.save(os.path.join(output_dir, filename))               # save output\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                           # input directory\n    output_directory = \u0026#39;output\u0026#39;                                                     # output directory\n    brightenImage(input_directory, output_directory)                                # brighten image\n\u003c/code\u003e\u003c/pre\u003e","title":"brigthen"},{"content":"Here\u0026rsquo;s a litte Python script that enhance a jpg image.\nimport os from PIL import ImageEnhance, Image def enhance(input_dir, output_dir, factor=1.75): os.makedirs(output_dir, exist_ok=True) # Create output directory for filename in os.listdir(input_dir): # Loop through all files if filename.lower().endswith(\u0026#39;.jpg\u0026#39;): # Check if JPG image with Image.open(os.path.join(input_dir, filename)) as img: # Open the image file enhanced_img = ImageEnhance.Color(img).enhance(factor) # Enhance image enhanced_img.save(os.path.join(output_dir, filename)) # Save image if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory enhance(input_directory, output_directory) # enhance ","permalink":"http://uly.me/posts/enhance/","summary":"\u003cp\u003eHere\u0026rsquo;s a litte Python script that enhance a jpg image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import ImageEnhance, Image\n\ndef enhance(input_dir, output_dir, factor=1.75):\n    os.makedirs(output_dir, exist_ok=True)                                  # Create output directory   \n    for filename in os.listdir(input_dir):                                  # Loop through all files\n        if filename.lower().endswith(\u0026#39;.jpg\u0026#39;):                               # Check if JPG image\n            with Image.open(os.path.join(input_dir, filename)) as img:      # Open the image file\n                enhanced_img = ImageEnhance.Color(img).enhance(factor)      # Enhance image\n                enhanced_img.save(os.path.join(output_dir, filename))       # Save image\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                   # input directory\n    output_directory = \u0026#39;output\u0026#39;                                             # output directory\n    enhance(input_directory, output_directory)                              # enhance\n\u003c/code\u003e\u003c/pre\u003e","title":"enhance"},{"content":"Here\u0026rsquo;s a little Python script that creates thumbnails.\nimport os from PIL import Image def resize(input_dir, output_dir, thumbnail_size=(720, 720)): # set to 720p os.makedirs(output_dir, exist_ok=True) # output directory for filename in os.listdir(input_dir): # loop through files if filename.lower().endswith(\u0026#39;.jpg\u0026#39;): # check if JPG with Image.open(os.path.join(input_dir, filename)) as img: # open image img.thumbnail(thumbnail_size) # reduce to thumbnail img.save(os.path.join(output_dir, filename)) # save thumbnail if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory resize(input_directory, output_directory) # resize images ","permalink":"http://uly.me/posts/resize/","summary":"\u003cp\u003eHere\u0026rsquo;s a little Python script that creates thumbnails.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import Image\n\ndef resize(input_dir, output_dir, thumbnail_size=(720, 720)):               # set to 720p\n    os.makedirs(output_dir, exist_ok=True)                                  # output directory \n    for filename in os.listdir(input_dir):                                  # loop through files \n        if filename.lower().endswith(\u0026#39;.jpg\u0026#39;):                               # check if JPG\n            with Image.open(os.path.join(input_dir, filename)) as img:      # open image\n                img.thumbnail(thumbnail_size)                               # reduce to thumbnail\n                img.save(os.path.join(output_dir, filename))                # save thumbnail\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                   # input directory\n    output_directory = \u0026#39;output\u0026#39;                                             # output directory\n    resize(input_directory, output_directory)                               # resize images\n\u003c/code\u003e\u003c/pre\u003e","title":"resize"},{"content":"Here\u0026rsquo;s a little Python script that makes vintage pictures.\nimport os from PIL import Image, ImageFilter, ImageOps, ImageEnhance def vintage(input_dir, output_dir): os.makedirs(output_dir, exist_ok=True) # output directory for filename in os.listdir(input_dir): # Loop through files if filename.lower().endswith(\u0026#39;.jpg\u0026#39;): # Check if JPG with Image.open(os.path.join(input_dir, filename)) as img: # Open jpg img = img.convert(\u0026#34;RGB\u0026#34;) # vintage effects img = ImageOps.grayscale(img) img = img.filter(ImageFilter.SMOOTH_MORE) img = ImageOps.posterize(img, 8) img = ImageEnhance.Contrast(img).enhance(1.4) img = ImageEnhance.Brightness(img).enhance(1.75) img = ImageOps.colorize(img, \u0026#34;#704214\u0026#34;, \u0026#34;#eeeeee\u0026#34;) img = ImageEnhance.Color(img).enhance(0.8) img.save(os.path.join(output_dir, filename)) # Save image if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory vintage(input_directory, output_directory) # make vintage ","permalink":"http://uly.me/posts/vintage/","summary":"\u003cp\u003eHere\u0026rsquo;s a little Python script that makes vintage pictures.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import Image, ImageFilter, ImageOps, ImageEnhance\n\ndef vintage(input_dir, output_dir):\n    os.makedirs(output_dir, exist_ok=True)                                  # output directory\n    for filename in os.listdir(input_dir):                                  # Loop through files\n        if filename.lower().endswith(\u0026#39;.jpg\u0026#39;):                               # Check if JPG\n\n            with Image.open(os.path.join(input_dir, filename)) as img:      # Open jpg\n                img = img.convert(\u0026#34;RGB\u0026#34;)                                    # vintage effects\n                img = ImageOps.grayscale(img)\n                img = img.filter(ImageFilter.SMOOTH_MORE)\n                img = ImageOps.posterize(img, 8)\n                img = ImageEnhance.Contrast(img).enhance(1.4)\n                img = ImageEnhance.Brightness(img).enhance(1.75)\n                img = ImageOps.colorize(img, \u0026#34;#704214\u0026#34;, \u0026#34;#eeeeee\u0026#34;)\n                img = ImageEnhance.Color(img).enhance(0.8)\n                img.save(os.path.join(output_dir, filename))                # Save image\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                   # input directory\n    output_directory = \u0026#39;output\u0026#39;                                             # output directory\n    vintage(input_directory, output_directory)                              # make vintage\n\u003c/code\u003e\u003c/pre\u003e","title":"vintage"},{"content":"Here\u0026rsquo;s a little Python script that corrects white balance.\nimport os from PIL import Image def whiteBalance(input_dir, output_dir, red_ratio=1.0, blue_ratio=1.0): os.makedirs(output_dir, exist_ok=True) # output directory for filename in os.listdir(input_dir): # Loop through files if filename.lower().endswith((\u0026#39;.jpg\u0026#39;, \u0026#39;.jpeg\u0026#39;, \u0026#39;.png\u0026#39;)): # Check if image with Image.open(os.path.join(input_dir, filename)) as img: # Open the image red_channel = img.getchannel(\u0026#39;R\u0026#39;) # wb correction green_channel = img.getchannel(\u0026#39;G\u0026#39;) blue_channel = img.getchannel(\u0026#39;B\u0026#39;) red_channel = red_channel.point(lambda p: min(int(p * red_ratio), 255)) # Adjust colors blue_channel = blue_channel.point(lambda p: min(int(p * blue_ratio), 255)) corrected_img = Image.merge(\u0026#39;RGB\u0026#39;, (red_channel, green_channel, blue_channel)) # merge colors corrected_img.save(os.path.join(output_dir, filename)) # Save image if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory red_ratio = 0.9 # Adjust red blue_ratio = 1.5 # Adjust blue whiteBalance(input_directory, output_directory, red_ratio, blue_ratio) # Correct wb ","permalink":"http://uly.me/posts/white-balance/","summary":"\u003cp\u003eHere\u0026rsquo;s a little Python script that corrects white balance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import Image\n\ndef whiteBalance(input_dir, output_dir, red_ratio=1.0, blue_ratio=1.0):\n    os.makedirs(output_dir, exist_ok=True)                                                          # output directory\n    for filename in os.listdir(input_dir):                                                          # Loop through files\n        if filename.lower().endswith((\u0026#39;.jpg\u0026#39;, \u0026#39;.jpeg\u0026#39;, \u0026#39;.png\u0026#39;)):                                    # Check if image \n            with Image.open(os.path.join(input_dir, filename)) as img:                              # Open the image\n                red_channel = img.getchannel(\u0026#39;R\u0026#39;)                                                   # wb correction\n                green_channel = img.getchannel(\u0026#39;G\u0026#39;)\n                blue_channel = img.getchannel(\u0026#39;B\u0026#39;)\n                red_channel = red_channel.point(lambda p: min(int(p * red_ratio), 255))             # Adjust colors\n                blue_channel = blue_channel.point(lambda p: min(int(p * blue_ratio), 255))\n                corrected_img = Image.merge(\u0026#39;RGB\u0026#39;, (red_channel, green_channel, blue_channel))      # merge colors\n                corrected_img.save(os.path.join(output_dir, filename))                              # Save image\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                                           # input directory\n    output_directory = \u0026#39;output\u0026#39;                                                                     # output directory\n    red_ratio = 0.9                                                                                 # Adjust red \n    blue_ratio = 1.5                                                                                # Adjust blue\n    whiteBalance(input_directory, output_directory, red_ratio, blue_ratio)                          # Correct wb\n\u003c/code\u003e\u003c/pre\u003e","title":"white balance"},{"content":"Here\u0026rsquo;s a Python code to convert JPG pictures to black and white.\nimport os from PIL import Image # black and white def blackWhite(input_dir, output_dir): os.makedirs(output_dir, exist_ok=True) # output directory for filename in os.listdir(input_dir): # loop all files if filename.lower().endswith(\u0026#39;.jpg\u0026#39;): # Check if JPG image with Image.open(os.path.join(input_dir, filename)) as img: # Open image file bw_img = img.convert(\u0026#39;L\u0026#39;) # Convert to bw bw_img.save(os.path.join(output_dir, filename)) # Save bw if __name__ == \u0026#39;__main__\u0026#39;: input_directory = \u0026#39;.\u0026#39; # input directory output_directory = \u0026#39;output\u0026#39; # output directory blackWhite(input_directory, output_directory) # conver to bw ","permalink":"http://uly.me/posts/black-and-white/","summary":"\u003cp\u003eHere\u0026rsquo;s a Python code to convert JPG pictures to black and white.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport os\nfrom PIL import Image\n\n# black and white\n\ndef blackWhite(input_dir, output_dir):\n    os.makedirs(output_dir, exist_ok=True)                                  # output directory\n    for filename in os.listdir(input_dir):                                  # loop all files\n        if filename.lower().endswith(\u0026#39;.jpg\u0026#39;):                               # Check if JPG image\n            with Image.open(os.path.join(input_dir, filename)) as img:      # Open image file\n                bw_img = img.convert(\u0026#39;L\u0026#39;)                                   # Convert to bw\n                bw_img.save(os.path.join(output_dir, filename))             # Save bw\n\nif __name__ == \u0026#39;__main__\u0026#39;:\n    input_directory = \u0026#39;.\u0026#39;                                                   # input directory\n    output_directory = \u0026#39;output\u0026#39;                                             # output directory\n    blackWhite(input_directory, output_directory)                           # conver to bw\n\u003c/code\u003e\u003c/pre\u003e","title":"black and white"},{"content":"If you have a Nikon DSLR camera and you shoot in RAW format, you\u0026rsquo;ll end up with a NEF file. You can easily convert several NEF files to JPG by running a Python script. It\u0026rsquo;s fast and works fairly well. If you want to run in a controlled Python environment, I suggest that you create a virtual environment. You can group all your imaging scripts in one virtual environment.\nHere\u0026rsquo;s the code to convert NEF files to JPG.\nimport glob import rawpy import imageio def nef2jpg(): directory = \u0026#34;.\u0026#34; # set directory pathnef = glob.glob(f\u0026#34;{directory}/*.nef\u0026#34;) # list of nef files pathNEF = glob.glob(f\u0026#34;{directory}/*.NEF\u0026#34;) # list of NEF files count = 0 number_files = len(pathnef) + len(pathNEF) print(\u0026#34;Total Number of Images: \u0026#34;, number_files) for path in pathnef: with rawpy.imread(path) as raw: rgb = raw.postprocess() imageio.imwrite(path.replace(\u0026#39;.nef\u0026#39;, \u0026#39;\u0026#39;) + \u0026#39;.jpg\u0026#39;, rgb) # convert nef to jpg count = count + 1 print(count, \u0026#39;/\u0026#39;, number_files) for path in pathNEF: with rawpy.imread(path) as raw: rgb = raw.postprocess() imageio.imwrite(path.replace(\u0026#39;.NEF\u0026#39;, \u0026#39;\u0026#39;) + \u0026#39;.jpg\u0026#39;, rgb) # convert NEF to jpg count = count + 1 print(count, \u0026#39;/\u0026#39;, number_files) if __name__ == \u0026#39;__main__\u0026#39;: nef2jpg() The script uses rawpy and imageio to convert files.\n","permalink":"http://uly.me/posts/nef-to-jpg/","summary":"\u003cp\u003eIf you have a Nikon DSLR camera and you shoot in RAW format, you\u0026rsquo;ll end up with a NEF file. You can easily convert several NEF files to JPG by running a Python script. It\u0026rsquo;s fast and works fairly well. If you want to run in a controlled Python environment, I suggest that you create a virtual environment. You can group all your imaging scripts in one virtual environment.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s the code to convert NEF files to JPG.\u003c/p\u003e","title":"nef to jpg"},{"content":"If you are tired of using the default Terminal prompt, then give oh-my-posh a try.\nWhether you\u0026rsquo;re using bash in Linux or zsh on a Mac, oh-my-posh can style your prompt.\nGet familiar with oh-my-posh\u0026rsquo;s syntax. It\u0026rsquo;s not difficult once you get rolling.\nBrowse several of the themes available on their site to get ideas.\nHead over to Canva.com to get a color palette.\nHere\u0026rsquo;s my current prompt setup.\n","permalink":"http://uly.me/posts/oh-my-posh/","summary":"\u003cp\u003eIf you are tired of using the default Terminal prompt, then give \u003ca href=\"https://ohmyposh.dev\"\u003eoh-my-posh\u003c/a\u003e a try.\u003c/p\u003e\n\u003cp\u003eWhether you\u0026rsquo;re using bash in Linux or zsh on a Mac, oh-my-posh can style your prompt.\u003c/p\u003e\n\u003cp\u003eGet familiar with oh-my-posh\u0026rsquo;s syntax. It\u0026rsquo;s not difficult once you get rolling.\u003c/p\u003e\n\u003cp\u003eBrowse several of the themes available on their \u003ca href=\"https://ohmyposh.dev\"\u003esite\u003c/a\u003e to get ideas.\u003c/p\u003e\n\u003cp\u003eHead over to \u003ca href=\"https://www.canva.com/colors/color-palette-generator/\"\u003eCanva.com\u003c/a\u003e to get a color palette.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s my current \u003ca href=\"https://gist.github.com/ulyssesronquillo/d66cfea9a266692e40f4aa19b06ccf9c\"\u003eprompt\u003c/a\u003e setup.\u003c/p\u003e","title":"oh-my-posh"},{"content":"A week ago, I was messing around with my motherboard trying to fix my RGB lights so that the RGB lights can all be controlled from one controller. I accidentally short-circuited something on the motherboard. The computer kept running to my suprise, but immediately after powering down the system, the computer would no longer power up. I thought I had fried my power supply. Worse, I may have fried the motherboard.\nThen I searched online and came across this trick to jump start the power supply. It was worth a try at this point in time. One, it was the cheapeast option. Frankly, I couldn\u0026rsquo;t tell what was preventing the system from powering up, either the power supply or the motherboard. It\u0026rsquo;s one or the other. So, the trick calls for getting a small paper clip and then removing the 24 pin connector from the motherboard, powering on the system and then placing the paper clip on pins 4 and 5. Pin 4 is the green wire. Pin 5 is the black wire.\nSo I gave it a try. Sure enough the power supply turned on like the articles mentioned. The fans and the LED lights turned on. I turned off the power supply and reconnected the 24 pin cable back on the motherboard. There had been no problems ever since. Who knew a paper clip can jump start a power supply. Nice little trick. It saved me a few dollars.\n","permalink":"http://uly.me/posts/jump-start-power-supply/","summary":"\u003cp\u003eA week ago, I was messing around with my motherboard trying to fix my RGB lights so that the RGB lights can all be controlled from one controller. I accidentally short-circuited something on the motherboard. The computer kept running to my suprise, but immediately after powering down the system, the computer would no longer power up. I thought I had fried my power supply. Worse, I may have fried the motherboard.\u003c/p\u003e","title":"jump start power supply"},{"content":"I ran supportconfig on a system the other day and it took all night. I gave up and killed it.\nSo, here are a few options that you can try to speed things up.\nsupportconfig -o OFILES,CRASH,FILES,PROC,NFS,LDAP,SSSD Hope that helps.\n","permalink":"http://uly.me/posts/supportconfig-options/","summary":"\u003cp\u003eI ran supportconfig on a system the other day and it took all night. I gave up and killed it.\u003c/p\u003e\n\u003cp\u003eSo, here are a few options that you can try to speed things up.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esupportconfig -o OFILES,CRASH,FILES,PROC,NFS,LDAP,SSSD\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHope that helps.\u003c/p\u003e","title":"supportconfig options"},{"content":"GCP has new generation of disks for demanding and mission-critical applications. Hyperdisks is not available on all VMs, but they are usually available on large machine types. You create a Hyperdisk from scratch and attach it to an existing VM or convert a current disk by way of a snapshot. Here\u0026rsquo;s the script to convert it an existing disk to Hyperdisk from a snapshot.\nThere are 3 types of Hyperdisks\nHyperdisk Balanced Hyperdisk Extreme Hyperdisk Throughput Convert from snapshot.\ngcloud compute disks create $disk \\ --source-snapshot=\u0026#34;$snap\u0026#34; \\ --type=\u0026#34;hyperdisk-extreme\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; Or create a new one.\ngcloud compute disks create $disk \\ --zone=\u0026#34;$zone\u0026#34; \\ --size=100 \\ --type=\u0026#34;hyperdisk-extreme\u0026#34; \\ --project=\u0026#34;$project\u0026#34; IOPS and Throughput are optional values. You can let GCP decide the default or override it.\n--provisioned-iops=IOPS_LIMIT --provisioned-throughput=THROUGHPUT_LIMIT ","permalink":"http://uly.me/posts/gcp-create-hyperdisks/","summary":"\u003cp\u003eGCP has new generation of disks for demanding and mission-critical applications. Hyperdisks is not available on all VMs, but they are usually available on large machine types. You create a Hyperdisk from scratch and attach it to an existing VM or convert a current disk by way of a snapshot. Here\u0026rsquo;s the script to convert it an existing disk to Hyperdisk from a snapshot.\u003c/p\u003e\n\u003cp\u003eThere are 3 types of Hyperdisks\u003c/p\u003e","title":"gcp create hyperdisks"},{"content":"Here\u0026rsquo;s a little script to display my internal and external IP addresses.\n#!/bin/bash main() { my_int_ip=$(ip addr show enp4s0 | grep -w \u0026#39;inet\u0026#39; | awk \u0026#39;{print $2}\u0026#39;) my_ext_ip=$(curl -s -4 ifconfig.me) echo \u0026#39;External IP: \u0026#39; $my_ext_ip echo \u0026#39;Internal IP: \u0026#39; $my_int_ip } main Output:\nExternal IP: xxx.xxx.xxx.xxx Internal IP: 192.168.0.100 ","permalink":"http://uly.me/posts/display-ip-addresses/","summary":"\u003cp\u003eHere\u0026rsquo;s a little script to display my internal and external IP addresses.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\nmain() {\n\n  my_int_ip=$(ip addr show enp4s0 | grep -w \u0026#39;inet\u0026#39; | awk \u0026#39;{print $2}\u0026#39;)\n  my_ext_ip=$(curl -s -4 ifconfig.me)\n\n  echo \u0026#39;External IP: \u0026#39; $my_ext_ip \n  echo \u0026#39;Internal IP: \u0026#39; $my_int_ip\n\n}\n\nmain\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eExternal IP: xxx.xxx.xxx.xxx\nInternal IP: 192.168.0.100\n\u003c/code\u003e\u003c/pre\u003e","title":"display ip addresses"},{"content":"My Ubiquiti router stopped working several months ago after many years of working almost flawlessly. I replaced it with an older Linksys E4200 router that I found in a plastic container in in the garage. The Linksys router has been stable, but it\u0026rsquo;s showing its age. It was released back in January of 2011. I thought about replacing my router with another Ubiquiti, but I can\u0026rsquo;t complain since the Linksys E4200 is working just fine. The other night I upgraded and changed the firmware and installed OpenWrt, an open-source firmware based on a Linux operating system that runs on many older routers. OpenWrt gives my router extensibility by providing features that you typically find only on high-end devices. It also gives me higher security since there are many added features. Firmware updates are published regularly which you\u0026rsquo;ll never receive on older routers since many hardware manufacturers no longer support their old routers. Performance is much better. Stability is another plus. And most of all, the price is right. OpenWrt is free. If you want to give an old router some life, give OpenWrt a try. By the way, you can get an old E4200 router in eBay for $15.00.\n","permalink":"http://uly.me/posts/openwrt/","summary":"\u003cp\u003eMy Ubiquiti router stopped working several months ago after many years of working almost flawlessly. I replaced it with an older Linksys E4200 router that I found in a plastic container in in the garage. The Linksys router has been stable, but it\u0026rsquo;s showing its age. It was released back in January of 2011. I thought about replacing my router with another Ubiquiti, but I can\u0026rsquo;t complain since the Linksys E4200 is working just fine. The other night I upgraded and changed the firmware and installed OpenWrt, an open-source firmware based on a Linux operating system that runs on many older routers. OpenWrt gives my router extensibility by providing features that you typically find only on high-end devices. It also gives me higher security since there are many added features. Firmware updates are published regularly which you\u0026rsquo;ll never receive on older routers since many hardware manufacturers no longer support their old routers. Performance is much better. Stability is another plus. And most of all, the price is right. OpenWrt is free. If you want to give an old router some life, give OpenWrt a try. By the way, you can get an old E4200 router in eBay for $15.00.\u003c/p\u003e","title":"openwrt"},{"content":"Here\u0026rsquo;s the traditional way of displaying a list of dashes across the screen.\necho \u0026#34;====================\u0026#34; Here\u0026rsquo;s the short cut.\nprintf -- \u0026#39;=%.s\u0026#39; {1..20}; echo Explanation:\nfirst I\u0026rsquo;m using printf instead of echo. printf is a little bit better when it comes to formatting. The \u0026ndash; option tells printf to ignore the rest of the remaining arguments so it renders properly. The character before the % percentage is the one being repeated. In this case, we are repeating \u0026ldquo;=.\u0026rdquo; 1-20 is the number of times the character before the % percentage is repeated. That\u0026rsquo;s it.\n","permalink":"http://uly.me/posts/display-dashes-across-screen/","summary":"\u003cp\u003eHere\u0026rsquo;s the traditional way of displaying a list of dashes across the screen.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#34;====================\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere\u0026rsquo;s the short cut.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprintf -- \u0026#39;=%.s\u0026#39; {1..20}; echo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExplanation:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003efirst I\u0026rsquo;m using printf instead of echo. printf is a little bit better when it comes to formatting.\u003c/li\u003e\n\u003cli\u003eThe \u0026ndash; option tells printf to ignore the rest of the remaining arguments so it renders properly.\u003c/li\u003e\n\u003cli\u003eThe character before the % percentage is the one being repeated. In this case, we are repeating \u0026ldquo;=.\u0026rdquo;\u003c/li\u003e\n\u003cli\u003e1-20 is the number of times the character before the % percentage is repeated.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThat\u0026rsquo;s it.\u003c/p\u003e","title":"display dashes across screen"},{"content":"If you are running a gcloud commands, it will be good to know if a user is still logged in. In some corporate settings, authentication is set to time out after a number of hours. The following lines of code checks if a user is still loggedin and displays a message to reauthenticate if logged out. In reality the script runs a list of GCP projects, but limits the output to just one line. The output is sent to a file. If the first line is equal to \u0026ldquo;Reauthentication required.\u0026rdquo;, then there\u0026rsquo;s a message telling the user to login again. If the first line has an error, it means the user is not logged in. It also tells the user to login again. Here\u0026rsquo;s the code.\ncheckLogin() { gcloud projects list --format=\u0026#34;value[](name)\u0026#34; --limit 1 \u0026gt; reauth.txt 2\u0026gt;\u0026amp;1 ok=$(cat reauth.txt | head -n 1) if [[ \u0026#34;$ok\u0026#34; == \u0026#34;Reauthentication required.\u0026#34; ]]; then echo \u0026#34;You\u0026#39;re not logged in to Google SDK. Please login, then try again.\u0026#34; exit elif [[ \u0026#34;$ok\u0026#34; =~ \u0026#34;ERROR\u0026#34; ]]; then echo \u0026#34;You\u0026#39;re not logged in to Google SDK. Please login, then try again.\u0026#34; exit fi rm -f reauth.txt } Just call it at the top of the script.\ncheckLogin ","permalink":"http://uly.me/posts/gcp-check-login/","summary":"\u003cp\u003eIf you are running a gcloud commands, it will be good to know if a user is still logged in. In some corporate settings, authentication is set to time out after a number of hours. The following lines of code checks if a user is still loggedin and displays a message to reauthenticate if logged out. In reality the script runs a list of GCP projects, but limits the output to just one line. The output is sent to a file. If the first line is equal to \u0026ldquo;Reauthentication required.\u0026rdquo;, then there\u0026rsquo;s a message telling the user to login again.  If the first line has an error, it means the user is not logged in. It also tells the user to login again. Here\u0026rsquo;s the code.\u003c/p\u003e","title":"gcp check login"},{"content":"Previously, I was showing both dates and titles on the main index page. Here\u0026rsquo;s the date format if I\u0026rsquo;ll ever need it again.\n{% raw %}\n{% endraw %}\n","permalink":"http://uly.me/posts/date-and-title/","summary":"\u003cp\u003ePreviously, I was showing both dates and titles on the main index page. Here\u0026rsquo;s the date format if I\u0026rsquo;ll ever need it again.\u003c/p\u003e\n\u003cp\u003e{% raw %}\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e{% endraw %}\u003c/p\u003e","title":"date and title"},{"content":"Vim is a terminal editor in Linux, Mac and Windows system if it\u0026rsquo;s installed. To be really efficient in using vim, you\u0026rsquo;ll need to master a few very important keystrokes. So, here\u0026rsquo;s a list of common vim keystrokes that can improve your vim experience.\nCursor movement\nh - move cursor left l - move cursor right k - move cursor up j - move cursor down H - move cursor to top of screen M - move cursor to middle of screen L - move cursor to bottom of screen w - jump forward to the start of a word e - jump forward to the end of a word b - jump backwards to the start of a word 0 - jump to the start of the line $ - jump to the end of the line gg - go to the first line of the document G - go the last line of the decoment Insert mode\ni - insert before cursor I - insert at the beginning of the line a - insert after the cursor A - insert at the end of the line To get a list of vim keystrokes, here\u0026rsquo;s a good list of shortcuts. Enjoy.\n","permalink":"http://uly.me/posts/vim-navigation-commands/","summary":"\u003cp\u003eVim is a terminal editor in Linux, Mac and Windows system if it\u0026rsquo;s installed. To be really efficient in using vim, you\u0026rsquo;ll need to master a few very important keystrokes. So, here\u0026rsquo;s a list of common vim keystrokes that can improve your vim experience.\u003c/p\u003e\n\u003cp\u003eCursor movement\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eh - move cursor left \nl - move cursor right\nk - move cursor up\nj - move cursor down\n\nH - move cursor to top of screen\nM - move cursor to middle of screen\nL - move cursor to bottom of screen\n\nw - jump forward to the start of a word \ne - jump forward to the end of a word\nb - jump backwards to the start of a word \n\n0 - jump to the start of the line\n$ - jump to the end of the line \n\ngg - go to the first line of the document \nG - go the last line of the decoment\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInsert mode\u003c/p\u003e","title":"vim navigation commands"},{"content":"In my [previous post]({% post_url 2024-01-12-terraform-gcp-vm-alias-ip %}), I\u0026rsquo;ve provisioned a vm with an alias ip using terraform. In this post, I will do the same but will use gcloud commands.\nFirst, let\u0026rsquo;s reserve an internal ip address.\ngcloud compute addresses create host-alias-ip \\ --addresses 10.10.10.10 --region us-central1 \\ --subnet projects/projectid/regions/us-central1/subnetworks/subnet-us-central1 \\ --project projectid To allocate automatically, leave out \u0026ndash;addresses.\ngcloud compute addresses create host-alias-ip \\ --region us-central1 \\ --subnet projects/projectid/regions/us-central1/subnetworks/subnet-us-central1 \\ --project projectid To check reservations, list all in the project.\ngcloud compute addresses list --project projectid Attach an alias ip to a vm instance.\ngcloud compute instances network-interfaces update hostname \\ --aliases 10.10.10.10 \\ --zone us-central1-c \\ --project projectid To detach leave aliases blank.\ngcloud compute instances network-interfaces update hostname \\ --aliases \u0026#34;\u0026#34; \\ --zone us-central1-c \\ --project projectid ","permalink":"http://uly.me/posts/gcloud-vm-alias-ip/","summary":"\u003cp\u003eIn my [previous post]({% post_url 2024-01-12-terraform-gcp-vm-alias-ip %}), I\u0026rsquo;ve provisioned a vm with an alias ip using terraform. In this post, I will do the same but will use gcloud commands.\u003c/p\u003e\n\u003cp\u003eFirst, let\u0026rsquo;s reserve an internal ip address.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses create host-alias-ip \\\n--addresses 10.10.10.10\n--region us-central1 \\\n--subnet projects/projectid/regions/us-central1/subnetworks/subnet-us-central1 \\\n--project projectid\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo allocate automatically, leave out \u0026ndash;addresses.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses create host-alias-ip \\\n--region us-central1 \\\n--subnet projects/projectid/regions/us-central1/subnetworks/subnet-us-central1 \\\n--project projectid\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo check reservations, list all in the project.\u003c/p\u003e","title":"gcloud vm alias ip"},{"content":"How to build a VM in GCP with a secondary alias IP. Assuming that you already have a compute and a local block in your Terraform file.\nGo to the locals block and add the local variables you\u0026rsquo;ll need.\nlocals { project = \u0026#34;projectId\u0026#34; hostname = \u0026#34;yourhostname\u0026#34; } Reserve an internal ip address by adding the google_compute_address block to your Terraform file.\nresource \u0026#34;google_compute_address\u0026#34; \u0026#34;alias-ip\u0026#34; { name = \u0026#34;${local.hostname}-alias-ip\u0026#34; region = \u0026#34;us-central1\u0026#34; address_type = \u0026#34;INTERNAL\u0026#34; subnetwork = local.subnetwork } Inside your existing compute instance block, add the alias_ip_range to the network interface block.\nnetwork_interface { network = local.network subnetwork = local.subnetwork alias_ip_range { ip_cidr_range = google_compute_address.alias-ip.address } } The script will reserve an internal ip address and attach it the vm as an alias ip.\n","permalink":"http://uly.me/posts/terraform-gcp-vm-alias-ip/","summary":"\u003cp\u003eHow to build a VM in GCP with a secondary alias IP. Assuming that you already have a compute and a local block in your Terraform file.\u003c/p\u003e\n\u003cp\u003eGo to the locals block and add the local variables you\u0026rsquo;ll need.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elocals {\n  project          = \u0026#34;projectId\u0026#34;\n  hostname         = \u0026#34;yourhostname\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReserve an internal ip address by adding the \u003cstrong\u003egoogle_compute_address\u003c/strong\u003e block to your Terraform file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eresource \u0026#34;google_compute_address\u0026#34; \u0026#34;alias-ip\u0026#34; {\n  name = \u0026#34;${local.hostname}-alias-ip\u0026#34;\n  region = \u0026#34;us-central1\u0026#34;\n  address_type = \u0026#34;INTERNAL\u0026#34;\n  subnetwork = local.subnetwork\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInside your existing compute instance block, add the \u003cstrong\u003ealias_ip_range\u003c/strong\u003e to the network interface block.\u003c/p\u003e","title":"terraform gcp vm alias ip"},{"content":"xrdp is a package that allows another desktop to connect to another using the rdp desktop software.\nInstall xrdp on the target desktop.\nsudo apt install xrdp Add a second user since you can\u0026rsquo;t use the default user. Use -m to create a home directory.\nsudo useradd -m john Give new user sudo access. This is optional, but is nice to have if running root commands.\nsudo usermod -a -G sudo john Set the user\u0026rsquo;s password.\nsudo passwd john You can now connect from a rdp client to your desktop using username john.\n","permalink":"http://uly.me/posts/install-xrdp/","summary":"\u003cp\u003exrdp is a package that allows another desktop to connect to another using the rdp desktop software.\u003c/p\u003e\n\u003cp\u003eInstall xrdp on the target desktop.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt install xrdp\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd a second user since you can\u0026rsquo;t use the default user. Use -m to create a home directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo useradd -m john\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGive new user sudo access. This is optional, but is nice to have if running root commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo usermod -a -G sudo john\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSet the user\u0026rsquo;s password.\u003c/p\u003e","title":"install xrdp"},{"content":"I found a really nice gem that sets all external links to open to a new tab. It\u0026rsquo;s called jekyll-target-blank. To add, just run the following.\nEdit Gemfile and add this line.\ngem \u0026#39;jekyll-target-blank\u0026#39; Edit the _config.yml file and add this line.\nplugins: - jekyll-target-blank Run bundle install.\n$ bundle install Because I\u0026rsquo;m running Jekyll in a docker container, I had to restart it.\ndocker-compose stop docker-compose up -d Check your external links. They should open up to a new tab.\n","permalink":"http://uly.me/posts/jekyll-target-blank/","summary":"\u003cp\u003eI found a really nice gem that sets all external links to open to a new tab. It\u0026rsquo;s called jekyll-target-blank. To add, just run the following.\u003c/p\u003e\n\u003cp\u003eEdit Gemfile and add this line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egem \u0026#39;jekyll-target-blank\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit the _config.yml file and add this line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eplugins:\n  - jekyll-target-blank\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun bundle install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ bundle install\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBecause I\u0026rsquo;m running Jekyll in a docker container, I had to restart it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker-compose stop\ndocker-compose up -d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck your external links. They should open up to a new tab.\u003c/p\u003e","title":"jekyll target blank"},{"content":"scp is an excellent utility for copying files to and from a server without the need for running a ftp server or some sort of file transfer service on the server. scp uses your existing ssh access to copy files to and from a server. You will need permissions to the remote server otherwise scp copy will fail. Whether pulling down a file or pushing a file to a server, scp can be invoked from a client regardless of file direction. You can copy a single file or multiple files. The examples below demonstrate this.\nscp copy a single file to a server.\nscp file.ext username@server:/home/homedir/ scp copy multiple local files to a server.\nscp file1.ext file2.ext file3.ext username@server:/home/homedir/ scp copy a single file from a server to the desktop.\nscp username@server:/home/homedir/file.ext . scp copy multiple files from a server to the desktop.\nscp username@server:/home/homedir/*.{txt,doc} . Here\u0026rsquo;s a script that I wrote to upload multiple files to a server. It looks for text and php files in the current directory and then uploads them to the server.\n#!/bin/bash # create temp file temp=\u0026#34;temp\u0026#34; \u0026gt;$temp # loop through selected files in the current directory for file in *.{txt,php}; do # put all files in one row echo -n \u0026#34;$file \u0026#34; \u0026gt;\u0026gt; $temp done # add new line at the end echo \u0026#34;\u0026#34; \u0026gt;\u0026gt; $temp # assign the list to a variable called $files files=$(cat $temp) # scp the files to the cloudreporting server scp $files username@server:/home/homedir # delete temp file rm -f $temp ","permalink":"http://uly.me/posts/scp-multiple-files/","summary":"\u003cp\u003escp is an excellent utility for copying files to and from a server without the need for running a ftp server or some sort of file transfer service on the server. scp uses your existing ssh access to copy files to and from a server. You will need permissions to the remote server otherwise scp copy will fail. Whether pulling down a file or pushing a file to a server, scp can be invoked from a client regardless of file direction. You can copy a single file or multiple files. The examples below demonstrate this.\u003c/p\u003e","title":"scp multiple files"},{"content":"If you find yourself entering the same value multiple times in your Terraform script, you can save yourself some time by declaring local variables inside a locals block and reuse them throughout your script or module.\nHere\u0026rsquo;s a locals block.\nlocals { project = \u0026#34;your_project_id\u0026#34; hostname = \u0026#34;your_hostname\u0026#34; machine_image = \u0026#34;your_machine_image\u0026#34; } Once the local variables are declared, you can reuse them anywhere and as many times as you want in your Terraform script or module.\nprovider \u0026#34;google\u0026#34; { project = local.project } data \u0026#34;google_compute_image\u0026#34; \u0026#34;boot-image\u0026#34; { family = local.machine_image project = local.project } resource \u0026#34;google_compute_instance\u0026#34; \u0026#34;instance\u0026#34; { name = local.hostname machine_type = local.machine_type ... } Local variables are helpful if you\u0026rsquo;re repeating the same values throughout your configuration. You can make a change in one place and it will apply to multiple locations. The only gotcha is to not overdo it, because it will make your code harder to read. Use it in moderation.\n","permalink":"http://uly.me/posts/terraform-local-variables/","summary":"\u003cp\u003eIf you find yourself entering the same value multiple times in your Terraform script, you can save yourself some time by declaring local variables inside a locals block and reuse them throughout your script or module.\u003c/p\u003e\n\u003cp\u003eHere\u0026rsquo;s a locals block.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elocals {\n  project          = \u0026#34;your_project_id\u0026#34;\n  hostname         = \u0026#34;your_hostname\u0026#34;\n  machine_image    = \u0026#34;your_machine_image\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce the local variables are declared, you can reuse them anywhere and as many times as you want in your Terraform script or module.\u003c/p\u003e","title":"terraform local variables"},{"content":"Here\u0026rsquo;s a simple Bash script that displays how long it takes for a script to run from beginning to end. This is perfect tool for long running scripts that run for hours, and where you need to know much time it took to run from beginning to end. This is ideal for a script that you\u0026rsquo;ll run unattended.\n#!/bin/bash log=\u0026#39;elapse.log\u0026#39; \u0026gt;$log start() { start=$(date) begin=$(date +%s) echo \u0026#39;Start: \u0026#39;$start | tee -a $log } stop() { stop=$(date) end=$(date +%s) echo \u0026#39;Stop: \u0026#39;$stop | tee -a $log elapse=$((end-begin)) } show_time() { num=$elapse min=0 hour=0 day=0 if((num\u0026gt;59));then ((sec=num%60)) ((num=num/60)) if((num\u0026gt;59));then ((min=num%60)) ((num=num/60)) if((num\u0026gt;23));then ((hour=num%24)) ((day=num/24)) else ((hour=num)) fi else ((min=num)) fi else ((sec=num)) fi echo \u0026#34;$day\u0026#34;d \u0026#34;$hour\u0026#34;h \u0026#34;$min\u0026#34;m \u0026#34;$sec\u0026#34;s | tee -a $log } script() { echo \u0026#34;running script now...\u0026#34; | tee -a $log sleep 10 } start script stop show_time In the example above, I\u0026rsquo;m running a script that echoes text and sleeps for 10s. Here\u0026rsquo;s the output.\nStart: Wed Jan 3 13:16:44 EST 2024 running script now... Stop: Wed Jan 3 13:16:54 EST 2024 0d 0h 0m 10s The result says it ran for 10s. You can also view the elapse.log file.\n$ cat elapse.log Start: Wed Jan 3 13:16:44 EST 2024 running script now... Stop: Wed Jan 3 13:16:54 EST 2024 0d 0h 0m 10s ","permalink":"http://uly.me/posts/display-elapse-time/","summary":"\u003cp\u003eHere\u0026rsquo;s a simple Bash script that displays how long it takes for a script to run from beginning to end. This is perfect tool for long running scripts that run for hours, and where you need to know much time it took to run from beginning to end. This is ideal for a script that you\u0026rsquo;ll run unattended.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\nlog=\u0026#39;elapse.log\u0026#39;\n\u0026gt;$log\n\nstart() {\n\n    start=$(date)\n    begin=$(date +%s)\n    echo \u0026#39;Start: \u0026#39;$start | tee -a $log\n\n}\n\nstop() {\n\n    stop=$(date)\n    end=$(date +%s)\n    echo \u0026#39;Stop: \u0026#39;$stop | tee -a $log\n    elapse=$((end-begin))\n\n}\n\nshow_time() {\n    num=$elapse\n    min=0\n    hour=0\n    day=0\n    if((num\u0026gt;59));then\n        ((sec=num%60))\n        ((num=num/60))\n        if((num\u0026gt;59));then\n            ((min=num%60))\n            ((num=num/60))\n            if((num\u0026gt;23));then\n                ((hour=num%24))\n                ((day=num/24))\n            else\n                ((hour=num))\n            fi\n        else\n            ((min=num))\n        fi\n    else\n        ((sec=num))\n    fi\n    echo \u0026#34;$day\u0026#34;d \u0026#34;$hour\u0026#34;h \u0026#34;$min\u0026#34;m \u0026#34;$sec\u0026#34;s | tee -a $log\n}\n\nscript() {\n\n    echo \u0026#34;running script now...\u0026#34; | tee -a $log\n    sleep 10\n\n}\n\nstart\nscript\nstop\nshow_time\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn the example above, I\u0026rsquo;m running a script that echoes text and sleeps for 10s. Here\u0026rsquo;s the output.\u003c/p\u003e","title":"display elapse time"},{"content":"I switched to a slightly different format in the home page to display the date first followed by the post titles. In addition to the format change, I wanted to truncate the titles that are longer than 40 characters to display only the first 40 characters followed by 3 dots or \u0026ldquo;\u0026hellip;\u0026rdquo; at the end. The key to making this possible was to use Jekyll\u0026rsquo;s advanced filters, and in particular, using the truncate filter. Swapping the order of date and post titles was the easy part, but the key was using the truncate filter.\nHere\u0026rsquo;s the code.\npost.title | downcase | truncate: 40, \u0026#39; ...\u0026#39; The downcase filter converts post.title to lowercase.\nThe truncate filter truncates post.title longer than 40 characters and adds 3 dots at the end.\nTruncate requires 2 parameters: the length of the string and the characters to append to the string.\n","permalink":"http://uly.me/posts/truncate-titles-in-jekyll/","summary":"\u003cp\u003eI switched to a slightly different format in the home page to display the date first followed by the post titles. In addition to the format change, I wanted to truncate the titles that are longer than 40 characters to display only the first 40 characters followed by 3 dots or \u0026ldquo;\u0026hellip;\u0026rdquo; at the end. The key to making this possible was to use Jekyll\u0026rsquo;s advanced \u003ca href=\"https://gist.github.com/JJediny/a466eed62cee30ad45e2\"\u003efilters\u003c/a\u003e, and in particular, using the truncate filter. Swapping the order of date and post titles was the easy part, but the key was using the truncate filter.\u003c/p\u003e","title":"truncate titles in jekyll"},{"content":"I recently bought a 2TB NVME SSD drive which I plan to install on my Linux Mint desktop. I have been taking a ton of pictures lately with my old Nikon D700 DSLR camera and I can use the extra space. Since the new drive is unformatted, here were the steps that I took to get it working on my desktop. This how-to assumes that I have installed the new NVME drive on your motherboard successfully.\nThe first thing to do is to find out the device name. It shows up as a 1.8TB disk on my desktop.\nlsblk nvme0n1 259:0 0 1.8T 0 disk Check if it\u0026rsquo;s formatted. It should be empty. If not, it will display the file system type.\nsudo file -s /dev/nvme0n1 If empty.\n/dev/nvme0n1: data If formatted with XFS.\n/dev/nvme0n1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs) Since it\u0026rsquo;s empty, let\u0026rsquo;s format the drive. I will use XFS as the file system.\nmkfs -t xfs /dev/nvme0n1 Let\u0026rsquo;s mount the drive after formatting. I will use the Nikon directory in my home directory as the mount volume.\nmkdir ~/Nikon sudo mount /dev/nvme0n1 /home/ulysses/Nikon Let\u0026rsquo;s unmount it temporarily.\nsudo umount /home/ulysses/Nikon Next, I will add an entry to the /etc/fstab to make the drive mount permanent after each reboot. Get the UUID of the new drive using the blkid command.\nsudo blkid Now edit the /etc/fstab file to add the new volume entry.\nvi /etc/fstab The entry will look similar to this. Enter the UUID by replacing the x\u0026rsquo;s.\nUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /home/ulysses/Nikon xfs defaults 0 0 Test it by mounting all.\nsudo mount -a If there are no errors, mount was successful. You can check by running the df command.\ndf -Th It should display something similar to below. I already have 5% data on the drive.\n/dev/nvme0n1 xfs 1.9T 83G 1.8T 5% /home/ulysses/Nikon Since everything looks good, I can now safely reboot.\nsudo shutdown -r ","permalink":"http://uly.me/posts/format-new-volume/","summary":"\u003cp\u003eI recently bought a 2TB NVME SSD drive which I plan to install on my Linux Mint desktop. I have been taking a ton of pictures lately with my old Nikon D700 DSLR camera and I can use the extra space. Since the new drive is unformatted, here were the steps that I took to get it working on my desktop. This how-to assumes that I have installed the new NVME drive on your motherboard successfully.\u003c/p\u003e","title":"format new volume"},{"content":"If you have a disk drive, SSD or NVME storage device that need to be wiped clean, I recommend that you use the shred command.\nIn this example, I\u0026rsquo;m cleaning up the contents of my NVME device at /dev/nvme0n1.\nsudo shred -v -n 1 --random-source=/dev/urandom -z /dev/nvme0n1 I\u0026rsquo;m using these options and their explanation.\n-v is verbose -n is the number of iterations. Mine is set to 1. You can increase it, but it can take hours. \u0026ndash;random-source is set to /dev/urandom which is the kernel\u0026rsquo;s random number generator. -z means everything gets overwritten by zeros. Shred will make it nearly impossible to steal your data.\n","permalink":"http://uly.me/posts/how-to-shred-a-volume/","summary":"\u003cp\u003eIf you have a disk drive, SSD or NVME storage device that need to be wiped clean, I recommend that you use the shred command.\u003c/p\u003e\n\u003cp\u003eIn this example, I\u0026rsquo;m cleaning up the contents of my NVME device at /dev/nvme0n1.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo shred -v -n 1 --random-source=/dev/urandom -z /dev/nvme0n1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI\u0026rsquo;m using these options and their explanation.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e-v is verbose\u003c/li\u003e\n\u003cli\u003e-n is the number of iterations. Mine is set to 1. You can increase it, but it can take hours.\u003c/li\u003e\n\u003cli\u003e\u0026ndash;random-source is set to /dev/urandom which is the kernel\u0026rsquo;s random number generator.\u003c/li\u003e\n\u003cli\u003e-z means everything gets overwritten by zeros.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eShred will make it nearly impossible to steal your data.\u003c/p\u003e","title":"how to shred a volume"},{"content":"Here are input options that you can use in Bash.\nYou can set variables within the script. You can pass the arguments via command line. You can prompt the user to input data. Or you create a script that incorporates all three.\nRemove comments if you want to set the variables in the script. Pass arguments via command line using the format provided. Or be prompted to enter all your arguments one at a time. # project=\u0026#34;projectid\u0026#34; # instance=\u0026#34;hostname\u0026#34; # zone=\u0026#34;us-central1-c\u0026#34; # policy=\u0026#34;hourly\u0026#34; # snapback=3 # Format (requires all 5 arguments): ./script.sh project host zone policy snapback # If no arguments are provided or less than 5 arguments, you will be prompted to enter your options. if [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then if [ \u0026#34;$#\u0026#34; -eq 5 ]; then project=$1 instance=$2 zone=$3 policy=$4 snapback=$5 else read -p \u0026#34;projectId : \u0026#34; project read -p \u0026#34;instance : \u0026#34; instance read -p \u0026#34;zone : \u0026#34; zone read -p \u0026#34;policy : \u0026#34; policy read -p \u0026#34;snapback : \u0026#34; snapback fi fi echo $project $instance $zone $policy $snapback ","permalink":"http://uly.me/posts/bash-input-options/","summary":"\u003cp\u003eHere are input options that you can use in Bash.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eYou can set variables within the script.\u003c/li\u003e\n\u003cli\u003eYou can pass the arguments via command line.\u003c/li\u003e\n\u003cli\u003eYou can prompt the user to input data.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eOr you create a script that incorporates all three.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eRemove comments if you want to set the variables in the script.\u003c/li\u003e\n\u003cli\u003ePass arguments via command line using the format provided.\u003c/li\u003e\n\u003cli\u003eOr be prompted to enter all your arguments one at a time.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# project=\u0026#34;projectid\u0026#34;\n# instance=\u0026#34;hostname\u0026#34;\n# zone=\u0026#34;us-central1-c\u0026#34;\n# policy=\u0026#34;hourly\u0026#34;\n# snapback=3\n\n# Format (requires all 5 arguments): ./script.sh project host zone policy snapback\n# If no arguments are provided or less than 5 arguments, you will be prompted to enter your options.\n\nif [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then\n    if  [ \u0026#34;$#\u0026#34; -eq 5 ]; then\n        project=$1\n        instance=$2\n        zone=$3\n        policy=$4\n        snapback=$5\n    else \n        read -p \u0026#34;projectId : \u0026#34; project\n        read -p \u0026#34;instance  : \u0026#34; instance\n        read -p \u0026#34;zone      : \u0026#34; zone\n        read -p \u0026#34;policy    : \u0026#34; policy\n        read -p \u0026#34;snapback  : \u0026#34; snapback\n    fi\nfi\necho $project $instance $zone $policy $snapback\n\u003c/code\u003e\u003c/pre\u003e","title":"bash input options"},{"content":"How to make a function call within a function in Bash.\nIn my previous [post]({% post_url 2023-12-20-gcp-restore-boot-disk %}), I used several functions. We will call them in the main function below.\nmain() { checkLogin displayHeader getDisks getSnaps read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then stopServer detachDisks deleteDisks createDisks attachDisks setAutodelete startServer fi } main ","permalink":"http://uly.me/posts/bash-function-within-a-function/","summary":"\u003cp\u003eHow to make a function call within a function in Bash.\u003c/p\u003e\n\u003cp\u003eIn my previous [post]({% post_url 2023-12-20-gcp-restore-boot-disk %}), I used several functions. We will call them in the main function below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emain() {\n\n  checkLogin\n  displayHeader\n  getDisks\n  getSnaps \n\n  read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r\n  echo    # (optional) move to a new line\n  if [[ $REPLY =~ ^[Yy]$ ]]\n  then\n    stopServer\n    detachDisks\n    deleteDisks\n    createDisks\n    attachDisks\n    setAutodelete\n    startServer\n  fi\n}\n\nmain \n\u003c/code\u003e\u003c/pre\u003e","title":"Bash function within a function"},{"content":"Here\u0026rsquo;s how to to generate random words from an array in Bash using shuf.\nFOOD=(\u0026#39;Milk\u0026#39; \u0026#39;Bread\u0026#39; \u0026#39;Eggs\u0026#39; \u0026#39;Sausage\u0026#39; \u0026#39;Grits\u0026#39; \u0026#39;Banana\u0026#39; \u0026#39;Oatmeal\u0026#39;) shuf -e ${FOOD[@]} Milk Grits Sausage Oatmeal Bread Banana Eggs You can limit output to 3 by piping output using head -n 3.\nFOOD=(\u0026#39;Milk\u0026#39; \u0026#39;Bread\u0026#39; \u0026#39;Eggs\u0026#39; \u0026#39;Sausage\u0026#39; \u0026#39;Grits\u0026#39; \u0026#39;Banana\u0026#39; \u0026#39;Oatmeal\u0026#39;) shuf -e ${FOOD[@]} | head -n 3 Bread Sausage Eggs ","permalink":"http://uly.me/posts/random-words-from-array/","summary":"\u003cp\u003eHere\u0026rsquo;s how to to generate random words from an array in Bash using shuf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFOOD=(\u0026#39;Milk\u0026#39; \u0026#39;Bread\u0026#39; \u0026#39;Eggs\u0026#39; \u0026#39;Sausage\u0026#39; \u0026#39;Grits\u0026#39; \u0026#39;Banana\u0026#39; \u0026#39;Oatmeal\u0026#39;)\nshuf -e ${FOOD[@]}\nMilk\nGrits\nSausage\nOatmeal\nBread\nBanana\nEggs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can limit output to 3 by piping output using head -n 3.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFOOD=(\u0026#39;Milk\u0026#39; \u0026#39;Bread\u0026#39; \u0026#39;Eggs\u0026#39; \u0026#39;Sausage\u0026#39; \u0026#39;Grits\u0026#39; \u0026#39;Banana\u0026#39; \u0026#39;Oatmeal\u0026#39;)\nshuf -e ${FOOD[@]} | head -n 3\nBread\nSausage\nEggs\n\u003c/code\u003e\u003c/pre\u003e","title":"Random words from array"},{"content":"Here\u0026rsquo;s a script I use to edit over 1000 files to convert my post titles to all lowercase.\n#!/bin/bash cd ~/Code/docker/ulyme/_posts searchReplace() { for filename in 20*.md; do sed -i -e \u0026#39;s/title:.*/\\L\u0026amp;/g\u0026#39; $filename done } searchReplace It took a mere 2-3 seconds to convert all titles on over 1000 files.\n","permalink":"http://uly.me/posts/search-replace-lowercase/","summary":"\u003cp\u003eHere\u0026rsquo;s a script I use to edit over 1000 files to convert my post titles to all lowercase.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash \ncd ~/Code/docker/ulyme/_posts\nsearchReplace() {\n    for filename in 20*.md; do\n        sed -i -e \u0026#39;s/title:.*/\\L\u0026amp;/g\u0026#39; $filename\n    done\n}\nsearchReplace\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt took a mere 2-3 seconds to convert all titles on over 1000 files.\u003c/p\u003e","title":"Search replace lowercase"},{"content":"Here\u0026rsquo;s my latest script on how to restore all disks of a VM in GCP.\n#!/bin/bash # project=\u0026#34;projectid\u0026#34; # instance=\u0026#34;hostname\u0026#34; # zone=\u0026#34;us-central1-c\u0026#34; # policy=\u0026#34;hourly\u0026#34; # snapback=3 # Format (requires all 5 arguments): ./script.sh project host zone policy snapback # If no arguments are provided or less than 5 arguments, you will be prompted to enter your options. if [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then if [ \u0026#34;$#\u0026#34; -eq 5 ]; then project=$1 instance=$2 zone=$3 policy=$4 snapback=$5 else read -p \u0026#34;projectId : \u0026#34; project read -p \u0026#34;instance : \u0026#34; instance read -p \u0026#34;zone : \u0026#34; zone read -p \u0026#34;policy : \u0026#34; policy read -p \u0026#34;snapback : \u0026#34; snapback fi fi echo $project $instance $zone $policy $snapback checkLogin() { user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;) user=$(echo $user | cut -d@ -f1) user=${user/./-} if [ -z \u0026#34;$user\u0026#34; ]; then echo \u0026#34;You\u0026#39;re not logged in to Google SDK.\u0026#34; exit fi } displayHeader() { echo \u0026#34;######################################################\u0026#34; echo \u0026#34;Starting the restore process for $instance \u0026#34; echo \u0026#34;######################################################\u0026#34; } getDisks() { disks=$(gcloud compute disks list \\ --filter=\u0026#34;users:$instance\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; \\ --project=\u0026#34;$project\u0026#34;) echo \u0026#34;Listing disks for $instance ... \u0026#34; for disk in $disks; do echo $disk done } getSnaps() { echo \u0026#34;Listing snapshots to restore for $instance ... \u0026#34; for disk in $disks; do snap=$(gcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy~$policy AND sourceDisk~$disk\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1) echo \u0026#34;$disk: $snap\u0026#34; done } stopServer() { echo \u0026#34;Stopping server ...\u0026#34; gcloud compute instances stop $instance \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } detachDisks() { echo \u0026#34;Detaching disks ...\u0026#34; for disk in $disks; do gcloud compute instances detach-disk $instance \\ --disk=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; done } deleteDisks() { echo \u0026#34;Deleting disks ...\u0026#34; for disk in $disks; do gcloud compute disks delete $disk \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; done } createDisks() { echo \u0026#34;Creating disks ...\u0026#34; for disk in $disks; do snap=$(gcloud compute snapshots list \\ --filter=\u0026#34;sourceDisk~$disk\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1) gcloud compute disks create $disk \\ --source-snapshot=\u0026#34;$snap\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; done } attachDisks() { echo \u0026#34;Attaching disks ...\u0026#34; count=1 for disk in $disks; do if [ $count == 1 ]; then gcloud compute instances attach-disk $instance \\ --disk=\u0026#34;$disk\u0026#34; \\ --device-name=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --boot else gcloud compute instances attach-disk $instance \\ --disk=\u0026#34;$disk\u0026#34; \\ --device-name=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; fi count=$((count+1)) done } setAutodelete() { echo \u0026#34;Setting autodelete on disks ...\u0026#34; for disk in $disks; do gcloud compute instances set-disk-auto-delete $instance \\ --auto-delete \\ --disk=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; done } startServer() { echo \u0026#34;Starting server ...\u0026#34; gcloud compute instances start $instance \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } main() { checkLogin displayHeader getDisks getSnaps read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then stopServer detachDisks deleteDisks createDisks attachDisks setAutodelete startServer fi } main ","permalink":"http://uly.me/posts/gcp-restore-all-disks/","summary":"\u003cp\u003eHere\u0026rsquo;s my latest script on how to restore all disks of a VM in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# project=\u0026#34;projectid\u0026#34;\n# instance=\u0026#34;hostname\u0026#34;\n# zone=\u0026#34;us-central1-c\u0026#34;\n# policy=\u0026#34;hourly\u0026#34;\n# snapback=3\n\n# Format (requires all 5 arguments): ./script.sh project host zone policy snapback\n# If no arguments are provided or less than 5 arguments, you will be prompted to enter your options.\n\nif [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then\n\n    if  [ \u0026#34;$#\u0026#34; -eq 5 ]; then\n        project=$1\n        instance=$2\n        zone=$3\n        policy=$4\n        snapback=$5\n    else \n        read -p \u0026#34;projectId : \u0026#34; project\n        read -p \u0026#34;instance  : \u0026#34; instance\n        read -p \u0026#34;zone      : \u0026#34; zone\n        read -p \u0026#34;policy    : \u0026#34; policy\n        read -p \u0026#34;snapback  : \u0026#34; snapback\n    fi\n\nfi\n\necho $project $instance $zone $policy $snapback\n\ncheckLogin() {\n\n    user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;)\n    user=$(echo $user | cut -d@ -f1)\n    user=${user/./-}\n\n    if [ -z \u0026#34;$user\u0026#34; ]; then\n        echo \u0026#34;You\u0026#39;re not logged in to Google SDK.\u0026#34;\n        exit\n    fi\n\n}\n\ndisplayHeader() {\n\n    echo \u0026#34;######################################################\u0026#34;\n    echo \u0026#34;Starting the restore process for $instance \u0026#34;\n    echo \u0026#34;######################################################\u0026#34;\n\n}\n\ngetDisks() {\n\n    disks=$(gcloud compute disks list \\\n        --filter=\u0026#34;users:$instance\u0026#34; \\\n        --format=\u0026#34;value(name)\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;)\n\n    echo \u0026#34;Listing disks for $instance ... \u0026#34;\n\n    for disk in $disks; do\n\n        echo $disk\n    \n    done\n\n}\n\ngetSnaps() {\n\n    echo \u0026#34;Listing snapshots to restore for $instance ... \u0026#34;\n\n    for disk in $disks; do\n\n        snap=$(gcloud compute snapshots list \\\n            --filter=\u0026#34;sourceSnapshotSchedulePolicy~$policy AND sourceDisk~$disk\u0026#34; \\\n            --format=\u0026#34;value(name)\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34; \\\n            --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1)\n\n        echo \u0026#34;$disk: $snap\u0026#34; \n\n    done \n\n}\n\nstopServer() {\n\n    echo \u0026#34;Stopping server ...\u0026#34;\n\n    gcloud compute instances stop $instance \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\ndetachDisks() {\n\n    echo \u0026#34;Detaching disks ...\u0026#34;\n\n    for disk in $disks; do\n\n        gcloud compute instances detach-disk $instance \\\n            --disk=\u0026#34;$disk\u0026#34; \\\n            --zone=\u0026#34;$zone\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34;\n\n    done \n\n}\n\ndeleteDisks() {\n\n    echo \u0026#34;Deleting disks ...\u0026#34;\n\n    for disk in $disks; do\n\n        gcloud compute disks delete $disk \\\n            --zone=\u0026#34;$zone\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34;\n\n    done\n\n}\n\ncreateDisks() {\n\n    echo \u0026#34;Creating disks ...\u0026#34;\n\n    for disk in $disks; do\n\n        snap=$(gcloud compute snapshots list \\\n            --filter=\u0026#34;sourceDisk~$disk\u0026#34; \\\n            --format=\u0026#34;value(name)\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34; \\\n            --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1)\n\n        gcloud compute disks create $disk \\\n            --source-snapshot=\u0026#34;$snap\u0026#34; \\\n            --zone=\u0026#34;$zone\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34;\n\n    done\n\n}\n\nattachDisks() {\n\n    echo \u0026#34;Attaching disks ...\u0026#34;\n\n    count=1\n\n    for disk in $disks; do\n\n        if [ $count == 1 ]; then \n            gcloud compute instances attach-disk $instance \\\n                --disk=\u0026#34;$disk\u0026#34; \\\n                --device-name=\u0026#34;$disk\u0026#34; \\\n                --zone=\u0026#34;$zone\u0026#34; \\\n                --project=\u0026#34;$project\u0026#34; \\\n                --boot\n        else \n            gcloud compute instances attach-disk $instance \\\n                --disk=\u0026#34;$disk\u0026#34; \\\n                --device-name=\u0026#34;$disk\u0026#34; \\\n                --zone=\u0026#34;$zone\u0026#34; \\\n                --project=\u0026#34;$project\u0026#34;\n        fi\n\n        count=$((count+1))\n\n    done \n\n}\n\nsetAutodelete() {\n\n    echo \u0026#34;Setting autodelete on disks ...\u0026#34;\n\n    for disk in $disks; do\n\n        gcloud compute instances set-disk-auto-delete $instance \\\n            --auto-delete \\\n            --disk=\u0026#34;$disk\u0026#34; \\\n            --zone=\u0026#34;$zone\u0026#34; \\\n            --project=\u0026#34;$project\u0026#34;\n\n    done \n\n}\n\nstartServer() {\n\n    echo \u0026#34;Starting server ...\u0026#34;\n\n    gcloud compute instances start $instance \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\nmain() {\n\n    checkLogin\n    displayHeader\n    getDisks\n    getSnaps \n\n    read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r\n    echo    # (optional) move to a new line\n    if [[ $REPLY =~ ^[Yy]$ ]]\n    then\n        stopServer\n        detachDisks\n        deleteDisks\n        createDisks\n        attachDisks\n        setAutodelete\n        startServer\n    fi\n    \n}\n\nmain\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp restore all disks"},{"content":"Here\u0026rsquo;s my latest script to restore the boot disk of a VM in GCP.\n#!/bin/bash # project=\u0026#34;projectid\u0026#34; # instance=\u0026#34;hostname\u0026#34; # zone=\u0026#34;us-central1-c\u0026#34; # policy=\u0026#34;hourly\u0026#34; # snapback=3 # Format (requires all 5 arguments): ./script.sh project host zone policy snapback # If no arguments are provided or if less than 5 arguments, then you will be prompted to enter options. if [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then if [ \u0026#34;$#\u0026#34; -eq 5 ]; then project=$1 instance=$2 zone=$3 policy=$4 snapback=$5 else read -p \u0026#34;projectId : \u0026#34; project read -p \u0026#34;instance : \u0026#34; instance read -p \u0026#34;zone : \u0026#34; zone read -p \u0026#34;policy : \u0026#34; policy read -p \u0026#34;snapback : \u0026#34; snapback fi fi echo $project $instance $zone $policy $snapback checkLogin() { user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;) user=$(echo $user | cut -d@ -f1) user=${user/./-} if [ -z \u0026#34;$user\u0026#34; ]; then echo \u0026#34;You\u0026#39;re not logged in to Google SDK.\u0026#34; exit fi } displayHeader() { echo \u0026#34;######################################################\u0026#34; echo \u0026#34;Starting the restore process for $instance \u0026#34; echo \u0026#34;######################################################\u0026#34; } getDisks() { disks=$(gcloud compute instances describe $instance \\ --project=\u0026#34;$project\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --format=\u0026#34;get(disks[0].source)\u0026#34;) echo \u0026#34;Listing disks for $instance ... \u0026#34; disk=$(echo ${disks##*/}) echo $disk } getSnaps() { echo \u0026#34;Listing snapshots to restore for $instance ... \u0026#34; snap=$(gcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy~$policy AND sourceDisk~$disk\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1) echo \u0026#34;$disk: $snap\u0026#34; } stopServer() { echo \u0026#34;Stopping server ...\u0026#34; gcloud compute instances stop $instance \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } detachDisks() { echo \u0026#34;Detaching disks ...\u0026#34; gcloud compute instances detach-disk $instance \\ --disk=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } deleteDisks() { echo \u0026#34;Deleting disks ...\u0026#34; gcloud compute disks delete $disk \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } createDisks() { echo \u0026#34;Creating disks ...\u0026#34; snap=$(gcloud compute snapshots list \\ --filter=\u0026#34;sourceDisk~$disk\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1) gcloud compute disks create $disk \\ --source-snapshot=\u0026#34;$snap\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } attachDisks() { echo \u0026#34;Attaching disks ...\u0026#34; gcloud compute instances attach-disk $instance \\ --disk=\u0026#34;$disk\u0026#34; \\ --device-name=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; \\ --boot } setAutodelete() { echo \u0026#34;Setting autodelete on disks ...\u0026#34; gcloud compute instances set-disk-auto-delete $instance \\ --auto-delete \\ --disk=\u0026#34;$disk\u0026#34; \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } startServer() { echo \u0026#34;Starting server ...\u0026#34; gcloud compute instances start $instance \\ --zone=\u0026#34;$zone\u0026#34; \\ --project=\u0026#34;$project\u0026#34; } main() { checkLogin displayHeader getDisks getSnaps read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then stopServer detachDisks deleteDisks createDisks attachDisks setAutodelete startServer fi } main ","permalink":"http://uly.me/posts/gcp-restore-boot-disk/","summary":"\u003cp\u003eHere\u0026rsquo;s my latest script to restore the boot disk of a VM in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# project=\u0026#34;projectid\u0026#34;\n# instance=\u0026#34;hostname\u0026#34;\n# zone=\u0026#34;us-central1-c\u0026#34;\n# policy=\u0026#34;hourly\u0026#34;\n# snapback=3\n\n# Format (requires all 5 arguments): ./script.sh project host zone policy snapback\n# If no arguments are provided or if less than 5 arguments, then you will be prompted to enter options.\n\nif [ -z \u0026#34;$project\u0026#34; ] || [ -z \u0026#34;$instance\u0026#34; ] || [ -z \u0026#34;$zone\u0026#34; ] || [ -z \u0026#34;$policy\u0026#34; ] || [ -z \u0026#34;$snapback\u0026#34; ]; then\n\n    if  [ \u0026#34;$#\u0026#34; -eq 5 ]; then\n        project=$1\n        instance=$2\n        zone=$3\n        policy=$4\n        snapback=$5\n    else \n        read -p \u0026#34;projectId : \u0026#34; project\n        read -p \u0026#34;instance  : \u0026#34; instance\n        read -p \u0026#34;zone      : \u0026#34; zone\n        read -p \u0026#34;policy    : \u0026#34; policy\n        read -p \u0026#34;snapback  : \u0026#34; snapback\n    fi\n\nfi\n\necho $project $instance $zone $policy $snapback\n\ncheckLogin() {\n\n    user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;)\n    user=$(echo $user | cut -d@ -f1)\n    user=${user/./-}\n\n    if [ -z \u0026#34;$user\u0026#34; ]; then\n        echo \u0026#34;You\u0026#39;re not logged in to Google SDK.\u0026#34;\n        exit\n    fi\n\n}\n\ndisplayHeader() {\n\n    echo \u0026#34;######################################################\u0026#34;\n    echo \u0026#34;Starting the restore process for $instance \u0026#34;\n    echo \u0026#34;######################################################\u0026#34;\n\n}\n\ngetDisks() {\n\n    disks=$(gcloud compute instances describe $instance \\\n        --project=\u0026#34;$project\u0026#34; \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --format=\u0026#34;get(disks[0].source)\u0026#34;)\n\n    echo \u0026#34;Listing disks for $instance ... \u0026#34;\n\n    disk=$(echo ${disks##*/})\n\n    echo $disk\n\n}\n\ngetSnaps() {\n\n    echo \u0026#34;Listing snapshots to restore for $instance ... \u0026#34;\n \n    snap=$(gcloud compute snapshots list \\\n        --filter=\u0026#34;sourceSnapshotSchedulePolicy~$policy AND sourceDisk~$disk\u0026#34; \\\n        --format=\u0026#34;value(name)\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34; \\\n        --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1)\n\n    echo \u0026#34;$disk: $snap\u0026#34; \n\n}\n\nstopServer() {\n\n    echo \u0026#34;Stopping server ...\u0026#34;\n\n    gcloud compute instances stop $instance \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\ndetachDisks() {\n\n    echo \u0026#34;Detaching disks ...\u0026#34;\n\n    gcloud compute instances detach-disk $instance \\\n        --disk=\u0026#34;$disk\u0026#34; \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\ndeleteDisks() {\n\n    echo \u0026#34;Deleting disks ...\u0026#34;\n\n    gcloud compute disks delete $disk \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\ncreateDisks() {\n\n    echo \u0026#34;Creating disks ...\u0026#34;\n\n    snap=$(gcloud compute snapshots list \\\n        --filter=\u0026#34;sourceDisk~$disk\u0026#34; \\\n        --format=\u0026#34;value(name)\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34; \\\n        --sort-by=\u0026#34;~creationTimestamp\u0026#34; | head -n $snapback | tail -n 1)\n\n    gcloud compute disks create $disk \\\n        --source-snapshot=\u0026#34;$snap\u0026#34; \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\nattachDisks() {\n\n    echo \u0026#34;Attaching disks ...\u0026#34;\n\n    gcloud compute instances attach-disk $instance \\\n        --disk=\u0026#34;$disk\u0026#34; \\\n        --device-name=\u0026#34;$disk\u0026#34; \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34; \\\n        --boot\n\n}\n\nsetAutodelete() {\n\n    echo \u0026#34;Setting autodelete on disks ...\u0026#34;\n\n    gcloud compute instances set-disk-auto-delete $instance \\\n        --auto-delete \\\n        --disk=\u0026#34;$disk\u0026#34; \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\nstartServer() {\n\n    echo \u0026#34;Starting server ...\u0026#34;\n\n    gcloud compute instances start $instance \\\n        --zone=\u0026#34;$zone\u0026#34; \\\n        --project=\u0026#34;$project\u0026#34;\n\n}\n\nmain() {\n\n    checkLogin\n    displayHeader\n    getDisks\n    getSnaps \n\n    read -p \u0026#34;Do you want to proceed with restore? Are you sure? \u0026#34; -n 1 -r\n    echo    # (optional) move to a new line\n    if [[ $REPLY =~ ^[Yy]$ ]]\n    then\n        stopServer\n        detachDisks\n        deleteDisks\n        createDisks\n        attachDisks\n        setAutodelete\n        startServer\n    fi\n    \n}\n\nmain\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp restore boot disk"},{"content":"Here\u0026rsquo;s how to list all the snapshots for a particular VM in GCP.\n#!/bin/bash if [ \u0026#34;$#\u0026#34; -ne 3 ] then echo \u0026#34;Usage: ./gcp-list-all-snapshots.sh project server policy\u0026#34; exit fi # Set the name of the snapshot schedule policy and the disk name to filter by PROJECT=$1 # PROJECT=\u0026#34;projectId\u0026#34; SERVER=$2 # DISK_NAME=\u0026#34;hostname\u0026#34; POLICY=$3 # POLICY_NAME=\u0026#34;hourly or daily\u0026#34; disks=$(gcloud compute disks list --project $PROJECT --filter=\u0026#34;name~$SERVER\u0026#34; --format=\u0026#34;value(name)\u0026#34;) for disk in $disks; do # List all snapshots created by the snapshot schedule policy gcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\ --format=\u0026#34;table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\ --sort-by \u0026#34;~creationTimestamp\u0026#34; \\ --project=\u0026#34;$PROJECT\u0026#34; done The script requires three arguments: projectId, hostname and policy.\n","permalink":"http://uly.me/posts/gcp-vm-list-all-snapshots/","summary":"\u003cp\u003eHere\u0026rsquo;s how to list all the snapshots for a particular VM in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\nif [ \u0026#34;$#\u0026#34; -ne 3 ]\nthen\n  echo \u0026#34;Usage: ./gcp-list-all-snapshots.sh project server policy\u0026#34;\n  exit\nfi\n\n# Set the name of the snapshot schedule policy and the disk name to filter by\nPROJECT=$1            # PROJECT=\u0026#34;projectId\u0026#34;\nSERVER=$2             # DISK_NAME=\u0026#34;hostname\u0026#34;\nPOLICY=$3             # POLICY_NAME=\u0026#34;hourly or daily\u0026#34;\n\ndisks=$(gcloud compute disks list --project $PROJECT --filter=\u0026#34;name~$SERVER\u0026#34; --format=\u0026#34;value(name)\u0026#34;) \n\nfor disk in $disks; do\n\n  # List all snapshots created by the snapshot schedule policy\n  gcloud compute snapshots list \\\n  --filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\\n  --format=\u0026#34;table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\\n  --sort-by \u0026#34;~creationTimestamp\u0026#34; \\\n  --project=\u0026#34;$PROJECT\u0026#34;\n\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe script requires three arguments: projectId, hostname and policy.\u003c/p\u003e","title":"gcp vm list all snapshots"},{"content":"Here\u0026rsquo;s my bash script that creates a new Jekyll post template. Once created, use vi to edit the post.\n#!/bin/bash if [ \u0026#34;$#\u0026#34; -ne 1 ] then echo \u0026#34;Missing argument. Usage: ./jekyllNewPost.sh new-post-title\u0026#34; exit fi cd ~/Code/docker/ulyme/_posts/ ts=$(date +%Y-%m-%d) title=$1 filename=($ts-$title.md) pretitle=$(echo \u0026#34;${title^}\u0026#34;) posttitle=$(echo $pretitle | tr \u0026#34;-\u0026#34; \u0026#34; \u0026#34;) cat \u0026lt;\u0026lt; EOF \u0026gt; $filename --- layout: post author: ulysses title: \u0026#39;$posttitle\u0026#39; --- EOF echo \u0026#34;vi ~/Code/docker/ulyme/_posts/$filename\u0026#34; ","permalink":"http://uly.me/posts/jekyll-new-post-script/","summary":"\u003cp\u003eHere\u0026rsquo;s my bash script that creates a new Jekyll post template. Once created, use vi to edit the post.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [ \u0026#34;$#\u0026#34; -ne 1 ]\nthen\n  echo \u0026#34;Missing argument. Usage: ./jekyllNewPost.sh new-post-title\u0026#34;\n  exit\nfi\n\ncd ~/Code/docker/ulyme/_posts/\nts=$(date +%Y-%m-%d)\n\ntitle=$1\nfilename=($ts-$title.md)\n\npretitle=$(echo \u0026#34;${title^}\u0026#34;)\nposttitle=$(echo $pretitle | tr \u0026#34;-\u0026#34; \u0026#34; \u0026#34;)\n\ncat \u0026lt;\u0026lt; EOF \u0026gt; $filename\n---\nlayout: post\nauthor: ulysses\ntitle: \u0026#39;$posttitle\u0026#39;\n---\nEOF\n\necho \u0026#34;vi ~/Code/docker/ulyme/_posts/$filename\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"jekyll new post script"},{"content":"I had problems echoing four variables into one line. There seem to be some carriage return or new line somewhere that\u0026rsquo;s not visible.\nSo, here\u0026rsquo;s a line of code that will strip any new line or carriage return in the variable, and then use printf to display the variables on one line.\nStrip the new lines.\nefs=\u0026#34;${efs//$\u0026#39;\\n\u0026#39;/ }\u0026#34; name=\u0026#34;${name//$\u0026#39;\\n\u0026#39;/}\u0026#34; total=\u0026#34;${total//$\u0026#39;\\n\u0026#39;/ }\u0026#34; mesg=\u0026#34;${mesg//$\u0026#39;\\n\u0026#39;/}\u0026#34; Now print them using printf on one line.\nprintf \u0026#34;%-30s %-40s %-20s %-30s\\n\u0026#34; \u0026#34;$efs\u0026#34; \u0026#34;$new\u0026#34; \u0026#34;$total\u0026#34; \u0026#34;$mesg\u0026#34; With that code, I\u0026rsquo;m now able to format my report nicely without the extra new lines.\n","permalink":"http://uly.me/posts/strip-new-lines-on-variables/","summary":"\u003cp\u003eI had problems echoing four variables into one line. There seem to be some carriage return or new line somewhere that\u0026rsquo;s not visible.\u003c/p\u003e\n\u003cp\u003eSo, here\u0026rsquo;s a line of code that will strip any new line or carriage return in the variable, and then use printf to display the variables on one line.\u003c/p\u003e\n\u003cp\u003eStrip the new lines.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eefs=\u0026#34;${efs//$\u0026#39;\\n\u0026#39;/ }\u0026#34;\nname=\u0026#34;${name//$\u0026#39;\\n\u0026#39;/}\u0026#34;\ntotal=\u0026#34;${total//$\u0026#39;\\n\u0026#39;/ }\u0026#34;\nmesg=\u0026#34;${mesg//$\u0026#39;\\n\u0026#39;/}\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNow print them using printf on one line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprintf \u0026#34;%-30s %-40s %-20s %-30s\\n\u0026#34; \u0026#34;$efs\u0026#34; \u0026#34;$new\u0026#34; \u0026#34;$total\u0026#34; \u0026#34;$mesg\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWith that code, I\u0026rsquo;m now able to format my report nicely without the extra new lines.\u003c/p\u003e","title":"strip new lines on variables"},{"content":"I have two Github accounts. The first one was cloned using HTTPS. When it was time to add a second one, I really didn\u0026rsquo;t want to mess around with multiple Github accounts and dealing with multiple credentials. I\u0026rsquo;ve decided to just clone the second account using SSH. I decided to do this mainly to simplify setup and to avoid the headaches with setting up multiple accounts in the config.\nFirst repo - was cloned using HTTPS Second repo - was cloned using SSH The first repo which uses HTTPS requires a github key which will need to be generated on Github. The first time a repo is cloned, you\u0026rsquo;ll be prompted to supply the key. This key is kept in the ~/.git-credentials file on the local desktop. The second repo which uses SSH requires a ssh key to be generated locally on your desktop, which you will then need to upload to github to allow authentication.\nSo here we go. Two separate ways of cloning repos without stepping on each other.\n","permalink":"http://uly.me/posts/multiple-github-accounts/","summary":"\u003cp\u003eI have two Github accounts. The first one was cloned using HTTPS. When it was time to add a second one, I really didn\u0026rsquo;t want to mess around with multiple Github accounts and dealing with multiple credentials. I\u0026rsquo;ve decided to just clone the second account using SSH. I decided to do this mainly to simplify setup and to avoid the headaches with setting up multiple accounts in the config.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eFirst repo - was cloned using HTTPS\u003c/li\u003e\n\u003cli\u003eSecond repo - was cloned using SSH\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe first repo which uses HTTPS requires a github key which will need to be generated on Github. The first time a repo is cloned, you\u0026rsquo;ll be prompted to supply the key. This key is kept in the \u003cstrong\u003e~/.git-credentials\u003c/strong\u003e file on the local desktop. The second repo which uses SSH requires a ssh key to be generated locally on your desktop, which you will then need to upload to github to allow authentication.\u003c/p\u003e","title":"multiple github accounts"},{"content":"Here\u0026rsquo;s how to use internal links within Jekyll. Use this format.\n{% raw %}\n[Some Link]({% post_url 2010-07-21-name-of-post %}) {% endraw %}\nI had to convert code to HTML characters to render properly.\n","permalink":"http://uly.me/posts/using-internal-links/","summary":"\u003cp\u003eHere\u0026rsquo;s how to use internal links within Jekyll. Use this format.\u003c/p\u003e\n\u003cp\u003e{% raw %}\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[Some Link]({% post_url 2010-07-21-name-of-post %})\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e{% endraw %}\u003c/p\u003e\n\u003cp\u003eI had to convert code to HTML characters to render properly.\u003c/p\u003e","title":"using internal links"},{"content":"Editing 1000+ files is not fun. Here\u0026rsquo;s a script that cycles through certain files in a directory and performs a search and replace.\n#!/bin/bash for filename in 20*.md; do sed -i -e \u0026#39;s/author: Ulysses/author: ulysses/g\u0026#39; $filename done In this particular script, it looks for files starting with 20 with an extension of .md.\nThe script uses the sed command to perform search and replace.\n","permalink":"http://uly.me/posts/editing-multiple-files/","summary":"\u003cp\u003eEditing 1000+ files is not fun. Here\u0026rsquo;s a script that cycles through certain files in a directory and performs a search and replace.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfor filename in 20*.md; do\n  sed -i -e \u0026#39;s/author: Ulysses/author: ulysses/g\u0026#39; $filename\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn this particular script, it looks for files starting with 20 with an extension of .md.\u003c/p\u003e\n\u003cp\u003eThe script uses the \u003cstrong\u003esed command\u003c/strong\u003e to perform search and replace.\u003c/p\u003e","title":"editing multiple files"},{"content":"I recently migrated this blog from WordPress to Jekyll due to several reasons.\nIt came down to these three reasons:\nCost Speed Security Cost. Jekyll generates static websites, meaning it can be hosted freely at Github. No more hosted VM\u0026rsquo;s. That\u0026rsquo;s a savings of $120 per year. Speed. Since Jekyll pages are static HTML pages, websites loads much faster. There are no more PHP, extra plugins or databases that slow down pages. Security. Since Jekyll pages are static files, they do not need a LAMP stack. So no more OS, PHP, plugins or MySQL databases to securely maintain. It\u0026rsquo;s a win win. The migration was quick and easy, but not it\u0026rsquo;s not entirely a 100% bug-free. I had to tweak Jekyll templates here and there to get it to look the way I wanted it. There are a ton of articles out there that covers the Jeklly to WordPress migration. I\u0026rsquo;m not going to cover the migration process here step by step. To quickly summarize, you\u0026rsquo;ll need to install a Jekyll exporter plugin in WordPress to export your posts. You can then import your posts into Jekyll and tweak Jekyll the way you want it. That\u0026rsquo;s it in a nutshell.\nBy the way, I\u0026rsquo;m running Jekyll in a Docker. If you are interested, here are the [instructions]({% post_url 2022-08-31-jekyll-on-docker-container %}) to run Jekyll in a Docker container.\n","permalink":"http://uly.me/posts/switching-from-wordpress-to-jekyll/","summary":"\u003cp\u003eI recently migrated this blog from WordPress to Jekyll due to several reasons.\u003c/p\u003e\n\u003cp\u003eIt came down to these three reasons:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCost\u003c/li\u003e\n\u003cli\u003eSpeed\u003c/li\u003e\n\u003cli\u003eSecurity\u003c/li\u003e\n\u003c/ul\u003e\n\u003col\u003e\n\u003cli\u003eCost. Jekyll generates static websites, meaning it can be hosted freely at Github. No more hosted VM\u0026rsquo;s. That\u0026rsquo;s a savings of $120 per year.\u003c/li\u003e\n\u003cli\u003eSpeed. Since Jekyll pages are static HTML pages, websites loads much faster. There are no more PHP, extra plugins or databases that slow down pages.\u003c/li\u003e\n\u003cli\u003eSecurity. Since Jekyll pages are static files, they do not need a LAMP stack. So no more OS, PHP, plugins or MySQL databases to securely maintain.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eIt\u0026rsquo;s a win win. The migration was quick and easy, but not it\u0026rsquo;s not entirely a 100% bug-free. I had to tweak Jekyll templates here and there to get it to look the way I wanted it. There are a ton of articles out there that covers the Jeklly to WordPress migration. I\u0026rsquo;m not going to cover the migration process here step by step. To quickly summarize, you\u0026rsquo;ll need to install a Jekyll exporter plugin in WordPress to export your posts. You can then import your posts into Jekyll and tweak Jekyll the way you want it. That\u0026rsquo;s it in a nutshell.\u003c/p\u003e","title":"switching from wordpress to jekyll"},{"content":"I ran into an issue with PHP not able to run gcloud commands via shell_exec. It turned out to be a permission issue.\nI ended up granting the apache user access to /usr/share/httpd/.config directory which was missing.\nGoogle SDK needs write access to this directory. I ran the commands below and it worked after the changes.\nmkdir /usr/share/httpd/.config chown apache:root /usr/share/httpd/.config ","permalink":"http://uly.me/posts/php-not-able-to-run-gcloud-via-shell-exec/","summary":"\u003cp\u003eI ran into an issue with PHP not able to run gcloud commands via shell_exec. It turned out to be a permission issue.\u003c/p\u003e\n\u003cp\u003eI ended up granting the \u003cstrong\u003eapache\u003c/strong\u003e user access to \u003cstrong\u003e/usr/share/httpd/.config\u003c/strong\u003e directory which was missing.\u003c/p\u003e\n\u003cp\u003eGoogle SDK needs write access to this directory. I ran the commands below and it worked after the changes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir /usr/share/httpd/.config\nchown apache:root /usr/share/httpd/.config\n\u003c/code\u003e\u003c/pre\u003e","title":"php not able to run gcloud commands via shell_exec"},{"content":"How to hide main password on Linux using OpenSSL.\nRun this on a web server once.\n$ echo \u0026#34;SecretPassword\u0026#34; | openssl enc -aes-256-cbc -md sha512 -a -salt -pass pass:NotSoSecretPassword \u0026gt; secret.txt $ chmod 600 secret.txt On client machine, download the secret file.\n$ curl https://webserver/some/dir/secret.txt --output -s secret.txt To retrieve the secret password, run the code below. For added measure, delete secret.txt file afterwards.\n$ cat secret.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:NotSoSecretPassword $rm -f secret.txt In addition, you can rotate the NotSoSecretPassword to make it more secure.\n","permalink":"http://uly.me/posts/hiding-passwords-using-openssl/","summary":"\u003cp\u003eHow to hide main password on Linux using OpenSSL.\u003c/p\u003e\n\u003cp\u003eRun this on a web server once.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ echo \u0026#34;SecretPassword\u0026#34; | openssl enc -aes-256-cbc -md sha512 -a -salt -pass pass:NotSoSecretPassword \u0026gt; secret.txt  \n$ chmod 600 secret.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOn client machine, download the secret file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ curl https://webserver/some/dir/secret.txt --output -s secret.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo retrieve the secret password, run the code below. For added measure, delete secret.txt file afterwards.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat secret.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:NotSoSecretPassword\n$rm -f secret.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn addition, you can rotate the NotSoSecretPassword to make it more secure.\u003c/p\u003e","title":"hiding passwords using openssl"},{"content":"As of this writing, the latest Terraform version supported by Homebrew is version 1.5.7. It’s a bit outdated considering the latest Terraform version is 1.6.2. To force Homebrew to install the latest version of Terraform, run the following commands from your MacOS Terminal. But prior to that, check your version first.\nCheck current version\n$ terraform --version Terraform v1.5.7 on darwin_amd64 Upgrade Terraform\n$ brew tap hashicorp/tap $ brew install hashicorp/tap/terraform Check version again\n$ terraform --version Terraform v1.6.2 on darwin_amd64 That’s it.\n","permalink":"http://uly.me/posts/install-latest-terraform-via-homebrew/","summary":"\u003cp\u003eAs of this writing, the latest Terraform version supported by Homebrew is version 1.5.7. It’s a bit outdated considering the latest Terraform version is 1.6.2. To force Homebrew to install the latest version of Terraform, run the following commands from your MacOS Terminal. But prior to that, check your version first.\u003c/p\u003e\n\u003cp\u003eCheck current version\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ terraform --version\nTerraform v1.5.7\non darwin_amd64\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUpgrade Terraform\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ brew tap hashicorp/tap\n$ brew install hashicorp/tap/terraform\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck version again\u003c/p\u003e","title":"install latest terraform via homebrew"},{"content":"When uploading videos, Youtube gives you an option to upload your own thumbnails. If you want to use your own pics, you can format them to 1280×720 pixels and use it as a thumbnail. The script below will resize any image regardless of the original size to 1280×720 pixels using the convert utility of ImageMagick. The conversion may crop the edges of your image if it’s not 16:9 or 1.777 format. The script will also resize an image in portrait format.\n#!/bin/bash cd /home/ulysses/Pictures/jpg image=$1 test=`convert $image -format \u0026#34;%[fx:(w/h\u0026gt;1)?1:0]\u0026#34; info:` if [ $test -eq 1 ]; then convert $image -resize 1280x720! 720_$image else convert $image -resize 720x1280! 720_$image fi Enjoy.\n","permalink":"http://uly.me/posts/youtube-thumbnail/","summary":"\u003cp\u003eWhen uploading videos, Youtube gives you an option to upload your own thumbnails. If you want to use your own pics, you can format them to 1280×720 pixels and use it as a thumbnail. The script below will resize any image regardless of the original size to 1280×720 pixels using the convert utility of ImageMagick. The conversion may crop the edges of your image if it’s not 16:9 or 1.777 format. The script will also resize an image in portrait format.\u003c/p\u003e","title":"youtube thumbnail"},{"content":"How to search the second column for string starting with.\nHere are the contents of results.txt.\nJohn 10 Mario 12 Derek 15 Mark 20 Matt 25 Display only individuals that are older than 20 using awk.\nawk \u0026#39;$2 ~ /^20/\u0026#39; results.txt Result.\nMark 20 Matt 25 You can easily adjust this to other columns.\n","permalink":"http://uly.me/posts/search-second-column-for-characters/","summary":"\u003cp\u003eHow to search the second column for string starting with.\u003c/p\u003e\n\u003cp\u003eHere are the contents of results.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eJohn 10\nMario 12\nDerek 15\nMark 20\nMatt 25\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay only individuals that are older than 20 using awk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eawk \u0026#39;$2 ~ /^20/\u0026#39; results.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eMark 20\nMatt 25\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can easily adjust this to other columns.\u003c/p\u003e","title":"search second column for characters"},{"content":"If you don’t have JQ (JSON Parser) installed, you can use a combination of echo, grep and sed to pull out the data.\n# create new credentials new_access_keys_json=$(aws iam create-access-key --user-name $user --profile $profile) new_access_key_id=$(echo \u0026#34;$new_access_keys_json\u0026#34; | grep -o \u0026#39;\u0026#34;AccessKeyId\u0026#34;: \u0026#34;[^\u0026#34;]*\u0026#39; | sed \u0026#39;s/\u0026#34;AccessKeyId\u0026#34;: \u0026#34;//\u0026#39;) new_access_secret_key=$(echo \u0026#34;$new_access_keys_json\u0026#34; | grep -o \u0026#39;\u0026#34;SecretAccessKey\u0026#34;: \u0026#34;[^\u0026#34;]*\u0026#39; | sed \u0026#39;s/\u0026#34;SecretAccessKey\u0026#34;: \u0026#34;//\u0026#39;) In this example, we are creating new AWS IAM credentials. AccessKeyID and secretKey are extracted from JSON.\n","permalink":"http://uly.me/posts/alternative-to-jq/","summary":"\u003cp\u003eIf you don’t have JQ (JSON Parser) installed, you can use a combination of echo, grep and sed to pull out the data.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# create new credentials\nnew_access_keys_json=$(aws iam create-access-key --user-name $user --profile $profile)\nnew_access_key_id=$(echo \u0026#34;$new_access_keys_json\u0026#34; | grep -o \u0026#39;\u0026#34;AccessKeyId\u0026#34;: \u0026#34;[^\u0026#34;]*\u0026#39; | sed \u0026#39;s/\u0026#34;AccessKeyId\u0026#34;: \u0026#34;//\u0026#39;)\nnew_access_secret_key=$(echo \u0026#34;$new_access_keys_json\u0026#34; | grep -o \u0026#39;\u0026#34;SecretAccessKey\u0026#34;: \u0026#34;[^\u0026#34;]*\u0026#39; | sed \u0026#39;s/\u0026#34;SecretAccessKey\u0026#34;: \u0026#34;//\u0026#39;)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn this example, we are creating new AWS IAM credentials. AccessKeyID and secretKey are extracted from JSON.\u003c/p\u003e","title":"alternative to jq"},{"content":"This is a Lambda function code that list EC2 instances from multiple regions and write the output to a S3 bucket.\nInclude name and IP address on the output.\nimport boto3 import json import os from botocore.exceptions import NoCredentialsError # Set the AWS regions you want to query regions = [\u0026#39;us-east-1\u0026#39;, \u0026#39;us-west-2\u0026#39;, \u0026#39;eu-west-1\u0026#39;] # Set the S3 bucket and object key for storing the output s3_bucket = \u0026#39;your-s3-bucket-name\u0026#39; s3_object_key = \u0026#39;ec2-instances-list.txt\u0026#39; def lambda_handler(event, context): ec2_instances = [] for region in regions: try: # Create an EC2 client for the specified region ec2 = boto3.client(\u0026#39;ec2\u0026#39;, region_name=region) # Describe EC2 instances in the region response = ec2.describe_instances() for reservation in response[\u0026#39;Reservations\u0026#39;]: for instance in reservation[\u0026#39;Instances\u0026#39;]: # Extract instance information instance_name = \u0026#34;N/A\u0026#34; instance_ip = \u0026#34;N/A\u0026#34; for tag in instance.get(\u0026#39;Tags\u0026#39;, []): if tag[\u0026#39;Key\u0026#39;] == \u0026#39;Name\u0026#39;: instance_name = tag[\u0026#39;Value\u0026#39;] if instance.get(\u0026#39;PublicIpAddress\u0026#39;): instance_ip = instance[\u0026#39;PublicIpAddress\u0026#39;] ec2_instances.append(f\u0026#34;Region: {region}, Name: {instance_name}, IP: {instance_ip}\u0026#34;) except NoCredentialsError: return \u0026#34;No AWS credentials found.\u0026#34; # Store the EC2 instance information in an S3 object s3 = boto3.client(\u0026#39;s3\u0026#39;) s3.put_object(Bucket=s3_bucket, Key=s3_object_key, Body=\u0026#39;\\n\u0026#39;.join(ec2_instances), ContentType=\u0026#39;text/plain\u0026#39;) return { \u0026#34;statusCode\u0026#34;: 200, \u0026#34;body\u0026#34;: json.dumps(\u0026#34;EC2 instance information has been saved to S3.\u0026#34;) } ","permalink":"http://uly.me/posts/lambda-function-list-ec2-instances/","summary":"\u003cp\u003eThis is a Lambda function code that list EC2 instances from multiple regions and write the output to a S3 bucket.\u003c/p\u003e\n\u003cp\u003eInclude name and IP address on the output.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport boto3\nimport json\nimport os\nfrom botocore.exceptions import NoCredentialsError\n\n# Set the AWS regions you want to query\nregions = [\u0026#39;us-east-1\u0026#39;, \u0026#39;us-west-2\u0026#39;, \u0026#39;eu-west-1\u0026#39;]\n\n# Set the S3 bucket and object key for storing the output\ns3_bucket = \u0026#39;your-s3-bucket-name\u0026#39;\ns3_object_key = \u0026#39;ec2-instances-list.txt\u0026#39;\n\ndef lambda_handler(event, context):\n    ec2_instances = []\n\n    for region in regions:\n        try:\n            # Create an EC2 client for the specified region\n            ec2 = boto3.client(\u0026#39;ec2\u0026#39;, region_name=region)\n\n            # Describe EC2 instances in the region\n            response = ec2.describe_instances()\n\n            for reservation in response[\u0026#39;Reservations\u0026#39;]:\n                for instance in reservation[\u0026#39;Instances\u0026#39;]:\n                    # Extract instance information\n                    instance_name = \u0026#34;N/A\u0026#34;\n                    instance_ip = \u0026#34;N/A\u0026#34;\n                    for tag in instance.get(\u0026#39;Tags\u0026#39;, []):\n                        if tag[\u0026#39;Key\u0026#39;] == \u0026#39;Name\u0026#39;:\n                            instance_name = tag[\u0026#39;Value\u0026#39;]\n                    if instance.get(\u0026#39;PublicIpAddress\u0026#39;):\n                        instance_ip = instance[\u0026#39;PublicIpAddress\u0026#39;]\n\n                    ec2_instances.append(f\u0026#34;Region: {region}, Name: {instance_name}, IP: {instance_ip}\u0026#34;)\n\n        except NoCredentialsError:\n            return \u0026#34;No AWS credentials found.\u0026#34;\n\n    # Store the EC2 instance information in an S3 object\n    s3 = boto3.client(\u0026#39;s3\u0026#39;)\n    s3.put_object(Bucket=s3_bucket, Key=s3_object_key, Body=\u0026#39;\\n\u0026#39;.join(ec2_instances), ContentType=\u0026#39;text/plain\u0026#39;)\n\n    return {\n        \u0026#34;statusCode\u0026#34;: 200,\n        \u0026#34;body\u0026#34;: json.dumps(\u0026#34;EC2 instance information has been saved to S3.\u0026#34;)\n    }\n\u003c/code\u003e\u003c/pre\u003e","title":"lambda function list ec2 instances"},{"content":"Here’s how to split a string that contains a delimeter.\nString\nserver-boot;server-data Split the string and print on every line.\ndata=\u0026#34;server-boot;server-data\u0026#34; for i in $(echo $data | tr \u0026#34;;\u0026#34; \u0026#34;\\n\u0026#34;); do echo $i done Result\nserver-boot server-data Send output to a file\nfile=\u0026#34;output.txt\u0026#34; \u0026gt; $file data=\u0026#34;server-boot;server-data\u0026#34; for i in $(echo $data | tr \u0026#34;;\u0026#34; \u0026#34;\\n\u0026#34;); do echo $i \u0026gt;\u0026gt; $file done ","permalink":"http://uly.me/posts/bash-split-a-string-with-delimiter/","summary":"\u003cp\u003eHere’s how to split a string that contains a delimeter.\u003c/p\u003e\n\u003cp\u003eString\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserver-boot;server-data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSplit the string and print on every line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edata=\u0026#34;server-boot;server-data\u0026#34;\nfor i in $(echo $data | tr \u0026#34;;\u0026#34; \u0026#34;\\n\u0026#34;); do\n  echo $i\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserver-boot\nserver-data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSend output to a file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efile=\u0026#34;output.txt\u0026#34;\n\u0026gt; $file\ndata=\u0026#34;server-boot;server-data\u0026#34;\nfor i in $(echo $data | tr \u0026#34;;\u0026#34; \u0026#34;\\n\u0026#34;); do\n  echo $i \u0026gt;\u0026gt; $file\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"bash split a string with delimiter"},{"content":"Here’s how to display asterisks when typing passwords in Bash.\n#!/bin/bash unset password prompt=\u0026#34;Enter Password:\u0026#34; while IFS= read -p \u0026#34;$prompt\u0026#34; -r -s -n 1 char do if [[ $char == $\u0026#39;\\0\u0026#39; ]] then break fi prompt=\u0026#39;*\u0026#39; password+=\u0026#34;$char\u0026#34; done echo echo \u0026#34;Done. Password=$password\u0026#34; ","permalink":"http://uly.me/posts/display-asterisks-when-typing-passwords-in-bash/","summary":"\u003cp\u003eHere’s how to display asterisks when typing passwords in Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nunset password\nprompt=\u0026#34;Enter Password:\u0026#34;\nwhile IFS= read -p \u0026#34;$prompt\u0026#34; -r -s -n 1 char\ndo\n    if [[ $char == $\u0026#39;\\0\u0026#39; ]]\n    then\n        break\n    fi\n    prompt=\u0026#39;*\u0026#39;\n    password+=\u0026#34;$char\u0026#34;\ndone\necho\necho \u0026#34;Done. Password=$password\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"display asterisks when typing passwords in bash"},{"content":"Differences using gcloud table vs CSV format.\nTable format\ngcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\ --format=\u0026#34;table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\ --sort-by \u0026#34;~creationTimestamp\u0026#34; \\ --project=\u0026#34;$PROJECT\u0026#34; CSV format\ngcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\ --format=\u0026#34;csv[separator=\u0026#39;,\u0026#39;](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\ --sort-by \u0026#34;~creationTimestamp\u0026#34; \\ --project=\u0026#34;$PROJECT\u0026#34; Output to file\ngcloud compute snapshots list \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\ --format=\u0026#34;csv[separator=\u0026#39;,\u0026#39;](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\ --sort-by \u0026#34;~creationTimestamp\u0026#34; \\ --project=\u0026#34;$PROJECT\u0026#34; \u0026gt; output.csv ","permalink":"http://uly.me/posts/gcloud-table-vs-csv-format/","summary":"\u003cp\u003eDifferences using gcloud table vs CSV format.\u003c/p\u003e\n\u003cp\u003eTable format\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute snapshots list \\\n--filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\\n--format=\u0026#34;table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\\n--sort-by \u0026#34;~creationTimestamp\u0026#34; \\\n--project=\u0026#34;$PROJECT\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCSV format\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute snapshots list \\\n--filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\\n--format=\u0026#34;csv[separator=\u0026#39;,\u0026#39;](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\\n--sort-by \u0026#34;~creationTimestamp\u0026#34; \\\n--project=\u0026#34;$PROJECT\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput to file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute snapshots list \\\n--filter=\u0026#34;sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$\u0026#34; \\\n--format=\u0026#34;csv[separator=\u0026#39;,\u0026#39;](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())\u0026#34; \\\n--sort-by \u0026#34;~creationTimestamp\u0026#34; \\\n--project=\u0026#34;$PROJECT\u0026#34; \u0026gt; output.csv\n\u003c/code\u003e\u003c/pre\u003e","title":"gcloud table vs csv format"},{"content":"If you are getting funky formatting in GCP Cloud Shell, run this to set the format.\ngcloud config set accessibility/screen_reader False ","permalink":"http://uly.me/posts/gcp-cloud-shell-format/","summary":"\u003cp\u003eIf you are getting funky formatting in GCP Cloud Shell, run this to set the format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud config set accessibility/screen_reader False\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp cloud shell format"},{"content":"Here’s the command to list what SSL and TLS protocols are active.\nopenssl ciphers -v | awk \u0026#39;{print $2}\u0026#39; | sort | uniq ","permalink":"http://uly.me/posts/active-ssl-and-tls-protocols/","summary":"\u003cp\u003eHere’s the command to list what SSL and TLS protocols are active.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eopenssl ciphers -v | awk \u0026#39;{print $2}\u0026#39; | sort | uniq\n\u003c/code\u003e\u003c/pre\u003e","title":"active ssl and tls protocols"},{"content":"Here’s another command to check what version of SSL and TLS is being used.\nnmap --script ssl-enum-ciphers -p 443 server.domain.com Result\nPORT STATE SERVICE 443/tcp open https | ssl-enum-ciphers: | TLSv1.2: | ciphers: ... In this example, only TLSv1.2 is in use. For security purposes, use TLSv1.2 or higher.\n","permalink":"http://uly.me/posts/checking-what-ssl-and-tls-are-in-use/","summary":"\u003cp\u003eHere’s another command to check what version of SSL and TLS is being used.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enmap --script ssl-enum-ciphers -p 443 server.domain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePORT    STATE SERVICE\n443/tcp open  https\n| ssl-enum-ciphers: \n|   TLSv1.2: \n|     ciphers:\n...\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn this example, only TLSv1.2 is in use. For security purposes, use TLSv1.2 or higher.\u003c/p\u003e","title":"checking what ssl and tls are in use"},{"content":"Here’s the command to list what app or package requires OpenSSL.\nrepoquery --whatrequires --installed --recursive openssl Result\nauthconfig-0:6.2.8-30.el7.x86_64 falcon-sensor-0:6.38.0-13501.el7.x86_64 python2-cryptography-0:1.7.2-2.el7.x86_64 realmd-0:0.16.1-12.el7_9.1.x86_64 terraform-0:1.3.6-1.x86_64 ","permalink":"http://uly.me/posts/what-requires-openssl/","summary":"\u003cp\u003eHere’s the command to list what app or package requires OpenSSL.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erepoquery --whatrequires --installed --recursive openssl\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eauthconfig-0:6.2.8-30.el7.x86_64\nfalcon-sensor-0:6.38.0-13501.el7.x86_64\npython2-cryptography-0:1.7.2-2.el7.x86_64\nrealmd-0:0.16.1-12.el7_9.1.x86_64\nterraform-0:1.3.6-1.x86_64\n\u003c/code\u003e\u003c/pre\u003e","title":"what requires openssl"},{"content":"Here’s the command to display VM OS licenses.\n#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log=\u0026#34;gcp-licenses-logs-$ts\u0026#34; \u0026gt;$log while read -r project; do echo \u0026#34;Project: $project\u0026#34; | tee -a $log gcloud compute instances list --project $project --format=\u0026#34;table[no-heading](name,zone.basename())\u0026#34; \u0026gt; instances.list while read -r instance zone; do gcloud compute instances describe $instance \\ --project $project \\ --zone $zone \\ --format=\u0026#34;table[no-heading](name,zone.basename(),disks[0].licenses[0].basename())\u0026#34; | tee -a $log done \u0026lt; instances.list done \u0026lt; projectIds.list It\u0026rsquo;s going to go through a list of VM\u0026rsquo;s in each project and display the name, zone and license information.\n","permalink":"http://uly.me/posts/gcp-vm-licenses/","summary":"\u003cp\u003eHere’s the command to display VM OS licenses.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nts=$(date +%Y%m%d-%H%M%S)\nlog=\u0026#34;gcp-licenses-logs-$ts\u0026#34;\n\u0026gt;$log\nwhile read -r project; do\n    echo \u0026#34;Project: $project\u0026#34; | tee -a $log\n    gcloud compute instances list --project $project --format=\u0026#34;table[no-heading](name,zone.basename())\u0026#34; \u0026gt; instances.list\n    while read -r instance zone; do\n        gcloud compute instances describe $instance \\\n        --project $project \\\n        --zone $zone \\\n        --format=\u0026#34;table[no-heading](name,zone.basename(),disks[0].licenses[0].basename())\u0026#34; | tee -a $log\n    done \u0026lt; instances.list\ndone \u0026lt; projectIds.list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt\u0026rsquo;s going to go through a list of VM\u0026rsquo;s in each project and display the name, zone and license information.\u003c/p\u003e","title":"gcp vm licenses"},{"content":"Here’s the command to capture a GCP VM serial port output to your terminal.\ngcloud compute instances get-serial-port-output servername \\ --zone us-central1-f \\ --project your-project \\ --port 1 You can also send the output to a file.\ngcloud compute instances get-serial-port-output servername \\ --zone us-central1-f \\ --project your-project \\ --port 1 \u0026gt; output.txt ","permalink":"http://uly.me/posts/capture-gcp-vm-serial-port-output-to-terminal/","summary":"\u003cp\u003eHere’s the command to capture a GCP VM serial port output to your terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances get-serial-port-output servername \\\n--zone us-central1-f \\\n--project your-project \\\n--port 1 \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also send the output to a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances get-serial-port-output servername \\\n--zone us-central1-f \\\n--project your-project \\\n--port 1 \u0026gt; output.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"capture gcp vm serial port output to terminal"},{"content":"When you exhausted all efforts trying to login to a VM and there’s no other way to log in to the server, here’s a breakglass method to allow you to log in to a VM via a startup script. Just add the following bash script to the VM startup section. Change the username and password to your liking. Restart the server to trigger the startup script. After reboot, it should give you access to the server. In addition, you will also have sudo access so you can switch as root.\n1. Edit the VM.\n2. Go to the Startup script section and add the following.\n#!/bin/bash user=\u0026#34;johndoe\u0026#34; pass=\u0026#34;password\u0026#34; if id $user \u0026gt;/dev/null 2\u0026gt;\u0026amp;1; then exit else adduser echo $user:$pass | chpasswd usermod -aG google-sudoers $user fi 3. Restart the server.\n4. Log in as user.\n5. Fix the login issue.\n6. Remove user.\n7. Remove the startup script.\n","permalink":"http://uly.me/posts/gcp-vm-breakglass-ssh/","summary":"\u003cp\u003eWhen you exhausted all efforts trying to login to a VM and there’s no other way to log in to the server, here’s a breakglass method to allow you to log in to a VM via a startup script. Just add the following bash script to the VM startup section. Change the username and password to your liking. Restart the server to trigger the startup script. After reboot, it should give you access to the server. In addition, you will also have sudo access so you can switch as root.\u003c/p\u003e","title":"gcp vm breakglass ssh"},{"content":"How to install pint utility on SLES machines.\nzypp in python-susepubliccloudinfo Once installed, you can run\npint amazon servers –region=\u0026#39;us-east-1\u0026#39; pint google servers –region=\u0026#39;us-central1\u0026#39; pint microsoft servers –region=\u0026#39;eastus\u0026#39; ","permalink":"http://uly.me/posts/install-pint-on-sles/","summary":"\u003cp\u003eHow to install pint utility on SLES machines.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ezypp in python-susepubliccloudinfo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce installed, you can run\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epint amazon servers –region=\u0026#39;us-east-1\u0026#39;\npint google servers –region=\u0026#39;us-central1\u0026#39;\npint microsoft servers –region=\u0026#39;eastus\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"install pint on sles"},{"content":"Converting Mac and Linux Dates\nLinux\n#!/bin/bash start_time=$(date +%s) log=$(date -d @$start_time +%Y%m%d-%H%M%S) start=$(date -d @$start_time) echo $start_time echo $log echo $start sleep 10 stop_time=$(date +%s) stop=$(date -d @$stop_time) echo $stop_time echo $stop Mac\n#!/bin/bash start_time=$(date +%s) log=$(date -r $start_time +%Y%m%d-%H%M%S) start=$(date -r $start_time) echo $start_time echo $log echo $start sleep 10 stop_time=$(date +%s) stop=$(date -r $stop_time) echo $stop_time echo $stop Same output for both\n1692292771 20230817-171931 Thu Aug 17 05:19:31 PM UTC 2023 1692292781 Thu Aug 17 05:19:41 PM UTC 2023 ","permalink":"http://uly.me/posts/mac-vs-linux-date/","summary":"\u003cp\u003eConverting Mac and Linux Dates\u003c/p\u003e\n\u003cp\u003eLinux\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nstart_time=$(date +%s)\nlog=$(date -d @$start_time +%Y%m%d-%H%M%S) \nstart=$(date -d @$start_time)\necho $start_time\necho $log\necho $start\nsleep 10\nstop_time=$(date +%s)\nstop=$(date -d @$stop_time)\necho $stop_time\necho $stop \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMac\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nstart_time=$(date +%s)\nlog=$(date -r $start_time +%Y%m%d-%H%M%S) \nstart=$(date -r $start_time)\necho $start_time\necho $log\necho $start\nsleep 10\nstop_time=$(date +%s)\nstop=$(date -r $stop_time)\necho $stop_time\necho $stop\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSame output for both\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e1692292771\n20230817-171931\nThu Aug 17 05:19:31 PM UTC 2023\n1692292781\nThu Aug 17 05:19:41 PM UTC 2023\n\u003c/code\u003e\u003c/pre\u003e","title":"mac vs linux date"},{"content":"If your Bash script calls for 3 arguments, here’s how to check it.\nif [ \u0026#34;$#\u0026#34; -ne 3 ] then echo \u0026#34;Usage: ./script.sh project diskname policy\u0026#34; exit fi You can adjust -ne 3 to any number based on the number of required arguments.\n","permalink":"http://uly.me/posts/check-if-multiple-arguments/","summary":"\u003cp\u003eIf your Bash script calls for 3 arguments, here’s how to check it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ \u0026#34;$#\u0026#34; -ne 3 ]\nthen\n  echo \u0026#34;Usage: ./script.sh project diskname policy\u0026#34;\n  exit\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can adjust -ne 3 to any number based on the number of required arguments.\u003c/p\u003e","title":"check if multiple arguments"},{"content":"When displaying in a time format, it’s best to display numbers below 10 with leading zeros.\nHere’s a nice function you can call to covert numbers below 10.\nconvert () { # print the number as a string with a leading zero number=$(printf \u0026#39;%02d\\n\u0026#39; \u0026#34;$1\u0026#34;) echo $number } convert 5 Result\n05 ","permalink":"http://uly.me/posts/leading-zeros-for-numbers-below-10/","summary":"\u003cp\u003eWhen displaying in a time format, it’s best to display numbers below 10 with leading zeros.\u003c/p\u003e\n\u003cp\u003eHere’s a nice function you can call to covert numbers below 10.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003econvert ()\n{\n    # print the number as a string with a leading zero\n    number=$(printf \u0026#39;%02d\\n\u0026#39; \u0026#34;$1\u0026#34;)\n    echo $number\n}\nconvert 5\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e05\n\u003c/code\u003e\u003c/pre\u003e","title":"leading zeros for numbers below 10"},{"content":"If you want to create dummy files, there’s a faster command than ‘dd’ called ‘fallocate.’\nCreate a 30GB called temp_30GB_file.\nfallocate -l 30G temp_30GB_file Unlike dd which can take minutes depending on file size, fallocate is instantaneous.\n","permalink":"http://uly.me/posts/fallocate/","summary":"\u003cp\u003eIf you want to create dummy files, there’s a faster command than ‘dd’ called ‘fallocate.’\u003c/p\u003e\n\u003cp\u003eCreate a 30GB called temp_30GB_file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efallocate -l 30G temp_30GB_file\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUnlike dd which can take minutes depending on file size, fallocate is instantaneous.\u003c/p\u003e","title":"fallocate"},{"content":"Just a few things about Bash variables.\nEvery variable in Bash is global and are accessible anywhere in the script.\nThey can be used in a function, loop, or conditional statement within the script.\n# setting a variable a = \u0026#34;hello\u0026#34; # printing a variable echo $a # using a variable inside a function hello_function () { echo $a } # passing a variable to a function hello_function $a ","permalink":"http://uly.me/posts/bash-global-variables/","summary":"\u003cp\u003eJust a few things about Bash variables.\u003c/p\u003e\n\u003cp\u003eEvery variable in Bash is global and are accessible anywhere in the script.\u003c/p\u003e\n\u003cp\u003eThey can be used in a function, loop, or conditional statement within the script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# setting a variable\na = \u0026#34;hello\u0026#34;\n# printing a variable\necho $a\n# using a variable inside a function\nhello_function () {\n  echo $a\n}\n# passing a variable to a function\nhello_function $a \n\u003c/code\u003e\u003c/pre\u003e","title":"bash global variables"},{"content":"Another time saving command if you want to clear the entire line on a terminal is Ctrl+K.\nCtrl+K ","permalink":"http://uly.me/posts/clear-the-line/","summary":"\u003cp\u003eAnother time saving command if you want to clear the entire line on a terminal is Ctrl+K.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCtrl+K\n\u003c/code\u003e\u003c/pre\u003e","title":"clear the line"},{"content":"If a command is too long, you can move your cursor to the beginning or the end of the line.\nMove to start of the line.\nctrl+A Move to end of the line.\nctrl+E ","permalink":"http://uly.me/posts/move-to-start-or-end-of-line/","summary":"\u003cp\u003eIf a command is too long, you can move your cursor to the beginning or the end of the line.\u003c/p\u003e\n\u003cp\u003eMove to start of the line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ectrl+A\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMove to end of the line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ectrl+E\n\u003c/code\u003e\u003c/pre\u003e","title":"move to start or end of line"},{"content":"How to merge several PDFs into one file.\nInstall\napt install poppler-utils Merging PDF files\npdfunite one.pdf two.pdf three.pdf output.pdf ","permalink":"http://uly.me/posts/pdfunite/","summary":"\u003cp\u003eHow to merge several PDFs into one file.\u003c/p\u003e\n\u003cp\u003eInstall\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install poppler-utils\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMerging PDF files\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epdfunite one.pdf two.pdf three.pdf output.pdf\n\u003c/code\u003e\u003c/pre\u003e","title":"pdfunite"},{"content":"Here’s how to display GCP VM labels.\nDisplay all labels.\ngcloud compute instances describe VM --zone ZONE --project PROJECT_ID --format=\u0026#34;value(labels)\u0026#34; Display a specific label.\ngcloud compute instances describe VM --zone ZONE --project PROJECT_ID --format=\u0026#34;value(labels.key)\u0026#34; ","permalink":"http://uly.me/posts/gcp-vm-display-label/","summary":"\u003cp\u003eHere’s how to display GCP VM labels.\u003c/p\u003e\n\u003cp\u003eDisplay all labels.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances describe VM --zone ZONE --project PROJECT_ID --format=\u0026#34;value(labels)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay a specific label.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances describe VM --zone ZONE --project PROJECT_ID --format=\u0026#34;value(labels.key)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp vm display label"},{"content":"Here’s how to run Debian on a Docker container.\ndocker pull debian docker run -it debian /bin/bash ","permalink":"http://uly.me/posts/run-debian-on-docker-container/","summary":"\u003cp\u003eHere’s how to run Debian on a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker pull debian\ndocker run -it debian /bin/bash\n\u003c/code\u003e\u003c/pre\u003e","title":"run debian on docker container"},{"content":"Here’s how to add labels to snapshots. It will cycle through from a list of disks.\n#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log=\u0026#34;add-labels-logs-$ts\u0026#34; \u0026gt;$log disks=\u0026#39;manual-disks.txt\u0026#39; now=$(date +%s) epoch=$(date +%s -d \u0026#34;+14 days\u0026#34;) while read -r project snapshot; do echo \u0026#34;Project: $project\u0026#34; gcloud compute snapshots add-labels $snapshot --labels=delete-after=$epoch --project $project done ","permalink":"http://uly.me/posts/gcp-adding-labels-to-snapshots/","summary":"\u003cp\u003eHere’s how to add labels to snapshots. It will cycle through from a list of disks.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nts=$(date +%Y%m%d-%H%M%S)\nlog=\u0026#34;add-labels-logs-$ts\u0026#34;\n\u0026gt;$log\ndisks=\u0026#39;manual-disks.txt\u0026#39;\nnow=$(date +%s)\nepoch=$(date +%s -d \u0026#34;+14 days\u0026#34;)\nwhile read -r project snapshot; do\n   echo \u0026#34;Project: $project\u0026#34;\n   gcloud compute snapshots add-labels $snapshot --labels=delete-after=$epoch --project $project\ndone \n\u003c/code\u003e\u003c/pre\u003e","title":"gcp adding labels to snapshots"},{"content":"Here’s an example of how to restore all the disks of a GCP VM from snapshots.\n#!/bin/bash # Set variables PROJECT_ID=\u0026#34;your-project-id\u0026#34; INSTANCE_NAME=\u0026#34;your-instance-name\u0026#34; # Get list of disks attached to the instance DISKS=$(gcloud compute instances describe ${INSTANCE_NAME} \\ --project ${PROJECT_ID} \\ --format=\u0026#34;value(disks.deviceName)\u0026#34;) # Loop through each disk and restore from most recent snapshot for DISK in $DISKS do # Get most recent snapshot for the disk SNAPSHOT=$(gcloud compute snapshots list \\ --project ${PROJECT_ID} \\ --filter=\u0026#34;sourceDisk=${INSTANCE_NAME}/${DISK} AND status=READY\u0026#34; \\ --sort-by=\u0026#34;~creationTimestamp\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34; | head -n 1) # Restore the disk from the snapshot gcloud compute disks create ${DISK} \\ --project ${PROJECT_ID} \\ --source-snapshot ${SNAPSHOT} \\ --zone=us-central1-a \\ --labels restored-from=${SNAPSHOT} # Attach the disk to the instance gcloud compute instances attach-disk ${INSTANCE_NAME} \\ --disk=${DISK} \\ --project ${PROJECT_ID} \\ --zone=us-central1-a done ","permalink":"http://uly.me/posts/restore-all-disks-of-a-gcp-vm/","summary":"\u003cp\u003eHere’s an example of how to restore all the disks of a GCP VM from snapshots.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# Set variables\nPROJECT_ID=\u0026#34;your-project-id\u0026#34;\nINSTANCE_NAME=\u0026#34;your-instance-name\u0026#34;\n\n# Get list of disks attached to the instance\nDISKS=$(gcloud compute instances describe ${INSTANCE_NAME} \\\n--project ${PROJECT_ID} \\\n--format=\u0026#34;value(disks.deviceName)\u0026#34;)\n\n# Loop through each disk and restore from most recent snapshot\nfor DISK in $DISKS\ndo\n  # Get most recent snapshot for the disk\n  SNAPSHOT=$(gcloud compute snapshots list \\\n  --project ${PROJECT_ID} \\\n  --filter=\u0026#34;sourceDisk=${INSTANCE_NAME}/${DISK} AND status=READY\u0026#34; \\\n  --sort-by=\u0026#34;~creationTimestamp\u0026#34; \\\n  --format=\u0026#34;value(name)\u0026#34; | head -n 1)\n\n  # Restore the disk from the snapshot\n  gcloud compute disks create ${DISK} \\\n  --project ${PROJECT_ID} \\\n  --source-snapshot ${SNAPSHOT} \\\n  --zone=us-central1-a \\\n  --labels restored-from=${SNAPSHOT}\n\n  # Attach the disk to the instance\n  gcloud compute instances attach-disk ${INSTANCE_NAME} \\\n  --disk=${DISK} \\\n  --project ${PROJECT_ID} \\\n  --zone=us-central1-a\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"restore all disks of a gcp vm"},{"content":"Here’s how to read a file line by line with multiple columns.\nwith open(\u0026#39;file.txt\u0026#39;) as file: for line in file: line = line.strip() columns = line.split() col1 = columns[0] col2 = columns[1] some_function(col1, col2) ","permalink":"http://uly.me/posts/python-read-file-multiple-columns/","summary":"\u003cp\u003eHere’s how to read a file line by line with multiple columns.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewith open(\u0026#39;file.txt\u0026#39;) as file:\n    for line in file:\n        line = line.strip()\n        columns = line.split()\n        col1 = columns[0]\n        col2 = columns[1]\n        some_function(col1, col2) \n\u003c/code\u003e\u003c/pre\u003e","title":"python read file multiple columns"},{"content":"The sed utility on a Mac OS running Z shell or zsh is a little different compared to gnu’s sed.\nInstall gnu sed on Mac OS.\nbrew install gnu-sed Use gsed instead of sed.\ngsed --version ","permalink":"http://uly.me/posts/gsed/","summary":"\u003cp\u003eThe sed utility on a Mac OS running Z shell or zsh is a little different compared to gnu’s sed.\u003c/p\u003e\n\u003cp\u003eInstall gnu sed on Mac OS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebrew install gnu-sed\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUse gsed instead of sed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsed --version\n\u003c/code\u003e\u003c/pre\u003e","title":"gsed"},{"content":"Here’s the Terraform code that creates an AWS IAM policy and attaches it to an existing role (ROLENAME).\n# CREDENTIALS provider \u0026#34;aws\u0026#34; { shared_credentials_files = [\u0026#34;~/.aws/credentials\u0026#34;] shared_config_files = [\u0026#34;~/.aws/config\u0026#34;] profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } # CREATE POLICY resource \u0026#34;aws_iam_policy\u0026#34; \u0026#34;s3-policy\u0026#34; { name = \u0026#34;s3-policy\u0026#34; description = \u0026#34;Allow role to write to bucket\u0026#34; policy = \u0026#34;${file(\u0026#34;policy.json\u0026#34;)}\u0026#34; } # ATTACH POLICY TO ROLE resource \u0026#34;aws_iam_role_policy_attachment\u0026#34; \u0026#34;s3-policy-attachment\u0026#34; { role = \u0026#34;ROLENAME\u0026#34; policy_arn = aws_iam_policy.s3-policy.arn } Here’s the policy.json file.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;VisualEditor0\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;s3:PutObject\u0026#34;, \u0026#34;s3:PutObjectAcl\u0026#34;, \u0026#34;s3:ListBucket\u0026#34;, \u0026#34;s3:GetBucketLocation\u0026#34;, \u0026#34;s3:GetObject\u0026#34;, \u0026#34;s3:GetObjectAcl\u0026#34;, \u0026#34;s3:DeleteObject\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::your-bucket/*\u0026#34; } } ] } ","permalink":"http://uly.me/posts/aws-terraform-create-policy-and-attach/","summary":"\u003cp\u003eHere’s the Terraform code that creates an AWS IAM policy and attaches it to an existing role (ROLENAME).\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# CREDENTIALS\nprovider \u0026#34;aws\u0026#34; {\n  shared_credentials_files = [\u0026#34;~/.aws/credentials\u0026#34;]\n  shared_config_files      = [\u0026#34;~/.aws/config\u0026#34;]\n  profile                  = \u0026#34;default\u0026#34;\n  region                   = \u0026#34;us-east-1\u0026#34;\n}\n# CREATE POLICY\nresource \u0026#34;aws_iam_policy\u0026#34; \u0026#34;s3-policy\u0026#34; {\n    name        = \u0026#34;s3-policy\u0026#34;\n    description = \u0026#34;Allow role to write to bucket\u0026#34;\n    policy = \u0026#34;${file(\u0026#34;policy.json\u0026#34;)}\u0026#34;\n}\n# ATTACH POLICY TO ROLE\nresource \u0026#34;aws_iam_role_policy_attachment\u0026#34; \u0026#34;s3-policy-attachment\u0026#34; {\n  role       = \u0026#34;ROLENAME\u0026#34;\n  policy_arn = aws_iam_policy.s3-policy.arn\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the policy.json file.\u003c/p\u003e","title":"aws terraform create policy and attach"},{"content":"Here’s the command to add labels to a snapshot.\ngcloud compute snapshots add-labels SNAPSHOTNAME --labels=KEY=VALUE --project PROJECT ","permalink":"http://uly.me/posts/gcp-add-labels-to-snapshots/","summary":"\u003cp\u003eHere’s the command to add labels to a snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute snapshots add-labels SNAPSHOTNAME --labels=KEY=VALUE --project PROJECT\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp add labels to snapshots"},{"content":"Here’s a handy little script that has multiple applications to calculate date from a year ago.\n#!/bin/bash now=$(date +%Y%m%d-%H%M%S) # mac os year_old=$(date -v-1y +%Y%m%d-%H%M%S) # linux os year_old=$(date -d \u0026#34;-1 year\u0026#34; +%Y%m%d-%H%M%S) echo $now echo $year_old Mac Os and Linux has slightly different formats. Pick one based on your OS.\nResults\n20230618-084940 20220618-084940 ","permalink":"http://uly.me/posts/date-from-a-year-ago/","summary":"\u003cp\u003eHere’s a handy little script that has multiple applications to calculate date from a year ago.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nnow=$(date +%Y%m%d-%H%M%S)\n# mac os\nyear_old=$(date -v-1y +%Y%m%d-%H%M%S) \n# linux os \nyear_old=$(date -d \u0026#34;-1 year\u0026#34; +%Y%m%d-%H%M%S)\necho $now\necho $year_old\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMac Os and Linux has slightly different formats. Pick one based on your OS.\u003c/p\u003e\n\u003cp\u003eResults\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e20230618-084940\n20220618-084940\n\u003c/code\u003e\u003c/pre\u003e","title":"date from a year ago"},{"content":"Here’s how to list snapshots older than a certain date. In this example, it’s snapshots older than 2023-12-14.\ngcloud compute snapshots list --project $project --filter=\u0026#34;creationTimestamp \u0026lt; 2023-12-14\u0026#34; --format=\u0026#34;get(name,creationTimestamp)\u0026#34; ","permalink":"http://uly.me/posts/gcp-list-snapshots-older-than/","summary":"\u003cp\u003eHere’s how to list snapshots older than a certain date. In this example, it’s snapshots older than 2023-12-14.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute snapshots list --project $project --filter=\u0026#34;creationTimestamp \u0026lt; 2023-12-14\u0026#34; --format=\u0026#34;get(name,creationTimestamp)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list snapshots older than"},{"content":"Here’s how to make a hostname stick on Amazon Linux.\nSet preserve_hostname to true in /etc/cloud/cloud.cfg.\npreserve_hostname: true Set the hostname in /etc/sysconfig/network.\nHOSTNAME=server.domain.com NETWORKING=yes NOZEROCONF=yes Reboot the server to make sure hostname sticks after a reboot.\nshutdown -r now Login to confirm hostname sticks.\n","permalink":"http://uly.me/posts/change-hostname-amazon-linux/","summary":"\u003cp\u003eHere’s how to make a hostname stick on Amazon Linux.\u003c/p\u003e\n\u003cp\u003eSet preserve_hostname to true in /etc/cloud/cloud.cfg.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epreserve_hostname: true\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSet the hostname in /etc/sysconfig/network.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eHOSTNAME=server.domain.com\nNETWORKING=yes\nNOZEROCONF=yes\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot the server to make sure hostname sticks after a reboot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eshutdown -r now\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin to confirm hostname sticks.\u003c/p\u003e","title":"change hostname amazon linux"},{"content":"Here’s how to change a VM’s service account in GCP\n#!/bin/bash read -p \u0026#34;project : \u0026#34; project read -p \u0026#34;instance : \u0026#34; instance read -p \u0026#34;srvAcct email : \u0026#34; serviceaccount # stop instance gcloud compute instances stop $instance --project $project # change service account gcloud compute instances set-service-account $instance --service-account $serviceaccount --scopes cloud-platform --project $project # start instance gcloud compute instances start $instance --project $project ","permalink":"http://uly.me/posts/gcp-change-vm-service-account/","summary":"\u003cp\u003eHere’s how to change a VM’s service account in GCP\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nread -p \u0026#34;project       : \u0026#34; project\nread -p \u0026#34;instance      : \u0026#34; instance\nread -p \u0026#34;srvAcct email : \u0026#34; serviceaccount\n# stop instance\ngcloud compute instances stop $instance --project $project \n# change service account\ngcloud compute instances set-service-account $instance --service-account $serviceaccount --scopes cloud-platform --project $project \n# start instance \ngcloud compute instances start $instance --project $project\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp change vm service account"},{"content":"Here’s how to list GCP’s manual snapshots. projectIds.txt contains a list of projects.\n#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log=\u0026#34;manual-snapshots-logs-$ts\u0026#34; \u0026gt;$log while read -r project; do snapshots=$(gcloud compute snapshots list \\ --project $project \\ --filter=\u0026#34;sourceSnapshotSchedulePolicy!=\u0026#39;\u0026#39;\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34;) for snapshot in $snapshots do printf \u0026#34;%-30s %-30s \\n\u0026#34; \u0026#34;$project\u0026#34; \u0026#34;$snapshot\u0026#34; | tee -a $log done done \u0026gt; projectIds.txt Another option.\n#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log=\u0026#34;manual-snapshots-logs-$ts\u0026#34; \u0026gt;$log while read -r project; do snapshots=$(gcloud compute snapshots list \\ --project $project \\ --filter=\u0026#34;-sourceSnapshotSchedulePolicy:*\u0026#34; \\ --format=\u0026#34;value(name)\u0026#34;) for snapshot in $snapshots do printf \u0026#34;%-30s %-30s \\n\u0026#34; \u0026#34;$project\u0026#34; \u0026#34;$snapshot\u0026#34; | tee -a $log done done \u0026gt; projectIds.txt ","permalink":"http://uly.me/posts/gcp-manual-snapshots/","summary":"\u003cp\u003eHere’s how to list GCP’s manual snapshots. projectIds.txt contains a list of projects.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nts=$(date +%Y%m%d-%H%M%S)\nlog=\u0026#34;manual-snapshots-logs-$ts\u0026#34;\n\u0026gt;$log\nwhile read -r project; do\n    snapshots=$(gcloud compute snapshots list \\\n                --project $project \\\n                --filter=\u0026#34;sourceSnapshotSchedulePolicy!=\u0026#39;\u0026#39;\u0026#34; \\\n                --format=\u0026#34;value(name)\u0026#34;)\n    for snapshot in $snapshots\n    do\n        printf \u0026#34;%-30s %-30s \\n\u0026#34; \u0026#34;$project\u0026#34; \u0026#34;$snapshot\u0026#34;  | tee -a $log\n    done\ndone \u0026gt; projectIds.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnother option.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nts=$(date +%Y%m%d-%H%M%S)\nlog=\u0026#34;manual-snapshots-logs-$ts\u0026#34;\n\u0026gt;$log\nwhile read -r project; do\n    snapshots=$(gcloud compute snapshots list \\\n                --project $project \\\n                --filter=\u0026#34;-sourceSnapshotSchedulePolicy:*\u0026#34; \\\n                --format=\u0026#34;value(name)\u0026#34;)\n    for snapshot in $snapshots\n    do\n        printf \u0026#34;%-30s %-30s \\n\u0026#34; \u0026#34;$project\u0026#34; \u0026#34;$snapshot\u0026#34;  | tee -a $log\n    done\ndone \u0026gt; projectIds.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp manual snapshots"},{"content":"Here’s how to list GCP Scheduled Snapshots older than 14 days. projectIds.txt contains a list of projects.\n#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) old=$(date -v -14d +%Y-%m-%dT%H:%M:%S) log=\u0026#34;scheduled-snapshots-logs-$ts\u0026#34; \u0026gt;$log while read -r project; do snapshots=$(gcloud compute snapshots list \\ --project $project \\ --format=\u0026#34;value(name)\u0026#34; \\ --filter=\u0026#34;creationTimestamp ","permalink":"http://uly.me/posts/gcp-old-scheduled-snapshots/","summary":"\u003cp\u003eHere’s how to list GCP Scheduled Snapshots older than 14 days. projectIds.txt contains a list of projects.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nts=$(date +%Y%m%d-%H%M%S)\nold=$(date -v -14d +%Y-%m-%dT%H:%M:%S)\nlog=\u0026#34;scheduled-snapshots-logs-$ts\u0026#34;\n\u0026gt;$log\nwhile read -r project; do\n    snapshots=$(gcloud compute snapshots list \\\n                --project $project \\\n                --format=\u0026#34;value(name)\u0026#34; \\\n                --filter=\u0026#34;creationTimestamp\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp old scheduled snapshots"},{"content":"How to add Snapshot Schedules to disks in Terraform. Add this to your existing VM.\nresource \u0026#34;google_compute_disk_resource_policy_attachment\u0026#34; \u0026#34;hourly_attachment\u0026#34; { name = \u0026#34;hourly-snapshots\u0026#34; disk = google_compute_instance.test.name zone = \u0026#34;us-central1-c\u0026#34; } resource \u0026#34;google_compute_disk_resource_policy_attachment\u0026#34; \u0026#34;daily_attachment\u0026#34; { name = \u0026#34;daily-snapshots\u0026#34; disk = google_compute_instance.test.name zone = \u0026#34;us-central1-c\u0026#34; } ","permalink":"http://uly.me/posts/add-snapshot-schedules-to-disks/","summary":"\u003cp\u003eHow to add Snapshot Schedules to disks in Terraform. Add this to your existing VM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eresource \u0026#34;google_compute_disk_resource_policy_attachment\u0026#34; \u0026#34;hourly_attachment\u0026#34; {\n  name = \u0026#34;hourly-snapshots\u0026#34;\n  disk = google_compute_instance.test.name\n  zone = \u0026#34;us-central1-c\u0026#34;\n}\n\nresource \u0026#34;google_compute_disk_resource_policy_attachment\u0026#34; \u0026#34;daily_attachment\u0026#34; {\n  name = \u0026#34;daily-snapshots\u0026#34;\n  disk = google_compute_instance.test.name\n  zone = \u0026#34;us-central1-c\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"add snapshot schedules to disks"},{"content":"How to enable unbound logs.\nAdd these line in /etc/unbound/unbound.conf.\nchroot: \u0026#34;\u0026#34; logfile: /var/log/unbound.log verbosity: 4 log-queries: yes Create the log file and set permissions.\ntouch /var/log/unbound.log chown unbound:unbound /var/log/unbound.log Restart the unbound service.\nsystemctl restart unbound Check status.\nsystemctl status unbound Finally, check the logs.\ntail -f /var/log/unbound.log ","permalink":"http://uly.me/posts/unbound-logs/","summary":"\u003cp\u003eHow to enable unbound logs.\u003c/p\u003e\n\u003cp\u003eAdd these line in /etc/unbound/unbound.conf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echroot: \u0026#34;\u0026#34;\nlogfile: /var/log/unbound.log\nverbosity: 4\nlog-queries: yes\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate the log file and set permissions.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etouch /var/log/unbound.log\nchown unbound:unbound /var/log/unbound.log\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart the unbound service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart unbound\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck status.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl status unbound\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally, check the logs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etail -f /var/log/unbound.log\n\u003c/code\u003e\u003c/pre\u003e","title":"unbound logs"},{"content":"If you want to run a script every 11 months, here’s the crontab entry.\n* * 1 */11 * /bin/bash /path/to/script.sh ","permalink":"http://uly.me/posts/crontab-every-11-months/","summary":"\u003cp\u003eIf you want to run a script every 11 months, here’s the crontab entry.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e* * 1 */11 * /bin/bash /path/to/script.sh \n\u003c/code\u003e\u003c/pre\u003e","title":"crontab every 11 months"},{"content":"Replace spaces with commas from one file and send the output to another file.\ntr -s \u0026#39;[:blank:]\u0026#39; \u0026#39;, \u0026#39; output.txt It’s perfect for creating a comma delimited file for importing to Excel.\n","permalink":"http://uly.me/posts/bash-replace-spaces-with-a-comma/","summary":"\u003cp\u003eReplace spaces with commas from one file and send the output to another file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etr -s \u0026#39;[:blank:]\u0026#39; \u0026#39;, \u0026#39;  output.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s perfect for creating a comma delimited file for importing to Excel.\u003c/p\u003e","title":"bash replace spaces with a comma"},{"content":"Here’s how to reduce a MP4 video using H.265 format.\nffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 I was able to reduce a video file from 550MB to 26MB without much quality loss.\n","permalink":"http://uly.me/posts/ffmpeg-resize-video/","summary":"\u003cp\u003eHere’s how to reduce a MP4 video using H.265 format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI was able to reduce a video file from 550MB to 26MB without much quality loss.\u003c/p\u003e","title":"ffmpeg resize video"},{"content":"How to sort files in Bash.\nDisplay contents\n$ cat file.txt bbb aaa ccc kkk uuu ppp Sort\n$ sort file.txt aaa bbb ccc kkk ppp uuu Sort in place\n$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu ","permalink":"http://uly.me/posts/bash-sort-files/","summary":"\u003cp\u003eHow to sort files in Bash.\u003c/p\u003e\n\u003cp\u003eDisplay contents\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat file.txt\nbbb\naaa\nccc\nkkk\nuuu\nppp\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSort\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sort file.txt\naaa\nbbb\nccc\nkkk\nppp\nuuu\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSort in place\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sort -o file.txt file.txt\n$ cat file.txt\naaa\nbbb\nccc\nkkk\nppp\nuuu\n\u003c/code\u003e\u003c/pre\u003e","title":"bash sort files"},{"content":"This will display only lines 40-50 in a file called lines.txt.\n$ cat lines.txt | head -n 50 | tail -n 10 For lines 90-100.\n$ cat lines.txt | head -n 100 | tail -n 10 and so on.\n","permalink":"http://uly.me/posts/display-certain-lines-in-a-file/","summary":"\u003cp\u003eThis will display only lines 40-50 in a file called lines.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat lines.txt | head -n 50 | tail -n 10\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor lines 90-100.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat lines.txt | head -n 100 | tail -n 10\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eand so on.\u003c/p\u003e","title":"display certain lines in a file"},{"content":"Here’s how to view system memory on Linux.\nDefault display is in kB\ncat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB Display in MB\nawk \u0026#39;$3==\u0026#34;kB\u0026#34;{$2=$2/1024;$3=\u0026#34;MB\u0026#34;} 1\u0026#39; /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB Output in GB\nawk \u0026#39;$3==\u0026#34;kB\u0026#34;{$2=$2/1024^2;$3=\u0026#34;GB\u0026#34;;} 1\u0026#39; /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB ","permalink":"http://uly.me/posts/memory-info-on-linux/","summary":"\u003cp\u003eHere’s how to view system memory on Linux.\u003c/p\u003e\n\u003cp\u003eDefault display is in kB\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat /proc/meminfo\nMemTotal:        7492768 kB\nMemFree:          427368 kB\nMemAvailable:    5424768 kB\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay in MB\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eawk \u0026#39;$3==\u0026#34;kB\u0026#34;{$2=$2/1024;$3=\u0026#34;MB\u0026#34;} 1\u0026#39; /proc/meminfo | column -t\nMemTotal:           7317.16      MB\nMemFree:            404.527      MB\nMemAvailable:       5285.4       MB\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput in GB\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eawk \u0026#39;$3==\u0026#34;kB\u0026#34;{$2=$2/1024^2;$3=\u0026#34;GB\u0026#34;;} 1\u0026#39; /proc/meminfo | column -t\nMemTotal:           7.14566      GB\nMemFree:            0.370392     GB\nMemAvailable:       5.13733      GB\n\u003c/code\u003e\u003c/pre\u003e","title":"memory info on linux"},{"content":"Key-based SSH login is prompting a password despite it’s already setup to use keys. As turns out, the home directory was changed to 777. To fix, I changed home folder permissions and restarted SSH. It probably does not need a restart, but it doesn’t hurt.\nchown -R username:username /home/username find /home/username -type d -exec chmod 755 {} \\; find /home/username -type f -exec chmod 644 {} \\; sudo systemctl restart ssh ","permalink":"http://uly.me/posts/key-based-ssh-prompting-password/","summary":"\u003cp\u003eKey-based SSH login is prompting a password despite it’s already setup to use keys. As turns out, the home directory was changed to 777. To fix, I changed home folder permissions and restarted SSH. It probably does not need a restart, but it doesn’t hurt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echown -R username:username /home/username\nfind /home/username -type d -exec chmod 755 {} \\;\nfind /home/username -type f -exec chmod 644 {} \\;\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo systemctl restart ssh\n\u003c/code\u003e\u003c/pre\u003e","title":"key-based ssh prompting password"},{"content":"How to lock a package or software in RedHat.\n# For RHEL 5 yum install yum-versionlock # For RHEL 6 and 7 yum install yum-plugin-versionlock # For RHEL 8 and 9 yum install python3-dnf-plugin-versionlock Locking a package\nyum versionlock gcc-* List locked packages\nyum versionlock list ","permalink":"http://uly.me/posts/yum-version-lock/","summary":"\u003cp\u003eHow to lock a package or software in RedHat.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# For RHEL 5\nyum install yum-versionlock\n# For RHEL 6 and 7\nyum install yum-plugin-versionlock\n# For RHEL 8 and 9\nyum install python3-dnf-plugin-versionlock\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLocking a package\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum versionlock gcc-*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList locked packages\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum versionlock list\n\u003c/code\u003e\u003c/pre\u003e","title":"yum version lock"},{"content":"Here’s how to restore or set the Bash prompt on RHEL systems.\necho \u0026#34;PS1=\u0026#39;\\u@\\h \\w]\\$\u0026#39;\u0026#34; \u0026gt;\u0026gt; ~/.bashrc source ~/.bashrc ","permalink":"http://uly.me/posts/missing-rhel-prompt-on-bash/","summary":"\u003cp\u003eHere’s how to restore or set the Bash prompt on RHEL systems.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#34;PS1=\u0026#39;\\u@\\h \\w]\\$\u0026#39;\u0026#34; \u0026gt;\u0026gt; ~/.bashrc\nsource ~/.bashrc\n\u003c/code\u003e\u003c/pre\u003e","title":"missing rhel prompt on bash"},{"content":"Here’s how to get health status of a GCP Load Balancer Backend Services.\nFor all load balancers except target pool.\ngcloud compute backend-services get-health BACKEND_SERVICE_NAME \\ --region us-central1 \\ --project project-id For target pool load balancers, use this command.\ngcloud compute target-pools get-health TARGET_POOL_NAME \\ --region us-central1 \\ --project project-id ","permalink":"http://uly.me/posts/gcp-backend-services-health-status/","summary":"\u003cp\u003eHere’s how to get health status of a GCP Load Balancer Backend Services.\u003c/p\u003e\n\u003cp\u003eFor all load balancers except target pool.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute backend-services get-health BACKEND_SERVICE_NAME \\\n--region us-central1 \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor target pool load balancers, use this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute target-pools get-health TARGET_POOL_NAME \\\n--region us-central1 \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp backend services health status"},{"content":"Here’s how to enable performance insights on a RDS instance.\nEnable\naws rds modify-db-instance \\ --db-instance-identifier sample-db-instance \\ --enable-performance-insights \\ --region us-east-1 \\ --profile default Disable\naws rds modify-db-instance \\ --db-instance-identifier sample-db-instance \\ --no-enable-performance-insights \\ --region us-east-1 \\ --profile default ","permalink":"http://uly.me/posts/aws-rds-enable-performance-insights/","summary":"\u003cp\u003eHere’s how to enable performance insights on a RDS instance.\u003c/p\u003e\n\u003cp\u003eEnable\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws rds modify-db-instance \\\n--db-instance-identifier sample-db-instance \\\n--enable-performance-insights \\\n--region us-east-1 \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws rds modify-db-instance \\\n--db-instance-identifier sample-db-instance \\\n--no-enable-performance-insights \\\n--region us-east-1 \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e","title":"aws rds enable performance insights"},{"content":"Here’s how to list the luns for a particular volume.\ngcloud bms volumes luns list --project project-id --region us-central1 --volume at-xxxxxxx-volxxx ","permalink":"http://uly.me/posts/gcp-bms-list-luns-in-volume/","summary":"\u003cp\u003eHere’s how to list the luns for a particular volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud bms volumes luns list --project project-id --region us-central1 --volume at-xxxxxxx-volxxx\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp bms list luns in volume"},{"content":"Here’s how to describe a Bare Metal Server (BMS). The output display storage LUNS and network information.\ngcloud bms instances describe INSTANCE --project PROJECT-ID --region us-central1 ","permalink":"http://uly.me/posts/gcp-bms-describe-instances/","summary":"\u003cp\u003eHere’s how to describe a Bare Metal Server (BMS). The output display storage LUNS and network information.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud bms instances describe INSTANCE --project PROJECT-ID --region us-central1\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp bms describe instances"},{"content":"Here’s how to describe a Bare Metal Server (BMS) volume within a project.\ngcloud bms volumes describe at-xxxxxxx-vol001-data --project project_id --region us-central1 ","permalink":"http://uly.me/posts/gcp-bms-describe-volume/","summary":"\u003cp\u003eHere’s how to describe a Bare Metal Server (BMS) volume within a project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud bms volumes describe at-xxxxxxx-vol001-data --project project_id --region us-central1\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp bms describe volume"},{"content":"Here’s how to list all your Bare Metal Servers (BMS) volumes within a project.\ngcloud bms volumes list --project PROJECT_ID --region us-central1 ","permalink":"http://uly.me/posts/gcp-bms-list-volumes/","summary":"\u003cp\u003eHere’s how to list all your Bare Metal Servers (BMS) volumes within a project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud bms volumes list --project PROJECT_ID --region us-central1\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp bms list volumes"},{"content":"Checking for new kernel on multiple distros.\nRedhat, Centos, Fedora, Rocky\nrpm -qa kernel yum list installed kernel Arch Linux\npacman -Q | grep linux Fedora\ndnf list installed kernel SUSE\nrpm -qa | grep -i kernel zypper search -i kernel Debian, Ubuntu, Mint\ndpkg --list | grep linux-image ","permalink":"http://uly.me/posts/check-for-new-kernel/","summary":"\u003cp\u003eChecking for new kernel on multiple distros.\u003c/p\u003e\n\u003cp\u003eRedhat, Centos, Fedora, Rocky\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa kernel\nyum list installed kernel\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eArch Linux\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epacman -Q | grep linux\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFedora\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ednf list installed kernel\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSUSE\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa | grep -i kernel\nzypper search -i kernel\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDebian, Ubuntu, Mint\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edpkg --list | grep linux-image\n\u003c/code\u003e\u003c/pre\u003e","title":"check for new kernel"},{"content":"Here’s a script to list Auto Scaling Groups from multiple AWS accounts. Accounts are in your AWS profiles.\n#!/bin/bash file=\u0026#39;results-aws-asg.txt\u0026#39; \u0026gt; $file declare -a account=(\u0026#34;default\u0026#34; \u0026#34;account-1\u0026#34; \u0026#34;account-2\u0026#34; \u0026#34;account-3\u0026#34; \u0026#34;account-4\u0026#34; \u0026#34;account-5\u0026#34;) declare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;) for i in \u0026#34;${account[@]}\u0026#34; do echo \u0026#39;----------------------\u0026#39; \u0026gt;\u0026gt; $file echo \u0026#39;Account: \u0026#39;$i \u0026gt;\u0026gt; $file for j in \u0026#34;${region[@]}\u0026#34; do echo \u0026#39;Region: \u0026#39;$j \u0026gt;\u0026gt; $file aws autoscaling describe-auto-scaling-groups \\ --query \u0026#34;AutoScalingGroups[].[AutoScalingGroupName,LaunchConfigurationName]\u0026#34; \\ --profile $i \\ --region $j \\ --output text \u0026gt;\u0026gt; $file done done ","permalink":"http://uly.me/posts/aws-list-of-auto-scaling-groups/","summary":"\u003cp\u003eHere’s a script to list Auto Scaling Groups from multiple AWS accounts. Accounts are in your AWS profiles.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfile=\u0026#39;results-aws-asg.txt\u0026#39;\n\u0026gt; $file\ndeclare -a account=(\u0026#34;default\u0026#34; \u0026#34;account-1\u0026#34; \u0026#34;account-2\u0026#34; \u0026#34;account-3\u0026#34; \u0026#34;account-4\u0026#34; \u0026#34;account-5\u0026#34;)\ndeclare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;)\nfor i in \u0026#34;${account[@]}\u0026#34;\ndo\n    echo \u0026#39;----------------------\u0026#39; \u0026gt;\u0026gt; $file\n    echo \u0026#39;Account: \u0026#39;$i \u0026gt;\u0026gt; $file\n    for j in \u0026#34;${region[@]}\u0026#34;\n    do\n        echo \u0026#39;Region: \u0026#39;$j \u0026gt;\u0026gt; $file\n        aws autoscaling describe-auto-scaling-groups \\\n        --query \u0026#34;AutoScalingGroups[].[AutoScalingGroupName,LaunchConfigurationName]\u0026#34; \\\n        --profile $i \\\n        --region $j \\\n        --output text \u0026gt;\u0026gt; $file\n    done\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"aws list of auto scaling groups"},{"content":"Here’s my Bash script to login to both AWS and GCP. It has a little bit of intelligence. It checks if you are already logged in, and skips if you are. If not logged in, it will open up the cloud web console which is protected by Okta. The script has been redacted and replace with generic usernames and web pages for security reasons.\n#!/bin/bash ## CHECK IF LOGGED IN TO GCP read -p \u0026#34;Login to GCP? (y/n) : \u0026#34; login_gcp if [[ $login_gcp = \u0026#34;y\u0026#34; ]]; then file1=\u0026#34;/Users/username/code/etc/auth-gcp.txt\u0026#34; gcloud auth print-identity-token 1\u0026gt; /dev/null 2\u0026gt; $file user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;) auth=$(cat \u0026#34;$file\u0026#34; | head -n 1) rm -f $file1 if [[ $auth == \u0026#34;Reauthentication required.\u0026#34; ]] || [[ $user != \u0026#34;first.last@domain.com\u0026#34; ]]; then echo \u0026#34;Logging in to Google Cloud Platform.\u0026#34; gcloud auth login gcloud auth application-default login open https://okta-login else echo \u0026#34;You are already logged in to Google Cloud Platform.\u0026#34; fi else echo \u0026#34;Skipping GCP ... \u0026#34; fi ## CHECK IF LOGGED IN TO AWS read -p \u0026#34;Login to AWS? (y/n) : \u0026#34; login_aws if [[ $login_aws = \u0026#34;y\u0026#34; ]]; then file2=\u0026#34;\u0026#34;/Users/username/code/etc/auth-aws.txt\u0026#34;\u0026#34; aws sts get-caller-identity 2\u0026gt; $file2 expired=$(tail -n +2 \u0026#34;$file2\u0026#34;) rm -f $file2 if [[ $expired =~ \u0026#34;expired\u0026#34; ]] || [[ $expired =~ \u0026#34;Unable\u0026#34; ]]; then open https://okta-login echo \u0026#34;please wait until web page loads ... \u0026#34; read -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s echo \u0026#34;\u0026#34; basecred=\u0026#39;/Users/username/.aws/credentials.base\u0026#39; newcreds=\u0026#39;/Users/username/Downloads/credentials\u0026#39; creds=\u0026#39;/Users/username/.aws/credentials\u0026#39; if [ ! -f $newcreds ]; then echo \u0026#39;No AWS credentials.\u0026#39; exit else cat $newcreds $basecred \u0026gt; $creds echo \u0026#39;New AWS credentials.\u0026#39; sleep 3 rm -f $newcreds fi else echo \u0026#34;You are already logged in to AWS.\u0026#34; fi else echo \u0026#34;Skipping AWS ... \u0026#34; fi ","permalink":"http://uly.me/posts/logging-in-to-aws-and-gcp/","summary":"\u003cp\u003eHere’s my Bash script to login to both AWS and GCP. It has a little bit of intelligence. It checks if you are already logged in, and skips if you are. If not logged in, it will open up the cloud web console which is protected by Okta. The script has been redacted and replace with generic usernames and web pages for security reasons.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n## CHECK IF LOGGED IN TO GCP \nread -p \u0026#34;Login to GCP? (y/n) : \u0026#34; login_gcp\nif [[ $login_gcp = \u0026#34;y\u0026#34; ]]; then\n  file1=\u0026#34;/Users/username/code/etc/auth-gcp.txt\u0026#34;\n  gcloud auth print-identity-token 1\u0026gt; /dev/null 2\u0026gt; $file\n  user=$(gcloud config list account --format \u0026#34;value(core.account)\u0026#34;)\n  auth=$(cat \u0026#34;$file\u0026#34; | head -n 1)\n  rm -f $file1\n  if [[ $auth == \u0026#34;Reauthentication required.\u0026#34; ]] ||  [[ $user != \u0026#34;first.last@domain.com\u0026#34; ]]; then\n    echo \u0026#34;Logging in to Google Cloud Platform.\u0026#34;\n    gcloud auth login\n    gcloud auth application-default login\n    open https://okta-login\n  else\n    echo \u0026#34;You are already logged in to Google Cloud Platform.\u0026#34;\n  fi\nelse\n  echo \u0026#34;Skipping GCP ... \u0026#34;\nfi\n## CHECK IF LOGGED IN TO AWS\nread -p \u0026#34;Login to AWS? (y/n) : \u0026#34; login_aws\nif [[ $login_aws = \u0026#34;y\u0026#34; ]]; then  \n  file2=\u0026#34;\u0026#34;/Users/username/code/etc/auth-aws.txt\u0026#34;\u0026#34;\n  aws sts get-caller-identity 2\u0026gt; $file2\n  expired=$(tail -n +2 \u0026#34;$file2\u0026#34;)\n  rm -f $file2\n  if [[ $expired =~ \u0026#34;expired\u0026#34; ]] || [[ $expired =~ \u0026#34;Unable\u0026#34; ]]; then\n    open https://okta-login\n    echo \u0026#34;please wait until web page loads ... \u0026#34;\n    read -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s\n    echo \u0026#34;\u0026#34;\n    basecred=\u0026#39;/Users/username/.aws/credentials.base\u0026#39;\n    newcreds=\u0026#39;/Users/username/Downloads/credentials\u0026#39;\n    creds=\u0026#39;/Users/username/.aws/credentials\u0026#39;\n    if [ ! -f $newcreds ]; then\n      echo \u0026#39;No AWS credentials.\u0026#39;\n      exit\n    else\n      cat $newcreds $basecred \u0026gt; $creds\n      echo \u0026#39;New AWS credentials.\u0026#39;\n      sleep 3\n      rm -f $newcreds\n    fi\n  else\n    echo \u0026#34;You are already logged in to AWS.\u0026#34;\n  fi\nelse \n  echo \u0026#34;Skipping AWS ... \u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"logging in to aws and gcp"},{"content":"Here’s another script that creates a volume from a snapshot, but also add the tags.\n#!/bin/bash read -p \u0026#34;server : \u0026#34; server read -p \u0026#34;volumeId : \u0026#34; volume read -p \u0026#34;snapshotId : \u0026#34; snapshot read -p \u0026#34;region : \u0026#34; region read -p \u0026#34;zone : \u0026#34; zone read -p \u0026#34;profile : \u0026#34; profile # get tags tags1=$(aws ec2 describe-volumes --volume-ids $volume --query \u0026#39;Volumes[].Tags[]\u0026#39; --region $region --profile $profile) # remove quotes tags2=$(echo \u0026#34;$tags1\u0026#34; | tr -d \u0026#39;\u0026#34;\u0026#39;) # remove spaces tags3=$(echo $tags2 | sed \u0026#39;s/ //g\u0026#39;) # replace : with = tags4=$(echo $tags3 | sed \u0026#39;s/:/=/g\u0026#39;) # if empty value replace with quotes tags5=$(echo $tags4 | sed \u0026#39;s/Value=}/Value=\u0026#34;\u0026#34;}/g\u0026#39;) # create volume aws ec2 create-volume \\ --availability-zone $zone \\ --encrypted \\ --iops 3000 \\ --volume-type gp3 \\ --snapshot-id $snapshot \\ --tag-specifications \u0026#39;ResourceType=volume,Tags=\u0026#39;$tags5\u0026#39;\u0026#39; \\ --region $region \\ --profile $profile ","permalink":"http://uly.me/posts/aws-create-volume-from-snapshot-with-tags/","summary":"\u003cp\u003eHere’s another script that creates a volume from a snapshot, but also add the tags.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nread -p \u0026#34;server     : \u0026#34; server\nread -p \u0026#34;volumeId   : \u0026#34; volume\nread -p \u0026#34;snapshotId : \u0026#34; snapshot\nread -p \u0026#34;region     : \u0026#34; region\nread -p \u0026#34;zone       : \u0026#34; zone\nread -p \u0026#34;profile    : \u0026#34; profile\n# get tags\ntags1=$(aws ec2 describe-volumes --volume-ids $volume --query \u0026#39;Volumes[].Tags[]\u0026#39; --region $region --profile $profile)\n# remove quotes\ntags2=$(echo \u0026#34;$tags1\u0026#34; | tr -d \u0026#39;\u0026#34;\u0026#39;)\n# remove spaces\ntags3=$(echo $tags2 | sed \u0026#39;s/ //g\u0026#39;)\n# replace : with =\ntags4=$(echo $tags3 | sed \u0026#39;s/:/=/g\u0026#39;)\n# if empty value replace with quotes\ntags5=$(echo $tags4 | sed \u0026#39;s/Value=}/Value=\u0026#34;\u0026#34;}/g\u0026#39;)\n# create volume\naws ec2 create-volume \\\n--availability-zone $zone \\\n--encrypted \\\n--iops 3000 \\\n--volume-type gp3 \\\n--snapshot-id $snapshot \\\n--tag-specifications \u0026#39;ResourceType=volume,Tags=\u0026#39;$tags5\u0026#39;\u0026#39; \\\n--region $region \\\n--profile $profile\n\u003c/code\u003e\u003c/pre\u003e","title":"aws create volume from snapshot with tags"},{"content":"Here’s a bash script that creates a volume from a snapshot in AWS.\n#!/bin/bash read -p \u0026#34;snapshotId : \u0026#34; snapshot read -p \u0026#34;server : \u0026#34; server read -p \u0026#34;tag1 : \u0026#34; tag1 read -p \u0026#34;tag2 : \u0026#34; tag2 read -p \u0026#34;region : \u0026#34; region read -p \u0026#34;zone : \u0026#34; zone read -p \u0026#34;profile : \u0026#34; profile aws ec2 create-volume \\ --availability-zone $zone \\ --encrypted \\ --iops 3000 \\ --volume-type gp3 \\ --snapshot-id $snapshot \\ --tag-specifications \u0026#34;ResourceType=volume,Tags=[{Key=Name,Value=\u0026#34;$server\u0026#34;},{Key=tag1,Value=\u0026#34;$tag1\u0026#34;},{Key=tag2,Value=\u0026#34;$tag2\u0026#34;}]\u0026#34; \\ --region $region \\ --profile $profile ","permalink":"http://uly.me/posts/aws-create-volume-from-snapshot/","summary":"\u003cp\u003eHere’s a bash script that creates a volume from a snapshot in AWS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nread -p \u0026#34;snapshotId : \u0026#34; snapshot\nread -p \u0026#34;server     : \u0026#34; server\nread -p \u0026#34;tag1       : \u0026#34; tag1\nread -p \u0026#34;tag2       : \u0026#34; tag2\nread -p \u0026#34;region     : \u0026#34; region\nread -p \u0026#34;zone       : \u0026#34; zone\nread -p \u0026#34;profile    : \u0026#34; profile\naws ec2 create-volume \\\n--availability-zone $zone \\\n--encrypted \\\n--iops 3000 \\\n--volume-type gp3 \\\n--snapshot-id $snapshot \\\n--tag-specifications \u0026#34;ResourceType=volume,Tags=[{Key=Name,Value=\u0026#34;$server\u0026#34;},{Key=tag1,Value=\u0026#34;$tag1\u0026#34;},{Key=tag2,Value=\u0026#34;$tag2\u0026#34;}]\u0026#34; \\\n--region $region \\\n--profile $profile\n\u003c/code\u003e\u003c/pre\u003e","title":"aws create volume from snapshot"},{"content":"Handy little script to see if nameserver is on an array.\n#!/bin/bash declare -a servers=(\u0026#34;127.0.0.53\u0026#34; \u0026#34;127.0.0.52\u0026#34; \u0026#34;127.0.0.51\u0026#34;) client=$(cat /etc/resolv.conf | grep nameserver) for i in \u0026#34;${servers[@]}\u0026#34; do if [[ $client =~ $i ]] then using_unbound=\u0026#34;true\u0026#34; break else using_unbound=\u0026#34;false\u0026#34; fi done echo $using_unbound \u0026#34;|\u0026#34; $client ","permalink":"http://uly.me/posts/checking-nameservers/","summary":"\u003cp\u003eHandy little script to see if nameserver is on an array.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ndeclare -a servers=(\u0026#34;127.0.0.53\u0026#34; \u0026#34;127.0.0.52\u0026#34; \u0026#34;127.0.0.51\u0026#34;)\nclient=$(cat /etc/resolv.conf | grep nameserver)\nfor i in \u0026#34;${servers[@]}\u0026#34;\ndo\n  if [[ $client =~ $i ]]\n  then \n    using_unbound=\u0026#34;true\u0026#34;\n    break\n  else\n    using_unbound=\u0026#34;false\u0026#34;\n  fi\ndone\necho $using_unbound \u0026#34;|\u0026#34; $client\n\u003c/code\u003e\u003c/pre\u003e","title":"checking nameservers"},{"content":"If you have to download a file from the Internet on a Windows server, can certainly use the browser. But if the browser is rendering the file instead of downloading them, you may have to use the curl command which is already pre-installed on most Windows servers. Just open the command line. Here’s the the curl command to download a file.\ncurl.exe --output index.txt --url https://website.domain/index.txt ","permalink":"http://uly.me/posts/windows-curl-command/","summary":"\u003cp\u003eIf you have to download a file from the Internet on a Windows server, can certainly use the browser. But if the browser is rendering the file instead of downloading them, you may have to use the curl command which is already pre-installed on most Windows servers. Just open the command line. Here’s the the curl command to download a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl.exe --output index.txt --url https://website.domain/index.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"windows curl command"},{"content":"Here’s how to list account aliases. I have four profiles in my credentials. I’m looping through all four and printing the aliases.\n#!/bin/bash file=\u0026#39;results-aws-account-aliases.txt\u0026#39; \u0026gt; $file declare -a account=(\u0026#34;default\u0026#34; \u0026#34;one\u0026#34; \u0026#34;two\u0026#34; \u0026#34;three\u0026#34;) for i in \u0026#34;${account[@]}\u0026#34; do echo \u0026#39;----------------------\u0026#39; \u0026gt;\u0026gt; $file echo \u0026#39;Account: \u0026#39;$i \u0026gt;\u0026gt; $file aws iam list-account-aliases \\ --profile $i done ","permalink":"http://uly.me/posts/aws-list-account-aliases/","summary":"\u003cp\u003eHere’s how to list account aliases. I have four profiles in my credentials. I’m looping through all four and printing the aliases.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfile=\u0026#39;results-aws-account-aliases.txt\u0026#39;\n\u0026gt; $file\ndeclare -a account=(\u0026#34;default\u0026#34; \u0026#34;one\u0026#34; \u0026#34;two\u0026#34; \u0026#34;three\u0026#34;)\nfor i in \u0026#34;${account[@]}\u0026#34;\ndo\n    echo \u0026#39;----------------------\u0026#39; \u0026gt;\u0026gt; $file\n    echo \u0026#39;Account: \u0026#39;$i \u0026gt;\u0026gt; $file\n    aws iam list-account-aliases \\\n    --profile $i \ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"aws list account aliases"},{"content":"Just documenting the Linux Screen command.\nInstall screen first.\nyum install screen dnf install screen apt install screen zypper install screen Start a new screen.\nscreen -S one screen -S two screen -S three Detach from screen.\nCtrl+a+d List active screens.\nscreen -ls There is a screen on: 15575.one (Detached) 15581.two (Detached) 15593.three (Detached) 1 Socket in /var/run/screen/S-root. Reattach to an existing screen.\nscreen -r one screen -r two screen -r three If there’s only one active screen, you can run screen -r without the name.\nscreen -r To exit or quit a screen, reattach and run exit.\nscreen -r three # exit [screen is terminating] ","permalink":"http://uly.me/posts/linux-screen-2/","summary":"\u003cp\u003eJust documenting the Linux Screen command.\u003c/p\u003e\n\u003cp\u003eInstall screen first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install screen\ndnf install screen\napt install screen\nzypper install screen\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart a new screen.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escreen -S one\nscreen -S two\nscreen -S three\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDetach from screen.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCtrl+a+d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList active screens.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escreen -ls \nThere is a screen on:\n        15575.one   (Detached)\n        15581.two   (Detached)\n        15593.three (Detached)\n1 Socket in /var/run/screen/S-root.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReattach to an existing screen.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escreen -r one\nscreen -r two\nscreen -r three\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf there’s only one active screen, you can run screen -r without the name.\u003c/p\u003e","title":"linux screen"},{"content":"I upgraded to Linux Mint Vera from Una.\nulysses@penguin:~/Code$ neofetch ...-:::::-... ulysses@penguin .-MMMMMMMMMMMMMMM-. --------------- .-MMMM`..-:::::::-..`MMMM-. OS: Linux Mint 21.1 x86_64 .:MMMM.:MMMMMMMMMMMMMMM:.MMMM:. Kernel: 5.15.0-56-generic -MMM-M---MMMMMMMMMMMMMMMMMMM.MMM- Uptime: 13 hours, 35 mins `:MMM:MM` :MMMM:....::-...-MMMM:MMM:` Packages: 2176 (dpkg) :MMM:MMM` :MM:` `` `` `:MMM:MMM: Shell: bash 5.1.16 .MMM.MMMM` :MM. -MM. .MM- `MMMM.MMM. Resolution: 3840x2160 :MMM:MMMM` :MM. -MM- .MM: `MMMM-MMM: DE: Cinnamon 5.6.5 :MMM:MMMM` :MM. -MM- .MM: `MMMM:MMM: WM: Mutter (Muffin) :MMM:MMMM` :MM. -MM- .MM: `MMMM-MMM: WM Theme: Mint-Y-Dark-Aqua (Mint-Y) .MMM.MMMM` :MM:--:MM:--:MM: `MMMM.MMM. Theme: Mint-Y-Aqua [GTK2/3] :MMM:MMM- `-MMMMMMMMMMMM-` -MMM-MMM: Icons: Mint-Y-Aqua [GTK2/3] :MMM:MMM:` `:MMM:MMM: Terminal: gnome-terminal .MMM.MMMM:--------------:MMMM.MMM. CPU: AMD Ryzen 7 1700X (16) @ 3.700GHz \u0026#39;-MMMM.-MMMMMMMMMMMMMMM-.MMMM-\u0026#39; GPU: AMD ATI Radeon R7 240/340 / Radeon 520 \u0026#39;.-MMMM``--:::::--``MMMM-.\u0026#39; Memory: 3864MiB / 15928MiB \u0026#39;-MMMMMMMMMMMMM-\u0026#39; ``-:::::-`` I have 2 issues out of the gate.\nAudio is crackling. Bluetooth does not automatically connect to my Logitech K11 keyboard. To fix my audio issues, I have to restart pulseaudio.\n#!/bin/bash pulseaudio -k pulseaudio --start You may have to refresh your browser or restart your app to hear audio.\nAnd here’s the command to connect my keyboard. I’ve provided commands how to scan, connect and pair.\n#!/bin/bash # bluetoothctl scan on # bluetoothctl connect 00:1F:20:A8:EE:1F # bluetoothctl pair 00:1F:20:A8:EE:1F # bluetoothctl trust 00:1F:20:A8:EE:1F # bluetoothctl devices # bluetoothctl paired-devices bluetoothctl connect 00:1F:20:A8:EE:1F Output\nulysses@penguin:~$ bluetoothctl connect 00:1F:20:A8:EE:1F Attempting to connect to 00:1F:20:A8:EE:1F [DEL] Device 72:D9:FF:CC:41:78 72-D9-FF-CC-41-78 [CHG] Device 00:1F:20:A8:EE:1F Connected: yes [CHG] Device 00:1F:20:A8:EE:1F Modalias: usb:v046DpB317d0900 [CHG] Device 00:1F:20:A8:EE:1F UUIDs: 00001000-0000-1000-8000-00805f9b34fb [CHG] Device 00:1F:20:A8:EE:1F UUIDs: 00001124-0000-1000-8000-00805f9b34fb [CHG] Device 00:1F:20:A8:EE:1F UUIDs: 00001200-0000-1000-8000-00805f9b34fb [CHG] Device 00:1F:20:A8:EE:1F ServicesResolved: yes [CHG] Device 00:1F:20:A8:EE:1F WakeAllowed: yes [CHG] Device 00:1F:20:A8:EE:1F Paired: yes Connection successful The connect command performs both connect and pair.\nHoping they patch this soon so I don’t need to run them @reboot in crontab.\n","permalink":"http://uly.me/posts/linux-mint-vera/","summary":"\u003cp\u003eI upgraded to Linux Mint Vera from Una.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eulysses@penguin:~/Code$ neofetch\n             ...-:::::-...                 ulysses@penguin \n          .-MMMMMMMMMMMMMMM-.              --------------- \n      .-MMMM`..-:::::::-..`MMMM-.          OS: Linux Mint 21.1 x86_64 \n    .:MMMM.:MMMMMMMMMMMMMMM:.MMMM:.        Kernel: 5.15.0-56-generic \n   -MMM-M---MMMMMMMMMMMMMMMMMMM.MMM-       Uptime: 13 hours, 35 mins \n `:MMM:MM`  :MMMM:....::-...-MMMM:MMM:`    Packages: 2176 (dpkg) \n :MMM:MMM`  :MM:`  ``    ``  `:MMM:MMM:    Shell: bash 5.1.16 \n.MMM.MMMM`  :MM.  -MM.  .MM-  `MMMM.MMM.   Resolution: 3840x2160 \n:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM-MMM:   DE: Cinnamon 5.6.5 \n:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM:MMM:   WM: Mutter (Muffin) \n:MMM:MMMM`  :MM.  -MM-  .MM:  `MMMM-MMM:   WM Theme: Mint-Y-Dark-Aqua (Mint-Y) \n.MMM.MMMM`  :MM:--:MM:--:MM:  `MMMM.MMM.   Theme: Mint-Y-Aqua [GTK2/3] \n :MMM:MMM-  `-MMMMMMMMMMMM-`  -MMM-MMM:    Icons: Mint-Y-Aqua [GTK2/3] \n  :MMM:MMM:`                `:MMM:MMM:     Terminal: gnome-terminal \n   .MMM.MMMM:--------------:MMMM.MMM.      CPU: AMD Ryzen 7 1700X (16) @ 3.700GHz \n     \u0026#39;-MMMM.-MMMMMMMMMMMMMMM-.MMMM-\u0026#39;       GPU: AMD ATI Radeon R7 240/340 / Radeon 520 \n       \u0026#39;.-MMMM``--:::::--``MMMM-.\u0026#39;         Memory: 3864MiB / 15928MiB \n            \u0026#39;-MMMMMMMMMMMMM-\u0026#39;\n               ``-:::::-``                                         \n                                                                   \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI have 2 issues out of the gate.\u003c/p\u003e","title":"linux mint vera"},{"content":"Here’s how to upgrade your Linux Mint Desktop.\nsudo apt update sudo apt install mintupgrade Then run the upgrade.\nsudo mintupgrade ","permalink":"http://uly.me/posts/linux-mint-upgrade/","summary":"\u003cp\u003eHere’s how to upgrade your Linux Mint Desktop.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt update\nsudo apt install mintupgrade\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThen run the upgrade.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo mintupgrade\n\u003c/code\u003e\u003c/pre\u003e","title":"linux mint upgrade"},{"content":"Here’s a nice little command to open a browser from Bash.\n#!/bin/bash open https://domain.com/path/to/web/page/index.html You can use this command to open a web page from your script.\n","permalink":"http://uly.me/posts/open-browser-in-bash/","summary":"\u003cp\u003eHere’s a nice little command to open a browser from Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nopen https://domain.com/path/to/web/page/index.html\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can use this command to open a web page from your script.\u003c/p\u003e","title":"open browser in bash"},{"content":"Here’s the script to add pauses in your Bash script.\necho \u0026#34;please wait until web page loads ... \u0026#34; read -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s You can also put it inside a function and call it multiple times.\nfunction press_any_key { echo \u0026#34;please wait until web page loads ... \u0026#34; read -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s } press_any_key ","permalink":"http://uly.me/posts/bash-any-key/","summary":"\u003cp\u003eHere’s the script to add pauses in your Bash script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#34;please wait until web page loads ... \u0026#34;\nread -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also put it inside a function and call it multiple times.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction press_any_key {\n  echo \u0026#34;please wait until web page loads ... \u0026#34;\n  read -p \u0026#34;Press any key to continue... \u0026#34; -n1 -s\n}\npress_any_key\n\u003c/code\u003e\u003c/pre\u003e","title":"bash any key"},{"content":"A recent OS upgrade rendered the crontab to malfunction on macOS Monterey. It turned out the system just needed a reset of System Preferences \u0026gt; Security \u0026amp; Privacy \u0026gt; Privacy tab, and to make sure cron has full access to disks. Once you flipped that, your crontab should start working. Hope that helps.\n","permalink":"http://uly.me/posts/crontab-on-macos-monterey/","summary":"\u003cp\u003eA recent OS upgrade rendered the crontab to malfunction on macOS Monterey. It turned out the system just needed a reset of System Preferences \u0026gt; Security \u0026amp; Privacy \u0026gt; Privacy tab, and to make sure cron has full access to disks. Once you flipped that, your crontab should start working. Hope that helps.\u003c/p\u003e","title":"crontab on macos monterey"},{"content":"If you’re into photography, you would know what crop factor means. I have a Nikon D90 camera with a crop factor of 1.5. For example, if you use a 24mm full frame lens on a D90, the focal length will be 36mm. So, here’s a handy bash script that calculates the crop factor by multiplying the full frame focal length by 1.5.\n#!/bin/bash if [ $# -eq 0 ] then echo \u0026#34;Usage: cropfactor.sh 24\u0026#34; exit fi a=$(echo \u0026#34;1.5 * $1\u0026#34; | bc) echo \u0026#34;Cropfactor focal length is: \u0026#34; $a\u0026#34;mm.\u0026#34; Result\nulysses@penguin:~/Code$ ./cropfactor.sh 24 Cropfactor focal length is: 36.0mm. ","permalink":"http://uly.me/posts/crop-factor-calculator/","summary":"\u003cp\u003eIf you’re into photography, you would know what crop factor means. I have a Nikon D90 camera with a crop factor of 1.5. For example, if you use a 24mm full frame lens on a D90, the focal length will be 36mm. So, here’s a handy bash script that calculates the crop factor by multiplying the full frame focal length by 1.5.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [ $# -eq 0 ]\n  then\n    echo \u0026#34;Usage: cropfactor.sh 24\u0026#34;\n    exit\nfi\na=$(echo \u0026#34;1.5 * $1\u0026#34; | bc)\necho \u0026#34;Cropfactor focal length is: \u0026#34; $a\u0026#34;mm.\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e","title":"crop factor calculator"},{"content":"Here’s how to resize videos and pictures using FFMPEG.\nBulk Resize Pictures\nfor filename in *.JPG; do ffmpeg -i \u0026#34;$filename\u0026#34; -vf scale=-1:720 final/\u0026#34;$filename\u0026#34;; done Bulk Resize Video and Create Thumbnail\nfor filename in *.MP4; do ffmpeg -i \u0026#34;$filename\u0026#34; -s 1080x720 -pix_fmt yuv420p -crf 18 \u0026#34;$filename\u0026#34;.mp4; ffmpeg -ss 00:00:00 -i \u0026#34;$filename\u0026#34; -vframes 1 \u0026#34;$filename\u0026#34;.jpg; done ","permalink":"http://uly.me/posts/bulk-ffmpeg-resize/","summary":"\u003cp\u003eHere’s how to resize videos and pictures using FFMPEG.\u003c/p\u003e\n\u003cp\u003eBulk Resize Pictures\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efor filename in *.JPG; do \n  ffmpeg -i \u0026#34;$filename\u0026#34; -vf scale=-1:720 final/\u0026#34;$filename\u0026#34;;\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBulk Resize Video and Create Thumbnail\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efor filename in *.MP4; do \n  ffmpeg -i \u0026#34;$filename\u0026#34; -s 1080x720 -pix_fmt yuv420p -crf 18 \u0026#34;$filename\u0026#34;.mp4; \n  ffmpeg -ss 00:00:00 -i \u0026#34;$filename\u0026#34; -vframes 1 \u0026#34;$filename\u0026#34;.jpg;\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"bulk ffmpeg resize"},{"content":"Almost all are not able to remember all the shortcuts that are available for the vi or vim editor. I will call it vim throughout this article. There are several cheatsheets out there, but the one that works for me is the one provided by rtorr in Github. I use the cheatsheet often. I suggest that you start small. At the very least learn how to navigate in vim. Once you feel comfortable doing that, you can learn other advanced shortcuts such as editing, search and replace, working with multiple files and many much more. I hope you’ll find the cheatsheet as helpful as it has done for me. Again if you missed the link above, I posted it below.\nVim Cheatsheet\n","permalink":"http://uly.me/posts/vim-cheatsheet/","summary":"\u003cp\u003eAlmost all are not able to remember all the shortcuts that are available for the vi or vim editor. I will call it vim throughout this article. There are several cheatsheets out there, but the one that works for me is the one provided by \u003ca href=\"https://vim.rtorr.com/\"\u003ertorr\u003c/a\u003e in Github. I use the cheatsheet often. I suggest that you start small. At the very least learn how to navigate in vim. Once you feel comfortable doing that, you can learn other advanced shortcuts such as editing, search and replace, working with multiple files and many much more. I hope you’ll find the cheatsheet as helpful as it has done for me. Again if you missed the link above, I posted it below.\u003c/p\u003e","title":"vim cheatsheet"},{"content":"How to resize JPEG using FFMPEG.\nffmpeg -i TREE.JPG -y -vf scale=iw*.2:ih*.2 tree.jpg Another option is to set resolution.\nffmpeg -i TREE.JPG -y -vf scale=-1:720 tree.jpg How to resize video using FFMPEG.\nffmpeg -i TREE.MP4 -s 640x360 -pix_fmt yuv420p -crf 18 tree.mp4 How to create a thumbnail from a video.\nffmpeg -ss 00:00:00 -i tree.mp4 -vframes 1 tree.jpg ","permalink":"http://uly.me/posts/ffmpeg-resize/","summary":"\u003cp\u003eHow to resize JPEG using FFMPEG.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i TREE.JPG -y -vf scale=iw*.2:ih*.2 tree.jpg\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnother option is to set resolution.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i TREE.JPG -y -vf scale=-1:720 tree.jpg\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to resize video using FFMPEG.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i TREE.MP4 -s 640x360 -pix_fmt yuv420p -crf 18 tree.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to create a thumbnail from a video.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -ss 00:00:00 -i tree.mp4 -vframes 1 tree.jpg\n\u003c/code\u003e\u003c/pre\u003e","title":"ffmpeg resize"},{"content":"I had trouble getting my vi editor to display all black background color. This includes the background color after the end of the file. I just wanted an all black background for better visibility. I did a little bit of googling and found this nice little gem. I happen to like the dessert theme and went with that instead of the recommended mustang theme which I don’t have installed. Hope you’ll find this helpful.\nset t_Co=256 set background=dark colorscheme dessert highlight Normal ctermbg=NONE highlight nonText ctermbg=NONE ","permalink":"http://uly.me/posts/vim-colors/","summary":"\u003cp\u003eI had trouble getting my vi editor to display all black background color. This includes the background color after the end of the file. I just wanted an all black background for better visibility. I did a little bit of googling and found this nice little gem. I happen to like the dessert theme and went with that instead of the recommended mustang theme which I don’t have installed. Hope you’ll find this helpful.\u003c/p\u003e","title":"vim colors"},{"content":"If you need to remove files from a repo after committing, use …\nRemove file\ngit rm --cached file.ext Push to repo\ngit push ","permalink":"http://uly.me/posts/git-remove-files-from-repo-after-commit/","summary":"\u003cp\u003eIf you need to remove files from a repo after committing, use …\u003c/p\u003e\n\u003cp\u003eRemove file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit rm --cached file.ext\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePush to repo\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit push\n\u003c/code\u003e\u003c/pre\u003e","title":"git remove files from repo after commit"},{"content":"Cockpit is a web-based graphical interface for Linux users and admins.\nInstall\ndnf install cockpit Start and Enable\nsystemctl start cockpit systemctl enable cockpit.socket Status\nsystemctl status cockpit Web access\nhttp://192.168.0.20:9090 ","permalink":"http://uly.me/posts/install-cockpit-on-rocky-9/","summary":"\u003cp\u003eCockpit is a web-based graphical interface for Linux users and admins.\u003c/p\u003e\n\u003cp\u003eInstall\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ednf install cockpit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart and Enable\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl start cockpit\nsystemctl enable cockpit.socket\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStatus\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl status cockpit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWeb access\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehttp://192.168.0.20:9090\n\u003c/code\u003e\u003c/pre\u003e","title":"install cockpit on rocky 9"},{"content":"How to integrate menus and functions in your Bash script.\n#!/bin/bash function show_logs { ls -l /var/log/ } function show_users { cat /etc/passwd } echo \u0026#39;--------\u0026#39; echo \u0026#39;My Menu\u0026#39; echo \u0026#39;--------\u0026#39; PS3=\u0026#39;Choose an option: \u0026#39; commands=(\u0026#34;Show logs\u0026#34; \u0026#34;Show users\u0026#34; \u0026#34;Quit\u0026#34;) COLUMNS=0 select cmd in \u0026#34;${commands[@]}\u0026#34;; do case $cmd in \u0026#34;Show logs\u0026#34;) echo \u0026#34;Showing logs ... \u0026#34; show_logs ;; \u0026#34;Show users\u0026#34;) echo \u0026#34;Showing users ... \u0026#34; show_users ;; \u0026#34;Quit\u0026#34;) echo \u0026#34;Exiting ... \u0026#34; exit ;; *) echo \u0026#34;invalid option $REPLY\u0026#34;;; esac done Result\n-------- My Menu -------- 1) Show logs 2) Show users 3) Quit ","permalink":"http://uly.me/posts/bash-menu-and-functions/","summary":"\u003cp\u003eHow to integrate menus and functions in your Bash script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfunction show_logs {\nls -l /var/log/\n}\nfunction show_users {\ncat /etc/passwd\n}\necho \u0026#39;--------\u0026#39;\necho \u0026#39;My Menu\u0026#39;\necho \u0026#39;--------\u0026#39;\nPS3=\u0026#39;Choose an option: \u0026#39;\ncommands=(\u0026#34;Show logs\u0026#34; \u0026#34;Show users\u0026#34; \u0026#34;Quit\u0026#34;)\nCOLUMNS=0\nselect cmd in \u0026#34;${commands[@]}\u0026#34;; do\n    case $cmd in\n        \u0026#34;Show logs\u0026#34;)\n            echo \u0026#34;Showing logs ... \u0026#34;\n            show_logs\n            ;;\n        \u0026#34;Show users\u0026#34;)\n            echo \u0026#34;Showing users ... \u0026#34;\n            show_users\n            ;;\n\t\u0026#34;Quit\u0026#34;)\n\t    echo \u0026#34;Exiting ... \u0026#34;\n\t    exit\n\t    ;;\n        *) echo \u0026#34;invalid option $REPLY\u0026#34;;;\n    esac\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e","title":"bash menu and functions"},{"content":"iptables can be saved or loaded from a file. Here’s a way to do it.\nSaving to a file\n# Debian/Ubuntu iptables-save \u0026gt; /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-save \u0026gt; /etc/sysconfig/iptables Loading from a file\n# Debian/Ubuntu iptables-restore \u0026gt; /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-restore \u0026gt; /etc/sysconfig/iptables Listing rules\niptables -L ","permalink":"http://uly.me/posts/saving-and-restoring-iptables/","summary":"\u003cp\u003eiptables can be saved or loaded from a file. Here’s a way to do it.\u003c/p\u003e\n\u003cp\u003eSaving to a file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Debian/Ubuntu\niptables-save \u0026gt; /etc/iptables/rules.v4\n# Redhat/Centos/Rocky\niptables-save \u0026gt; /etc/sysconfig/iptables\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLoading from a file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Debian/Ubuntu\niptables-restore \u0026gt; /etc/iptables/rules.v4\n# Redhat/Centos/Rocky\niptables-restore \u0026gt; /etc/sysconfig/iptables\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eListing rules\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eiptables -L\n\u003c/code\u003e\u003c/pre\u003e","title":"saving and restoring iptables"},{"content":"Here’s how to list Bare Metal Servers in Google Cloud Platform via gcloud.\ngcloud bms instances list --region REGION --project PROJECT Result\nNAME ID PROJECT REGION MACHINE_TYPE CLIENT_IPS PRIVATE_IPS STATE server-001 at-xxxxxxx-svr001 project-01 us-central1 o2-ultramem-896-metal 10.0.0.1 192.168.253.1,192.168.252.1 RUNNING server-002 at-xxxxxxx-svr002 project-02 us-central1 o2-ultramem-896-metal 10.0.0.2 192.168.253.2,192.168.252.2 RUNNING Obviously you can see the same from GCP’s Console.\n","permalink":"http://uly.me/posts/gcp-list-of-bms-servers/","summary":"\u003cp\u003eHere’s how to list Bare Metal Servers in Google Cloud Platform via gcloud.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud bms instances list --region REGION --project PROJECT\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eNAME            ID                 PROJECT         REGION       MACHINE_TYPE           CLIENT_IPS    PRIVATE_IPS                    STATE\nserver-001      at-xxxxxxx-svr001  project-01      us-central1  o2-ultramem-896-metal  10.0.0.1      192.168.253.1,192.168.252.1    RUNNING\nserver-002      at-xxxxxxx-svr002  project-02      us-central1  o2-ultramem-896-metal  10.0.0.2      192.168.253.2,192.168.252.2    RUNNING\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eObviously you can see the same from GCP’s Console.\u003c/p\u003e","title":"gcp list of bms servers"},{"content":"Here’s how to isolate a process via the top command.\ntop -c -p $(pgrep -f process_name | head -20 | tr \u0026#34;\\\\n\u0026#34; \u0026#34;,\u0026#34; | sed \u0026#39;s/,$//\u0026#39;) ","permalink":"http://uly.me/posts/running-top-by-process/","summary":"\u003cp\u003eHere’s how to isolate a process via the top command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etop -c -p $(pgrep -f process_name | head -20 | tr \u0026#34;\\\\n\u0026#34; \u0026#34;,\u0026#34; | sed \u0026#39;s/,$//\u0026#39;)\n\u003c/code\u003e\u003c/pre\u003e","title":"running top by process"},{"content":"Less clutter is good. There are times when there’s too many windows in our desktop. Having less clutter leads to better focus. Here’s how to hide all Windows on a Mac OS except for the current or active one.\nCommand + Option + h I wished there was a command to bring them all back, but I have not found one yet.\n","permalink":"http://uly.me/posts/hide-all-windows-except-current/","summary":"\u003cp\u003eLess clutter is good. There are times when there’s too many windows in our desktop. Having less clutter leads to better focus. Here’s how to hide all Windows on a Mac OS except for the current or active one.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCommand + Option + h\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI wished there was a command to bring them all back, but I have not found one yet.\u003c/p\u003e","title":"hide all windows except current"},{"content":"Here’s how to display history without the line numbers.\nhistory -w /dev/stdout Result\ncd /etc/httpd/conf view httpd.conf vim wiki.conf vim ssl.conf ","permalink":"http://uly.me/posts/history-without-line-numbers/","summary":"\u003cp\u003eHere’s how to display history without the line numbers.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehistory -w /dev/stdout\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /etc/httpd/conf\nview httpd.conf \nvim wiki.conf \nvim ssl.conf\n\u003c/code\u003e\u003c/pre\u003e","title":"history without line numbers"},{"content":"How to give someone access to enable/disable CloudWatch notifications.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Action\u0026#34;: [ \u0026#34;cloudwatch:DescribeAlarms\u0026#34;, \u0026#34;cloudwatch:EnableAlarmActions\u0026#34;, \u0026#34;cloudwatch:DisableAlarmActions\u0026#34; ], \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } ","permalink":"http://uly.me/posts/cloudwatch-notifications/","summary":"\u003cp\u003eHow to give someone access to enable/disable CloudWatch notifications.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;cloudwatch:DescribeAlarms\u0026#34;,\n                \u0026#34;cloudwatch:EnableAlarmActions\u0026#34;,\n                \u0026#34;cloudwatch:DisableAlarmActions\u0026#34;\n            ],\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"cloudwatch notifications"},{"content":"Here’s a workaround if the df command takes too long to run.\nThis limits listing to local file systems only.\ndf -l ","permalink":"http://uly.me/posts/df-command-takes-too-long/","summary":"\u003cp\u003eHere’s a workaround if the df command takes too long to run.\u003c/p\u003e\n\u003cp\u003eThis limits listing to local file systems only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edf -l\n\u003c/code\u003e\u003c/pre\u003e","title":"df command takes too long"},{"content":"How to display the policy binding.\ngcloud compute instances get-iam-policy SERVER --project=PROJECT_ID --zone=ZONE Result\n# There is no binding policy etag: ACAB # There is a binding policy bindings: - members: - serviceAccount:SERVICEACCOUNT role: organizations/xxxxxxxxxxxx/roles/ROLE etag: xxxxxxxxxxx= version: 1 Add a role binding policy\ngcloud compute instances add-iam-policy-binding SERVER \\ --project=PROJECT_ID \\ --zone=ZONE \\ --member=serviceAccount:SERVICEACCOUNT \\ --role=\u0026#34;organizations/xxxxxxxxxxxx/roles/ROLE\u0026#34; Remove a role binding policy\ngcloud compute instances remove-iam-policy-binding SERVER \\ --project=PROJECT_ID \\ --zone=ZONE \\ --member=serviceAccount:SERVICEACCOUNT \\ --role=\u0026#34;organizations/xxxxxxxxxxxx/roles/ROLE\u0026#34; ","permalink":"http://uly.me/posts/gcp-role-policy-binding/","summary":"\u003cp\u003eHow to display the policy binding.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances get-iam-policy SERVER --project=PROJECT_ID --zone=ZONE\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# There is no binding policy\netag: ACAB\n\n# There is a binding policy\nbindings:\n- members:\n  - serviceAccount:SERVICEACCOUNT\n  role: organizations/xxxxxxxxxxxx/roles/ROLE\netag: xxxxxxxxxxx=\nversion: 1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd a role binding policy\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-iam-policy-binding SERVER \\\n--project=PROJECT_ID \\\n--zone=ZONE \\\n--member=serviceAccount:SERVICEACCOUNT \\\n--role=\u0026#34;organizations/xxxxxxxxxxxx/roles/ROLE\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove a role binding policy\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances remove-iam-policy-binding SERVER \\\n--project=PROJECT_ID \\\n--zone=ZONE \\\n--member=serviceAccount:SERVICEACCOUNT \\\n--role=\u0026#34;organizations/xxxxxxxxxxxx/roles/ROLE\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp role policy binding"},{"content":"Here’s how to run Jekyll in a Docker container.\nmkdir blog cd blog docker run -v $(pwd):/site bretfisher/jekyll new . Start jekyll.\ndocker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve Another option is to use docker compose. Just create a docker-compose.yml file.\nversion: 3.5 services: jekyll: image: bretfisher/jekyll-serve volumes: - .:/site ports: - \u0026#39;4000:4000\u0026#39; Start Jekyll by using docker-compose up. -d means detach or run in the background.\ncd blog docker-compose up -d Stop Jekyll.\ncd blog docker-compose down ","permalink":"http://uly.me/posts/jekyll-on-docker-container/","summary":"\u003cp\u003eHere’s how to run Jekyll in a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir blog\ncd blog\ndocker run -v $(pwd):/site bretfisher/jekyll new .\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart jekyll.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnother option is to use docker compose. Just create a docker-compose.yml file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eversion: 3.5\nservices:\n  jekyll:\n    image: bretfisher/jekyll-serve\n    volumes:\n      - .:/site\n    ports:\n      - \u0026#39;4000:4000\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart Jekyll by using docker-compose up. -d means detach or run in the background.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd blog\ndocker-compose up -d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStop Jekyll.\u003c/p\u003e","title":"jekyll on docker container"},{"content":"How to unmount CVS snapshot volumes all at once using a Bash script. I ran into a scenario where I had to unmount 115 volumes. Instead of manually running umount on each one, I use the script below to unmount all 115 volumes. The script performs a grep for ‘.snapshot’ and then writes the results to a file. I then read the file line by line and perform unmount on each one.\n#!/bin/bash file=\u0026#39;/tmp/snapshots.txt\u0026#39; df -h | grep .snapshot | awk \u0026#39;{print $6}\u0026#39; \u0026gt; $file while IFS= read -r line; do echo \u0026#39;unmounting \u0026#39;$line umount $line done ","permalink":"http://uly.me/posts/cleanup-cvs-snapshot-volumes/","summary":"\u003cp\u003eHow to unmount CVS snapshot volumes all at once using a Bash script. I ran into a scenario where I had to unmount 115 volumes. Instead of manually running umount on each one, I use the script below to unmount all 115 volumes. The script performs a grep for ‘.snapshot’ and then writes the results to a file. I then read the file line by line and perform unmount on each one.\u003c/p\u003e","title":"cleanup cvs snapshot volumes"},{"content":"Here’s the script that looks mounts with stale file handles and removes them.\n#!/bin/bash file=\u0026#39;/tmp/stale.txt\u0026#39; df -h | grep Stale \u0026gt; $file sed -i -e \u0026#39;s/df: ‘/\u0026#39;\u0026#34;\u0026#34;\u0026#39;/g\u0026#39; $file sed -i -e \u0026#39;s/’: Stale file handle/\u0026#39;\u0026#34;\u0026#34;\u0026#39;/g\u0026#39; $file while IFS= read -r line; do echo \u0026#39;unmounting \u0026#39;$line umount $line done ","permalink":"http://uly.me/posts/cleanup-stale-cvs-snapshots/","summary":"\u003cp\u003eHere’s the script that looks mounts with stale file handles and removes them.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfile=\u0026#39;/tmp/stale.txt\u0026#39;\ndf -h | grep Stale \u0026gt; $file\nsed -i -e \u0026#39;s/df: ‘/\u0026#39;\u0026#34;\u0026#34;\u0026#39;/g\u0026#39; $file\nsed -i -e \u0026#39;s/’: Stale file handle/\u0026#39;\u0026#34;\u0026#34;\u0026#39;/g\u0026#39; $file\nwhile IFS= read -r line; do\n  echo \u0026#39;unmounting \u0026#39;$line\n  umount $line\ndone \n\u003c/code\u003e\u003c/pre\u003e","title":"cleanup stale cvs snapshots"},{"content":"Here’s how to copy a directory structure from one directory to another without the files.\nCopy directory structure of DIR1 to DIR2.\nfind /DIR1 -type d \u0026gt; /tmp/dirs.txt sed -i \u0026#39;s/DIR1/DIR2/\u0026#39; /tmp/dirs.txt xargs mkdir -p ","permalink":"http://uly.me/posts/copy-directory-structure/","summary":"\u003cp\u003eHere’s how to copy a directory structure from one directory to another without the files.\u003c/p\u003e\n\u003cp\u003eCopy directory structure of DIR1 to DIR2.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efind /DIR1 -type d \u0026gt; /tmp/dirs.txt\nsed -i \u0026#39;s/DIR1/DIR2/\u0026#39; /tmp/dirs.txt \nxargs mkdir -p \n\u003c/code\u003e\u003c/pre\u003e","title":"copy directory structure"},{"content":"How to run editors from the Terminal.\nSublime, Visual Studio Code, Atom and Bluefish examples.\nOpen from the current directory.\nsubl . code . atom . bluefish . Open editor using path and file.\nsubl /etc/hosts code /etc/hosts atom /etc/hosts bluefish /etc/hosts ","permalink":"http://uly.me/posts/editors-on-terminal/","summary":"\u003cp\u003eHow to run editors from the Terminal.\u003c/p\u003e\n\u003cp\u003eSublime, Visual Studio Code, Atom and Bluefish examples.\u003c/p\u003e\n\u003cp\u003eOpen from the current directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esubl .\ncode .\natom .\nbluefish .\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOpen editor using path and file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esubl /etc/hosts\ncode /etc/hosts\natom /etc/hosts\nbluefish /etc/hosts\n\u003c/code\u003e\u003c/pre\u003e","title":"editors on terminal"},{"content":"Here’s how to add breaks in your Bash scripts. The function is called spacebar.\nfunction spacebar { echo \u0026#39;Press spacebar to continue. Press Ctrl-C to exit.\u0026#39; stty -echo \u0026gt; /dev/null until read -r -n 1 -t 0.001 \u0026amp;\u0026amp; [ \u0026#34;$REPLY\u0026#34; = \u0026#39; \u0026#39; ]; do abc=\u0026#39;\u0026#39;; done stty echo \u0026gt; /dev/null } spacebar You can call it multiple times in your script since it’s a function.\n","permalink":"http://uly.me/posts/bash-spacebar-break/","summary":"\u003cp\u003eHere’s how to add breaks in your Bash scripts. The function is called spacebar.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction spacebar {\n  echo \u0026#39;Press spacebar to continue. Press Ctrl-C to exit.\u0026#39;\n  stty -echo \u0026gt; /dev/null\n  until read -r -n 1 -t 0.001 \u0026amp;\u0026amp; [ \u0026#34;$REPLY\u0026#34; = \u0026#39; \u0026#39; ]; do abc=\u0026#39;\u0026#39;; done\n  stty echo \u0026gt; /dev/null\n}\n\nspacebar\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can call it multiple times in your script since it’s a function.\u003c/p\u003e","title":"bash spacebar break"},{"content":"Here’s how to set Vim colors permanently.\nvi ~/.vimrc Add the following.\nhighlight Normal ctermfg=white ctermbg=black ","permalink":"http://uly.me/posts/set-vim-colors-permanently/","summary":"\u003cp\u003eHere’s how to set Vim colors permanently.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evi ~/.vimrc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehighlight Normal ctermfg=white ctermbg=black\n\u003c/code\u003e\u003c/pre\u003e","title":"set vim colors permanently"},{"content":"Here’s a little snippet of Bash code that waits for spacebar to be pressed to continue.\nfunction spacebar { echo \u0026#39;Press spacebar to continue. Press Ctrl-C to exit.\u0026#39; stty -echo \u0026gt; /dev/null until read -r -n 1 -t 0.001 \u0026amp;\u0026amp; [ \u0026#34;$REPLY\u0026#34; = \u0026#39; \u0026#39; ]; do abc=\u0026#39;\u0026#39;; done stty echo \u0026gt; /dev/null } echo \u0026#39;Starting upgrade\u0026#39; spacebar Output\nStarting upgrade Press spacebar to continue. Or Ctrl-C to exit. If you press spacebar it will continue. Ctrl-C exits the program.\n","permalink":"http://uly.me/posts/press-spacebar-to-continue/","summary":"\u003cp\u003eHere’s a little snippet of Bash code that waits for spacebar to be pressed to continue.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction spacebar {\n  echo \u0026#39;Press spacebar to continue. Press Ctrl-C to exit.\u0026#39;\n  stty -echo \u0026gt; /dev/null\n  until read -r -n 1 -t 0.001 \u0026amp;\u0026amp; [ \u0026#34;$REPLY\u0026#34; = \u0026#39; \u0026#39; ]; do abc=\u0026#39;\u0026#39;; done\n  stty echo \u0026gt; /dev/null\n}\necho \u0026#39;Starting upgrade\u0026#39;\nspacebar\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eStarting upgrade\nPress spacebar to continue. Or Ctrl-C to exit.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you press spacebar it will continue. Ctrl-C exits the program.\u003c/p\u003e","title":"press spacebar to continue"},{"content":"Why would you choose Bare Metal Servers?\nAdvantages\n– BMS are dedicated to a single organization\n– Single tenant or dedicated host\n– No sharing of hardware, storage, connection, bandwidth (noisy neighbor)\n– There is no hypervisor layer\n– No virtualization overhead\n– OS is loaded straight to the server\n– Results in higher performance\n– Quality of hardware\n– Compliance and security due to single tenant\n– Flexible contract, billing options\nDisadvantages\n– Procurement could take weeks depending on hardware type\n– And that goes for replacement hardware as well.\n","permalink":"http://uly.me/posts/bare-metal-servers/","summary":"\u003cp\u003eWhy would you choose Bare Metal Servers?\u003c/p\u003e\n\u003cp\u003eAdvantages\u003c/p\u003e\n\u003cp\u003e– BMS are dedicated to a single organization\u003cbr\u003e\n– Single tenant or dedicated host\u003cbr\u003e\n– No sharing of hardware, storage, connection, bandwidth (noisy neighbor)\u003cbr\u003e\n– There is no hypervisor layer\u003cbr\u003e\n– No virtualization overhead\u003cbr\u003e\n– OS is loaded straight to the server\u003cbr\u003e\n– Results in higher performance\u003cbr\u003e\n– Quality of hardware\u003cbr\u003e\n– Compliance and security due to single tenant\u003cbr\u003e\n– Flexible contract, billing options\u003c/p\u003e","title":"bare metal servers"},{"content":"Check mounted file systems using df. Displaying different options.\ndf df -h df -Th To get rid tmpfs, run this.\ndf -Th| grep -Ev \u0026#39;(udev|tmpfs)\u0026#39; ","permalink":"http://uly.me/posts/check-mounted-file-systems/","summary":"\u003cp\u003eCheck mounted file systems using df. Displaying different options.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edf \ndf -h\ndf -Th\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo get rid tmpfs, run this.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edf -Th| grep -Ev \u0026#39;(udev|tmpfs)\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"check mounted file systems"},{"content":"Here’s how to extend an ext4 boot volume.\ngcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID Resize the file system. Example / is on sda3.\ngrowpart /dev/sda 3 resize2fs /dev/sda3 ","permalink":"http://uly.me/posts/gcp-extend-ext4-boot-volume/","summary":"\u003cp\u003eHere’s how to extend an ext4 boot volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResize the file system. Example / is on sda3.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egrowpart /dev/sda 3\nresize2fs /dev/sda3\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp extend ext4 boot volume"},{"content":"How to look for an access key in AWS. Find the account.\n$ aws sts get-access-key-info --access-key-id AKIA8XXXXXXXXXXXXXXX { \u0026#34;Account\u0026#34;: \u0026#34;XXXXXXXXXXXX\u0026#34; } ","permalink":"http://uly.me/posts/aws-get-access-key-info/","summary":"\u003cp\u003eHow to look for an access key in AWS. Find the account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws sts get-access-key-info --access-key-id AKIA8XXXXXXXXXXXXXXX\n{\n    \u0026#34;Account\u0026#34;: \u0026#34;XXXXXXXXXXXX\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws get access key info"},{"content":"How to create service account in GCP via Terraform.\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;your_project_id\u0026#34; } resource \u0026#34;google_service_account\u0026#34; \u0026#34;service_account\u0026#34; { account_id = \u0026#34;your-service-account-name\u0026#34; display_name = \u0026#34;test service account built by terraform\u0026#34; } ","permalink":"http://uly.me/posts/gcp-create-service-account-via-terraform/","summary":"\u003cp\u003eHow to create service account in GCP via Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n  project = \u0026#34;your_project_id\u0026#34;\n}\nresource \u0026#34;google_service_account\u0026#34; \u0026#34;service_account\u0026#34; {\n  account_id   = \u0026#34;your-service-account-name\u0026#34;\n  display_name = \u0026#34;test service account built by terraform\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create service account via terraform"},{"content":"Here’s a script to convert date to epoch time on Mac OS.\n#!/bin/bash if [[ -z $1 ]]; then echo \u0026#34;Format: date2epoch.sh 2022/01/01-04:58:06\u0026#34; else echo \u0026#34;$1\u0026#34;; date -j -f date -j -f \u0026#34;%Y/%m/%d-%T\u0026#34; \u0026#34;$1\u0026#34; +\u0026#34;%s\u0026#34; fi Result\n$ ./date2epoch.sh 2022/08/31-22:00:00 2022/08/31-22:00:00 1661997600 ","permalink":"http://uly.me/posts/calculate-date-to-epoch-time/","summary":"\u003cp\u003eHere’s a script to convert date to epoch time on Mac OS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [[ -z $1 ]]; then\n  echo \u0026#34;Format: date2epoch.sh 2022/01/01-04:58:06\u0026#34;\nelse\n  echo \u0026#34;$1\u0026#34;; date -j -f date -j -f \u0026#34;%Y/%m/%d-%T\u0026#34; \u0026#34;$1\u0026#34; +\u0026#34;%s\u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ ./date2epoch.sh 2022/08/31-22:00:00\n2022/08/31-22:00:00\n1661997600\n\u003c/code\u003e\u003c/pre\u003e","title":"calculate date to epoch time"},{"content":"Connect to your CloudShell environment from your terminal.\n$ gcloud cloud-shell ssh Welcome to Cloud Shell! Type \u0026#34;help\u0026#34; to get started. first.last@cloudshell $ first.last@cloudshell $ Once logged in, you can set your project.\nfirst.last@cloudshell $ gcloud config set project $PROJECT_ID ","permalink":"http://uly.me/posts/gcp-cloudshell-via-terminal/","summary":"\u003cp\u003eConnect to your CloudShell environment from your terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ gcloud cloud-shell ssh\nWelcome to Cloud Shell! Type \u0026#34;help\u0026#34; to get started.\nfirst.last@cloudshell $\nfirst.last@cloudshell $\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce logged in, you can set your project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efirst.last@cloudshell $ gcloud config set project $PROJECT_ID\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp cloudshell via terminal"},{"content":"Here’s how to move a VM to another VPC.\nStop VM.\ngcloud compute instances stop $INSTANCE_NAME \\ --zone $ZONE_NAME \\ --project $PROJECT_ID Move VM to another VPC.\ngcloud compute instances network-interfaces update $INSTANCE_NAME \\ --zone $ZONE_NAME \\ --network-interface=nic0 \\ --network $YOUR_NETWORK \\ --subnetwork $YOUR_SUBNETWORK \\ --project $PROJECT_ID Start VM.\ngcloud compute instances start $INSTANCE_NAME \\ --zone $ZONE_NAME \\ --project $PROJECT_ID ","permalink":"http://uly.me/posts/gcp-move-vm-to-another-vpc/","summary":"\u003cp\u003eHere’s how to move a VM to another VPC.\u003c/p\u003e\n\u003cp\u003eStop VM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances stop $INSTANCE_NAME \\\n--zone $ZONE_NAME \\\n--project $PROJECT_ID\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMove VM to another VPC.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances network-interfaces update $INSTANCE_NAME \\\n--zone $ZONE_NAME \\\n--network-interface=nic0 \\\n--network $YOUR_NETWORK \\\n--subnetwork $YOUR_SUBNETWORK \\\n--project $PROJECT_ID\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart VM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances start $INSTANCE_NAME \\\n--zone $ZONE_NAME \\\n--project $PROJECT_ID\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp move vm to another vpc"},{"content":"How to describe a GCP bucket.\ngsutil ls -L -b gs://my-bucket ","permalink":"http://uly.me/posts/gsutil-describe-bucket/","summary":"\u003cp\u003eHow to describe a GCP bucket.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsutil ls -L -b gs://my-bucket\n\u003c/code\u003e\u003c/pre\u003e","title":"gsutil describe bucket"},{"content":"Here’s how to reset a file from the master branch.\ngit checkout origin/master test.py This will undo your changes and matches what’s in the master repo.\n","permalink":"http://uly.me/posts/git-reset-file-from-master/","summary":"\u003cp\u003eHere’s how to reset a file from the master branch.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit checkout origin/master test.py\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis will undo your changes and matches what’s in the master repo.\u003c/p\u003e","title":"git reset file from master"},{"content":"Just implemented an Ajax live search on a website.\nHere’s the search page. Results are displayed in div output.\n\u0026lt;script src=\u0026#34;https://code.jquery.com/jquery-3.4.1.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script type=\u0026#34;text/javascript\u0026#34;\u0026gt; $(document).ready(function(){ $(\u0026#34;#search\u0026#34;).keyup(function(){ var query = $(this).val(); if (query != \u0026#34;\u0026#34;) { $.ajax({ url: \u0026#39;links-ajax.php\u0026#39;, method: \u0026#39;POST\u0026#39;, data: {query:query}, success: function(data){ $(\u0026#39;#output\u0026#39;).html(data); $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;block\u0026#39;); $(\u0026#34;#output a\u0026#34;).on(\u0026#34;click\u0026#34;, function(){ $(\u0026#34;#output\u0026#34;).val($(this).html()); }); $(\u0026#34;#search\u0026#34;).focusout(function(){ window.setTimeout(function() { $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;none\u0026#39;); }, 500); }); $(\u0026#34;#search\u0026#34;).focusin(function(){ $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;block\u0026#39;); }); } }); } else { $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;none\u0026#39;); } }); }); \u0026lt;/script\u0026gt; \u0026lt;div class=\u0026#34;form-row\u0026#34;\u0026gt; \u0026lt;div class=\u0026#34;col\u0026#34;\u0026gt; \u0026lt;input autocomplete=\u0026#34;off\u0026#34; class=\u0026#34;form-control form-control-success\u0026#34; id=\u0026#34;search\u0026#34; name=\u0026#34;search\u0026#34; placeholder=\u0026#34;Search here....\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;div id=\u0026#34;output\u0026#34;\u0026gt;\u0026lt;/div\u0026gt; Here’s the links-ajax.php which display the search results with links.\n\u0026lt;?php $servername=\u0026#39;localhost\u0026#39;; $username=\u0026#39;\u0026#39;; $password=\u0026#39;\u0026#39;; $dbname = \u0026#34;\u0026#34;; $conn=mysqli_connect($servername,$username,$password,\u0026#34;$dbname\u0026#34;); if(!$conn) { die(\u0026#39;Could not Connect MySql Server:\u0026#39; .mysql_error()); } if (isset($_POST[\u0026#39;query\u0026#39;])) { $query = \u0026lt;\u0026lt;\u0026lt;\u0026#34;SQL SELECT * FROM links WHERE `name` LIKE \u0026#39;%{$_POST[\u0026#39;query\u0026#39;]}%\u0026#39; OR `url` LIKE \u0026#39;%{$_POST[\u0026#39;query\u0026#39;]}%\u0026#39; OR `tag` LIKE \u0026#39;%{$_POST[\u0026#39;query\u0026#39;]}%\u0026#39; ORDER BY name ASC, url ASC\u0026#34; SQL; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) ?\u0026gt; 0) { while ($user = mysqli_fetch_array($result)) { echo \u0026#34;\u0026lt;a rel=\u0026#34;noopener\u0026#34; target=\u0026#34;_blank\u0026#34;\u0026gt;\u0026#34;.$user[\u0026#39;name\u0026#39;].\u0026#34;\u0026lt;/a\u0026gt;\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#34;; } } else { echo \u0026#34;\u0026lt;p style=\u0026#34;color:red\u0026#34;\u0026gt;No results found...\u0026lt;/p\u0026gt;\u0026#34;; } } ?\u0026gt; I couldn’t get the links working, until I added the 500ms of timeout in .focusout.\n","permalink":"http://uly.me/posts/ajax-live-search/","summary":"\u003cp\u003eJust implemented an Ajax live search on a website.\u003c/p\u003e\n\u003cp\u003eHere’s the search page. Results are displayed in div output.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;script src=\u0026#34;https://code.jquery.com/jquery-3.4.1.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;\n\u0026lt;script type=\u0026#34;text/javascript\u0026#34;\u0026gt;\n$(document).ready(function(){\n    $(\u0026#34;#search\u0026#34;).keyup(function(){\n        var query = $(this).val();\n        if (query != \u0026#34;\u0026#34;) {\n        $.ajax({\n            url: \u0026#39;links-ajax.php\u0026#39;,\n            method: \u0026#39;POST\u0026#39;,\n            data: {query:query},\n            success: function(data){\n            $(\u0026#39;#output\u0026#39;).html(data);\n            $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;block\u0026#39;);\n            $(\u0026#34;#output a\u0026#34;).on(\u0026#34;click\u0026#34;, function(){\n                $(\u0026#34;#output\u0026#34;).val($(this).html());\n            });\n            $(\u0026#34;#search\u0026#34;).focusout(function(){\n                window.setTimeout(function() {\n                $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;none\u0026#39;);\n                }, 500);\n            });\n            $(\u0026#34;#search\u0026#34;).focusin(function(){\n                $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;block\u0026#39;);\n            });\n            }\n        });\n        } else {\n        $(\u0026#39;#output\u0026#39;).css(\u0026#39;display\u0026#39;, \u0026#39;none\u0026#39;);\n    }\n    });\n});\n\u0026lt;/script\u0026gt;\n\n\u0026lt;div class=\u0026#34;form-row\u0026#34;\u0026gt;\n    \u0026lt;div class=\u0026#34;col\u0026#34;\u0026gt;\n        \u0026lt;input autocomplete=\u0026#34;off\u0026#34; class=\u0026#34;form-control form-control-success\u0026#34; id=\u0026#34;search\u0026#34; name=\u0026#34;search\u0026#34; placeholder=\u0026#34;Search here....\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\n    \u0026lt;/div\u0026gt;\n\u0026lt;/div\u0026gt;\n\u0026lt;div id=\u0026#34;output\u0026#34;\u0026gt;\u0026lt;/div\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the links-ajax.php which display the search results with links.\u003c/p\u003e","title":"ajax live search"},{"content":"Here’s a quick way to start a web server using Python (not recommended for production).\nIf you want to use python3, you may have to use explicitly use python3.\nCheck what versions you have first.\npython --version python3 --version Start web server using port 8080 in the current directory.\npython -m http.server 8080 If you want an alternate directory, use this -d option.\npython -m http.server 8080 -d /tmp It’s a great tool for quick downloads.\n","permalink":"http://uly.me/posts/python-web-server/","summary":"\u003cp\u003eHere’s a quick way to start a web server using Python (not recommended for production).\u003c/p\u003e\n\u003cp\u003eIf you want to use python3, you may have to use explicitly use python3.\u003c/p\u003e\n\u003cp\u003eCheck what versions you have first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython --version\npython3 --version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart web server using port 8080 in the current directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython -m http.server 8080\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want an alternate directory, use this -d option.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython -m http.server 8080 -d /tmp\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s a great tool for quick downloads.\u003c/p\u003e","title":"python web server"},{"content":"How to find a boot disk from an instance.\ngcloud compute instances describe servername \\ --format=\u0026#39;get(disks[0].source)\u0026#39; \\ --zone=us-central1-c \\ --project project-id Result\nhttps://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot ","permalink":"http://uly.me/posts/gcp-find-instance-boot-disk/","summary":"\u003cp\u003eHow to find a boot disk from an instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances describe servername \\\n--format=\u0026#39;get(disks[0].source)\u0026#39; \\\n--zone=us-central1-c \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehttps://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp find instance boot disk"},{"content":"Install\nbrew install p7zip Extract\n7z x file.7z Compress\n7z a file.7z mydirectory ","permalink":"http://uly.me/posts/7zip-in-mac-os/","summary":"\u003cp\u003eInstall\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebrew install p7zip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExtract\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e7z x file.7z\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCompress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e7z a file.7z mydirectory\n\u003c/code\u003e\u003c/pre\u003e","title":"7zip in mac os"},{"content":"Here’s the script to backup GCP disks.\n#!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter=\u0026#34;users:instance\u0026#34; --format=\u0026#34;value(name)\u0026#34;) for disk in $disks do gcloud compute disks snapshot $disk \\ --snapshot-names=$disk-$now \\ --zone=us-central1-a \\ --project=project-id \\ --async done ","permalink":"http://uly.me/posts/gcp-backup-instance/","summary":"\u003cp\u003eHere’s the script to backup GCP disks.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nnow=$(date +%s)\ndisks=$(gcloud compute disks list --project project-id --filter=\u0026#34;users:instance\u0026#34; --format=\u0026#34;value(name)\u0026#34;)\nfor disk in $disks\ndo\n  gcloud compute disks snapshot $disk \\\n  --snapshot-names=$disk-$now \\\n  --zone=us-central1-a \\\n  --project=project-id \\\n  --async\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp backup instance"},{"content":"If you have a file with @ sign at end, this is how to remove extended attributes on the Mac OS.\nExample.\nls -l -rwxr-xr-x@ 4 username staff 128 Mar 24 10:51 sample.txt Remove extended attributes.\nxattr -c sample.txt Result\nls -l -rwxr-xr-x 4 username staff 128 Mar 24 10:51 sample.txt ","permalink":"http://uly.me/posts/remove-extended-attributes-on-mac/","summary":"\u003cp\u003eIf you have a file with @ sign at end, this is how to remove extended attributes on the Mac OS.\u003c/p\u003e\n\u003cp\u003eExample.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003els -l\n-rwxr-xr-x@  4 username  staff   128 Mar 24 10:51 sample.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove extended attributes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003exattr -c sample.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003els -l\n-rwxr-xr-x  4 username  staff   128 Mar 24 10:51 sample.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"remove extended attributes on mac"},{"content":"How to do search and replace in Vim.\nSearch for “foo” and replace it with “bar” in the current line. Use :s\n:s/foo/bar/g Search for “foo” and replace it with “bar” in the entire document. Use :%s\n:%s/foo/bar/g You can also pipe instead of forward slash. Useful if your search contains a /.\n:%s|foo/|bar|g ","permalink":"http://uly.me/posts/vi-search-and-replace/","summary":"\u003cp\u003eHow to do search and replace in Vim.\u003c/p\u003e\n\u003cp\u003eSearch for “foo” and replace it with “bar” in the current line. Use :s\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e:s/foo/bar/g\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSearch for “foo” and replace it with “bar” in the entire document. Use :%s\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e:%s/foo/bar/g\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also pipe instead of forward slash. Useful if your search contains a /.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e:%s|foo/|bar|g\n\u003c/code\u003e\u003c/pre\u003e","title":"vi search and replace"},{"content":"In Redhat 8, every time you the Network Manager get’s restarted it overwrites /etc/resolv.conf. To prevent that from hapenning, create a new file called /etc/NetworkManager/conf.d/90-dns-none.conf and add the following lines. Restart Network Manager. Your /etc/resolv.conf should be unchanged.\n[main] dns=none Restart Network Manager\n$ systemctl reload NetworkManager ","permalink":"http://uly.me/posts/redhat-8-network-manager/","summary":"\u003cp\u003eIn Redhat 8, every time you the Network Manager get’s restarted it overwrites /etc/resolv.conf. To prevent that from hapenning, create a new file called /etc/NetworkManager/conf.d/90-dns-none.conf and add the following lines. Restart Network Manager. Your /etc/resolv.conf should be unchanged.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[main]\ndns=none\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart Network Manager\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ systemctl reload NetworkManager\n\u003c/code\u003e\u003c/pre\u003e","title":"redhat 8 network manager"},{"content":"Here’s how to get your project quotas in GCP.\ngcloud compute project-info describe --project your-project-id ","permalink":"http://uly.me/posts/gcp-project-quotas/","summary":"\u003cp\u003eHere’s how to get your project quotas in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute project-info describe --project your-project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp project quotas"},{"content":"Here’s how to get Regional Quotas for your project in GCP.\ngcloud compute regions describe us-central1 --project your-project-id ","permalink":"http://uly.me/posts/gcp-regional-quotas/","summary":"\u003cp\u003eHere’s how to get Regional Quotas for your project in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute regions describe us-central1 --project your-project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp regional quotas"},{"content":"Here’s how to check if port is listening on a Windows Server.\nLog in to the destination server.\nnetstat -ano | find \u0026#34;443\u0026#34; | find \u0026#34;LISTEN\u0026#34; tasklist /fi \u0026#34;PID eq \u0026#34;443\u0026#34; ","permalink":"http://uly.me/posts/windows-check-if-port-is-listening/","summary":"\u003cp\u003eHere’s how to check if port is listening on a Windows Server.\u003c/p\u003e\n\u003cp\u003eLog in to the destination server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enetstat -ano | find \u0026#34;443\u0026#34; | find \u0026#34;LISTEN\u0026#34;\ntasklist /fi \u0026#34;PID eq \u0026#34;443\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"windows check if port is listening"},{"content":"How to reformat numbers in Bash.\n$ n=1023555 $ m=$(numfmt --to=si n) $ echo $m 1.1M Other options\n--to=none # no scaling. Output: 1023555 --to=si # International System of Units (SI) standard. Output 1.1M --to=iec # International Electrotechnical Commission (IEC) standard. Output: 1.1Mi --to=iec-i # International Electrotechnical Commission (IEC) standard. Output: 1.1M --to=auto # ‘auto’ can only be used with --from. fmtnum\n","permalink":"http://uly.me/posts/bash-reformat-numbers/","summary":"\u003cp\u003eHow to reformat numbers in Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ n=1023555\n$ m=$(numfmt --to=si n)\n$ echo $m\n1.1M\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOther options\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e--to=none     # no scaling. Output: 1023555\n--to=si       # International System of Units (SI) standard. Output 1.1M\n--to=iec      # International Electrotechnical Commission (IEC) standard. Output: 1.1Mi \n--to=iec-i    # International Electrotechnical Commission (IEC) standard. Output: 1.1M\n--to=auto     # ‘auto’ can only be used with --from.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e\u003ca href=\"http://www.gnu.org/software/coreutils/manual/html_node/numfmt-invocation.html\"\u003efmtnum\u003c/a\u003e\u003c/p\u003e","title":"bash reformat numbers"},{"content":"How to list S3 objects using Python Boto3\nimport boto3 from sys import argv bucket=argv[1] s3 = boto3.resource(\u0026#39;s3\u0026#39;) mybucket = s3.Bucket(bucket) def list_buckets(): print(\u0026#34;List of Buckets: \u0026#34;) for bucket in s3.buckets.all(): print(bucket.name) def list_files(): print(\u0026#34;Buckets: The objects in the \\\u0026#34;\u0026#34; + bucket + \u0026#34;\\\u0026#34; buckets are ... \u0026#34;) for files in mybucket.objects.all(): print(files.key) def main(): #list_buckets() list_files() if __name__ == \u0026#34;__main__\u0026#34;: main() Running command\n$ python test.py bucket-name # with python $ ./test.py bucket-name # without python Results\nBuckets: The objects in the \u0026#34;bucket-name\u0026#34; are .... abc.txt def.txt ","permalink":"http://uly.me/posts/python-boto3-s3-list-objects/","summary":"\u003cp\u003eHow to list S3 objects using Python Boto3\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport boto3\nfrom sys import argv\nbucket=argv[1]\ns3 = boto3.resource(\u0026#39;s3\u0026#39;)\nmybucket = s3.Bucket(bucket)\ndef list_buckets():\n    print(\u0026#34;List of Buckets: \u0026#34;)\n    for bucket in s3.buckets.all():\n        print(bucket.name)\ndef list_files():\n    print(\u0026#34;Buckets: The objects in the \\\u0026#34;\u0026#34; + bucket + \u0026#34;\\\u0026#34; buckets are ... \u0026#34;)\n    for files in mybucket.objects.all():\n        print(files.key)\ndef main():\n    #list_buckets()\n    list_files()\nif __name__ == \u0026#34;__main__\u0026#34;:\n    main()\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRunning command\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ python test.py bucket-name    # with python\n$ ./test.py bucket-name         # without python\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResults\u003c/p\u003e","title":"python boto3 s3 list objects"},{"content":"How to create a Python virtual environment.\nOn Windows\n$ pip install venv $ python3 -m venv ~/python-test On Ubuntu\n$ sudo apt install python3.8-venv $ python3 -m venv ~/python-test On Mac OS\n$ brew install virtualenv $ virtualenv python-test Activate\n$ cd ~/python-test $ source bin/activate Deactivate\n$ deactivate ","permalink":"http://uly.me/posts/python-virtual-environment/","summary":"\u003cp\u003eHow to create a Python virtual environment.\u003c/p\u003e\n\u003cp\u003eOn Windows\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ pip install venv\n$ python3 -m venv ~/python-test\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOn Ubuntu\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo apt install python3.8-venv\n$ python3 -m venv ~/python-test\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOn Mac OS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ brew install virtualenv\n$ virtualenv python-test\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eActivate\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cd ~/python-test\n$ source bin/activate\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDeactivate\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ deactivate\n\u003c/code\u003e\u003c/pre\u003e","title":"python virtual environment"},{"content":"You can monitor the success or failure of a service account in GCP.\ngcloud policy-intelligence query-activity \\ --activity-type=ACTIVITY_TYPE \\ --project=PROJECT_ID \\ --limit=LIMIT The two options you can use for ACTIVITY_TYPE are:\nserviceAccountKeyLastAuthentication serviceAccountLastAuthentication ","permalink":"http://uly.me/posts/gcp-monitor-service-account/","summary":"\u003cp\u003eYou can monitor the success or failure of a service account in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud policy-intelligence query-activity \\\n--activity-type=ACTIVITY_TYPE \\ \n--project=PROJECT_ID \\\n--limit=LIMIT\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe two options you can use for ACTIVITY_TYPE are:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eserviceAccountKeyLastAuthentication\u003c/li\u003e\n\u003cli\u003eserviceAccountLastAuthentication\u003c/li\u003e\n\u003c/ul\u003e","title":"gcp monitor service account"},{"content":"Occasionally I was getting this random error when running Terraform.\n╷ │ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found. │ │ Please see https://registry.terraform.io/providers/hashicorp/aws │ for more information about providing credentials. │ │ Error: RequestError: send request failed │ caused by: Post \u0026#34;https://sts.amazonaws.com/\u0026#34;: read tcp xx.xx.xx.xx:59422-\u0026gt;xx.xx.xx.xx:443: read: connection reset by peer │ │ │ with provider[\u0026#34;registry.terraform.io/hashicorp/aws\u0026#34;], │ on main.tf line 10, in provider \u0026#34;aws\u0026#34;: │ 10: provider \u0026#34;aws\u0026#34; { Here’s the fix. Place this in your ~/.bash_profile.\nexport AWS_SDK_LOAD_CONFIG=1 This forces Terraform to use both config and credentials file.\n","permalink":"http://uly.me/posts/aws-sdk-load-config/","summary":"\u003cp\u003eOccasionally I was getting this random error when running Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e╷\n│ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.\n│ \n│ Please see https://registry.terraform.io/providers/hashicorp/aws\n│ for more information about providing credentials.\n│ \n│ Error: RequestError: send request failed\n│ caused by: Post \u0026#34;https://sts.amazonaws.com/\u0026#34;: read tcp xx.xx.xx.xx:59422-\u0026gt;xx.xx.xx.xx:443: read: connection reset by peer\n│ \n│ \n│   with provider[\u0026#34;registry.terraform.io/hashicorp/aws\u0026#34;],\n│   on main.tf line 10, in provider \u0026#34;aws\u0026#34;:\n│   10: provider \u0026#34;aws\u0026#34; {\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the fix. Place this in your ~/.bash_profile.\u003c/p\u003e","title":"aws sdk load config"},{"content":"Instead of the GCP Console, you can reset Windows Server password via gcloud.\ngcloud compute reset-windows-password server-name \\ --zone us-central1-a \\ --project project-id Username and password will generated.\n","permalink":"http://uly.me/posts/gcp-windows-password-reset/","summary":"\u003cp\u003eInstead of the GCP Console, you can reset Windows Server password via gcloud.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute reset-windows-password server-name \\\n--zone us-central1-a \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUsername and password will generated.\u003c/p\u003e","title":"gcp windows password reset"},{"content":"I’m having trouble logging in using Google SDK Compute SSH on a Mac Terminal.\nHere’s the fix.\ngcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2\u0026gt;\u0026amp;1 There was an issue with a redirect to another shell.\n","permalink":"http://uly.me/posts/google-sdk-ssh-mac-terminal/","summary":"\u003cp\u003eI’m having trouble logging in using Google SDK Compute SSH on a Mac Terminal.\u003c/p\u003e\n\u003cp\u003eHere’s the fix.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2\u0026gt;\u0026amp;1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere was an issue with a redirect to another shell.\u003c/p\u003e","title":"google sdk ssh mac terminal"},{"content":"Use Saml2Aws CLI as an alternative to SAML to AWS STS Key Conversion.\nInstall on Mac.\nbrew install saml2aws saml2aws --version Configure. Provide information.\nsaml2aws configure It will create a ~/.saml2aws config file. Set session to 8 hours.\naws_session_duration = 28800 Login.\nsaml2aws login After authentication and/or MFA, your ~/.aws/credentials will be updated.\n","permalink":"http://uly.me/posts/saml2aws/","summary":"\u003cp\u003eUse Saml2Aws CLI as an alternative to SAML to AWS STS Key Conversion.\u003c/p\u003e\n\u003cp\u003eInstall on Mac.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebrew install saml2aws\nsaml2aws --version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eConfigure. Provide information.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esaml2aws configure\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt will create a ~/.saml2aws config file. Set session to 8 hours.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws_session_duration    = 28800\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esaml2aws login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAfter authentication and/or MFA, your ~/.aws/credentials will be updated.\u003c/p\u003e","title":"saml2aws"},{"content":"How to add startup and shutdown scripts on GCP Compute Engine.\nStartup Script\ngcloud compute instances add-metadata servername \\ --project project-id \\ --zone us-central1-c \\ --metadata=startup-script=\u0026#39;#! /bin/bash sudo -i echo \u0026#34;Time: $(date)\u0026#34; \u0026gt;\u0026gt; /tmp/date.txt\u0026#39; Shutdown Script\ngcloud compute instances add-metadata servername \\ --project project-id \\ --zone us-central1-c \\ --metadata=shutdown-script=\u0026#39;#! /bin/bash # Shuts down Apache server /etc/init.d/apache2 stop\u0026#39; ","permalink":"http://uly.me/posts/gcp-compute-startup-script/","summary":"\u003cp\u003eHow to add startup and shutdown scripts on GCP Compute Engine.\u003c/p\u003e\n\u003cp\u003eStartup Script\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata servername \\\n--project project-id \\\n--zone us-central1-c \\\n--metadata=startup-script=\u0026#39;#! /bin/bash\nsudo -i\necho \u0026#34;Time: $(date)\u0026#34; \u0026gt;\u0026gt; /tmp/date.txt\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eShutdown Script\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata servername \\\n--project project-id \\\n--zone us-central1-c \\\n--metadata=shutdown-script=\u0026#39;#! /bin/bash\n# Shuts down Apache server\n/etc/init.d/apache2 stop\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp compute startup script"},{"content":"Reset uncommitted changes to both files and directories.\ngit reset --hard Remove untracked files and directories.\ngit clean -fd ","permalink":"http://uly.me/posts/git-reset-hard/","summary":"\u003cp\u003eReset uncommitted changes to both files and directories.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit reset --hard\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove untracked files and directories.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit clean -fd\n\u003c/code\u003e\u003c/pre\u003e","title":"git reset hard"},{"content":"Here’s the command to display only the current directory.\nexport PROMPT_DIRTRIM=1 Place the command in your ~/.bashrc to make it permanent.\n","permalink":"http://uly.me/posts/linux-prompt-display-current-directory-only/","summary":"\u003cp\u003eHere’s the command to display only the current directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport PROMPT_DIRTRIM=1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePlace the command in your ~/.bashrc to make it permanent.\u003c/p\u003e","title":"linux prompt display current directory only"},{"content":"Every time I log in to Google Cloud, it’s using the Chromium.\nSet BROWSER env to Firefox instead.\nexport BROWSER=/usr/bin/firefox Login to GCP. It should open up Firefox browser instead of Chromium.\ngcloud auth login Add it your .bashrc or .bashprofile if you want it to be permanent.\n","permalink":"http://uly.me/posts/set-terminal-browser-to-firefox/","summary":"\u003cp\u003eEvery time I log in to Google Cloud, it’s using the Chromium.\u003c/p\u003e\n\u003cp\u003eSet BROWSER env to Firefox instead.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport BROWSER=/usr/bin/firefox\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin to GCP. It should open up Firefox browser instead of Chromium.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd it your .bashrc or .bashprofile if you want it to be permanent.\u003c/p\u003e","title":"set terminal browser to firefox"},{"content":"Here are command lines you can within SFTP.\nLogin.\nsftp username@servername Commands available from the local client.\nlls lcd lmkdir lpwd lumask Commands available on remote server.\ncd chmod chown exit get help ln ls mkdir put pwd rename rm rmdir version ! ","permalink":"http://uly.me/posts/sftp-command-line/","summary":"\u003cp\u003eHere are command lines you can within SFTP.\u003c/p\u003e\n\u003cp\u003eLogin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esftp username@servername\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCommands available from the local client.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ells\nlcd\nlmkdir\nlpwd\nlumask\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCommands available on remote server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd\nchmod\nchown\nexit\nget\nhelp\nln\nls\nmkdir\nput\npwd\nrename\nrm\nrmdir\nversion\n!\n\u003c/code\u003e\u003c/pre\u003e","title":"sftp command line"},{"content":"How to extend a LVM logical volume.\nExtend the physical drive.\ngcloud compute disks resize data-drive --size=40GB SSH to a server and extend the physical volume.\n$ pvresize /dev/sdb Physical volume \u0026#34;/dev/sdb\u0026#34; changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized $ pvs PV VG Fmt Attr PSize PFree /dev/sdb vg lvm2 a-- $ vgs VG #PV #LV #SN Attr VSize VFree vg 1 1 0 wz--n- $ lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert data vg -wi-ao---- Extend the logical volume.\n$ lvresize -l +100%FREE /dev/vg/data Size of logical volume vg/data changed from\nCheck the volume size.\n$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi └─sda2 8:2 0 19.8G 0 part / sdb 8:16 0 40G 0 disk └─vg-data 253:0 0 40G 0 lvm /mnt Still at 30GB.\n$ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 385M 0 385M 0% /dev tmpfs tmpfs 403M 0 403M 0% /dev/shm tmpfs tmpfs 403M 5.5M 398M 2% /run tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup /dev/sda2 xfs 20G 2.9G 17G 15% / /dev/sda1 vfat 200M 5.8M 195M 3% /boot/efi /dev/mapper/vg-data xfs 30G 247M 30G 1% /mnt tmpfs tmpfs 81M 0 81M 0% /run/user/1001 Extend the file system.\n$ xfs_growfs /dev/vg/data meta-data=/dev/mapper/vg-data isize=512 agcount=12, agsize=655360 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=7863296, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 7863296 to 10484736 Let\u0026rsquo;s check again.\n$ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 385M 0 385M 0% /dev tmpfs tmpfs 403M 0 403M 0% /dev/shm tmpfs tmpfs 403M 5.5M 398M 2% /run tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup /dev/sda2 xfs 20G 2.9G 17G 15% / /dev/sda1 vfat 200M 5.8M 195M 3% /boot/efi /dev/mapper/vg-data xfs 40G 319M 40G 1% /mnt tmpfs tmpfs 81M 0 81M 0% /run/user/1001 The logical volume is now at 40GB.\n","permalink":"http://uly.me/posts/extend-lvm-logical-volume/","summary":"\u003cp\u003eHow to extend a LVM logical volume.\u003c/p\u003e\n\u003cp\u003eExtend the physical drive.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks resize data-drive --size=40GB\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSSH to a server and extend the physical volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ pvresize /dev/sdb\n  Physical volume \u0026#34;/dev/sdb\u0026#34; changed\n  1 physical volume(s) resized or updated / 0 physical volume(s) not resized\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ pvs\n  PV         VG Fmt  Attr PSize   PFree \n  /dev/sdb   vg lvm2 a--  \n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ vgs\n  VG #PV #LV #SN Attr   VSize   VFree \n  vg   1   1   0 wz--n- \n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ lvs\n  LV   VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  data vg -wi-ao---- \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExtend the logical volume.\u003c/p\u003e","title":"extend lvm logical volume"},{"content":"How to setup Logical Volume Manager on a VM.\nInstall LVM.\nyum install lvm2 Check the disks available. We are going to run LVM on /dev/sdb.\n$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi └─sda2 8:2 0 19.8G 0 part / sdb 8:16 0 20G 0 disk Create a physical volume on /dev/sdb.\n$ pvcreate /dev/sdb Physical volume \u0026#34;/dev/sdb\u0026#34; successfully created. $ pvs PV VG Fmt Attr PSize PFree /dev/sdb vg lvm2 a-- Create a volume group called vg.\n$ vgcreate vg /dev/sdb Volume group \u0026#34;vg\u0026#34; successfully created $ vgs VG #PV #LV #SN Attr VSize VFree vg 1 0 0 wz--n- Create a 10GB logical volume group called data.\n$ lvcreate -L 10G -n data vg Logical volume \u0026#34;data\u0026#34; created. $ lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert data vg -wi-a----- 10.00g Format the volume group and mount it.\n$ mkfs.xfs /dev/vg/data meta-data=/dev/vg/data isize=512 agcount=4, agsize=655360 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 Discarding blocks...Done. $ mount /dev/vg/data /mnt Check your logical volume. It says 10GB.\n$ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 385M 0 385M 0% /dev tmpfs tmpfs 403M 0 403M 0% /dev/shm tmpfs tmpfs 403M 5.5M 398M 2% /run tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup /dev/sda2 xfs 20G 2.9G 17G 15% / /dev/sda1 vfat 200M 5.8M 195M 3% /boot/efi tmpfs tmpfs 81M 0 81M 0% /run/user/1000 /dev/mapper/vg-data xfs 10G 104M 9.9G 2% /mnt Let\u0026rsquo;s now extend the logical volume to 20GB.\n$ lvextend -l +100%FREE /dev/vg/data Size of logical volume vg/data changed from 10.00 GiB (2560 extents) to Although lsblk says 20GB, our logical volume still says 10GB\n$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi └─sda2 8:2 0 19.8G 0 part / sdb 8:16 0 20G 0 disk └─vg-data 253:0 0 20G 0 lvm /mnt $ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 385M 0 385M 0% /dev tmpfs tmpfs 403M 0 403M 0% /dev/shm tmpfs tmpfs 403M 5.5M 398M 2% /run tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup /dev/sda2 xfs 20G 2.9G 17G 15% / /dev/sda1 vfat 200M 5.8M 195M 3% /boot/efi tmpfs tmpfs 81M 0 81M 0% /run/user/1000 /dev/mapper/vg-data xfs 10G 104M 9.9G 2% /mnt We need to grow the file system.\n$ xfs_growfs /dev/vg/data meta-data=/dev/mapper/vg-data isize=512 agcount=4, agsize=655360 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 2621440 to 5241856 Let\u0026rsquo;s check again.\n$ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 385M 0 385M 0% /dev tmpfs tmpfs 403M 0 403M 0% /dev/shm tmpfs tmpfs 403M 5.5M 398M 2% /run tmpfs tmpfs 403M 0 403M 0% /sys/fs/cgroup /dev/sda2 xfs 20G 2.9G 17G 15% / /dev/sda1 vfat 200M 5.8M 195M 3% /boot/efi tmpfs tmpfs 81M 0 81M 0% /run/user/1000 /dev/mapper/vg-data xfs 20G 176M 20G 1% /mnt It now says 20GB.\n","permalink":"http://uly.me/posts/setup-lvm-on-a-vm/","summary":"\u003cp\u003eHow to setup Logical Volume Manager on a VM.\u003c/p\u003e\n\u003cp\u003eInstall LVM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install lvm2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck the disks available. We are going to run LVM on /dev/sdb.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ lsblk\nNAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nsda      8:0    0   20G  0 disk \n├─sda1   8:1    0  200M  0 part /boot/efi\n└─sda2   8:2    0 19.8G  0 part /\nsdb      8:16   0   20G  0 disk\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a physical volume on /dev/sdb.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ pvcreate /dev/sdb\n  Physical volume \u0026#34;/dev/sdb\u0026#34; successfully created.\n$ pvs\n  PV         VG Fmt  Attr PSize   PFree\n  /dev/sdb   vg lvm2 a--  \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a volume group called vg.\u003c/p\u003e","title":"setup lvm on a vm"},{"content":"How to reset password of a GCP Compute Engine running on Windows OS.\ngcloud compute reset-windows-password servername \\ --zone us-central1-a \\ --project your-project-id Output\nThis command creates an account and sets an initial password for the user [firstname_lastname] if the account does not already exist. If the account already exists, resetting the password can cause the LOSS OF ENCRYPTED DATA secured with the current password, including files and stored passwords. For more information, see: https://cloud.google.com/compute/docs/operating-systems/windows#reset Would you like to set or reset the password for [firstname_lastname] (Y/n)? y Resetting and retrieving password for [firstname_lastname] on [servername] Updated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/servername]. WARNING: Instance [servername] does not appear to have an external IP address, so it will not be able to accept external connections. To add an external IP address to the instance, use gcloud compute instances add-access-config. password: xxxxxxxxxxxxxxx username: firstname_lastname ","permalink":"http://uly.me/posts/gcp-reset-windows-password/","summary":"\u003cp\u003eHow to reset password of a GCP Compute Engine running on Windows OS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute reset-windows-password servername \\\n--zone us-central1-a \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eThis command creates an account and sets an initial password for the\nuser [firstname_lastname] if the account does not already exist.\nIf the account already exists, resetting the password can cause the\nLOSS OF ENCRYPTED DATA secured with the current password, including\nfiles and stored passwords.\n\nFor more information, see:\nhttps://cloud.google.com/compute/docs/operating-systems/windows#reset\n\nWould you like to set or reset the password for [firstname_lastname]\n(Y/n)?  y\n\nResetting and retrieving password for [firstname_lastname] on [servername]\nUpdated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/servername].\nWARNING: Instance [servername] does not appear to have an external IP\naddress, so it will not be able to accept external connections.\nTo add an external IP address to the instance, use\ngcloud compute instances add-access-config.\npassword: xxxxxxxxxxxxxxx\nusername: firstname_lastname\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp reset windows password"},{"content":"How to add a second drive on GCP Compute Engine using Terraform.\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;your-project-id\u0026#34; zone = \u0026#34;us-central1-c\u0026#34; } resource \u0026#34;google_compute_disk\u0026#34; \u0026#34;data-drive\u0026#34; { name = \u0026#34;data-drive\u0026#34; type = \u0026#34;pd-standard\u0026#34; zone = \u0026#34;us-central1-c\u0026#34; size = \u0026#34;20\u0026#34; } resource \u0026#34;google_compute_attached_disk\u0026#34; \u0026#34;attach-data-drive\u0026#34; { count = 1 disk = google_compute_disk.data-drive.id instance = google_compute_instance.test.id } resource \u0026#34;google_compute_instance\u0026#34; \u0026#34;test\u0026#34; { name = \u0026#34;test\u0026#34; machine_type = \u0026#34;e2-micro\u0026#34; boot_disk { initialize_params { image = \u0026#34;rocky-linux-cloud/rocky-linux-8\u0026#34; } } scheduling { preemptible = true automatic_restart = false } network_interface { network = \u0026#34;default\u0026#34; access_config { } } } ","permalink":"http://uly.me/posts/gcp-terraform-second-drive/","summary":"\u003cp\u003eHow to add a second drive on GCP Compute Engine using Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n  project = \u0026#34;your-project-id\u0026#34;\n  zone    = \u0026#34;us-central1-c\u0026#34;\n}\n\nresource \u0026#34;google_compute_disk\u0026#34; \u0026#34;data-drive\u0026#34; {\n  name = \u0026#34;data-drive\u0026#34;\n  type = \u0026#34;pd-standard\u0026#34;\n  zone = \u0026#34;us-central1-c\u0026#34;\n  size = \u0026#34;20\u0026#34;\n}\n\nresource \u0026#34;google_compute_attached_disk\u0026#34; \u0026#34;attach-data-drive\u0026#34; {\n  count    = 1\n  disk     = google_compute_disk.data-drive.id\n  instance = google_compute_instance.test.id\n}\n\nresource \u0026#34;google_compute_instance\u0026#34; \u0026#34;test\u0026#34; {\n  name         = \u0026#34;test\u0026#34;\n  machine_type = \u0026#34;e2-micro\u0026#34;\n\n  boot_disk {\n    initialize_params {\n      image = \u0026#34;rocky-linux-cloud/rocky-linux-8\u0026#34;\n    }\n  }\n\n  scheduling {\n    preemptible       = true\n    automatic_restart = false\n  }\n  network_interface {\n    network = \u0026#34;default\u0026#34;\n    access_config {\n    }\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp terraform second drive"},{"content":"If you’re getting a “HTTP Error 404 – Not Found” error when trying to run yum update, it could be a corrupted cache. Clear the cache on the system by running the following.\nyum clean all rm -rf /var/cache/yum/* Run yum update again. The errors should be gone.\n","permalink":"http://uly.me/posts/yum-cache-corruption/","summary":"\u003cp\u003eIf you’re getting a “HTTP Error 404 – Not Found” error when trying to run yum update, it could be a corrupted cache. Clear the cache on the system by running the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum clean all\nrm -rf /var/cache/yum/*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun yum update again. The errors should be gone.\u003c/p\u003e","title":"yum cache corruption"},{"content":"How to add a startup-script to metadata. The script executes every time VM is started.\ngcloud compute instances add-metadata instance-name \\ --project your-project-id \\ --zone us-central1-c \\ --metadata=startup-script=\u0026#39;#! /bin/bash sudo -i echo \u0026#34;Time: $(date)\u0026#34; \u0026gt;\u0026gt; /tmp/date.txt\u0026#39; ","permalink":"http://uly.me/posts/gcp-compute-add-startup-script-to-metadata/","summary":"\u003cp\u003eHow to add a startup-script to metadata. The script executes every time VM is started.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata instance-name \\\n--project your-project-id \\\n--zone us-central1-c \\\n--metadata=startup-script=\u0026#39;#! /bin/bash\nsudo -i\necho \u0026#34;Time: $(date)\u0026#34; \u0026gt;\u0026gt; /tmp/date.txt\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp compute add startup-script to metadata"},{"content":"How to create scheduled snapshots in GCP.\ngcloud compute resource-policies create snapshot-schedule hourly \\ --description \u0026#34;my hourly schedule\u0026#34; \\ --max-retention-days 7 \\ --start-time 00:00 \\ --hourly-schedule 1 \\ --region us-central1 \\ --on-source-disk-delete keep-auto-snapshots \\ --storage-location US Add snapshot schedule to a disk.\ngcloud compute disks add-resource-policies disk-name \\ --resource-policies hourly \\ --zone us-central1-a gcloud compute disks create disk-name \\ --resource-policies hourly \\ --zone us-central1-a List snapshot schedules.\ngcloud compute resource-policies list Describe snapshot schedule.\ngcloud compute resource-policies describe hourly ","permalink":"http://uly.me/posts/gcp-create-scheduled-snapshots/","summary":"\u003cp\u003eHow to create scheduled snapshots in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute resource-policies create snapshot-schedule hourly \\\n--description \u0026#34;my hourly schedule\u0026#34; \\\n--max-retention-days 7 \\\n--start-time 00:00 \\\n--hourly-schedule 1 \\\n--region us-central1 \\\n--on-source-disk-delete keep-auto-snapshots \\\n--storage-location US\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd snapshot schedule to a disk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks add-resource-policies disk-name \\\n--resource-policies hourly \\\n--zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create disk-name \\\n--resource-policies hourly \\\n--zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList snapshot schedules.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute resource-policies list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDescribe snapshot schedule.\u003c/p\u003e","title":"gcp create scheduled snapshots"},{"content":"Here’s how to update SSL certificates to AWS ELB.\nImport SSL certificate\naws acm import-certificate \\ --certificate fileb://example.crt \\ --private-key fileb://example.key \\ --certificate-chain fileb://example-bundle.crt \\ --tags Key=Name,Value=mydomain.com_20220107 \\ --profile default Add SSL to a listener.\naws elbv2 add-listener-certificates \\ --listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\ --certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\ --profile default Modify listener. Set SSL certificate as default.\naws elbv2 modify-listener \\ --listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\ --certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\ --profile default Remove SSL from a listener.\naws elbv2 remove-listener-certificates \\ --listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\ --certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\ --profile default ","permalink":"http://uly.me/posts/aws-elb-ssl-listener/","summary":"\u003cp\u003eHere’s how to update SSL certificates to AWS ELB.\u003c/p\u003e\n\u003cp\u003eImport SSL certificate\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm import-certificate \\\n--certificate fileb://example.crt \\\n--private-key fileb://example.key \\\n--certificate-chain fileb://example-bundle.crt \\\n--tags Key=Name,Value=mydomain.com_20220107 \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd SSL to a listener.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elbv2 add-listener-certificates \\\n--listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\\n--certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eModify listener. Set SSL certificate as default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elbv2 modify-listener \\\n--listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\\n--certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove SSL from a listener.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elbv2 remove-listener-certificates \\\n--listener-arn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxxxxxxx:listener/app/elbname/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx \\\n--certificates CertificateArn=arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e","title":"aws elb ssl listener"},{"content":"Here’s how to download/upload files using gcloud compute scp.\nMake sure you are authenticated.\ngcloud auth login How to download.\ngcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \\ --project your-project-id \\ --zone us-central1-a \\ --internal-ip How to upload.\ngcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \\ --project your-project-id \\ --zone us-central1-a \\ --internal-ip ","permalink":"http://uly.me/posts/gcp-gcloud-compute-scp/","summary":"\u003cp\u003eHere’s how to download/upload files using gcloud compute scp.\u003c/p\u003e\n\u003cp\u003eMake sure you are authenticated.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to download.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \\\n--project your-project-id \\\n--zone us-central1-a \\\n--internal-ip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to upload.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \\\n--project your-project-id \\\n--zone us-central1-a \\\n--internal-ip\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp gcloud compute scp"},{"content":"How to create a local repo in Rocky Linux 8.\nInstall nginx. Enable service.\ndnf install nginx systemctl enable nginx --now systemctl status nginx Create repo.\ndnf repolist dnf install createrepo yum-utils mkdir /usr/share/nginx/html/repos mkdir -p /usr/share/nginx/html/repos/{baseos,appstream} Sync repos.\ndnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata createrepo /usr/share/nginx/html/repos/baseos/ createrepo /usr/share/nginx/html/repos/appstream/ Create cron to sync repos daily. Create file called /etc/cron.daily/update-localrepos\n#!/bin/bash /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata /bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata /usr/bin/createrepo /usr/share/nginx/html/repos/baseos/ /usr/bin/createrepo /usr/share/nginx/html/repos/appstream/ Create a file called /etc/nginx/conf.d/repos.conf.\nserver { listen 80; server_name reposerver.example.com; root /usr/share/nginx/html/repos; index index.html; location / { autoindex on; } } Restart nginx.\nsystemctl restart nginx Configure firewall and SELinux.\nfirewall-cmd --zone=public --permanent --add-service=http firewall-cmd --reload getenforce chcon -Rt httpd_sys_content_t /usr/share/nginx/html/repos/ Move existing repos to /tmp.\nmv /etc/yum.repos.d/*.repo /tmp/ Create a new repo called /etc/yum.repos.d/localrepo.repo\n[localrepo-base] name=RockyLinux Base baseurl=http://reposerver.example.com/baseos/ gpgcheck=0 enabled=1 [localrepo-appstream] name=RockyLinux Base baseurl=http://reposerver.example.com/appstream/ gpgcheck=0 enabled=1 Clean cache and check repolist.\ndnf clean all dnf repolist Edit /etc/hosts and add reposerver.example.com. Add it to other hosts.\necho \u0026#34;10.10.10.10 reposerver.example.com reposerver\u0026#34; \u0026gt;\u0026gt; /etc/hosts Finally, run yum install against the local repo. Installing lvm in this example.\nyum install lvm2 ","permalink":"http://uly.me/posts/create-local-repo-in-rocky-linux-8/","summary":"\u003cp\u003eHow to create a local repo in Rocky Linux 8.\u003c/p\u003e\n\u003cp\u003eInstall nginx. Enable service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ednf install nginx\nsystemctl enable nginx --now\nsystemctl status nginx\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate repo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ednf repolist\ndnf install createrepo yum-utils\nmkdir /usr/share/nginx/html/repos\nmkdir -p /usr/share/nginx/html/repos/{baseos,appstream}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSync repos.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ednf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata\ndnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata\ncreaterepo /usr/share/nginx/html/repos/baseos/\ncreaterepo /usr/share/nginx/html/repos/appstream/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate cron to sync repos daily. Create file called /etc/cron.daily/update-localrepos\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=baseos --newest-only --download-metadata\n/bin/dnf reposync -g --delete -p /usr/share/nginx/html/repos/ --repoid=appstream --newest-only --download-metadata\n/usr/bin/createrepo /usr/share/nginx/html/repos/baseos/\n/usr/bin/createrepo /usr/share/nginx/html/repos/appstream/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a file called /etc/nginx/conf.d/repos.conf.\u003c/p\u003e","title":"create local repo in rocky linux 8"},{"content":"Here are the mount instructions for NFS and SMB drives for GCP Netapp CVS.\nNFS\nsudo yum install -y nfs-utils sudo apt-get install nfs-common sudo mkdir /condescending-sharp-hugle sudo mount -t nfs -o rw,hard,rsize=65536,wsize=65536,vers=3,tcp 10.49.253.6:/condescending-sharp-hugle /condescending-sharp-hugle SMB\nMapping your network drive 1. Click the Start button and then click on Computer. 2. Click Map Network Drive. 3. In the Drive list, click any available drive letter. 4. In the folder box, type \\\\shared.mydomain.com\\myshare. To connect every time you log on to your computer, select the Reconnect at sign-in check box. \\\\shared.mydomain.com\\myshare 5. Click Finish. ","permalink":"http://uly.me/posts/gcp-cvs-mount-instructions/","summary":"\u003cp\u003eHere are the mount instructions for NFS and SMB drives for GCP Netapp CVS.\u003c/p\u003e\n\u003cp\u003eNFS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install -y nfs-utils\nsudo apt-get install nfs-common\nsudo mkdir /condescending-sharp-hugle\nsudo mount -t nfs -o rw,hard,rsize=65536,wsize=65536,vers=3,tcp 10.49.253.6:/condescending-sharp-hugle /condescending-sharp-hugle\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSMB\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eMapping your network drive\n1. Click the Start button and then click on Computer.\n2. Click Map Network Drive.\n3. In the Drive list, click any available drive letter.\n4. In the folder box, type \\\\shared.mydomain.com\\myshare.\nTo connect every time you log on to your computer, select the Reconnect at sign-in check box.\n\\\\shared.mydomain.com\\myshare\n5. Click Finish.\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp cvs mount instructions"},{"content":"How to list all the keys of a GCP service account.\ngcloud iam service-accounts keys list \\ --iam-account=your-service-account@your-project-id.iam.gserviceaccount.com \\ --project project-id Result. Keys are redacted.\nKEY_ID CREATED_AT EXPIRES_AT DISABLED xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2022-01-10T19:21:18Z 2022-01-26T19:21:18Z xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2022-01-19T00:06:49Z 2022-02-04T00:06:49Z ","permalink":"http://uly.me/posts/gcp-list-keys-of-service-account/","summary":"\u003cp\u003eHow to list all the keys of a GCP service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud iam service-accounts keys list \\\n--iam-account=your-service-account@your-project-id.iam.gserviceaccount.com \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult. Keys are redacted.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eKEY_ID                                    CREATED_AT            EXPIRES_AT            DISABLED\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  2022-01-10T19:21:18Z  2022-01-26T19:21:18Z\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  2022-01-19T00:06:49Z  2022-02-04T00:06:49Z\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list keys of service account"},{"content":"If you have trouble cloning a github repo using https, you can tell it to switch to SSH instead.\nHere’s the command.\ngit config --global url.ssh://git@github.com/.insteadOf https://github.com/ I had to specify reconfigure when I ran terraform init.\nterraform init --reconfigure ","permalink":"http://uly.me/posts/git-switch-from-https-to-ssh/","summary":"\u003cp\u003eIf you have trouble cloning a github repo using https, you can tell it to switch to SSH instead.\u003c/p\u003e\n\u003cp\u003eHere’s the command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit config --global url.ssh://git@github.com/.insteadOf https://github.com/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI had to specify reconfigure when I ran terraform init.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform init --reconfigure\n\u003c/code\u003e\u003c/pre\u003e","title":"git switch from https to ssh"},{"content":"Allow shared key access only for one user in SSH.\nDisable the password authentication for one user in your SSH config. Edit /etc/ssh/sshd_config.\nMatch User username PasswordAuthentication no Restart the SSH service.\nservice ssh restart Copy user’s public key to the destination server’s authorized file in ~/.ssh/authorized_keys.\nssh-rsa AAAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Back on your client, login via SSH. User will not be prompted for password since public key is already authorized on server.\nssh username@server ","permalink":"http://uly.me/posts/allow-key-access-for-user-in-ssh/","summary":"\u003cp\u003eAllow shared key access only for one user in SSH.\u003c/p\u003e\n\u003cp\u003eDisable the password authentication for one user in your SSH config. Edit /etc/ssh/sshd_config.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eMatch User username\n  PasswordAuthentication no\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart the SSH service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice ssh restart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCopy user’s public key to the destination server’s authorized file in ~/.ssh/authorized_keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh-rsa AAAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBack on your client, login via SSH. User will not be prompted for password since public key is already authorized on server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh username@server\n\u003c/code\u003e\u003c/pre\u003e","title":"allow key access for user in ssh"},{"content":"Here’s the metadata URLs for both AWS and GCP.\ncurl http://169.254.169.254/computeMetadata/v1/ -H \u0026#34;Metadata-Flavor: Google\u0026#34; curl http://169.254.169.254/latest/meta-data/ ","permalink":"http://uly.me/posts/metadata-url/","summary":"\u003cp\u003eHere’s the metadata URLs for both AWS and GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl http://169.254.169.254/computeMetadata/v1/ -H \u0026#34;Metadata-Flavor: Google\u0026#34;\ncurl http://169.254.169.254/latest/meta-data/\n\u003c/code\u003e\u003c/pre\u003e","title":"metadata url"},{"content":"If you have a json file that needs formatting, you can use a built-in tool in Python.\npython -m json.tool sample.json Output will be printed on screen. You can also send the output to a file.\npython -m json.tool sample.json \u0026gt; sample2.json ","permalink":"http://uly.me/posts/json-formatter/","summary":"\u003cp\u003eIf you have a json file that needs formatting, you can use a built-in tool in Python.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython -m json.tool sample.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput will be printed on screen. You can also send the output to a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython -m json.tool sample.json \u0026gt; sample2.json\n\u003c/code\u003e\u003c/pre\u003e","title":"json formatter"},{"content":"How to add an alias in csh. Edit .cshrc file. Add an alias.\nalias hello ls -l Load.\nsource .cshrc ","permalink":"http://uly.me/posts/add-alias-in-csh/","summary":"\u003cp\u003eHow to add an alias in csh. Edit .cshrc file. Add an alias.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias hello ls -l\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLoad.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esource .cshrc\n\u003c/code\u003e\u003c/pre\u003e","title":"add alias in csh"},{"content":"How to add path in csh. Open or create .cshrc file. Add to an existing path.\nset path = ( /home/ubuntu $path ) Activate.\nsource .cshrc ","permalink":"http://uly.me/posts/adding-path-in-csh/","summary":"\u003cp\u003eHow to add path in csh. Open or create .cshrc file. Add to an existing path.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eset path = ( /home/ubuntu $path )\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eActivate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esource .cshrc\n\u003c/code\u003e\u003c/pre\u003e","title":"adding path in csh"},{"content":"Here’s how to lockdown a package to a specific version.\nSearch for the current package.\n$ sudo rpm -qa | grep sdk google-cloud-sdk-365.0.1-1.x86_64 Install versionlock.\nyum install yum-plugin-versionlock Lock a package.\nyum versionlock google-cloud-sdk-365.0.1-1.x86_64 Display all locked versions.\nyum versionlock list Unlock and clear.\nyum versionlock clear ","permalink":"http://uly.me/posts/lock-a-package-in-linux/","summary":"\u003cp\u003eHere’s how to lockdown a package to a specific version.\u003c/p\u003e\n\u003cp\u003eSearch for the current package.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo rpm -qa |  grep sdk\ngoogle-cloud-sdk-365.0.1-1.x86_64\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall versionlock.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install yum-plugin-versionlock\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLock a package.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum versionlock google-cloud-sdk-365.0.1-1.x86_64\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay all locked versions.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum versionlock list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUnlock and clear.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum versionlock clear\n\u003c/code\u003e\u003c/pre\u003e","title":"lock a package in linux"},{"content":"Find out when SSL expires from a PEM file.\n$ openssl x509 -enddate -noout -in your.cert notAfter=Jan 5 07:08:14 2032 GMT notAfter date is returned.\n","permalink":"http://uly.me/posts/ssl-pem-expiration/","summary":"\u003cp\u003eFind out when SSL expires from a PEM file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ openssl x509 -enddate -noout -in your.cert\nnotAfter=Jan  5 07:08:14 2032 GMT\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003enotAfter date is returned.\u003c/p\u003e","title":"ssl pem expiration"},{"content":"How to list SSL certificates in AWS Certificate Manager.\naws acm list-certificates Result\n{ \u0026#34;CertificateSummaryList\u0026#34;: [ { \u0026#34;CertificateArn\u0026#34;: \u0026#34;arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;, \u0026#34;DomainName\u0026#34;: \u0026#34;mydomain.com\u0026#34; } ] } Describe details about the certificate.\naws acm describe-certificate \\ --certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\ --region us-east-1 \\ --profile my-profile ","permalink":"http://uly.me/posts/aws-acm-list-certificates/","summary":"\u003cp\u003eHow to list SSL certificates in AWS Certificate Manager.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm list-certificates\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;CertificateSummaryList\u0026#34;: [\n        {\n            \u0026#34;CertificateArn\u0026#34;: \u0026#34;arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;,\n            \u0026#34;DomainName\u0026#34;: \u0026#34;mydomain.com\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDescribe details about the certificate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm describe-certificate \\\n--certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\\n--region us-east-1 \\\n--profile my-profile\n\u003c/code\u003e\u003c/pre\u003e","title":"aws acm list certificates"},{"content":"How to create AWS security groups using Terraform.\nresource \u0026#34;aws_security_group\u0026#34; \u0026#34;my-security-group\u0026#34; { name = \u0026#34;my-security-group\u0026#34; description = \u0026#34;allow ports\u0026#34; vpc_id = aws_vpc.my-vpc.id ingress { description = \u0026#34;ping\u0026#34; from_port = 0 to_port = 0 protocol = \u0026#34;-1\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } ingress { description = \u0026#34;http\u0026#34; from_port = 80 to_port = 80 protocol = \u0026#34;tcp\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } ingress { description = \u0026#34;https\u0026#34; from_port = 443 to_port = 443 protocol = \u0026#34;tcp\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } egress { from_port = 0 to_port = 0 protocol = \u0026#34;ALL\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } tags = { Name = \u0026#34;my-security-group\u0026#34; } } ","permalink":"http://uly.me/posts/aws-terraform-security-group/","summary":"\u003cp\u003eHow to create AWS security groups using Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eresource \u0026#34;aws_security_group\u0026#34; \u0026#34;my-security-group\u0026#34; {\n  name        = \u0026#34;my-security-group\u0026#34;\n  description = \u0026#34;allow ports\u0026#34;\n  vpc_id      = aws_vpc.my-vpc.id\n\n  ingress {\n    description = \u0026#34;ping\u0026#34;\n    from_port   = 0\n    to_port     = 0\n    protocol    = \u0026#34;-1\u0026#34;\n    cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  ingress {\n    description = \u0026#34;http\u0026#34;\n    from_port   = 80\n    to_port     = 80\n    protocol    = \u0026#34;tcp\u0026#34;\n    cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  ingress {\n    description = \u0026#34;https\u0026#34;\n    from_port   = 443\n    to_port     = 443\n    protocol    = \u0026#34;tcp\u0026#34;\n    cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \u0026#34;ALL\u0026#34;\n    cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  tags = {\n    Name = \u0026#34;my-security-group\u0026#34;\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws terraform security group"},{"content":"Here’s a simple way to search for a RDS instance in AWS via CLI.\naws rds describe-db-instances \\ --db-instance-identifier rds-instance-name \\ --region us-east-1 \\ --profile my-account You may have to cycle through accounts and regions to find it.\n","permalink":"http://uly.me/posts/aws-search-for-rds/","summary":"\u003cp\u003eHere’s a simple way to search for a RDS instance in AWS via CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws rds describe-db-instances \\\n--db-instance-identifier rds-instance-name \\\n--region us-east-1 \\\n--profile my-account\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may have to cycle through accounts and regions to find it.\u003c/p\u003e","title":"aws search for rds"},{"content":"How to install the latest version of the Sublime Text editor on Ubuntu or Mint.\nwget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - sudo apt-get install apt-transport-https echo \u0026#34;deb https://download.sublimetext.com/ apt/stable/\u0026#34; | sudo tee /etc/apt/sources.list.d/sublime-text.list sudo apt-get update sudo apt-get install sublime-text It will add the sublime-text.list file in /etc/apt/sources.list.d directory.\n","permalink":"http://uly.me/posts/install-latest-sublime-text/","summary":"\u003cp\u003eHow to install the latest version of the Sublime Text editor on Ubuntu or Mint.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -\nsudo apt-get install apt-transport-https\necho \u0026#34;deb https://download.sublimetext.com/ apt/stable/\u0026#34; | sudo tee /etc/apt/sources.list.d/sublime-text.list\nsudo apt-get update\nsudo apt-get install sublime-text\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt will add the sublime-text.list file in /etc/apt/sources.list.d directory.\u003c/p\u003e","title":"install latest sublime text"},{"content":"How to zip multiple files into one zip file.\nUsing zip.\nzip test.zip *.txt Using tar.\ntar cvzf test.tar.gz *.txt Untar in current directory or specify another directory.\ntar xvzf test.tar.gz . tar xvzf test.tar.gz -C /path/to/dir ","permalink":"http://uly.me/posts/zip-multiple-files-into-one-zip/","summary":"\u003cp\u003eHow to zip multiple files into one zip file.\u003c/p\u003e\n\u003cp\u003eUsing zip.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ezip test.zip *.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUsing tar.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar cvzf test.tar.gz *.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUntar in current directory or specify another directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar xvzf test.tar.gz .\ntar xvzf test.tar.gz -C /path/to/dir\n\u003c/code\u003e\u003c/pre\u003e","title":"zip multiple files into one zip"},{"content":"AWS CloudFormation to create security groups. Includes self-refencing ingress and egress rules.\nAWSTemplateFormatVersion: \u0026#39;2010-09-09\u0026#39; Description: my-security-groups ###################################### Parameters: EC2Vpc: ConstraintDescription: Must be a valid VpcId Description: Select the VPC to use Type: AWS::EC2::VPC::Id ############################################################################## Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: VPC Parameters: - EC2Vpc ############################################################################## Resources: EC2InstanceSecurityGroup1: Type: AWS::EC2::SecurityGroup Properties: VpcId: Ref: EC2Vpc GroupDescription: my-security-group-1 GroupName: my-security-group-1 SecurityGroupIngress: - {CidrIp: 10.0.0.0/8, IpProtocol: tcp, FromPort: \u0026#39;80\u0026#39;, ToPort: \u0026#39;80\u0026#39;, Description: \u0026#39;HTTP\u0026#39;} SecurityGroupEgress: - {CidrIp: 10.0.0.0/8, IpProtocol: udp, FromPort: \u0026#39;123\u0026#39;, ToPort: \u0026#39;123\u0026#39;, Description: \u0026#39;NTP\u0026#39;} - {CidrIp: 10.0.0.0/8, IpProtocol: tcp, FromPort: \u0026#39;53\u0026#39;, ToPort: \u0026#39;53\u0026#39;, Description: \u0026#39;DNS\u0026#39;} Tags: - {Key: Name, Value: \u0026#39;my-security-group-1\u0026#39;} EC2InstanceSecurityGroup2: Type: AWS::EC2::SecurityGroup Properties: VpcId: Ref: EC2Vpc GroupDescription: my-security-group-2 GroupName: my-security-group-2 SecurityGroupIngress: - {CidrIp: 0.0.0.0/0, IpProtocol: tcp, FromPort: \u0026#39;443\u0026#39;, ToPort: \u0026#39;443\u0026#39;, Description: \u0026#39;HTTP\u0026#39;} - {CidrIp: 0.0.0.0/0, IpProtocol: icmp, FromPort: \u0026#39;-1\u0026#39;, ToPort: \u0026#39;-1\u0026#39;, Description: \u0026#39;ICMP ping\u0026#39;} SecurityGroupEgress: - {CidrIp: 10.0.0.0/8, IpProtocol: udp, FromPort: \u0026#39;123\u0026#39;, ToPort: \u0026#39;123\u0026#39;, Description: \u0026#39;NTP\u0026#39;} - {CidrIp: 10.0.0.0/8, IpProtocol: tcp, FromPort: \u0026#39;53\u0026#39;, ToPort: \u0026#39;53\u0026#39;, Description: \u0026#39;DNS\u0026#39;} - {CidrIp: 0.0.0.0/0, IpProtocol: icmp, FromPort: \u0026#39;-1\u0026#39;, ToPort: \u0026#39;-1\u0026#39;, Description: \u0026#39;ICMP ping\u0026#39;} Tags: - {Key: Name, Value: \u0026#39;my-security-group-2\u0026#39;} MyIngressSelfAll: Type: AWS::EC2::SecurityGroupIngress Properties: GroupId: !Ref EC2InstanceSecurityGroup2 SourceSecurityGroupId: !GetAtt EC2InstanceSecurityGroup2.GroupId IpProtocol: -1 FromPort: 0 ToPort: 65535 MyEgressSelfAll: Type: AWS::EC2::SecurityGroupEgress Properties: GroupId: !Ref EC2InstanceSecurityGroup2 DestinationSecurityGroupId: !GetAtt EC2InstanceSecurityGroup2.GroupId IpProtocol: -1 FromPort: 0 ToPort: 65535 ############################################################################## Outputs: SecurityGroupId: Description: The Security Group that was created Value: {Ref: EC2InstanceSecurityGroup1} Value: {Ref: EC2InstanceSecurityGroup2} StackName: Description: Name of this stack for Fn::ImportValue use by children of top level stack Value: {Ref: \u0026#39;AWS::StackName\u0026#39;} ","permalink":"http://uly.me/posts/aws-cloudformation-security-group/","summary":"\u003cp\u003eAWS CloudFormation to create security groups. Includes self-refencing ingress and egress rules.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eAWSTemplateFormatVersion: \u0026#39;2010-09-09\u0026#39;\nDescription: my-security-groups\n######################################\nParameters:\n  EC2Vpc:\n    ConstraintDescription: Must be a valid VpcId\n    Description: Select the VPC to use\n    Type: AWS::EC2::VPC::Id\n##############################################################################\nMetadata:\n  AWS::CloudFormation::Interface:\n    ParameterGroups:\n    - Label:\n        default: VPC\n      Parameters:\n      - EC2Vpc\n##############################################################################\nResources:\n  EC2InstanceSecurityGroup1:\n    Type: AWS::EC2::SecurityGroup\n    Properties:\n      VpcId: \n        Ref: EC2Vpc\n      GroupDescription: my-security-group-1\n      GroupName: my-security-group-1\n      SecurityGroupIngress:\n        - {CidrIp: 10.0.0.0/8,                        IpProtocol: tcp,  FromPort: \u0026#39;80\u0026#39;,      ToPort: \u0026#39;80\u0026#39;,    Description: \u0026#39;HTTP\u0026#39;}  \n      SecurityGroupEgress:\n        - {CidrIp: 10.0.0.0/8,                        IpProtocol: udp,  FromPort: \u0026#39;123\u0026#39;,     ToPort: \u0026#39;123\u0026#39;,   Description: \u0026#39;NTP\u0026#39;}  \n        - {CidrIp: 10.0.0.0/8,                        IpProtocol: tcp,  FromPort: \u0026#39;53\u0026#39;,      ToPort: \u0026#39;53\u0026#39;,    Description: \u0026#39;DNS\u0026#39;}\n      Tags:\n        - {Key: Name,         Value: \u0026#39;my-security-group-1\u0026#39;}\n  EC2InstanceSecurityGroup2:\n    Type: AWS::EC2::SecurityGroup\n    Properties:\n      VpcId: \n        Ref: EC2Vpc\n      GroupDescription: my-security-group-2\n      GroupName: my-security-group-2\n      SecurityGroupIngress:\n        - {CidrIp: 0.0.0.0/0,                        IpProtocol: tcp,  FromPort: \u0026#39;443\u0026#39;,     ToPort: \u0026#39;443\u0026#39;,   Description: \u0026#39;HTTP\u0026#39;}  \n        - {CidrIp: 0.0.0.0/0,                        IpProtocol: icmp, FromPort: \u0026#39;-1\u0026#39;,      ToPort: \u0026#39;-1\u0026#39;,    Description: \u0026#39;ICMP ping\u0026#39;}\n      SecurityGroupEgress:\n        - {CidrIp: 10.0.0.0/8,                       IpProtocol: udp,  FromPort: \u0026#39;123\u0026#39;,     ToPort: \u0026#39;123\u0026#39;,   Description: \u0026#39;NTP\u0026#39;}  \n        - {CidrIp: 10.0.0.0/8,                       IpProtocol: tcp,  FromPort: \u0026#39;53\u0026#39;,      ToPort: \u0026#39;53\u0026#39;,    Description: \u0026#39;DNS\u0026#39;}\n        - {CidrIp: 0.0.0.0/0,                        IpProtocol: icmp, FromPort: \u0026#39;-1\u0026#39;,      ToPort: \u0026#39;-1\u0026#39;,    Description: \u0026#39;ICMP ping\u0026#39;}\n      Tags:\n        - {Key: Name,         Value: \u0026#39;my-security-group-2\u0026#39;}\n  MyIngressSelfAll:\n    Type: AWS::EC2::SecurityGroupIngress\n    Properties:\n      GroupId: !Ref EC2InstanceSecurityGroup2\n      SourceSecurityGroupId: !GetAtt EC2InstanceSecurityGroup2.GroupId\n      IpProtocol: -1\n      FromPort: 0\n      ToPort: 65535\n  MyEgressSelfAll:\n    Type: AWS::EC2::SecurityGroupEgress\n    Properties: \n      GroupId: !Ref EC2InstanceSecurityGroup2\n      DestinationSecurityGroupId: !GetAtt EC2InstanceSecurityGroup2.GroupId\n      IpProtocol: -1 \n      FromPort: 0\n      ToPort: 65535\n##############################################################################\nOutputs:\n  SecurityGroupId:\n    Description: The Security Group that was created\n    Value: {Ref: EC2InstanceSecurityGroup1}\n    Value: {Ref: EC2InstanceSecurityGroup2}\n  StackName:\n    Description: Name of this stack for Fn::ImportValue use by children of top level stack\n    Value: {Ref: \u0026#39;AWS::StackName\u0026#39;}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cloudformation security group"},{"content":"You can copy rules from a security group to a new security group created within the same Region.\nOpen the Amazon Elastic Compute Cloud (Amazon EC2) console.\nIn the navigation pane, choose Security Groups. Select the security group you’d like to copy. For Actions, choose Copy to new. The Create Security Group dialog opens, and is populated with the rules from your existing security group. Specify a Security group name and Description for your new security group. For VPC, choose the ID of the VPC. Choose Create. ","permalink":"http://uly.me/posts/aws-copy-security-group/","summary":"\u003cp\u003eYou can copy rules from a security group to a new security group created within the same Region.\u003c/p\u003e\n\u003cp\u003eOpen the Amazon Elastic Compute Cloud (Amazon EC2) console.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eIn the navigation pane, choose Security Groups.\u003c/li\u003e\n\u003cli\u003eSelect the security group you’d like to copy.\u003c/li\u003e\n\u003cli\u003eFor Actions, choose Copy to new.\u003c/li\u003e\n\u003cli\u003eThe Create Security Group dialog opens, and is populated with the rules from your existing security group.\u003c/li\u003e\n\u003cli\u003eSpecify a Security group name and Description for your new security group.\u003c/li\u003e\n\u003cli\u003eFor VPC, choose the ID of the VPC.\u003c/li\u003e\n\u003cli\u003eChoose Create.\u003c/li\u003e\n\u003c/ol\u003e","title":"aws copy security group"},{"content":"Here’s how to move an AWS instance to another zone.\nStop the instance first.\naws ec2 stop-instances --instance-ids i-1234567890abcdef0 Create an AMI image.\naws ec2 create-image \\ --instance-id i-1234567890abcdef0 \\ --name \u0026#34;my-ami\u0026#34; \\ --description \u0026#34;my-ami\u0026#34; Create EC2 instance using Terraform. The contents of main.tf.\nterraform { required_providers { aws = { source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_instance\u0026#34; \u0026#34;ulysses\u0026#34; { ami = \u0026#34;ami-1234567890abcdef0\u0026#34; key_name = \u0026#34;servers\u0026#34; iam_instance_profile = \u0026#34;machine-role\u0026#34; instance_type = \u0026#34;t3.micro\u0026#34; subnet_id = \u0026#34;subnet-1234567890abcdef0\u0026#34; security_groups = [\u0026#34;sg-1234567890abcdef0\u0026#34;, \u0026#34;sg-1234567890abcdef1\u0026#34;] tags = { Name = \u0026#34;moving-instance\u0026#34; tag1 = \u0026#34;test1\u0026#34; tag2 = \u0026#34;test2\u0026#34; } } Launch it.\nterraform init terraform plan terraform apply ","permalink":"http://uly.me/posts/aws-move-instance-to-another-zone/","summary":"\u003cp\u003eHere’s how to move an AWS instance to another zone.\u003c/p\u003e\n\u003cp\u003eStop the instance first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 stop-instances --instance-ids i-1234567890abcdef0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an AMI image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 create-image \\\n--instance-id i-1234567890abcdef0 \\\n--name \u0026#34;my-ami\u0026#34; \\\n--description \u0026#34;my-ami\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate EC2 instance using Terraform. The contents of main.tf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\nresource \u0026#34;aws_instance\u0026#34; \u0026#34;ulysses\u0026#34; {\n  ami                           = \u0026#34;ami-1234567890abcdef0\u0026#34;\n  key_name                      = \u0026#34;servers\u0026#34;\n  iam_instance_profile          = \u0026#34;machine-role\u0026#34;\n  instance_type                 = \u0026#34;t3.micro\u0026#34;\n  subnet_id                     = \u0026#34;subnet-1234567890abcdef0\u0026#34;\n  security_groups               = [\u0026#34;sg-1234567890abcdef0\u0026#34;, \u0026#34;sg-1234567890abcdef1\u0026#34;]\n  tags = {\n    Name = \u0026#34;moving-instance\u0026#34;\n    tag1 = \u0026#34;test1\u0026#34;\n    tag2 = \u0026#34;test2\u0026#34;\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLaunch it.\u003c/p\u003e","title":"aws move instance to another zone"},{"content":"How to add bash scripts on startup.\nupdate-rc.d\nsudo cp /path/to/yourscript.sh /etc/init.d/yourscript.sh sudo update-rc.d /etc/init.d/yourscript.sh defaults chmod +x /etc/init.d/yourscript.sh Root Crontab\nsudo crontab -e @reboot /path/to/yourscript.sh ","permalink":"http://uly.me/posts/bash-script-on-startup/","summary":"\u003cp\u003eHow to add bash scripts on startup.\u003c/p\u003e\n\u003cp\u003eupdate-rc.d\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo cp /path/to/yourscript.sh /etc/init.d/yourscript.sh\nsudo update-rc.d /etc/init.d/yourscript.sh defaults\nchmod +x /etc/init.d/yourscript.sh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRoot Crontab\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo crontab -e\n@reboot /path/to/yourscript.sh\n\u003c/code\u003e\u003c/pre\u003e","title":"bash script on startup"},{"content":"To list all disk types available in your project in all regions. Result is truncated.\n$ gcloud compute disk-types list NAME ZONE VALID_DISK_SIZES pd-balanced 10GB-65536GB pd-ssd 10GB-65536GB pd-standard 200GB-65536GB pd-balanced 10GB-65536GB ... To list a specific region, use the filter option.\n$ gcloud compute disk-types list --filter=\u0026#34;zone~\u0026#39;us-central1\u0026#39;\u0026#34; NAME ZONE VALID_DISK_SIZES pd-balanced us-central1-a 10GB-65536GB pd-extreme us-central1-a 500GB-65536GB pd-ssd us-central1-a 10GB-65536GB pd-standard us-central1-a 10GB-65536GB pd-balanced us-central1-b 10GB-65536GB pd-extreme us-central1-b 500GB-65536GB pd-ssd us-central1-b 10GB-65536GB pd-standard us-central1-b 10GB-65536GB pd-balanced us-central1-c 10GB-65536GB pd-extreme us-central1-c 500GB-65536GB pd-ssd us-central1-c 10GB-65536GB pd-standard us-central1-c 10GB-65536GB pd-balanced us-central1-f 10GB-65536GB pd-extreme us-central1-f 500GB-65536GB pd-ssd us-central1-f 10GB-65536GB pd-standard us-central1-f 10GB-65536GB pd-balanced us-central1-d 10GB-65536GB pd-extreme us-central1-d 500GB-65536GB pd-ssd us-central1-d 10GB-65536GB pd-standard us-central1-d 10GB-65536GB To a list a specific region and local SSDs only.\ngcloud compute disk-types list --filter=\u0026#34;zone~\u0026#39;us-central1\u0026#39; AND name~\u0026#39;local-\u0026#39;\u0026#34; NAME ZONE VALID_DISK_SIZES local-ssd us-central1-a 375GB-375GB local-ssd us-central1-b 375GB-375GB local-ssd us-central1-c 375GB-375GB local-ssd us-central1-f 375GB-375GB local-ssd us-central1-d 375GB-375GB ","permalink":"http://uly.me/posts/gcp-list-disk-types/","summary":"\u003cp\u003eTo list all disk types available in your project in all regions. Result is truncated.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ gcloud compute disk-types list\nNAME         ZONE                       VALID_DISK_SIZES\npd-balanced                             10GB-65536GB\npd-ssd                                  10GB-65536GB\npd-standard                             200GB-65536GB\npd-balanced                             10GB-65536GB\n...\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo list a specific region, use the filter option.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ gcloud compute disk-types list --filter=\u0026#34;zone~\u0026#39;us-central1\u0026#39;\u0026#34;\nNAME         ZONE           VALID_DISK_SIZES\npd-balanced  us-central1-a  10GB-65536GB\npd-extreme   us-central1-a  500GB-65536GB\npd-ssd       us-central1-a  10GB-65536GB\npd-standard  us-central1-a  10GB-65536GB\npd-balanced  us-central1-b  10GB-65536GB\npd-extreme   us-central1-b  500GB-65536GB\npd-ssd       us-central1-b  10GB-65536GB\npd-standard  us-central1-b  10GB-65536GB\npd-balanced  us-central1-c  10GB-65536GB\npd-extreme   us-central1-c  500GB-65536GB\npd-ssd       us-central1-c  10GB-65536GB\npd-standard  us-central1-c  10GB-65536GB\npd-balanced  us-central1-f  10GB-65536GB\npd-extreme   us-central1-f  500GB-65536GB\npd-ssd       us-central1-f  10GB-65536GB\npd-standard  us-central1-f  10GB-65536GB\npd-balanced  us-central1-d  10GB-65536GB\npd-extreme   us-central1-d  500GB-65536GB\npd-ssd       us-central1-d  10GB-65536GB\npd-standard  us-central1-d  10GB-65536GB\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo a list a specific region and local SSDs only.\u003c/p\u003e","title":"gcp list disk types"},{"content":"Creating a VPC in AWS using Terraform. The script will do the following:\nCreate a VPC Create a Subnet Create an Internet Gateway Create a route in the default route table using the Internet Gateway Contents of main.tf\nterraform { required_providers { aws = { source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;tfc\u0026#34; region = \u0026#34;us-west-1\u0026#34; } resource \u0026#34;aws_vpc\u0026#34; \u0026#34;my-vpc\u0026#34; { cidr_block = \u0026#34;10.0.4.0/24\u0026#34; instance_tenancy = \u0026#34;default\u0026#34; tags = { Name = \u0026#34;my-vpc\u0026#34; } } resource \u0026#34;aws_subnet\u0026#34; \u0026#34;my-subnet\u0026#34; { vpc_id = aws_vpc.my-vpc.id cidr_block = \u0026#34;10.0.4.0/24\u0026#34; availability_zone = \u0026#34;us-west-1a\u0026#34; tags = { Name = \u0026#34;my-subnet-us-west-1a\u0026#34; } } resource \u0026#34;aws_internet_gateway\u0026#34; \u0026#34;my-igw\u0026#34; { vpc_id = aws_vpc.my-vpc.id tags = { Name = \u0026#34;my-internet-gateway\u0026#34; } } resource \u0026#34;aws_default_route_table\u0026#34; \u0026#34;my-rt\u0026#34; { default_route_table_id = aws_vpc.my-vpc.default_route_table_id route { cidr_block = \u0026#34;0.0.0.0/0\u0026#34; gateway_id = aws_internet_gateway.my-igw.id } tags = { Name = \u0026#34;my-route-table\u0026#34; } } ","permalink":"http://uly.me/posts/create-aws-vpc-using-terraform/","summary":"\u003cp\u003eCreating a VPC in AWS using Terraform. The script will do the following:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCreate a VPC\u003c/li\u003e\n\u003cli\u003eCreate a Subnet\u003c/li\u003e\n\u003cli\u003eCreate an Internet Gateway\u003c/li\u003e\n\u003cli\u003eCreate a route in the default route table using the Internet Gateway\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eContents of main.tf\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\n\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;tfc\u0026#34;\n  region  = \u0026#34;us-west-1\u0026#34;\n}\n\nresource \u0026#34;aws_vpc\u0026#34; \u0026#34;my-vpc\u0026#34; {\n  cidr_block       = \u0026#34;10.0.4.0/24\u0026#34;\n  instance_tenancy = \u0026#34;default\u0026#34;\n  tags = {\n    Name = \u0026#34;my-vpc\u0026#34;\n  }\n}\n\nresource \u0026#34;aws_subnet\u0026#34; \u0026#34;my-subnet\u0026#34; {\n  vpc_id            = aws_vpc.my-vpc.id\n  cidr_block        = \u0026#34;10.0.4.0/24\u0026#34;\n  availability_zone = \u0026#34;us-west-1a\u0026#34;\n  tags = {\n    Name = \u0026#34;my-subnet-us-west-1a\u0026#34;\n  }\n}\n\nresource \u0026#34;aws_internet_gateway\u0026#34; \u0026#34;my-igw\u0026#34; {\n  vpc_id = aws_vpc.my-vpc.id\n  tags = {\n    Name = \u0026#34;my-internet-gateway\u0026#34;\n  }\n}\n\nresource \u0026#34;aws_default_route_table\u0026#34; \u0026#34;my-rt\u0026#34; {\n  default_route_table_id = aws_vpc.my-vpc.default_route_table_id\n  route {\n    cidr_block = \u0026#34;0.0.0.0/0\u0026#34;\n    gateway_id = aws_internet_gateway.my-igw.id\n  }\n  tags = {\n    Name = \u0026#34;my-route-table\u0026#34;\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"create aws vpc using terraform"},{"content":"GCS Fuse allows you to mount a Google bucket as a file system. It’s similar to S3FS.\nSetup repo\nsudo tee /etc/yum.repos.d/gcsfuse.repo \u0026gt; /dev/null Yum install\nsudo yum install gcsfuse For Ubuntu or Linux Mint, download the deb package.\ncurl -L -O https://github.com/GoogleCloudPlatform/gcsfuse/releases/download/v0.39.2/gcsfuse_0.39.2_amd64.deb sudo dpkg --install gcsfuse_0.39.2_amd64.deb rm gcsfuse_0.39.2_amd64.deb Check if installed.\ngcsfuse -v Login.\ngcloud auth login gcloud auth application-default login Setup mount.\nmkdir -p /path/to/mount chown username:username /path/to/mount Mount it.\ngcsfuse my-bucket /path/to/mount Alternative using service account key.\ngcsfuse my-bucket /path/to/mount --key-file /root/key.json --uid=xxx --gid=xxx -o rw,allow_other Automatic mount in /etc/fstab.\nmy-bucket /path/to/mount gcsfuse _netdev,allow_other,user,rw,uid=1000,gid=1000 0 0 Unmount\nfusermount -u /path/to/mount ","permalink":"http://uly.me/posts/gcs-fuse/","summary":"\u003cp\u003eGCS Fuse allows you to mount a Google bucket as a file system. It’s similar to \u003ca href=\"https://uly.me/s3fs/\"\u003eS3FS\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eSetup repo\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo tee /etc/yum.repos.d/gcsfuse.repo \u0026gt; /dev/null \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYum install\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install gcsfuse\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor Ubuntu or Linux Mint, download the deb package.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl -L -O https://github.com/GoogleCloudPlatform/gcsfuse/releases/download/v0.39.2/gcsfuse_0.39.2_amd64.deb\nsudo dpkg --install gcsfuse_0.39.2_amd64.deb\nrm gcsfuse_0.39.2_amd64.deb\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcsfuse -v\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth login\ngcloud auth application-default login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSetup mount.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir -p /path/to/mount\nchown username:username /path/to/mount\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcsfuse my-bucket /path/to/mount\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAlternative using service account key.\u003c/p\u003e","title":"gcs fuse"},{"content":"Core dumps are triggered by kernel when a program crashses. It saves memory to a file.\nHow to enable core dumps.\nulimit -S -c unlimited Enable core dumps permanently. Edit /etc/security/limits.conf. Add the following.\n* soft core unlimited Disable core dumps.\nulimit -S -c 0 Disable core dumps permanently. Edit /etc/security/limits.conf. Add the following.\n* soft core 0 * hard core 0 ","permalink":"http://uly.me/posts/enable-core-dumps/","summary":"\u003cp\u003eCore dumps are triggered by kernel when a program crashses. It saves memory to a file.\u003c/p\u003e\n\u003cp\u003eHow to enable core dumps.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eulimit -S -c unlimited\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEnable core dumps permanently. Edit /etc/security/limits.conf. Add the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e* soft core unlimited\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable core dumps.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eulimit -S -c 0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable core dumps permanently. Edit /etc/security/limits.conf. Add the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e* soft core 0\n* hard core 0\n\u003c/code\u003e\u003c/pre\u003e","title":"enable core dumps"},{"content":"How to uninstall IBM Tivoli System Automation from Linux.\nCheck if domain is online.\nlsrpdomain Stop the domain.\nstoprpdomain \u0026lt;domain\u0026gt; \u0026lt;/domain\u0026gt; Uninstall.\ncd /opt/IBM/tsamp/sam/uninst/ ./uninstallSAM Check the logs.\n/tmp/uninstallSAM..log ","permalink":"http://uly.me/posts/uninstall-ibm-tivoli-system-automation/","summary":"\u003cp\u003eHow to uninstall IBM Tivoli System Automation from Linux.\u003c/p\u003e\n\u003cp\u003eCheck if domain is online.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsrpdomain\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStop the domain.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003estoprpdomain \u0026lt;domain\u0026gt;\n\u0026lt;/domain\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUninstall.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /opt/IBM/tsamp/sam/uninst/\n./uninstallSAM\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck the logs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/tmp/uninstallSAM..log\n\u003c/code\u003e\u003c/pre\u003e","title":"uninstall ibm tivoli system automation"},{"content":"How to rebuild your application from scratch using Docker.\n#!/bin/bash docker-compose down -v docker rmi $(docker images -a -q) docker-compose up -d docker-compose restart -t 10 Steps\nPurge the containers. Delete docker images. Reinitiate docker. Restart docker. ","permalink":"http://uly.me/posts/rebuild-docker-containers/","summary":"\u003cp\u003eHow to rebuild your application from scratch using Docker.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ndocker-compose down -v\ndocker rmi $(docker images -a -q)\ndocker-compose up -d\ndocker-compose restart -t 10\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSteps\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ePurge the containers.\u003c/li\u003e\n\u003cli\u003eDelete docker images.\u003c/li\u003e\n\u003cli\u003eReinitiate docker.\u003c/li\u003e\n\u003cli\u003eRestart docker.\u003c/li\u003e\n\u003c/ul\u003e","title":"rebuild docker containers"},{"content":"How to run MySQL commands in a Docker container.\n#!/bin/bash set -a; source /dev/null The first command loads the content of .env to environment variables. The MySQL password can then be used using the ${MYSQL_PASSWORD} variable. I’m using sed to get around the special characters in the password. The second command runs docker exec on wp_db container. The last 3 commands are the actual sql commands. We are selecting to use the db1 database. Then we run select statements from the wp_options table. Finally, 2\u0026gt;/dev/null suppresses errors and warning to null. ","permalink":"http://uly.me/posts/run-mysql-in-a-docker-container/","summary":"\u003cp\u003eHow to run MySQL commands in a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nset -a; source /dev/null\n\u003c/code\u003e\u003c/pre\u003e\u003cul\u003e\n\u003cli\u003eThe first command loads the content of .env to environment variables.\u003c/li\u003e\n\u003cli\u003eThe MySQL password can then be used using the ${MYSQL_PASSWORD} variable.\u003c/li\u003e\n\u003cli\u003eI’m using sed to get around the special characters in the password.\u003c/li\u003e\n\u003cli\u003eThe second command runs docker exec on wp_db container.\u003c/li\u003e\n\u003cli\u003eThe last 3 commands are the actual sql commands.\u003c/li\u003e\n\u003cli\u003eWe are selecting to use the db1 database.\u003c/li\u003e\n\u003cli\u003eThen we run select statements from the wp_options table.\u003c/li\u003e\n\u003cli\u003eFinally, 2\u0026gt;/dev/null suppresses errors and warning to null.\u003c/li\u003e\n\u003c/ul\u003e","title":"run mysql in a docker container"},{"content":"Steps how to install Docker and Docker Compose on Amazon Linux 2.\nInstall Docker\n$ sudo amazon-linux-extras install docker $ sudo service docker start $ sudo usermod -a -G docker ec2-user Start at boot.\n$ sudo chkconfig docker on Install git (optional).\n$ sudo yum install -y git Install Docker Compose\n$ sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) \\ -o /usr/bin/docker-compose $ sudo chmod +x /usr/local/bin/docker-compose Check\ndocker --version docker-compose --version ","permalink":"http://uly.me/posts/install-docker-on-amazon-linux-2/","summary":"\u003cp\u003eSteps how to install Docker and Docker Compose on Amazon Linux 2.\u003c/p\u003e\n\u003cp\u003eInstall Docker\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo amazon-linux-extras install docker\n$ sudo service docker start\n$ sudo usermod -a -G docker ec2-user\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart at boot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo chkconfig docker on\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall git (optional).\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo yum install -y git\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall Docker Compose\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) \\\n-o /usr/bin/docker-compose\n$ sudo chmod +x /usr/local/bin/docker-compose \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker --version\ndocker-compose --version\n\u003c/code\u003e\u003c/pre\u003e","title":"install docker on amazon linux 2"},{"content":"How to stop and remove all Docker containers.\nStop all containers\n$ docker kill $(docker ps -q) Remove all containers\n$ docker rm $(docker ps -a -q) Delete all docker images\n$ docker rmi $(docker images -q) ","permalink":"http://uly.me/posts/stop-and-remove-all-docker-containers/","summary":"\u003cp\u003eHow to stop and remove all Docker containers.\u003c/p\u003e\n\u003cp\u003eStop all containers\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker kill $(docker ps -q)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove all containers\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker rm $(docker ps -a -q)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete all docker images\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker rmi $(docker images -q)\n\u003c/code\u003e\u003c/pre\u003e","title":"stop and remove all docker containers"},{"content":"How to check Docker container logs. Look for the container ID.\n$ docker ps -a 3e2c1193915f To view the logs for the container.\ndocker logs 3e2c1193915f # or docker container logs 3e2c1193915f ","permalink":"http://uly.me/posts/docker-container-logs/","summary":"\u003cp\u003eHow to check Docker container logs. Look for the container ID.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker ps -a\n3e2c1193915f\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo view the logs for the container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker logs 3e2c1193915f\n# or\ndocker container logs 3e2c1193915f\n\u003c/code\u003e\u003c/pre\u003e","title":"docker container logs"},{"content":"How to activate a GCP service account for other users in Linux.\nFirst generate a key for the service account. Save as key.json.\nLogin to the server as that user and copy the key there. Activate the service account.\n$ gcloud auth activate-service-account [ACCOUNT] --key-file=key.json Once authenticated, you should be able to check if service account is active.\n$ gcloud config list A better option without needing a key.\ngcloud config set core/account service-account@project-id.iam.gserviceaccount.com ","permalink":"http://uly.me/posts/gcp-activate-service-account/","summary":"\u003cp\u003eHow to activate a GCP service account for other users in Linux.\u003c/p\u003e\n\u003cp\u003eFirst generate a key for the service account. Save as key.json.\u003c/p\u003e\n\u003cp\u003eLogin to the server as that user and copy the key there. Activate the service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ gcloud auth activate-service-account [ACCOUNT] --key-file=key.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce authenticated, you should be able to check if service account is active.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ gcloud config list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eA better option without needing a key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud config set core/account service-account@project-id.iam.gserviceaccount.com\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp activate service account"},{"content":"Generate a ssh key for Github\nssh-keygen -t ed25519 -C \u0026#34;your_email@example.com\u0026#34; Copy and paste the ‘id_ed25519.pub’ key to Github.\ncd .ssh $ ls -l -rw-r--r-- 1 ulysses ulysses 537 Jul 14 12:54 id_ed25519 -rw-r--r-- 1 ulysses ulysses 194 Jul 14 12:54 id_ed25519.pub Go to Settings \u0026gt; SSH and GPG keys. Add new SSH key and authorize.\nYou can then clone using the SSH format.\n$ git init $ git clone git@github.com:acoount/repo.git ","permalink":"http://uly.me/posts/github-generate-a-key/","summary":"\u003cp\u003eGenerate a ssh key for Github\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh-keygen -t ed25519 -C \u0026#34;your_email@example.com\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCopy and paste the ‘id_ed25519.pub’ key to Github.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd .ssh\n$ ls -l \n-rw-r--r-- 1 ulysses ulysses   537 Jul 14 12:54 id_ed25519\n-rw-r--r-- 1 ulysses ulysses   194 Jul 14 12:54 id_ed25519.pub\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGo to Settings \u0026gt; SSH and GPG keys. Add new SSH key and authorize.\u003c/p\u003e\n\u003cp\u003eYou can then clone using the SSH format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ git init\n$ git clone git@github.com:acoount/repo.git\n\u003c/code\u003e\u003c/pre\u003e","title":"github generate a key"},{"content":"Check Docker running processes.\n$ docker ps -a To see it in real time.\n$ watch docker ps ","permalink":"http://uly.me/posts/docker-ps/","summary":"\u003cp\u003eCheck Docker running processes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ docker ps -a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo see it in real time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ watch docker ps\n\u003c/code\u003e\u003c/pre\u003e","title":"docker ps"},{"content":"Spot VMs are preemtible, they can be reclaimed by the Cloud provider.\nHowever you can get deep discounts using them.\nLaunch a spot instance in GCP using Terraform.\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;airy-totality-151318\u0026#34; zone = \u0026#34;us-central1-c\u0026#34; } resource \u0026#34;google_compute_instance\u0026#34; \u0026#34;test\u0026#34; { name = \u0026#34;test\u0026#34; machine_type = \u0026#34;e2-micro\u0026#34; boot_disk { initialize_params { image = \u0026#34;debian-cloud/debian-9\u0026#34; } } scheduling { preemptible = true automatic_restart = false } network_interface { network = \u0026#34;default\u0026#34; access_config { } } } ","permalink":"http://uly.me/posts/gcp-spot-vm/","summary":"\u003cp\u003eSpot VMs are preemtible, they can be reclaimed by the Cloud provider.\u003c/p\u003e\n\u003cp\u003eHowever you can get deep discounts using them.\u003c/p\u003e\n\u003cp\u003eLaunch a spot instance in GCP using Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n  project = \u0026#34;airy-totality-151318\u0026#34;\n  zone    = \u0026#34;us-central1-c\u0026#34;\n}\n\nresource \u0026#34;google_compute_instance\u0026#34; \u0026#34;test\u0026#34; {\n  name         = \u0026#34;test\u0026#34;\n  machine_type = \u0026#34;e2-micro\u0026#34;\n\n  boot_disk {\n    initialize_params {\n      image = \u0026#34;debian-cloud/debian-9\u0026#34;\n    }\n  }\n\n  scheduling {\n    preemptible       = true\n    automatic_restart = false\n  }\n\n  network_interface {\n    network = \u0026#34;default\u0026#34;\n    access_config {\n    }\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp spot vm"},{"content":"This is a script that fixes /etc/hosts in GCP.\n#!/bin/bash # VARIABLES FILE=\u0026#39;/etc/hosts\u0026#39; #BACKUP /etc/hosts before changes cp -ipHR $FILE $FILE_$(date +%Y-%m-%d_%H-%M-%S) # GET IP ADDRESS IP=$(/sbin/ifconfig | grep \u0026#39;inet\u0026#39; | grep -v \u0026#39;inet6\u0026#39; | grep -v \u0026#39;127.0\u0026#39; | cut -d: -f2 | awk \u0026#39;{print $2}\u0026#39; | head -1) # GET HOSTNAME HN=$(/bin/hostname) # GET PROJECT ID echo \u0026#34;169.254.169.254 metadata.google.internal # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE PR=$(curl -f -s http://metadata.google.internal/computeMetadata/v1/project/project-id -H \u0026#34;Metadata-Flavor: Google\u0026#34;) # ADD HOSTNAME ENTRY TO /etc/hosts STRING=\u0026#34;$IP $HN.mydomain.com\u0026#34; if grep -q \u0026#34;$STRING\u0026#34; \u0026#34;$FILE\u0026#34; then echo \u0026#34;Valid host entry.\u0026#34; else echo \u0026#34;Adding host entry.\u0026#34; echo $STRING $HN \u0026gt;\u0026gt; $FILE fi # DELETE GOOGLE ENTRIES. sed -i \u0026#39;/# Added by Google/d\u0026#39; $FILE # ADD BACK GOOGLE ENTRIES. echo $IP $HN\u0026#34;.c.\u0026#34;$PR\u0026#34;.internal\u0026#34; $HN\u0026#34; # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE echo \u0026#34;169.254.169.254 metadata.google.internal # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE # SET PERMISSIONS. chmod 644 $FILE # DISPLAY /etc/hosts cat $FILE Result\n127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 10.128.0.30 test.mydomain.com test 10.128.0.30 test.c.project-id.internal test # Added by Google 169.254.169.254 metadata.google.internal # Added by Google It adds a proper host entry before the Google entries. /etc/hosts has top to bottom precedence.\n","permalink":"http://uly.me/posts/gcp-fix-hosts/","summary":"\u003cp\u003eThis is a script that fixes /etc/hosts in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\n# VARIABLES\nFILE=\u0026#39;/etc/hosts\u0026#39;\n\n#BACKUP /etc/hosts before changes\ncp -ipHR $FILE $FILE_$(date +%Y-%m-%d_%H-%M-%S)\n\n# GET IP ADDRESS\nIP=$(/sbin/ifconfig | grep \u0026#39;inet\u0026#39; | grep -v \u0026#39;inet6\u0026#39; | grep -v \u0026#39;127.0\u0026#39; | cut -d: -f2 | awk \u0026#39;{print $2}\u0026#39; | head -1)\n\n# GET HOSTNAME\nHN=$(/bin/hostname)\n\n# GET PROJECT ID\necho \u0026#34;169.254.169.254 metadata.google.internal  # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE\nPR=$(curl -f -s http://metadata.google.internal/computeMetadata/v1/project/project-id -H \u0026#34;Metadata-Flavor: Google\u0026#34;)\n\n# ADD HOSTNAME ENTRY TO /etc/hosts\nSTRING=\u0026#34;$IP $HN.mydomain.com\u0026#34;\n\nif grep -q \u0026#34;$STRING\u0026#34; \u0026#34;$FILE\u0026#34;\nthen\n  echo \u0026#34;Valid host entry.\u0026#34;\nelse\n  echo \u0026#34;Adding host entry.\u0026#34;\n  echo $STRING $HN \u0026gt;\u0026gt; $FILE\nfi\n\n# DELETE GOOGLE ENTRIES.\nsed -i \u0026#39;/# Added by Google/d\u0026#39; $FILE\n\n# ADD BACK GOOGLE ENTRIES.\necho $IP $HN\u0026#34;.c.\u0026#34;$PR\u0026#34;.internal\u0026#34; $HN\u0026#34;  # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE\necho \u0026#34;169.254.169.254 metadata.google.internal  # Added by Google\u0026#34; \u0026gt;\u0026gt; $FILE\n\n# SET PERMISSIONS.\nchmod 644 $FILE\n\n# DISPLAY /etc/hosts\ncat $FILE\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e","title":"gcp fix hosts"},{"content":"How to calculate Fibonacci sequence in Python.\nCreate a file called fib.py.\nnterms = int(input(\u0026#34;How many terms? \u0026#34;)) n1, n2 = 0, 1 count = 0 if nterms Run it.\n$ python fib.py How many terms? 5 Fibonacci sequence: 0 1 1 2 3 Again.\n$ python fib.py How many terms? 10 Fibonacci sequence: 0 1 1 2 3 5 8 13 21 34 ","permalink":"http://uly.me/posts/fibonacci-sequence-in-python/","summary":"\u003cp\u003eHow to calculate Fibonacci sequence in Python.\u003c/p\u003e\n\u003cp\u003eCreate a file called fib.py.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enterms = int(input(\u0026#34;How many terms? \u0026#34;))\nn1, n2 = 0, 1\ncount = 0\nif nterms \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ python fib.py\nHow many terms? 5\nFibonacci sequence:\n0\n1\n1\n2\n3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAgain.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ python fib.py\nHow many terms? 10\nFibonacci sequence:\n0\n1\n1\n2\n3\n5\n8\n13\n21\n34\n\u003c/code\u003e\u003c/pre\u003e","title":"fibonacci sequence in python"},{"content":"How to display Lightsail snapshots.\n#!/bin/bash displaysnapshots () { echo \u0026#39;--------------------------------------------------------\u0026#39; aws lightsail get-instance-snapshots --query \u0026#39;instanceSnapshots[].[name]\u0026#39; --output text | sort echo \u0026#39;--------------------------------------------------------\u0026#39; } displaysnapshots Result.\ndaily_ulyme_1637812801 daily_ulyme_1637899201 daily_ulyme_1637985601 daily_ulyme_1638072001 Adding timestamp to the output.\naws lightsail get-instance-snapshots --query \u0026#39;instanceSnapshots[].[name,createdAt]\u0026#39; --output text | sort Result.\ndaily_ulyme_1637812801\t1637812806.853 daily_ulyme_1637899201\t1637899208.285 daily_ulyme_1637985601\t1637985606.184 daily_ulyme_1638072001\t1638072006.579 Convert Unix timestamp to iso8601. Edit your ~/.aws/config file. Add this line.\ncli_timestamp_format = iso8601 Result.\ndaily_ulyme_1637812801\t2021-11-25T04:00:06.853000+00:00 daily_ulyme_1637899201\t2021-11-26T04:00:08.285000+00:00 daily_ulyme_1637985601\t2021-11-27T04:00:06.184000+00:00 daily_ulyme_1638072001\t2021-11-28T04:00:06.579000+00:00 ","permalink":"http://uly.me/posts/aws-display-lightsail-snapshots/","summary":"\u003cp\u003eHow to display Lightsail snapshots.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ndisplaysnapshots () {\n  echo \u0026#39;--------------------------------------------------------\u0026#39;\n  aws lightsail get-instance-snapshots --query \u0026#39;instanceSnapshots[].[name]\u0026#39; --output text | sort\n  echo \u0026#39;--------------------------------------------------------\u0026#39;\n}\ndisplaysnapshots\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edaily_ulyme_1637812801\ndaily_ulyme_1637899201\ndaily_ulyme_1637985601\ndaily_ulyme_1638072001\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdding timestamp to the output.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail get-instance-snapshots --query \u0026#39;instanceSnapshots[].[name,createdAt]\u0026#39; --output text | sort\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edaily_ulyme_1637812801\t1637812806.853\ndaily_ulyme_1637899201\t1637899208.285\ndaily_ulyme_1637985601\t1637985606.184\ndaily_ulyme_1638072001\t1638072006.579\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eConvert Unix timestamp to iso8601. Edit your ~/.aws/config file. Add this line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecli_timestamp_format = iso8601\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edaily_ulyme_1637812801\t2021-11-25T04:00:06.853000+00:00\ndaily_ulyme_1637899201\t2021-11-26T04:00:08.285000+00:00\ndaily_ulyme_1637985601\t2021-11-27T04:00:06.184000+00:00\ndaily_ulyme_1638072001\t2021-11-28T04:00:06.579000+00:00\n\u003c/code\u003e\u003c/pre\u003e","title":"aws display lightsail snapshots"},{"content":"How to execute functions in Bash based on argument.\nThere are 2 functions: build and terminate.\n#!/bin/bash build () { echo \u0026#39;Building services\u0026#39; } terminate () { echo \u0026#39;Terminating services\u0026#39; } if [ $1 == \u0026#39;build\u0026#39; ]; then build elif [ $1 == \u0026#39;terminate\u0026#39; ]; then terminate else echo \u0026#39;Valid options are \u0026#34;build\u0026#34; or \u0026#34;terminate\u0026#34;\u0026#39; fi Execute a function based on argument.\n$ bash test.sh build Building services $ bash test.sh terminate Terminating services $ bash test.sh anyother Valid options are \u0026#34;build\u0026#34; or \u0026#34;terminate\u0026#34; ","permalink":"http://uly.me/posts/bash-input-executes-functions/","summary":"\u003cp\u003eHow to execute functions in Bash based on argument.\u003c/p\u003e\n\u003cp\u003eThere are 2 functions: build and terminate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nbuild () {\n echo \u0026#39;Building services\u0026#39;\n}\nterminate () {\n echo \u0026#39;Terminating services\u0026#39;\n}\nif [ $1 == \u0026#39;build\u0026#39; ]; then build\nelif [ $1 == \u0026#39;terminate\u0026#39; ]; then terminate\nelse echo \u0026#39;Valid options are \u0026#34;build\u0026#34; or \u0026#34;terminate\u0026#34;\u0026#39;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExecute a function based on argument.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ bash test.sh build\nBuilding services\n\n$ bash test.sh terminate\nTerminating services\n\n$ bash test.sh anyother\nValid options are \u0026#34;build\u0026#34; or \u0026#34;terminate\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"bash input executes functions"},{"content":"How to read a file line by line in Bash.\n#!/bin/bash file=test.txt while IFS= read -r line; do echo $line done Contents of test.txt.\none two three Results when running test.sh.\n$ bash test.sh one two three To read multiple strings line by line.\n#!/bin/bash file=test.txt while read -r a b; do echo $b done Modified contents of test.txt.\none 1 two 2 three 3 New results.\n$ bash test.sh 1 2 3 ","permalink":"http://uly.me/posts/bash-read-file/","summary":"\u003cp\u003eHow to read a file line by line in Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfile=test.txt\nwhile IFS= read -r line; do\n  echo $line\ndone\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eContents of test.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eone\ntwo\nthree\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResults when running test.sh.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ bash test.sh\none\ntwo\nthree\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo read multiple strings line by line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nfile=test.txt\nwhile read -r a b; do\n  echo $b\ndone \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eModified contents of test.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eone 1\ntwo 2\nthree 3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNew results.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ bash test.sh\n1\n2\n3\n\u003c/code\u003e\u003c/pre\u003e","title":"bash read file"},{"content":"How to delete a line containing a pattern using sed.\nContents of test.txt.\n$ cat test.txt one two three Delete a line matching the string “one.”\nsed -i \u0026#39;/one/d\u0026#39; test.txt Display test.txt\n$ cat test.txt two three ","permalink":"http://uly.me/posts/delete-lines-using-sed/","summary":"\u003cp\u003eHow to delete a line containing a pattern using sed.\u003c/p\u003e\n\u003cp\u003eContents of test.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat test.txt\none\ntwo\nthree\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete a line matching the string “one.”\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esed -i \u0026#39;/one/d\u0026#39; test.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay test.txt\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat test.txt\ntwo\nthree\n\u003c/code\u003e\u003c/pre\u003e","title":"delete lines using sed"},{"content":"Here’s a script that removes Oracle Java on your system. Installs OpenJDK Hotspot as a replacement.\n#!/bin/bash # set env oracle_jre_version=\u0026#34;jdk1.8.0_172\u0026#34; open_jre_version=\u0026#34;java-1.8.0-openjdk\u0026#34; # REMOVE LINKS deljdk () { sudo update-alternatives --remove \u0026#34;java\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/java\u0026#34; sudo update-alternatives --remove \u0026#34;javac\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/javac\u0026#34; sudo update-alternatives --remove \u0026#34;javaws\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/javaws\u0026#34; } # REMOVE RPM delrpm () { jdk=$(rpm -qa | grep jdk-1.7) rpm -e $jdk jdk=$(rpm -qa | grep jdk1.8) rpm -e $jdk sudo rm -rf /usr/java/jdk* } # REMOVE SYMBOLIC LINKS delsym () { rm /usr/java/default /usr/java/latest rm /usr/lib/mozilla/plugins/libnpjp2.so rm /usr/lib/mozilla/plugins/libnpjp2.so } # INSTALL OPENJDK addjdk () { cd /usr/java rm -f /usr/java/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz wget --no-check-certificate https://10.49.39.125/download/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz tar xzf OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz chown -R username:username /usr/java/jdk8u302-b08 } # ADD PATH addpath () { sed -i \u0026#39;/jdk8u302-b08/d\u0026#39; /home/username/.zshrc sed -i \u0026#39;/jdk8u302-b08/d\u0026#39; /home/username/.profile echo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a ~/.bashrc echo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a /home/username/.zshrc echo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a /home/username/.profile chown username:username /home/username/.zshrc chown username:username /home/username/.profile } deljdk delrpm delsym addjdk addpath ","permalink":"http://uly.me/posts/remove-oracle-java/","summary":"\u003cp\u003eHere’s a script that removes Oracle Java on your system. Installs OpenJDK Hotspot as a replacement.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# set env\noracle_jre_version=\u0026#34;jdk1.8.0_172\u0026#34;\nopen_jre_version=\u0026#34;java-1.8.0-openjdk\u0026#34;\n# REMOVE LINKS\ndeljdk () {\n\tsudo update-alternatives --remove \u0026#34;java\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/java\u0026#34;\n\tsudo update-alternatives --remove \u0026#34;javac\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/javac\u0026#34;\n\tsudo update-alternatives --remove \u0026#34;javaws\u0026#34; \u0026#34;/usr/lib/jvm/$oracle_jre_version/bin/javaws\u0026#34;\n}\n# REMOVE RPM\ndelrpm () {\n\tjdk=$(rpm -qa | grep jdk-1.7)\n\trpm -e $jdk\n\tjdk=$(rpm -qa | grep jdk1.8)\n\trpm -e $jdk\n\tsudo rm -rf /usr/java/jdk*\n}\n# REMOVE SYMBOLIC LINKS\ndelsym () {\n\trm /usr/java/default /usr/java/latest\n\trm /usr/lib/mozilla/plugins/libnpjp2.so\n\trm /usr/lib/mozilla/plugins/libnpjp2.so\n}\n# INSTALL OPENJDK\naddjdk () {\n\tcd /usr/java\n\trm -f /usr/java/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz\n\twget --no-check-certificate https://10.49.39.125/download/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz\n\ttar xzf OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz\n\tchown -R username:username /usr/java/jdk8u302-b08\n}\n# ADD PATH\naddpath () {\n\tsed -i \u0026#39;/jdk8u302-b08/d\u0026#39; /home/username/.zshrc\n\tsed -i \u0026#39;/jdk8u302-b08/d\u0026#39; /home/username/.profile\n\techo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a ~/.bashrc\n\techo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a /home/username/.zshrc\n\techo \u0026#39;export PATH=/usr/java/jdk8u302-b08/bin:$PATH\u0026#39; | tee -a /home/username/.profile\n\tchown username:username /home/username/.zshrc\n\tchown username:username /home/username/.profile\n}\ndeljdk\ndelrpm\ndelsym\naddjdk\naddpath\n\u003c/code\u003e\u003c/pre\u003e","title":"remove oracle java"},{"content":"How to clone repositories with multiple Github accounts.\ngit clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git ","permalink":"http://uly.me/posts/git-clone-multiple-accounts/","summary":"\u003cp\u003eHow to clone repositories with multiple Github accounts.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit clone git@github.com-yourgitaccount:yourgitaccount/myrepo.git\n\u003c/code\u003e\u003c/pre\u003e","title":"git clone multiple accounts"},{"content":"You can save anywhere from 60-91% using a spot instance. The downside is, the instance can be preempted anytime.\nCreate a spot instance.\ngcloud beta compute instances create spot-example \\ --provisioning-model=SPOT \\ --instance-termination-action=STOP \\ --image-project=ubuntu-os-cloud \\ --image-family=ubuntu-2004-lts \\ --machine-type=e2-micro \\ --project=your-project-id \\ --zone=us-central1-a Delete instance.\ngcloud compute instances delete spot-example \\ --project=your-project-id \\ --zone=us-central1-a ","permalink":"http://uly.me/posts/gcp-spot-instance/","summary":"\u003cp\u003eYou can save anywhere from 60-91% using a spot instance. The downside is, the instance can be preempted anytime.\u003c/p\u003e\n\u003cp\u003eCreate a spot instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta compute instances create spot-example \\\n--provisioning-model=SPOT \\\n--instance-termination-action=STOP \\\n--image-project=ubuntu-os-cloud \\\n--image-family=ubuntu-2004-lts \\\n--machine-type=e2-micro \\\n--project=your-project-id \\\n--zone=us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances delete spot-example \\\n--project=your-project-id \\\n--zone=us-central1-a\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp spot instance"},{"content":"How to create S3 bucket via Terraform.\nterraform { required_providers { aws = { source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_s3_bucket\u0026#34; \u0026#34;bucket\u0026#34; { bucket = \u0026#34;my-ulysses-bucket\u0026#34; acl = \u0026#34;private\u0026#34; tags = { Name = \u0026#34;My Ulysses bucket\u0026#34; Environment = \u0026#34;Dev\u0026#34; } } resource \u0026#34;aws_s3_bucket_public_access_block\u0026#34; \u0026#34;example\u0026#34; { bucket = aws_s3_bucket.bucket.id block_public_acls = true block_public_policy = true ignore_public_acls = true restrict_public_buckets = true } ","permalink":"http://uly.me/posts/terraform-aws-s3/","summary":"\u003cp\u003eHow to create S3 bucket via Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\n\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\n\nresource \u0026#34;aws_s3_bucket\u0026#34; \u0026#34;bucket\u0026#34; {\n  bucket = \u0026#34;my-ulysses-bucket\u0026#34;\n  acl    = \u0026#34;private\u0026#34;\n\n  tags = {\n    Name        = \u0026#34;My Ulysses bucket\u0026#34;\n    Environment = \u0026#34;Dev\u0026#34;\n  }\n}\n\nresource \u0026#34;aws_s3_bucket_public_access_block\u0026#34; \u0026#34;example\u0026#34; {\n  bucket = aws_s3_bucket.bucket.id\n  block_public_acls = true\n  block_public_policy = true\n  ignore_public_acls = true\n  restrict_public_buckets = true\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform aws s3"},{"content":"How to create a security group in AWS via Terraform.\nterraform { required_providers { aws = { source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_security_group\u0026#34; \u0026#34;my_sg\u0026#34; { vpc_id = \u0026#34;vpc-xxxxxxxxxxxxxxxxx\u0026#34; name = \u0026#34;My Security Group\u0026#34; description = \u0026#34;My Security Group\u0026#34; ingress { from_port = 8088 to_port = 8088 protocol = \u0026#34;tcp\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } egress { from_port = 0 to_port = 0 protocol = \u0026#34;-1\u0026#34; cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;] } tags = { Name = \u0026#34;My Security Group\u0026#34; } } ","permalink":"http://uly.me/posts/terraform-aws-security-group/","summary":"\u003cp\u003eHow to create a security group in AWS via Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\n\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\n\nresource \u0026#34;aws_security_group\u0026#34; \u0026#34;my_sg\u0026#34; {\n  vpc_id       = \u0026#34;vpc-xxxxxxxxxxxxxxxxx\u0026#34;\n  name         = \u0026#34;My Security Group\u0026#34;\n  description  = \u0026#34;My Security Group\u0026#34;\n  ingress {\n\tfrom_port   = 8088\n\tto_port     = 8088\n        protocol    = \u0026#34;tcp\u0026#34;\n        cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  egress {\n        from_port   = 0\n        to_port     = 0\n        protocol    = \u0026#34;-1\u0026#34;\n        cidr_blocks = [\u0026#34;0.0.0.0/0\u0026#34;]\n  }\n  tags = {\n        Name = \u0026#34;My Security Group\u0026#34;\n  }  \n}\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform aws security group"},{"content":"Here’s where the Wiki keeps its SSL certificate keys.\n/etc/pki/tls/certs/yourdomain.crt /etc/pki/tls/private/yourdomain.key In some cases, SSL needs to be converted so it doesn’t prompt you for a password if you restart Apache.\nConversion\nopenssl rsa -in /etc/pki/tls/private/yourdomain.key.new -out /etc/pki/tls/private/yourdomain.key.new_no_pass ","permalink":"http://uly.me/posts/wiki-ssl-certificate-location/","summary":"\u003cp\u003eHere’s where the Wiki keeps its SSL certificate keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/etc/pki/tls/certs/yourdomain.crt\n/etc/pki/tls/private/yourdomain.key\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn some cases, SSL needs to be converted so it doesn’t prompt you for a password if you restart Apache.\u003c/p\u003e\n\u003cp\u003eConversion\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eopenssl rsa -in /etc/pki/tls/private/yourdomain.key.new -out /etc/pki/tls/private/yourdomain.key.new_no_pass\n\u003c/code\u003e\u003c/pre\u003e","title":"wiki ssl certificate location"},{"content":"Here’s how to setup your SSH keys to work with Github.\nGenerate a key using ed25519 public-key signature system.\nssh-keygen -t ed25519 It creates a id_ed25519.pub file.\nGo to Github.com and open up Settings \u0026gt; SSH \u0026amp; GPG keys.\nClick New SSH key. Give a title and paste your pub key. Authorize.\n","permalink":"http://uly.me/posts/github-ssh-keys-setup/","summary":"\u003cp\u003eHere’s how to setup your SSH keys to work with Github.\u003c/p\u003e\n\u003cp\u003eGenerate a key using ed25519 public-key signature system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh-keygen -t ed25519\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt creates a id_ed25519.pub file.\u003c/p\u003e\n\u003cp\u003eGo to Github.com and open up Settings \u0026gt; SSH \u0026amp; GPG keys.\u003c/p\u003e\n\u003cp\u003eClick New SSH key. Give a title and paste your pub key. Authorize.\u003c/p\u003e","title":"github ssh keys setup"},{"content":"Here’s how to list a GCP firewall rule by name.\ngcloud compute firewall-rules list \\ --filter=\u0026#34;name=(\u0026#39;wowza-rtmp\u0026#39;)\u0026#34; \\ --format=json You can use different formats. Supported formats are:\nconfig, csv, default, diff, disable, flattened, get, json, list, multi, none, object, table, text, value, yaml\n","permalink":"http://uly.me/posts/gcp-list-firewall-rule-by-name/","summary":"\u003cp\u003eHere’s how to list a GCP firewall rule by name.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules list \\\n--filter=\u0026#34;name=(\u0026#39;wowza-rtmp\u0026#39;)\u0026#34; \\\n--format=json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can use different formats. Supported formats are:\u003c/p\u003e\n\u003cp\u003econfig, csv, default, diff, disable, flattened, get, json, list, multi, none, object, table, text, value, yaml\u003c/p\u003e","title":"gcp list firewall rule by name"},{"content":"Services that user Security Groups\nEC2-Classic instance\nAmazon EC2 instances\nElasticCache\nAWS Elastic Beanstalk\nAmazon Elastic MapReduce\nAmazon RDS (Relational Database Service)\nAmazon Redshift\nAmazon ElastiCache\nAmazon CloudSearch\nElastic Load Balancing\nLambda\nFargate\nEFS\n","permalink":"http://uly.me/posts/aws-services-that-use-security-groups/","summary":"\u003cp\u003eServices that user Security Groups\u003c/p\u003e\n\u003cp\u003eEC2-Classic instance\u003cbr\u003e\nAmazon EC2 instances\u003cbr\u003e\nElasticCache\u003cbr\u003e\nAWS Elastic Beanstalk\u003cbr\u003e\nAmazon Elastic MapReduce\u003cbr\u003e\nAmazon RDS (Relational Database Service)\u003cbr\u003e\nAmazon Redshift\u003cbr\u003e\nAmazon ElastiCache\u003cbr\u003e\nAmazon CloudSearch\u003cbr\u003e\nElastic Load Balancing\u003cbr\u003e\nLambda\u003cbr\u003e\nFargate\u003cbr\u003e\nEFS\u003c/p\u003e","title":"aws services that use security groups"},{"content":"Here’s the software packages updated the last month.\nrpm -qa --last | grep -w \u0026#34;$(date --date=\u0026#39;1 month ago\u0026#39; +\u0026#39;%b %Y\u0026#39;)\u0026#34; Result\npython-perf-3.10.0-1160.42.2.el7.x86_64 Mon 04 Oct 2021 02:16:16 AM UTC openldap-2.4.44-24.el7_9.x86_64 Mon 04 Oct 2021 02:16:12 AM UTC kpartx-0.4.9-135.el7_9.x86_64 Mon 04 Oct 2021 02:16:09 AM UTC kernel-tools-libs-3.10.0-1160.42.2.el7.x86_64 Mon 04 Oct 2021 02:16:05 AM UTC kernel-tools-3.10.0-1160.42.2.el7.x86_64 Mon 04 Oct 2021 02:16:05 AM UTC kernel-3.10.0-1160.42.2.el7.x86_64 Mon 04 Oct 2021 02:14:41 AM UTC virt-what-1.18-4.el7_9.1.x86_64 Mon 04 Oct 2021 01:03:22 AM UTC bind-export-libs-9.11.4-26.P2.el7_9.7.x86_64 Mon 04 Oct 2021 01:03:22 AM UTC # ... truncated output ","permalink":"http://uly.me/posts/rpm-updates-the-last-month/","summary":"\u003cp\u003eHere’s the software packages updated the last month.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa --last | grep -w \u0026#34;$(date --date=\u0026#39;1 month ago\u0026#39; +\u0026#39;%b %Y\u0026#39;)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epython-perf-3.10.0-1160.42.2.el7.x86_64       Mon 04 Oct 2021 02:16:16 AM UTC\nopenldap-2.4.44-24.el7_9.x86_64               Mon 04 Oct 2021 02:16:12 AM UTC\nkpartx-0.4.9-135.el7_9.x86_64                 Mon 04 Oct 2021 02:16:09 AM UTC\nkernel-tools-libs-3.10.0-1160.42.2.el7.x86_64 Mon 04 Oct 2021 02:16:05 AM UTC\nkernel-tools-3.10.0-1160.42.2.el7.x86_64      Mon 04 Oct 2021 02:16:05 AM UTC\nkernel-3.10.0-1160.42.2.el7.x86_64            Mon 04 Oct 2021 02:14:41 AM UTC\nvirt-what-1.18-4.el7_9.1.x86_64               Mon 04 Oct 2021 01:03:22 AM UTC\nbind-export-libs-9.11.4-26.P2.el7_9.7.x86_64  Mon 04 Oct 2021 01:03:22 AM UTC\n# ... truncated output\n\u003c/code\u003e\u003c/pre\u003e","title":"rpm updates the last month"},{"content":"If you find yourself using a named profile for every awscli command, you can set it temporarily.\nListing a bucket with a named profile.\naws s3 ls --profile=yourprofile If you set AWS_PROFILE, you can then list a bucket without a named profile.\nexport AWS_PROFILE=yourprofile aws s3 ls After you are done, you can reset it back to default.\nexport AWS_PROFILE=default ","permalink":"http://uly.me/posts/aws-set-profile/","summary":"\u003cp\u003eIf you find yourself using a named profile for every awscli command, you can set it temporarily.\u003c/p\u003e\n\u003cp\u003eListing a bucket with a named profile.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 ls --profile=yourprofile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you set AWS_PROFILE, you can then list a bucket without a named profile.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport AWS_PROFILE=yourprofile\naws s3 ls\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAfter you are done, you can reset it back to default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport AWS_PROFILE=default\n\u003c/code\u003e\u003c/pre\u003e","title":"aws set profile"},{"content":"Here’s how to create a local yum repo.\nInstall Apache.\nsudo yum install httpd sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd Install the repo packages.\nsudo yum install createrepo yum-utils Create repo directories.\nsudo mkdir /var/www/html/{baseos,extras,appstream,epel} Sync the repos.\nsudo yum reposync -p=/var/www/html --repoid=baseos --download-metadata sudo yum reposync -p=/var/www/html --repoid=extras --download-metadata sudo yum reposync -p=/var/www/html --repoid=appstream --download-metadata sudo yum reposync -p=/var/www/html --repoid=epel --download-metadata Create a new repo.\nsudo createrepo /var/www/html/ Setup a local repo.\nsudo nano /etc/yum.repos.d/local.repo Contents of local.repo.\nlocal-base] name=Yum Local Base baseurl=http://10.10.0.20:80/base enabled=1 gpgcheck=0 [local-extras] name=Yum Local Extras baseurl=http://10.10.0.20:80/extras enabled=1 gpgcheck=0 [local-appstream] name=Yum Local Appstream baseurl=http://10.10.0.20:80/appstream enabled=1 gpgcheck=0 [local-epel] name=Yum Local Epel baseurl=http://10.10.0.20:80/epel enabled=1 gpgcheck=0 Confirm new repo is in the repolist.\nsudo yum repolist ","permalink":"http://uly.me/posts/create-local-yum-repo/","summary":"\u003cp\u003eHere’s how to create a local yum repo.\u003c/p\u003e\n\u003cp\u003eInstall Apache.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install httpd\nsudo systemctl start httpd\nsudo systemctl enable httpd\nsudo systemctl status httpd\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall the repo packages.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum install createrepo yum-utils\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate repo directories.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo mkdir /var/www/html/{baseos,extras,appstream,epel}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSync the repos.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum reposync -p=/var/www/html --repoid=baseos --download-metadata\nsudo yum reposync -p=/var/www/html --repoid=extras --download-metadata\nsudo yum reposync -p=/var/www/html --repoid=appstream --download-metadata\nsudo yum reposync -p=/var/www/html --repoid=epel --download-metadata\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a new repo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo createrepo /var/www/html/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSetup a local repo.\u003c/p\u003e","title":"create local yum repo"},{"content":"How to remove an environment variable in Linux.\nunset AWS_PROFILE You can run env to validate if variable is still present.\nenv ","permalink":"http://uly.me/posts/remove-an-environment-variable/","summary":"\u003cp\u003eHow to remove an environment variable in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eunset AWS_PROFILE\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can run env to validate if variable is still present.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eenv\n\u003c/code\u003e\u003c/pre\u003e","title":"remove an environment variable"},{"content":"Here’s how to run Rocky Linux in a Docker container.\nDownload the image.\ndocker pull rockylinux/rockylinux Create a Rocky Linux container called bullwinkle.\ndocker run -it --name bullwinkle -d rockylinux/rockylinux Login to the container using bash.\ndocker exec -it --user root bullwinkle /bin/bash When done, stop and delete the container.\ndocker ps -a docker stop container_ID docker rm container_ID ","permalink":"http://uly.me/posts/rocky-linux-in-a-container/","summary":"\u003cp\u003eHere’s how to run Rocky Linux in a Docker container.\u003c/p\u003e\n\u003cp\u003eDownload the image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker pull rockylinux/rockylinux\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a Rocky Linux container called bullwinkle.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run -it --name bullwinkle -d rockylinux/rockylinux\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin to the container using bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker exec -it --user root bullwinkle /bin/bash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWhen done, stop and delete the container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker ps -a\ndocker stop container_ID\ndocker rm container_ID\n\u003c/code\u003e\u003c/pre\u003e","title":"rocky linux in a container"},{"content":"Here’s how to add a path to zsh permanently.\nEdit .zshrc file and add the path. Create .zshrc file if it’s missing.\nexport PATH=$PATH:/new/path Exit and relaunch shell. The new path should be in effect.\nEcho to display new path.\necho $PATH ","permalink":"http://uly.me/posts/add-path-to-zsh/","summary":"\u003cp\u003eHere’s how to add a path to zsh permanently.\u003c/p\u003e\n\u003cp\u003eEdit .zshrc file and add the path. Create .zshrc file if it’s missing.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport PATH=$PATH:/new/path\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExit and relaunch shell. The new path should be in effect.\u003c/p\u003e\n\u003cp\u003eEcho to display new path.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $PATH\n\u003c/code\u003e\u003c/pre\u003e","title":"add path to zsh"},{"content":"Here’s how to delete a line from a file using awk.\nawk \u0026#39;!/Redhat/\u0026#39; sample.txt \u0026gt; sample.tmp \u0026amp;\u0026amp; mv sample.tmp sample.txt The command above looks for ‘Redhat’ in a file and removes that line from the file.\nYou can add the line in the crontab to run at reboot if you like.\ncrontab -e @reboot awk \u0026#39;!/Redhat/\u0026#39; sample.txt \u0026gt; sample.tmp \u0026amp;\u0026amp; mv sample.tmp sample.txt ","permalink":"http://uly.me/posts/delete-lines-using-awk/","summary":"\u003cp\u003eHere’s how to delete a line from a file using awk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eawk \u0026#39;!/Redhat/\u0026#39; sample.txt \u0026gt; sample.tmp \u0026amp;\u0026amp; mv sample.tmp sample.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe command above looks for ‘Redhat’ in a file and removes that line from the file.\u003c/p\u003e\n\u003cp\u003eYou can add the line in the crontab to run at reboot if you like.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab -e\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e@reboot awk \u0026#39;!/Redhat/\u0026#39; sample.txt \u0026gt; sample.tmp \u0026amp;\u0026amp; mv sample.tmp sample.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"delete lines using awk"},{"content":"Here’s the command to create a Linux user with a specific user id and group id.\nsudo groupadd -r -g 1234567 username sudo useradd -r -u 1234567 -g 1234567 -m -d /home/username -s /bin/bash nexus -c \u0026#34;my new account\u0026#34; ","permalink":"http://uly.me/posts/useradd-with-specific-uid-and-guid/","summary":"\u003cp\u003eHere’s the command to create a Linux user with a specific user id and group id.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo groupadd -r -g 1234567 username\nsudo useradd -r -u 1234567 -g 1234567 -m -d /home/username -s /bin/bash nexus -c \u0026#34;my new account\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"useradd with specific uid and guid"},{"content":"You can run database clients on your Linux distro by installing them.\nMySQL\n$ yum install mysql $ apt install mysql Postgress\n$ yum install postgresql postgresql-client $ apt install postgresql postgresql-client MSSQL\n$ yum install mysql-tools $ apt install mssql-tools ","permalink":"http://uly.me/posts/database-clients-on-linux/","summary":"\u003cp\u003eYou can run database clients on your Linux distro by installing them.\u003c/p\u003e\n\u003cp\u003eMySQL\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ yum install mysql\n$ apt install mysql\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePostgress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ yum install postgresql postgresql-client\n$ apt install postgresql postgresql-client\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMSSQL\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ yum install mysql-tools\n$ apt install mssql-tools\n\u003c/code\u003e\u003c/pre\u003e","title":"database clients on linux"},{"content":"OpenJDK is an open-source implementation of the Java.\nHow to install AdoptOpenJDK.\nTAR\ncd /usr/java wget --no-check-certificate https://bit.ly/3jKm3KZ tar xzf OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz export PATH=$PWD/jdk8u312-b07/bin:$PATH java -version RPM\ncat /etc/yum.repos.d/adoptopenjdk.repo [AdoptOpenJDK] name=AdoptOpenJDK baseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/$releasever/$basearch enabled=1 gpgcheck=1 gpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public EOF yum install adoptopenjdk-8-openj9 ","permalink":"http://uly.me/posts/install-adoptopenjdk/","summary":"\u003cp\u003eOpenJDK is an open-source implementation of the Java.\u003c/p\u003e\n\u003cp\u003eHow to install AdoptOpenJDK.\u003c/p\u003e\n\u003cp\u003eTAR\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /usr/java\nwget --no-check-certificate https://bit.ly/3jKm3KZ\ntar xzf OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz\nexport PATH=$PWD/jdk8u312-b07/bin:$PATH\njava -version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRPM\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat  /etc/yum.repos.d/adoptopenjdk.repo\n[AdoptOpenJDK]\nname=AdoptOpenJDK\nbaseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/$releasever/$basearch\nenabled=1\ngpgcheck=1\ngpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public\nEOF\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install adoptopenjdk-8-openj9\n\u003c/code\u003e\u003c/pre\u003e","title":"install adoptopenjdk"},{"content":"Here’s how to add userdata in Terraform.\nuser_data = filebase64(\u0026#34;${path.module}/example.sh\u0026#34;) ","permalink":"http://uly.me/posts/terraform-user-data/","summary":"\u003cp\u003eHere’s how to add userdata in Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003euser_data = filebase64(\u0026#34;${path.module}/example.sh\u0026#34;)\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform user data"},{"content":"How to enable and disable CloudWatch alarms\n$ aws cloudwatch disable-alarm-actions --alarm-names myalarm --region us-east-1 $ aws cloudwatch enable-alarm-actions --alarm-names myalarm --region us-east-1 ","permalink":"http://uly.me/posts/aws-cloudwatch-alarms/","summary":"\u003cp\u003eHow to enable and disable CloudWatch alarms\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws cloudwatch disable-alarm-actions --alarm-names myalarm --region us-east-1\n$ aws cloudwatch enable-alarm-actions --alarm-names myalarm --region us-east-1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cloudwatch alarms"},{"content":"You can administratively suspend a process in AWS Auto Scaling group for troubleshooting purposes.\nHere are the available processes.\nTerminate Launch AddToLoadBalancer AlarmNotification AZRebalance HealthCheck ReplaceUnhealthy ScheduledActions If you have difficulty launching a VM, check if any of these processes are suspended.\nRemoved them if applicable.\n","permalink":"http://uly.me/posts/aws-suspend-auto-scaling-group/","summary":"\u003cp\u003eYou can administratively suspend a process in AWS Auto Scaling group for troubleshooting purposes.\u003c/p\u003e\n\u003cp\u003eHere are the available processes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eTerminate\nLaunch\nAddToLoadBalancer\nAlarmNotification\nAZRebalance\nHealthCheck\nReplaceUnhealthy\nScheduledActions\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have difficulty launching a VM, check if any of these processes are suspended.\u003c/p\u003e\n\u003cp\u003eRemoved them if applicable.\u003c/p\u003e","title":"aws suspend auto scaling group"},{"content":"Here’s the openssl command to find out if a cert is expired.\n$ openssl s_client -connect yourdomain.com:443 -servername yourdomain.com 2\u0026gt; /dev/null | openssl x509 -noout -dates Result\nnotBefore=Apr 9 00:00:00 2020 GMT notAfter=Apr 9 23:59:59 2022 GMT ","permalink":"http://uly.me/posts/check-certificate-expiration/","summary":"\u003cp\u003eHere’s the openssl command to find out if a cert is expired.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ openssl s_client -connect yourdomain.com:443 -servername yourdomain.com 2\u0026gt; /dev/null | openssl x509 -noout -dates\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enotBefore=Apr  9 00:00:00 2020 GMT\nnotAfter=Apr  9 23:59:59 2022 GMT\n\u003c/code\u003e\u003c/pre\u003e","title":"check certificate expiration"},{"content":"Although telnet is not used regularly since insecure, it’s a handy tool for testing ports.\nFor example, to check if a port 80 is open, you run this command.\n$ telnet servername 80 Git Bash does not come with telnet, but you can use the Windows version by using winpty.\n$ winpty telnet servername 457 Connecting To servername...Could not open connection to the host, on port 457: Connect failed If port is open, you get an empty reply, just like in Windows.\n","permalink":"http://uly.me/posts/run-telnet-on-git-bash/","summary":"\u003cp\u003eAlthough telnet is not used regularly since insecure, it’s a handy tool for testing ports.\u003c/p\u003e\n\u003cp\u003eFor example, to check if a port 80 is open, you run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ telnet servername 80\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGit Bash does not come with telnet, but you can use the Windows version by using winpty.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ winpty telnet servername 457\nConnecting To servername...Could not open connection to the host, on port 457: Connect failed\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf port is open, you get an empty reply, just like in Windows.\u003c/p\u003e","title":"run telnet on git bash"},{"content":"You can use gsutil to copy directly from a S3 bucket to a GCS bucket.\ngsutil can read/write to a S3 bucket as long as it has access to your AWS credentials.\nThe -R option is recursive and -m is for multi-threaded or multi-processing.\ngsutil -m cp -R s3://bucket/ gs://bucket You can also use rsync instead of cp. Just be aware that rsync does not copy empty directory trees\ngsutil -m rsync -r s3://bucket/ gs://bucket If you plan to use -d, Use it with caution since it deletes content.\nYou may have to set the following to your defaults accounts.\nexport AWS_PROFILE=yourprofile gcloud config set project your-project-id This ensures that default profile and projects are used in both AWS and GCP.\n","permalink":"http://uly.me/posts/copy-s3-to-gcs/","summary":"\u003cp\u003eYou can use gsutil to copy directly from a S3 bucket to a GCS bucket.\u003c/p\u003e\n\u003cp\u003egsutil can read/write to a S3 bucket as long as it has access to your AWS credentials.\u003c/p\u003e\n\u003cp\u003eThe -R option is recursive and -m is for multi-threaded or multi-processing.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsutil -m cp -R s3://bucket/ gs://bucket\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also use rsync instead of cp. Just be aware that rsync does not copy empty directory trees\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsutil -m rsync -r s3://bucket/ gs://bucket\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you plan to use -d, Use it with caution since it deletes content.\u003c/p\u003e","title":"copy s3 to gcs"},{"content":"To undo a git add, run git reset file or get reset.\ngit reset filename git reset Run git status to check.\ngit status ","permalink":"http://uly.me/posts/git-undo-add/","summary":"\u003cp\u003eTo undo a git add, run git reset file or get reset.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit reset filename\ngit reset \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun git status to check.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit status\n\u003c/code\u003e\u003c/pre\u003e","title":"git undo add"},{"content":"Here’s how to search for an IAM user in AWS by filtering their access key.\naws iam list-users --query \u0026#39;Users[?UserId==`AIDAxxxxxxxxxxxxxxxxx`]\u0026#39; \\ --profile your-profile The results only returns one user with that UserID.\n[ { \u0026#34;Path\u0026#34;: \u0026#34;/\u0026#34;, \u0026#34;UserName\u0026#34;: \u0026#34;your-username\u0026#34;, \u0026#34;UserId\u0026#34;: \u0026#34;AIDAxxxxxxxxxxxxxxxxx\u0026#34;, \u0026#34;Arn\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxxxx:user/sa-lucidchart\u0026#34;, \u0026#34;CreateDate\u0026#34;: \u0026#34;2019-04-15T15:53:18+00:00\u0026#34; } ] ","permalink":"http://uly.me/posts/aws-cli-search-iam-userid/","summary":"\u003cp\u003eHere’s how to search for an IAM user in AWS by filtering their access key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam list-users --query \u0026#39;Users[?UserId==`AIDAxxxxxxxxxxxxxxxxx`]\u0026#39; \\\n--profile your-profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe results only returns one user with that UserID.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[\n    {\n        \u0026#34;Path\u0026#34;: \u0026#34;/\u0026#34;,\n        \u0026#34;UserName\u0026#34;: \u0026#34;your-username\u0026#34;,\n        \u0026#34;UserId\u0026#34;: \u0026#34;AIDAxxxxxxxxxxxxxxxxx\u0026#34;,\n        \u0026#34;Arn\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxxxx:user/sa-lucidchart\u0026#34;,\n        \u0026#34;CreateDate\u0026#34;: \u0026#34;2019-04-15T15:53:18+00:00\u0026#34;\n    }\n]\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli search iam userid"},{"content":"How to display roles assigned to a GCP service account.\ngcloud projects get-iam-policy your-project-id \\ --flatten=\u0026#34;bindings[].members\u0026#34; \\ --format=\u0026#39;table(bindings.role)\u0026#39; \\ --filter=\u0026#34;bindings.members:your-service-account@your-project.iam.gserviceaccount.com\u0026#34; Result\nROLE organizations/xxxxxxxxxxxxx/roles/role-name roles/compute.instanceAdmin.v1 roles/compute.networkViewer roles/logging.logWriter roles/monitoring.metricWriter ","permalink":"http://uly.me/posts/gcp-display-roles-on-service-account/","summary":"\u003cp\u003eHow to display roles assigned to a GCP service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud projects get-iam-policy your-project-id \\\n--flatten=\u0026#34;bindings[].members\u0026#34; \\\n--format=\u0026#39;table(bindings.role)\u0026#39; \\\n--filter=\u0026#34;bindings.members:your-service-account@your-project.iam.gserviceaccount.com\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eROLE\norganizations/xxxxxxxxxxxxx/roles/role-name\nroles/compute.instanceAdmin.v1\nroles/compute.networkViewer\nroles/logging.logWriter\nroles/monitoring.metricWriter\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp display roles on service account"},{"content":"How to display a list service accounts in a GCP project.\ngcloud iam service-accounts list --project your-project ","permalink":"http://uly.me/posts/gcp-list-service-accounts-in-project/","summary":"\u003cp\u003eHow to display a list service accounts in a GCP project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud iam service-accounts list --project your-project\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list service accounts in project"},{"content":"How to find where the executable is located in Windows? Use the where command in CMD.\nwhere gcloud C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud.cmd It will list multiple locations if you have several versions installed on your system.\n","permalink":"http://uly.me/posts/where-in-windows/","summary":"\u003cp\u003eHow to find where the executable is located in Windows? Use the where command in CMD.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewhere gcloud\nC:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud\nC:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud.cmd\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt will list multiple locations if you have several versions installed on your system.\u003c/p\u003e","title":"where in windows"},{"content":"How to find where php.ini is being from the command line.\n$ php -i | grep \u0026#39;grep \u0026#39;Configuration File\u0026#39; Configuration File (php.ini) Path =\u0026gt; /etc Loaded Configuration File =\u0026gt; /etc/php.ini ","permalink":"http://uly.me/posts/wheres-php-ini/","summary":"\u003cp\u003eHow to find where php.ini is being from the command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ php -i | grep \u0026#39;grep \u0026#39;Configuration File\u0026#39;\nConfiguration File (php.ini) Path =\u0026gt; /etc\nLoaded Configuration File =\u0026gt; /etc/php.ini\n\u003c/code\u003e\u003c/pre\u003e","title":"where is php.ini?"},{"content":"If you tried to run apt update and you get this error, try the following.\n$ apt update E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) [duplicate] Kill the process.\n$ sudo killall apt apt-get If that doesn’t work, remove the locked files.\n$ sudo rm /var/lib/apt/lists/lock $ sudo rm /var/cache/apt/archives/lock $ sudo rm /var/lib/dpkg/lock* Run apt update again.\n","permalink":"http://uly.me/posts/apt-locked-files/","summary":"\u003cp\u003eIf you tried to run apt update and you get this error, try the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ apt update\nE: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) [duplicate]\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eKill the process.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo killall apt apt-get\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf that doesn’t work, remove the locked files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo rm /var/lib/apt/lists/lock\n$ sudo rm /var/cache/apt/archives/lock\n$ sudo rm /var/lib/dpkg/lock*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun apt update again.\u003c/p\u003e","title":"apt locked files"},{"content":"Occassionally, AWS requires validation of your domain via email message. Here’s the command to send a request.\naws acm resend-validation-email \\ --certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\ --domain yourdomain.com \\ --validation-domain yourdomain.com aws acm resend-validation-email \\ --certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\ --domain www.yourdomain.com \\ --validation-domain yourdomain.com You will need acm:ResendValidationEmail permission to run the command.\n","permalink":"http://uly.me/posts/aws-request-domain-renewal/","summary":"\u003cp\u003eOccassionally, AWS requires validation of your domain via email message. Here’s the command to send a request.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm resend-validation-email \\\n--certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\\n--domain yourdomain.com \\\n--validation-domain yourdomain.com\n\naws acm resend-validation-email \\\n--certificate-arn arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\\n--domain www.yourdomain.com \\\n--validation-domain yourdomain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou will need acm:ResendValidationEmail permission to run the command.\u003c/p\u003e","title":"aws request domain renewal"},{"content":"When running awscli as a user, I’m getting a permissioned denied.\n[user@servername ~]$ aws s3 ls Traceback (most recent call last): File \u0026#34;/home/db2inst1/.local/bin/aws\u0026#34;, line 19, in \u0026lt;module\u0026gt; import awscli.clidriver File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/awscli/clidriver.py\u0026#34;, line 17, in \u0026lt;module\u0026gt; import botocore.session File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/session.py\u0026#34;, line 26, in \u0026lt;module\u0026gt; import botocore.configloader File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/configloader.py\u0026#34;, line 19, in \u0026lt;module\u0026gt; from botocore.compat import six File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/compat.py\u0026#34;, line 172, in \u0026lt;module\u0026gt; import xml.etree.cElementTree File \u0026#34;/usr/lib64/python2.7/xml/etree/cElementTree.py\u0026#34;, line 3, in \u0026lt;module\u0026gt; from _elementtree import * ImportError: PyCapsule_Import could not import module \u0026#34;pyexpat\u0026#34; \u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt; This is a permission error with the directory where the awscli is installed.\n$ which aws /usr/local/bin/aws I ran chmod to fix the directory permission.\nchmod -R 755 /usr/local/aws-cli/ The error is now gone.\n$ aws s3 ls bucket-1 bucket-2 bucket-3 ","permalink":"http://uly.me/posts/awscli-permission-denied/","summary":"\u003cp\u003eWhen running awscli as a user, I’m getting a permissioned denied.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[user@servername ~]$ aws s3 ls\nTraceback (most recent call last):\n  File \u0026#34;/home/db2inst1/.local/bin/aws\u0026#34;, line 19, in \u0026lt;module\u0026gt;\n    import awscli.clidriver\n  File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/awscli/clidriver.py\u0026#34;, line 17, in \u0026lt;module\u0026gt;\n    import botocore.session\n  File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/session.py\u0026#34;, line 26, in \u0026lt;module\u0026gt;\n    import botocore.configloader\n  File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/configloader.py\u0026#34;, line 19, in \u0026lt;module\u0026gt;\n    from botocore.compat import six\n  File \u0026#34;/home/db2inst1/.local/lib/python2.7/site-packages/botocore/compat.py\u0026#34;, line 172, in \u0026lt;module\u0026gt;\n    import xml.etree.cElementTree\n  File \u0026#34;/usr/lib64/python2.7/xml/etree/cElementTree.py\u0026#34;, line 3, in \u0026lt;module\u0026gt;\n    from _elementtree import *\nImportError: PyCapsule_Import could not import module \u0026#34;pyexpat\u0026#34;\n\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\u0026lt;/module\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is a permission error with the directory where the awscli is installed.\u003c/p\u003e","title":"awscli permission denied"},{"content":"Use this option if you want to scan the top 1000 ports.\n$ nmap -F 10.10.10.10 If you want a single specific port, then use -p option.\n$ nmap -p 80 10.10.10.10 ","permalink":"http://uly.me/posts/nmap-scan-top-1000-ports/","summary":"\u003cp\u003eUse this option if you want to scan the top 1000 ports.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ nmap -F 10.10.10.10\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want a single specific port, then use -p option.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ nmap -p 80 10.10.10.10\n\u003c/code\u003e\u003c/pre\u003e","title":"nmap scan top 1000 ports"},{"content":"Here’s how to list GCP firewall rules while filtering a service account. Output is exported as a CSV file.\ngcloud compute firewall-rules list \\ --project host-project \\ --filter=service-account-name \\ --format=\u0026#34;csv( name, network, direction, priority, sourceRanges.list():label=SRC_RANGES, destinationRanges.list():label=DEST_RANGES, allowed[].map().firewall_rule().list():label=ALLOW, denied[].map().firewall_rule().list():label=DENY, sourceTags.list():label=SRC_TAGS, sourceServiceAccounts.list():label=SRC_SVC_ACCT, targetTags.list():label=TARGET_TAGS, targetServiceAccounts.list():label=TARGET_SVC_ACCT, disabled)\u0026#34; \\ \u0026gt; export.csv ","permalink":"http://uly.me/posts/gcp-list-firewall-rules/","summary":"\u003cp\u003eHere’s how to list GCP firewall rules while filtering a service account. Output is exported as a CSV file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules list \\\n--project host-project \\\n--filter=service-account-name \\\n--format=\u0026#34;csv(\nname,\nnetwork,\ndirection,\npriority,\nsourceRanges.list():label=SRC_RANGES,\ndestinationRanges.list():label=DEST_RANGES,\nallowed[].map().firewall_rule().list():label=ALLOW,\ndenied[].map().firewall_rule().list():label=DENY,\nsourceTags.list():label=SRC_TAGS,\nsourceServiceAccounts.list():label=SRC_SVC_ACCT,\ntargetTags.list():label=TARGET_TAGS,\ntargetServiceAccounts.list():label=TARGET_SVC_ACCT,\ndisabled)\u0026#34; \\\n\u0026gt; export.csv\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list firewall rules"},{"content":"Check if there’s a runaway rpm process. This returns number of processes that are running.\nps -ef | grep rpm | wc -l Kill it.\nkillall -9 rpm You should be able to run yum updates from this point on.\n","permalink":"http://uly.me/posts/rpm-hung/","summary":"\u003cp\u003eCheck if there’s a runaway rpm process. This returns number of processes that are running.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eps -ef | grep rpm | wc -l\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eKill it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ekillall -9 rpm\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou should be able to run yum updates from this point on.\u003c/p\u003e","title":"rpm hung"},{"content":"In AWSCLI Version 2, it’s using “less” by default to send output to the screen. Less displays output one page at a time.\nIf less interferes with your script, then you can set “cli_pager” in ~/.aws/config to use nothing.\n[default] region = us-east-2 output = json cli_pager = If you have other profiles, add them as well.\n[lightsail] region = us-east-2 output = json cli_pager = ","permalink":"http://uly.me/posts/awscli-cli_pager/","summary":"\u003cp\u003eIn AWSCLI Version 2, it’s using “less” by default to send output to the screen. Less displays output one page at a time.\u003c/p\u003e\n\u003cp\u003eIf less interferes with your script, then you can set “cli_pager” in ~/.aws/config to use nothing.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[default]\nregion = us-east-2\noutput = json\ncli_pager =\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have other profiles, add them as well.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[lightsail]\nregion = us-east-2\noutput = json\ncli_pager =\n\u003c/code\u003e\u003c/pre\u003e","title":"awscli cli_pager"},{"content":"Convert PPK to PEM format.\nOpen Puttygen. Click Load in the Actions section. Select the PPK file you wish to convert. Go to the Conversions menu and select Export OpenSSH key. Click Yes to convert key without a password. Name your private key and save it with a .pem extension. Click Save. Your pem file should begin with “—–BEGIN RSA PRIVATE KEY—–” and ends with “—–END RSA PRIVATE KEY—–.”\nYou can also use puttygen in Linux. Install it first.\n$ sudo apt-get install putty-tools Convert your key.\n$ puttygen yourkey.ppk -O private-openssh -o yourkey.pem SSH to your server.\n$ chmod 400 yourkey.pem $ ssh -i yourkey.pem ec2-user@server-ip ","permalink":"http://uly.me/posts/convert-ppk-to-pem/","summary":"\u003cp\u003eConvert PPK to PEM format.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eOpen Puttygen.\u003c/li\u003e\n\u003cli\u003eClick Load in the Actions section.\u003c/li\u003e\n\u003cli\u003eSelect the PPK file you wish to convert.\u003c/li\u003e\n\u003cli\u003eGo to the Conversions menu and select Export OpenSSH key.\u003c/li\u003e\n\u003cli\u003eClick Yes to convert key without a password.\u003c/li\u003e\n\u003cli\u003eName your private key and save it with a .pem extension.\u003c/li\u003e\n\u003cli\u003eClick Save.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eYour pem file should begin with “—–BEGIN RSA PRIVATE KEY—–” and ends with “—–END RSA PRIVATE KEY—–.”\u003c/p\u003e\n\u003cp\u003eYou can also use puttygen in Linux. Install it first.\u003c/p\u003e","title":"convert ppk to pem"},{"content":"How to uninstall AWSCLI version 2 on Linux\nLocate aws.\n$ which aws /usr/local/bin/aws Delete the symlinks.\n$ ls -l /usr/local/bin/aws $ sudo rm /usr/local/bin/aws $ sudo rm /usr/local/bin/aws_completer Delete the install directory.\n$ sudo rm -rf /usr/local/aws-cli Once deleted, you can reinstall awscli.\n","permalink":"http://uly.me/posts/uninstall-awscli-v2-on-linux/","summary":"\u003cp\u003eHow to uninstall AWSCLI version 2 on Linux\u003c/p\u003e\n\u003cp\u003eLocate aws.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ which aws\n/usr/local/bin/aws\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete the symlinks.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ ls -l /usr/local/bin/aws\n$ sudo rm /usr/local/bin/aws\n$ sudo rm /usr/local/bin/aws_completer\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete the install directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo rm -rf /usr/local/aws-cli\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce deleted, you can reinstall awscli.\u003c/p\u003e","title":"uninstall awscli v2 on linux"},{"content":"In GCP console you can see the VM’s Device Names. In this case, it’s boot and persistent-disk-1.\nName\tDevice name server-boot boot\tserver-data persistent-disk-1\tTo display the volume names on the OS, run this command.\n$ ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 Aug 2 01:12 google-boot -\u0026gt; ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 google-boot-part1 -\u0026gt; ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 google-persistent-disk-1 -\u0026gt; ../../sdb lrwxrwxrwx. 1 root root 9 Aug 2 01:12 scsi-0Google_PersistentDisk_boot -\u0026gt; ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 scsi-0Google_PersistentDisk_boot-part1 -\u0026gt; ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -\u0026gt; ../../sdb As you can see, boot and persistent-disk-1 are displayed along with its device names /dev/sda and /dev/sdb.\n","permalink":"http://uly.me/posts/gcp-display-device-names-on-os/","summary":"\u003cp\u003eIn GCP console you can see the VM’s Device Names. In this case, it’s boot and persistent-disk-1.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eName\t\t          Device name\nserver-boot               boot\t\nserver-data               persistent-disk-1\t\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo display the volume names on the OS, run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ ls -l /dev/disk/by-id\ntotal 0\nlrwxrwxrwx. 1 root root  9 Aug  2 01:12 google-boot -\u0026gt; ../../sda\nlrwxrwxrwx. 1 root root 10 Aug  2 01:12 google-boot-part1 -\u0026gt; ../../sda1\nlrwxrwxrwx. 1 root root  9 Aug 18 18:48 google-persistent-disk-1 -\u0026gt; ../../sdb\nlrwxrwxrwx. 1 root root  9 Aug  2 01:12 scsi-0Google_PersistentDisk_boot -\u0026gt; ../../sda\nlrwxrwxrwx. 1 root root 10 Aug  2 01:12 scsi-0Google_PersistentDisk_boot-part1 -\u0026gt; ../../sda1\nlrwxrwxrwx. 1 root root  9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -\u0026gt; ../../sdb\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAs you can see, boot and persistent-disk-1 are displayed along with its device names /dev/sda and /dev/sdb.\u003c/p\u003e","title":"gcp display device names on os"},{"content":"Here are a few tools to check if ports are open from a remote host.\nnc -zvw10 192.168.0.1 22 nmap 192.168.0.1 -p 22 telnet 192.168.0.1 22 You may have to install netcat and nmap if missing in your distro.\nyum install nc yum install nmap ","permalink":"http://uly.me/posts/check-open-ports-remotely/","summary":"\u003cp\u003eHere are a few tools to check if ports are open from a remote host.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enc -zvw10 192.168.0.1 22\nnmap 192.168.0.1 -p 22\ntelnet 192.168.0.1 22\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may have to install netcat and nmap if missing in your distro.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install nc\nyum install nmap\n\u003c/code\u003e\u003c/pre\u003e","title":"check open ports remotely"},{"content":"How to implement image family with Terraform in GCP.\nDeclare the machine image in terraform.tfvars.\nimage-family = \u0026#34;centos-7\u0026#34; Declare data type for the machine image in maint.tf.\ndata \u0026#34;google_compute_image\u0026#34; \u0026#34;my_image\u0026#34; { family = var.image-family project = \u0026#34;your-project-id\u0026#34; } In main.tf use “google_compute_instance” under boot disk section in main.tf.\nboot_disk { initialize_params { image = data.google_compute_image.my_image.self_link } } ","permalink":"http://uly.me/posts/terraform-gcloud-vm-image-family/","summary":"\u003cp\u003eHow to implement image family with Terraform in GCP.\u003c/p\u003e\n\u003cp\u003eDeclare the machine image in terraform.tfvars.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimage-family = \u0026#34;centos-7\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDeclare data type for the machine image in maint.tf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edata \u0026#34;google_compute_image\u0026#34; \u0026#34;my_image\u0026#34; {\n  family  = var.image-family\n  project = \u0026#34;your-project-id\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn main.tf use “google_compute_instance” under boot disk section in main.tf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eboot_disk {\n  initialize_params {\n    image = data.google_compute_image.my_image.self_link\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform gcloud vm image family"},{"content":"Here’s how to check in Bash if a variable is empty or unset.\nif [ -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39; else echo \u0026#39;do another\u0026#39; fi One liner\nif [ -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39;; else echo \u0026#39;do another\u0026#39;; fi The inverse\nif [ ! -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39; else echo \u0026#39;do another\u0026#39; fi if [ ! -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39;; else echo \u0026#39;do another\u0026#39;; fi ","permalink":"http://uly.me/posts/bash-variable-empty/","summary":"\u003cp\u003eHere’s how to check in Bash if a variable is empty or unset.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ -z \u0026#34;${VAR}\u0026#34; ]; \nthen\n  echo \u0026#39;do something\u0026#39;\nelse\n  echo \u0026#39;do another\u0026#39;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOne liner\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39;; else echo \u0026#39;do another\u0026#39;; fi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe inverse\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ ! -z \u0026#34;${VAR}\u0026#34; ]; \nthen\n  echo \u0026#39;do something\u0026#39;\nelse\n  echo \u0026#39;do another\u0026#39;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ ! -z \u0026#34;${VAR}\u0026#34; ]; then echo \u0026#39;do something\u0026#39;; else echo \u0026#39;do another\u0026#39;; fi\n\u003c/code\u003e\u003c/pre\u003e","title":"bash variable empty"},{"content":"Here are the SAP Corosync settings.\n[root@server ~]corosync-cmapctl | grep fail_recv_const runtime.config.totem.fail_recv_const (u32) = 500 ","permalink":"http://uly.me/posts/corosync-settings/","summary":"\u003cp\u003eHere are the SAP Corosync settings.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[root@server ~]corosync-cmapctl | grep fail_recv_const\nruntime.config.totem.fail_recv_const (u32) = 500\n\u003c/code\u003e\u003c/pre\u003e","title":"corosync settings"},{"content":"Style your text using markdown. If you use GitHub, markdown will come in handy.\nExamples:\n# This is an \u0026lt;h1\u0026gt; tag ## This is an \u0026lt;h2\u0026gt; tag ###### This is an \u0026lt;h6\u0026gt; tag \u0026lt;/h6\u0026gt;\u0026lt;/h2\u0026gt;\u0026lt;/h1\u0026gt; Here are more markdown examples.\n","permalink":"http://uly.me/posts/markdown-language/","summary":"\u003cp\u003eStyle your text using markdown. If you use GitHub, markdown will come in handy.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# This is an \u0026lt;h1\u0026gt; tag\n## This is an \u0026lt;h2\u0026gt; tag\n###### This is an \u0026lt;h6\u0026gt; tag\n\u0026lt;/h6\u0026gt;\u0026lt;/h2\u0026gt;\u0026lt;/h1\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere are more \u003ca href=\"https://guides.github.com/features/mastering-markdown/#examples\"\u003emarkdown examples\u003c/a\u003e.\u003c/p\u003e","title":"markdown language"},{"content":"If you use Terraform and Sublime Text, add Terraform Syntax Highlighter using Package Control.\nPress Ctrl+Shift+P or Cmd+Shift+P. Select “Package Control: Install package” Select “Terraform” It should install in a few seconds.\n","permalink":"http://uly.me/posts/sublime-text-terraform-syntax/","summary":"\u003cp\u003eIf you use Terraform and Sublime Text, add Terraform Syntax Highlighter using Package Control.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePress Ctrl+Shift+P or Cmd+Shift+P.\nSelect “Package Control: Install package”\nSelect “Terraform”\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt should install in a few seconds.\u003c/p\u003e","title":"sublime text terraform syntax"},{"content":"If you have SSSD running and the default shell is ksh even with the default shell set to bash.\nHere’s the fix to override the default shell in /etc/sssd/sssd.conf. Add override_shell.\ndefault_shell = /bin/bash override_shell = /bin/bash To check which shell you are using.\necho $SHELL /bin/bash ","permalink":"http://uly.me/posts/sssd-override-shell/","summary":"\u003cp\u003eIf you have SSSD running and the default shell is ksh even with the default shell set to bash.\u003c/p\u003e\n\u003cp\u003eHere’s the fix to override the default shell in /etc/sssd/sssd.conf. Add override_shell.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edefault_shell = /bin/bash\noverride_shell = /bin/bash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo check which shell you are using.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $SHELL\n/bin/bash\n\u003c/code\u003e\u003c/pre\u003e","title":"sssd override shell"},{"content":"There are a few issues that prop up every once in a while with gcloud compute ssh. gcloud compute ssh creates local user at first login. The account password has a default expiration of 90 days. If unable to login, you can try logging in as a different name (even a fictitious name) e.g. superheroes, etc. something unique.\ngcloud compute ssh username@servername --zone us-central1-c --project project-id --internal-ip Once logged in, you can delete local users with expired passwords or perform other admin tasks.\nuserdel -r username You can also try to run chage to adjust the password expiration.\nchage -M 180 username ​ (extends expiration from 90 to 180 days) If you continue to have login issues, you can also delete Metadata SSH keys in both the instance and project levels.\nLast resort you can use force key overwrite which will regenerate a new key and overwrite broken ssh keys.\ngcloud compute ssh username@servername \\ --force-key-file-overwrite \\ --zone us-central1-c \\ --project project-id \\ --internal-ip ","permalink":"http://uly.me/posts/gcp-ssh-issues/","summary":"\u003cp\u003eThere are a few issues that prop up every once in a while with gcloud compute ssh. gcloud compute ssh creates local user at first login. The account password has a default expiration of 90 days. If unable to login, you can try logging in as a different name (even a fictitious name) e.g. superheroes, etc. something unique.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssh username@servername --zone us-central1-c --project project-id --internal-ip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce logged in, you can delete local users with expired passwords or perform other admin tasks.\u003c/p\u003e","title":"gcp ssh issues"},{"content":"Here’s how to move a VM to another network.\nStop the VM.\ngcloud compute instances stop server-name \\ --zone=us-central1-c \\ --project project-id Migrate the VM. Use self link for network and subnetwork.\ngcloud compute instances network-interfaces update server-name \\ --zone=us-central1-c \\ --network-interface=nic0 \\ --network=your-network \\ --subnetwork=your-sub-network \\ --project project-id Start the VM.\ngcloud compute instances start server-name \\ --zone=us-central1-c \\ --project project-id ","permalink":"http://uly.me/posts/migrate-vm-to-other-network/","summary":"\u003cp\u003eHere’s how to move a VM to another network.\u003c/p\u003e\n\u003cp\u003eStop the VM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances stop server-name \\\n--zone=us-central1-c \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMigrate the VM. Use self link for network and subnetwork.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances network-interfaces update server-name \\\n--zone=us-central1-c \\\n--network-interface=nic0 \\\n--network=your-network \\\n--subnetwork=your-sub-network \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart the VM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances start server-name \\\n--zone=us-central1-c \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"migrate vm to other network"},{"content":"This will download the latest awscli and run it in a container.\nA new container will be built every time the command is run.\nYour current credentials in ~/.aws will be used.\ndocker run --rm -it -v ~/.aws:/root/.aws amazon/aws-cli:latest Create an alias for convenience.\nalias aws=\u0026#39;docker run --rm -ti -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli\u0026#39; You can now run any aws cli after.\naws --version aws-cli/2.2.20 Python/3.8.8 Linux/5.4.0-66-generic docker/x86_64.amzn.2 prompt/off ","permalink":"http://uly.me/posts/awscli-in-docker-container/","summary":"\u003cp\u003eThis will download the latest awscli and run it in a container.\u003c/p\u003e\n\u003cp\u003eA new container will be built every time the command is run.\u003c/p\u003e\n\u003cp\u003eYour current credentials in ~/.aws will be used.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run --rm -it -v ~/.aws:/root/.aws amazon/aws-cli:latest\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an alias for convenience.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias aws=\u0026#39;docker run --rm -ti -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can now run any aws cli after.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws --version\naws-cli/2.2.20 Python/3.8.8 Linux/5.4.0-66-generic docker/x86_64.amzn.2 prompt/off\n\u003c/code\u003e\u003c/pre\u003e","title":"awscli in docker container"},{"content":"Create an alias.\nalias gcloud=\u0026#39;docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk:latest gcloud\u0026#39; Remove an alias.\nunalias gcloud ","permalink":"http://uly.me/posts/bash-aliases/","summary":"\u003cp\u003eCreate an alias.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias gcloud=\u0026#39;docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk:latest gcloud\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove an alias.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eunalias gcloud\n\u003c/code\u003e\u003c/pre\u003e","title":"bash aliases"},{"content":"How to downgrade a Redhat kernel within the same release.\nList kernel.\nyum list kernel-3.10.0-862* yum list kernel-3.10* Install previous kernel if missing.\nyum install kernel-3.10.0-862.el7 Downgrade to next minor release.\nyum downgrade redhat-release ","permalink":"http://uly.me/posts/downgrade-redhat-kernel/","summary":"\u003cp\u003eHow to downgrade a Redhat kernel within the same release.\u003c/p\u003e\n\u003cp\u003eList kernel.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum list kernel-3.10.0-862*\nyum list kernel-3.10*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall previous kernel if missing.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install kernel-3.10.0-862.el7\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDowngrade to next minor release.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum downgrade redhat-release\n\u003c/code\u003e\u003c/pre\u003e","title":"downgrade redhat kernel"},{"content":"You can run a gcloud commands in a Docker container.\ndocker run -ti --name gcloud-config google/cloud-sdk gcloud auth login Create an alias.\nalias gcloud=\u0026#39;docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk:latest gcloud\u0026#39; Run the command.\ngcloud --version Google Cloud SDK 348.0.0 alpha 2021.07.09 app-engine-go 1.9.71 app-engine-java 1.9.90 app-engine-python 1.9.93 app-engine-python-extras 1.9.93 beta 2021.07.09 bigtable bq 2.0.70 cbt 0.10.0 cloud-datastore-emulator 2.1.0 cloud-firestore-emulator 1.13.0 cloud-spanner-emulator 1.2.0 core 2021.07.09 datalab 20190610 gsutil 4.65 kpt 0.39.3 local-extract 1.2.0 pubsub-emulator 0.4.1 Create one for gsutil.\nalias gsutil=\u0026#39;docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk:latest gsutil\u0026#39; ","permalink":"http://uly.me/posts/gcloud-in-a-docker-container/","summary":"\u003cp\u003eYou can run a gcloud commands in a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run -ti --name gcloud-config google/cloud-sdk gcloud auth login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an alias.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias gcloud=\u0026#39;docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk:latest gcloud\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun the command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud --version\nGoogle Cloud SDK 348.0.0\nalpha 2021.07.09\napp-engine-go 1.9.71\napp-engine-java 1.9.90\napp-engine-python 1.9.93\napp-engine-python-extras 1.9.93\nbeta 2021.07.09\nbigtable \nbq 2.0.70\ncbt 0.10.0\ncloud-datastore-emulator 2.1.0\ncloud-firestore-emulator 1.13.0\ncloud-spanner-emulator 1.2.0\ncore 2021.07.09\ndatalab 20190610\ngsutil 4.65\nkpt 0.39.3\nlocal-extract 1.2.0\npubsub-emulator 0.4.1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate one for gsutil.\u003c/p\u003e","title":"gcloud in a docker container"},{"content":"Run Terraform in a Docker container.\ndocker run --rm -it --name terraform -v ~/.aws:/root/.aws -v $(pwd):/workspace -w /workspace hashicorp/terraform:latest Create an alias.\nalias terraform=\u0026#39;docker run --rm -it --name terraform -v ~/.aws:/root/.aws -v $(pwd):/workspace -w /workspace hashicorp/terraform:latest\u0026#39; Run the command\nterraform --version Terraform v1.0.2 on linux_amd64 ","permalink":"http://uly.me/posts/terraform-in-a-docker-container/","summary":"\u003cp\u003eRun Terraform in a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run --rm -it --name terraform -v ~/.aws:/root/.aws -v $(pwd):/workspace -w /workspace hashicorp/terraform:latest\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an alias.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias terraform=\u0026#39;docker run --rm -it --name terraform -v ~/.aws:/root/.aws -v $(pwd):/workspace -w /workspace hashicorp/terraform:latest\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun the command\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform --version\nTerraform v1.0.2\non linux_amd64\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform in a docker container"},{"content":"Check if reboot is required in Ubuntu.\nat /var/run/reboot-required *** System restart required *** ","permalink":"http://uly.me/posts/ubuntu-check-reboot-required/","summary":"\u003cp\u003eCheck if reboot is required in Ubuntu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eat /var/run/reboot-required\n*** System restart required ***\n\u003c/code\u003e\u003c/pre\u003e","title":"ubuntu check reboot required"},{"content":"Here’s the command to check if the system needs a reboot after running yum update.\nMust be root or run it sudo.\n$ needs-restarting -r ; echo $? Core libraries or services have been updated: openssl-libs -\u0026gt; 1:1.0.2k-21.el7_9 kernel -\u0026gt; 3.10.0-1160.31.1.el7 dbus -\u0026gt; 1:1.10.24-15.el7 linux-firmware -\u0026gt; 20200421-80.git78c0348.el7_9 glibc -\u0026gt; 2.17-324.el7_9 systemd -\u0026gt; 219-78.el7_9.3 Reboot is required to ensure that your system benefits from these updates. More information: https://access.redhat.com/solutions/27943 1 In this instance, it requires a reboot due to a new kernel.\n","permalink":"http://uly.me/posts/check-reboot-after-updates/","summary":"\u003cp\u003eHere’s the command to check if the system needs a reboot after running yum update.\u003c/p\u003e\n\u003cp\u003eMust be root or run it sudo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ needs-restarting -r ; echo $?\nCore libraries or services have been updated:\n  openssl-libs -\u0026gt; 1:1.0.2k-21.el7_9\n  kernel -\u0026gt; 3.10.0-1160.31.1.el7\n  dbus -\u0026gt; 1:1.10.24-15.el7\n  linux-firmware -\u0026gt; 20200421-80.git78c0348.el7_9\n  glibc -\u0026gt; 2.17-324.el7_9\n  systemd -\u0026gt; 219-78.el7_9.3\n\nReboot is required to ensure that your system benefits from these updates.\n\nMore information:\nhttps://access.redhat.com/solutions/27943\n1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn this instance, it requires a reboot due to a new kernel.\u003c/p\u003e","title":"check reboot after updates"},{"content":"There’s a new beta command to rename a GCP VM.\nYou must stop instance first.\ngcloud compute instances stop server-name \\ --zone us-central1-c \\ --project your-project-id Rename the instance.\ngcloud beta compute instances set-name old-server-name \\ --new-name=new-server-name \\ --zone us-central1-c \\ --project your-project-id Start the instance.\ngcloud compute instances start server-name \\ --zone us-central1-c \\ --project your-project-id Login.\ngcloud compute ssh server-name \\ --zone us-central1-c \\ --project your-project-id \\ --internal-ip \u0026amp; ","permalink":"http://uly.me/posts/gcp-rename-vm/","summary":"\u003cp\u003eThere’s a new beta command to rename a GCP VM.\u003c/p\u003e\n\u003cp\u003eYou must stop instance first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances stop server-name \\\n--zone us-central1-c \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRename the instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta compute instances set-name old-server-name \\\n--new-name=new-server-name \\\n--zone us-central1-c \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart the instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances start server-name \\\n--zone us-central1-c \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssh server-name \\\n--zone us-central1-c \\\n--project your-project-id \\\n--internal-ip \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp rename vm"},{"content":"If you are getting this return code [1] error, check if enable-oslogin metadata is set to TRUE in your VM.\nHere’s the error when logging in.\ngcloud compute ssh your-server-name \\ --zone us-central1-a \\ --project your-project-id \\ --internal-ip \u0026amp; ERROR: (gcloud.compute.ssh) [C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\sdk\\plink.exe] exited with return code [1]. Remove metadata.\ngcloud compute instances remove-metadata your-server-name \\ --keys=enable-oslogin \\ --zone us-central1-a \\ --project your-project-id Updated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/your-server-name]. Run gcloud ssh again.\ngcloud compute ssh your-server-name \\ --zone us-central1-a \\ --project your-project-id \\ --internal-ip \u0026amp; [1] 1257 This time it opens up a Putty session and you’re able to login.\n","permalink":"http://uly.me/posts/gcp-ssh-issues-return-code-1/","summary":"\u003cp\u003eIf you are getting this return code [1] error, check if enable-oslogin metadata is set to TRUE in your VM.\u003c/p\u003e\n\u003cp\u003eHere’s the error when logging in.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssh your-server-name \\\n--zone us-central1-a \\\n--project your-project-id \\\n--internal-ip \u0026amp;\nERROR: (gcloud.compute.ssh) [C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\sdk\\plink.exe] exited with return code [1].\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove metadata.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances remove-metadata your-server-name \\\n--keys=enable-oslogin \\\n--zone us-central1-a \\\n--project your-project-id\nUpdated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/your-server-name].\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun gcloud ssh again.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssh your-server-name \\\n--zone us-central1-a \\\n--project your-project-id \\\n--internal-ip \u0026amp;\n[1] 1257\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis time it opens up a Putty session and you’re able to login.\u003c/p\u003e","title":"gcp ssh issues return code [1]"},{"content":"How to resize a root partition in GCP.\nIncrease disk size.\ngcloud compute disks resize server-boot-disk-name \\ --size=50GB \\ --zone us-central1-c \\ --project your-project-id Run growpart.\ngrowpart /dev/sda 1 Run xfs_growfs.\nxfs_growfs /dev/sda1 To verify, run these.\nlsblk df -Th ","permalink":"http://uly.me/posts/resizing-xfs-root-partition-in-gcp/","summary":"\u003cp\u003eHow to resize a root partition in GCP.\u003c/p\u003e\n\u003cp\u003eIncrease disk size.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks resize server-boot-disk-name \\\n--size=50GB \\\n--zone us-central1-c \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun growpart.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egrowpart /dev/sda 1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun xfs_growfs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003exfs_growfs /dev/sda1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo verify, run these.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk\ndf -Th\n\u003c/code\u003e\u003c/pre\u003e","title":"resizing xfs root partition in gcp"},{"content":"To check which packages are available for an update.\nyum check-update ","permalink":"http://uly.me/posts/yum-check-update/","summary":"\u003cp\u003eTo check which packages are available for an update.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum check-update\n\u003c/code\u003e\u003c/pre\u003e","title":"yum check update"},{"content":"JQ is a json processor. It’s for slicing and dicing data.\nDownload\nTo install on GitBash, unzip the file and copy the executable to /usr/bin.\nmv jq-win64.exe to /usr/bin/jq.exe Create an alias. Edit ~/.bashrc.\nalias jq=\u0026#39;/usr/bin/jq.exe\u0026#39; Using JQ.\njq --version jq \u0026#39;.selfLink\u0026#39; vm.json ","permalink":"http://uly.me/posts/jq-on-gitbash/","summary":"\u003cp\u003eJQ is a json processor. It’s for slicing and dicing data.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://stedolan.github.io/jq/\"\u003eDownload\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eTo install on GitBash, unzip the file and copy the executable to /usr/bin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv jq-win64.exe to /usr/bin/jq.exe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an alias. Edit ~/.bashrc.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ealias jq=\u0026#39;/usr/bin/jq.exe\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUsing JQ.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ejq --version\njq \u0026#39;.selfLink\u0026#39; vm.json\n\u003c/code\u003e\u003c/pre\u003e","title":"jq on gitbash"},{"content":"If you create scripts in Windows, editors sometimes add a carriage return in addition to the line feed.\nYou can use dos2unix to remove the extra characters. Or you can use sed.\nsed -i -e \u0026#39;s/\\r$//\u0026#39; script.sh ","permalink":"http://uly.me/posts/dos2unix-alternative/","summary":"\u003cp\u003eIf you create scripts in Windows, editors sometimes add a carriage return in addition to the line feed.\u003c/p\u003e\n\u003cp\u003eYou can use dos2unix to remove the extra characters. Or you can use sed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esed -i -e \u0026#39;s/\\r$//\u0026#39; script.sh\n\u003c/code\u003e\u003c/pre\u003e","title":"dos2unix alternative"},{"content":"You are probably wondering how the sudoers file works. Here’s a simple explanation.\nCommand\nusername host=(user:group) tag:commands Explanation\nusername – the specified user allowed to run commands. host – the specified host the command is allowed to run. user – specifies which users can use the command. group – specifies which groups can run the command. tag – the option allowed. NOPASSWD command – the command allowed to run. Examples\nroot ALL=(ALL) ALL username ALL=(ALL) ALL john test=(ALL) NOPASSWD: /bin/useradd jane ALL=(sales) NOPASSWD: /bin/sh %sudo ALL=(ALL) ALL %adgroup ALL=(ALL) ALL ","permalink":"http://uly.me/posts/sudoers-file-explained/","summary":"\u003cp\u003eYou are probably wondering how the sudoers file works. Here’s a simple explanation.\u003c/p\u003e\n\u003cp\u003eCommand\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eusername host=(user:group) tag:commands\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExplanation\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cul\u003e\n\u003cli\u003eusername – the specified user allowed to run commands.\n\u003cul\u003e\n\u003cli\u003ehost – the specified host the command is allowed to run.\u003c/li\u003e\n\u003cli\u003euser – specifies which users can use the command.\u003c/li\u003e\n\u003cli\u003egroup – specifies which groups can run the command.\u003c/li\u003e\n\u003cli\u003etag – the option allowed. NOPASSWD\u003c/li\u003e\n\u003cli\u003ecommand – the command allowed to run.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eExamples\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eroot    ALL=(ALL) ALL\nusername ALL=(ALL) ALL\njohn test=(ALL) NOPASSWD: /bin/useradd\njane ALL=(sales) NOPASSWD: /bin/sh\n%sudo ALL=(ALL) ALL\n%adgroup ALL=(ALL) ALL\n\u003c/code\u003e\u003c/pre\u003e","title":"sudoers file explained"},{"content":"Buckets are regional. Your source and destination buckets should be in different regions.\naws s3 sync s3://DOC-EXAMPLE-BUCKET-SOURCE s3://DOC-EXAMPLE-BUCKET-TARGET Use the sync command. It will copy new or modified files.\n","permalink":"http://uly.me/posts/copy-s3-to-another-region/","summary":"\u003cp\u003eBuckets are regional. Your source and destination buckets should be in different regions.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 sync s3://DOC-EXAMPLE-BUCKET-SOURCE s3://DOC-EXAMPLE-BUCKET-TARGET\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUse the sync command. It will copy new or modified files.\u003c/p\u003e","title":"copy s3 to another region"},{"content":"gcloud compute ssl-certificates create certificate-name \\ --description=\u0026#34;ssl cert for domain-name.com\u0026#34; \\ --domains=domain-name.com \\ --certificate=certificate-file \\ --private-key=private-key \\ --region=us-central1-c \\ --global ","permalink":"http://uly.me/posts/gcp-create-ssl-certificate/","summary":"\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssl-certificates create certificate-name \\\n--description=\u0026#34;ssl cert for domain-name.com\u0026#34; \\\n--domains=domain-name.com \\\n--certificate=certificate-file \\\n--private-key=private-key \\\n--region=us-central1-c \\\n--global\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create ssl certificate"},{"content":"Make an IP alias reservation.\ngcloud compute instances network-interfaces update instance-name \\ --zone us-central1-c \\ --aliases default:/32 \\ --project project-id ","permalink":"http://uly.me/posts/gcp-reserve-alias-ip/","summary":"\u003cp\u003eMake an IP alias reservation.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances network-interfaces update instance-name \\\n--zone us-central1-c \\\n--aliases default:/32 \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp reserve alias ip"},{"content":"How to update an instance metadata in GCP.\ngcloud compute instances add-metadata instance-name \\ --metadata key-name=value \\ --project your-project-id \\ --zone us-central1-a In this example, we are adding enable-oslogin=TRUE.\ngcloud compute instances add-metadata instance-name \\ --metadata enable-oslogin=TRUE \\ --project your-project-id \\ --zone us-central1-a ","permalink":"http://uly.me/posts/gcp-update-instance-metadata/","summary":"\u003cp\u003eHow to update an instance metadata in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata instance-name \\\n--metadata key-name=value \\\n--project your-project-id \\\n--zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn this example, we are adding enable-oslogin=TRUE.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata instance-name \\\n--metadata enable-oslogin=TRUE \\\n--project your-project-id \\\n--zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp update instance metadata"},{"content":"There are multiple ways to change URL in WordPress.\nHere’s one via wp-config.php.\ndefine( \u0026#39;WP_HOME\u0026#39;, \u0026#39;http://example.com\u0026#39; ); define( \u0026#39;WP_SITEURL\u0026#39;, \u0026#39;http://example.com\u0026#39; ); If you have a redirect in Apache, comment it out.\n#Redirect permanent / https://yourdomain.com/ This is by far the easiest way to change URL in WordPress.\n","permalink":"http://uly.me/posts/change-wordpress-url/","summary":"\u003cp\u003eThere are multiple ways to change URL in WordPress.\u003c/p\u003e\n\u003cp\u003eHere’s one via wp-config.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edefine( \u0026#39;WP_HOME\u0026#39;, \u0026#39;http://example.com\u0026#39; );\ndefine( \u0026#39;WP_SITEURL\u0026#39;, \u0026#39;http://example.com\u0026#39; );\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have a redirect in Apache, comment it out.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#Redirect permanent / https://yourdomain.com/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is by far the easiest way to change URL in WordPress.\u003c/p\u003e","title":"change wordpress url"},{"content":"How to create GCP firewall via Terraform.\nIngress\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;project-id\u0026#34; } resource \u0026#34;google_compute_firewall\u0026#34; \u0026#34;default\u0026#34; { name = \u0026#34;test-firewall\u0026#34; description = \u0026#34;this is a test firewall\u0026#34; priority = \u0026#34;1000\u0026#34; direction = \u0026#34;INGRESS\u0026#34; network = \u0026#34;projects/project-id/regions/us-east1/subnetworks/default\u0026#34; target_service_accounts = [\u0026#34;service-account-compute@developer.gserviceaccount.com\u0026#34;] source_ranges = [\u0026#34;10.128.0.0/20\u0026#34;] allow { protocol = \u0026#34;tcp\u0026#34; ports = [\u0026#34;80\u0026#34;, \u0026#34;8080\u0026#34;, \u0026#34;1000-2000\u0026#34;] } } Egress\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;project-id\u0026#34; } resource \u0026#34;google_compute_firewall\u0026#34; \u0026#34;default\u0026#34; { name = \u0026#34;test-firewall\u0026#34; description = \u0026#34;this is a test firewall\u0026#34; priority = \u0026#34;1000\u0026#34; direction = \u0026#34;EGRESS\u0026#34; network = \u0026#34;projects/project-id/regions/us-east1/subnetworks/default\u0026#34; target_service_accounts = [\u0026#34;service-account-compute@developer.gserviceaccount.com\u0026#34;] destination_ranges = [\u0026#34;10.128.0.0/20\u0026#34;] allow { protocol = \u0026#34;tcp\u0026#34; ports = [\u0026#34;80\u0026#34;, \u0026#34;8080\u0026#34;, \u0026#34;1000-2000\u0026#34;] } } Service account to Service account.\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;project-id\u0026#34; } resource \u0026#34;google_compute_firewall\u0026#34; \u0026#34;default\u0026#34; { name = \u0026#34;test-firewall\u0026#34; description = \u0026#34;this is a test firewall\u0026#34; priority = \u0026#34;1000\u0026#34; direction = \u0026#34;INGRESS\u0026#34; network = \u0026#34;projects/project-id/regions/us-east1/subnetworks/default\u0026#34; source_service_accounts = [\u0026#34;source-service-account-compute@developer.gserviceaccount.com\u0026#34;] target_service_accounts = [\u0026#34;target-service-account-compute@developer.gserviceaccount.com\u0026#34;] source_ranges = [\u0026#34;10.128.0.0/20\u0026#34;] allow { protocol = \u0026#34;tcp\u0026#34; ports = [\u0026#34;80\u0026#34;, \u0026#34;8080\u0026#34;, \u0026#34;1000-2000\u0026#34;] } } ","permalink":"http://uly.me/posts/terraform-gcp-firewall/","summary":"\u003cp\u003eHow to create GCP firewall via Terraform.\u003c/p\u003e\n\u003cp\u003eIngress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n    project = \u0026#34;project-id\u0026#34;\n}\nresource \u0026#34;google_compute_firewall\u0026#34; \u0026#34;default\u0026#34; {\n    name    = \u0026#34;test-firewall\u0026#34;\n    description = \u0026#34;this is a test firewall\u0026#34;\n    priority = \u0026#34;1000\u0026#34;\n    direction = \u0026#34;INGRESS\u0026#34;\n    network = \u0026#34;projects/project-id/regions/us-east1/subnetworks/default\u0026#34;\n    target_service_accounts = [\u0026#34;service-account-compute@developer.gserviceaccount.com\u0026#34;]\n    source_ranges = [\u0026#34;10.128.0.0/20\u0026#34;]\n    allow {\n        protocol = \u0026#34;tcp\u0026#34;\n        ports    = [\u0026#34;80\u0026#34;, \u0026#34;8080\u0026#34;, \u0026#34;1000-2000\u0026#34;]\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEgress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n    project = \u0026#34;project-id\u0026#34;\n}\nresource \u0026#34;google_compute_firewall\u0026#34; \u0026#34;default\u0026#34; {\n    name    = \u0026#34;test-firewall\u0026#34;\n    description = \u0026#34;this is a test firewall\u0026#34;\n    priority = \u0026#34;1000\u0026#34;\n    direction = \u0026#34;EGRESS\u0026#34;\n    network = \u0026#34;projects/project-id/regions/us-east1/subnetworks/default\u0026#34;\n    target_service_accounts = [\u0026#34;service-account-compute@developer.gserviceaccount.com\u0026#34;]\n    destination_ranges = [\u0026#34;10.128.0.0/20\u0026#34;]\n    allow {\n        protocol = \u0026#34;tcp\u0026#34;\n        ports    = [\u0026#34;80\u0026#34;, \u0026#34;8080\u0026#34;, \u0026#34;1000-2000\u0026#34;]\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eService account to Service account.\u003c/p\u003e","title":"terraform gcp firewall"},{"content":"Tomcat requires JRE.\nwget jre-8uversion-linux-x64.tar.gz # or apt-get install default-jdk Install Tomcat 8 on Linux.\nwget https://mirrors.gigenet.com/apache/tomcat/tomcat-8/v8.5.66/bin/apache-tomcat-8.5.66.tar.gz tar zxpvf apache-tomcat-8.5.66.tar.gz cd /opt/tomcat/apache-tomcat-8.5.66/bin/ ./startup.sh Status|Start|Stop|Restart Tomcat.\nsystemctl status tomcat8 systemctl start tomcat8 systemctl stop tomcat8 systemctl restart tomcat8 ","permalink":"http://uly.me/posts/tomcat-install/","summary":"\u003cp\u003eTomcat requires JRE.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget jre-8uversion-linux-x64.tar.gz\n# or\napt-get install default-jdk\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall Tomcat 8 on Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget https://mirrors.gigenet.com/apache/tomcat/tomcat-8/v8.5.66/bin/apache-tomcat-8.5.66.tar.gz\ntar zxpvf apache-tomcat-8.5.66.tar.gz\ncd /opt/tomcat/apache-tomcat-8.5.66/bin/\n./startup.sh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStatus|Start|Stop|Restart Tomcat.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl status tomcat8\nsystemctl start tomcat8\nsystemctl stop tomcat8\nsystemctl restart tomcat8\n\u003c/code\u003e\u003c/pre\u003e","title":"tomcat install"},{"content":"How to install syslog-np on Centos 7.\ncd /tmp wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum -y reinstall ./epel-release-latest-7.noarch.rpm chattr +i /etc/yum.repos.d/epel* yum -y install syslog-ng Enable syslog-np. Disable rsyslog.\nsystemctl enable syslog-ng systemctl start syslog-ng yum -y erase rsyslog ","permalink":"http://uly.me/posts/install-syslog/","summary":"\u003cp\u003eHow to install syslog-np on Centos 7.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /tmp\nwget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm\nyum -y reinstall ./epel-release-latest-7.noarch.rpm\nchattr +i /etc/yum.repos.d/epel*\nyum -y install syslog-ng\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEnable syslog-np. Disable rsyslog.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl enable syslog-ng\nsystemctl start syslog-ng\nyum -y erase rsyslog\n\u003c/code\u003e\u003c/pre\u003e","title":"install syslog"},{"content":"GCP recently added Instance Schedule to its console.\nTo configure, perform the following.\n– Create an instance schedule.\n– Add instance(s) to a schedule.\n– If no errors, the service account has the correct permissions.\nThe service account used by Instance Schedule is owned by GCP and is not visible in the GCP console.\nIf service account has no permissions, the you must perform the following.\n– Create a custom role with compute.instances.start and compute.instances.stop permissions.\n– Add custom role to the service account.\nFinally, validate instances are starting and stopping based on schedule.\n","permalink":"http://uly.me/posts/gcp-instance-scheduler/","summary":"\u003cp\u003eGCP recently added Instance Schedule to its console.\u003c/p\u003e\n\u003cp\u003eTo configure, perform the following.\u003c/p\u003e\n\u003cp\u003e– Create an instance schedule.\u003cbr\u003e\n– Add instance(s) to a schedule.\u003cbr\u003e\n– If no errors, the service account has the correct permissions.\u003c/p\u003e\n\u003cp\u003eThe service account used by Instance Schedule is owned by GCP and is not visible in the GCP console.\u003c/p\u003e\n\u003cp\u003eIf service account has no permissions, the you must perform the following.\u003c/p\u003e\n\u003cp\u003e– Create a custom role with compute.instances.start and compute.instances.stop permissions.\u003cbr\u003e\n– Add custom role to the service account.\u003c/p\u003e","title":"gcp instance scheduler"},{"content":"If you have trouble logging in (SSH) to your GCP instance, you may have to enable OS Login.\ngcloud compute instances add-metadata server-name \\ --metadata enable-oslogin=TRUE \\ --zone us-central1-c \\ --project project-id When done, you can set it back to FALSE.\n","permalink":"http://uly.me/posts/gcp-compute-enable-os-login/","summary":"\u003cp\u003eIf you have trouble logging in (SSH) to your GCP instance, you may have to enable OS Login.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances add-metadata server-name \\\n--metadata enable-oslogin=TRUE \\\n--zone us-central1-c \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWhen done, you can set it back to FALSE.\u003c/p\u003e","title":"gcp compute enable os login"},{"content":"If your /etc/resolv.conf keeps getting overwritten, take a look at /etc/NetworkManager/NetworkManager.conf. Set DNS to none.\n[main] dns=none ","permalink":"http://uly.me/posts/generated-by-networkmanager/","summary":"\u003cp\u003eIf your /etc/resolv.conf keeps getting overwritten, take a look at /etc/NetworkManager/NetworkManager.conf. Set DNS to none.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[main]\ndns=none\n\u003c/code\u003e\u003c/pre\u003e","title":"generated by networkmanager"},{"content":"How to display serial port in GCP Cloud Shell.\ngcloud compute instances get-serial-port-output instance-name \\ --zone=us-central1-a \\ --project=your-project-id ","permalink":"http://uly.me/posts/gcp-display-serial-port-in-shell/","summary":"\u003cp\u003eHow to display serial port in GCP Cloud Shell.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances get-serial-port-output instance-name \\\n--zone=us-central1-a \\\n--project=your-project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp display serial port in shell"},{"content":"How to remove SSSD package.\n#!/bin/bash service sssd stop chkconfig sssd off rm -rf /var/lib/sss/db/* rm -f /etc/sssd/sssd.conf rm -f /etc/krb5.conf rm -f /etc/krb5.keytab yum remove -y adcli sssd authconfig pam_krb5 samba4-common realmd ","permalink":"http://uly.me/posts/remove-sssd-package/","summary":"\u003cp\u003eHow to remove SSSD package.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nservice sssd stop\nchkconfig sssd off\nrm -rf /var/lib/sss/db/*\nrm -f /etc/sssd/sssd.conf\nrm -f /etc/krb5.conf\nrm -f /etc/krb5.keytab\nyum remove -y adcli sssd authconfig pam_krb5 samba4-common realmd\n\u003c/code\u003e\u003c/pre\u003e","title":"remove sssd package"},{"content":"Generate a SSSD report.\n#!/bin/bash log=\u0026#34;log\u0026#34; \u0026gt; $log sep () { echo \u0026#34;--------------------------------\u0026#34; \u0026gt;\u0026gt; $log; } sep echo \u0026#34;SSSD Status\u0026#34; \u0026gt;\u0026gt; $log sep systemctl status sssd \u0026gt;\u0026gt; $log sep echo \u0026#34;Contents of /etc/resolv.conf\u0026#34; \u0026gt;\u0026gt; $log sep cat /etc/resolv.conf \u0026gt;\u0026gt; $log sep echo \u0026#34;Contents of /etc/sssd/sssd.conf\u0026#34; \u0026gt;\u0026gt; $log sep cat /etc/sssd/sssd.conf \u0026gt;\u0026gt; $log sep echo \u0026#34;Versions of /etc/resolv.conf\u0026#34; \u0026gt;\u0026gt; $log sep ls -l /etc/resolv.conf* \u0026gt;\u0026gt; $log sep echo \u0026#34;Versions of /etc/sssd/sssd.conf\u0026#34; \u0026gt;\u0026gt; $log sep ls -l /etc/sssd/sssd.conf* \u0026gt;\u0026gt; $log sep echo \u0026#34;Contents of /var/log/sssd-rollout.log\u0026#34; \u0026gt;\u0026gt; $log sep cat /var/log/sssd-rollout.log \u0026gt;\u0026gt; $log sep echo \u0026#34;Contents of /var/log/sssd-rollout3.log\u0026#34; \u0026gt;\u0026gt; $log sep cat /var/log/sssd-rollout3.log \u0026gt;\u0026gt; $log sep ","permalink":"http://uly.me/posts/sssd-report/","summary":"\u003cp\u003eGenerate a SSSD report.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nlog=\u0026#34;log\u0026#34;\n\u0026gt; $log\nsep () { echo \u0026#34;--------------------------------\u0026#34; \u0026gt;\u0026gt; $log; }\nsep\necho \u0026#34;SSSD Status\u0026#34; \u0026gt;\u0026gt; $log\nsep\nsystemctl status sssd \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Contents of /etc/resolv.conf\u0026#34; \u0026gt;\u0026gt; $log\nsep\ncat /etc/resolv.conf \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Contents of /etc/sssd/sssd.conf\u0026#34; \u0026gt;\u0026gt; $log\nsep\ncat /etc/sssd/sssd.conf \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Versions of /etc/resolv.conf\u0026#34; \u0026gt;\u0026gt; $log\nsep\nls -l /etc/resolv.conf* \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Versions of /etc/sssd/sssd.conf\u0026#34; \u0026gt;\u0026gt; $log\nsep\nls -l /etc/sssd/sssd.conf* \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Contents of /var/log/sssd-rollout.log\u0026#34; \u0026gt;\u0026gt; $log\nsep\ncat /var/log/sssd-rollout.log \u0026gt;\u0026gt; $log\nsep\necho \u0026#34;Contents of /var/log/sssd-rollout3.log\u0026#34; \u0026gt;\u0026gt; $log\nsep\ncat /var/log/sssd-rollout3.log \u0026gt;\u0026gt; $log\nsep\n\u003c/code\u003e\u003c/pre\u003e","title":"sssd report"},{"content":"Here’s the process to restore Winbind.\nRestore old config.\ncp /etc/sssd/sssd.conf-xxxxxxx /etc/sssd/sssd.conf cp /etc/krb5.conf-xxxxxxx /etc/krb5.conf Disable SSSD. Authconfig creates /etc/nswitch.conf.\nauthconfig --disablesssd --disablesssdauth --updateall Start Winbind.\nservice winbind start; service smb start; service nmb start ","permalink":"http://uly.me/posts/winbind-fix/","summary":"\u003cp\u003eHere’s the process to restore Winbind.\u003c/p\u003e\n\u003cp\u003eRestore old config.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecp /etc/sssd/sssd.conf-xxxxxxx /etc/sssd/sssd.conf\ncp /etc/krb5.conf-xxxxxxx /etc/krb5.conf\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable SSSD. Authconfig creates /etc/nswitch.conf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eauthconfig --disablesssd --disablesssdauth --updateall\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart Winbind.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice winbind start; service smb start; service nmb start\n\u003c/code\u003e\u003c/pre\u003e","title":"winbind fix"},{"content":"If you get this error, something happened to the rpm database. To fix.\nrm -f /var/lib/rpm/__db* db_verify /var/lib/rpm/Packages rpm --rebuilddb yum clean all Run yum again.\n","permalink":"http://uly.me/posts/rpmdb-open-failed/","summary":"\u003cp\u003eIf you get this error, something happened to the rpm database. To fix.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erm -f /var/lib/rpm/__db*\ndb_verify /var/lib/rpm/Packages\nrpm --rebuilddb\nyum clean all\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun yum again.\u003c/p\u003e","title":"rpmdb open failed"},{"content":"Here’s the command to authenticate as a service account.\ngcloud auth activate-service-account --key-file=key.json To log out.\ngcloud auth revoke ","permalink":"http://uly.me/posts/gcp-login-service-account/","summary":"\u003cp\u003eHere’s the command to authenticate as a service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth activate-service-account --key-file=key.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo log out.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth revoke\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp login service account"},{"content":"Here’s how to modify a line in a file using sed.\nsed -i \u0026#39;s/replace me.*/with this text/\u0026#39; /path/to/a/file.txt ","permalink":"http://uly.me/posts/modify-a-line-using-sed/","summary":"\u003cp\u003eHere’s how to modify a line in a file using sed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esed -i \u0026#39;s/replace me.*/with this text/\u0026#39; /path/to/a/file.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"modify a line using sed"},{"content":"AWS has machine types that require ENA Support. You can run AWS CLI to find out if instance is ENA enabled.\naws ec2 describe-instances \\ --instance-id i-xxxxxxxxxxxxxxxxx \\ --profile default \\ --region us-east-1 \\ --query \u0026#39;Reservations[].Instances[].EnaSupport\u0026#39; Login to the instance and verify.\nsudo lspci | grep -i Amazon List driver details.\nmodinfo nvme Verify modules loaded at startup.\nlsmod | grep nvme lsmod | grep ena If ENA drivers are missing, install them.\nyum install pciutils ","permalink":"http://uly.me/posts/aws-ec2-ena-support/","summary":"\u003cp\u003eAWS has machine types that require ENA Support. You can run AWS CLI to find out if instance is ENA enabled.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instances \\\n--instance-id i-xxxxxxxxxxxxxxxxx \\\n--profile default \\\n--region us-east-1 \\\n--query \u0026#39;Reservations[].Instances[].EnaSupport\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin to the instance and verify.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo lspci | grep -i Amazon\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList driver details.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emodinfo nvme\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVerify modules loaded at startup.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsmod | grep nvme\nlsmod | grep ena\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf ENA drivers are missing, install them.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install pciutils\n\u003c/code\u003e\u003c/pre\u003e","title":"aws ec2 ena support"},{"content":"Keep your disks when a VM is deleted.\ngcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-1 gcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-2 To delete.\ngcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-1 gcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-2 ","permalink":"http://uly.me/posts/gcp-keep-disk/","summary":"\u003cp\u003eKeep your disks when a VM is deleted.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-1\ngcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo delete.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-1\ngcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-2\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp keep disk"},{"content":"s3fs allows Linux to mount S3 buckets as a file system.\nInstall s3fs.\nsudo apt install s3fs Setup credentials.\necho ACCESS_KEY_ID:SECRET_ACCESS_KEY \u0026gt; /etc/.passwd-s3fs chmod 400 ${HOME}/.passwd-s3fs Setup mount directory.\nmkdir -p /mountpoint chown username:username /mountpoint Mount it.\ns3fs bucketname /mountpoint -o passwd_file=/etc/.passwd-s3fs Mount it automatically.\nbucketname /mountpoint fuse.s3fs _netdev,allow_other,passwd_file=/etc/.passwd-s3fs,rw,uid=1000,gid=1000,umask=022 0 0 Alternative.\ns3fs#bucketname /mountpoint fuse _netdev,allow_other,use_cache=/root/cache,uid=1000,gid=1000,umask=022 0 0 ","permalink":"http://uly.me/posts/s3fs/","summary":"\u003cp\u003es3fs allows Linux to mount S3 buckets as a file system.\u003c/p\u003e\n\u003cp\u003eInstall s3fs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt install s3fs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSetup credentials.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho ACCESS_KEY_ID:SECRET_ACCESS_KEY \u0026gt; /etc/.passwd-s3fs\nchmod 400 ${HOME}/.passwd-s3fs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSetup mount directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir -p /mountpoint\nchown username:username /mountpoint\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003es3fs bucketname /mountpoint -o passwd_file=/etc/.passwd-s3fs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount it automatically.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebucketname /mountpoint fuse.s3fs _netdev,allow_other,passwd_file=/etc/.passwd-s3fs,rw,uid=1000,gid=1000,umask=022 0 0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAlternative.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003es3fs#bucketname /mountpoint fuse _netdev,allow_other,use_cache=/root/cache,uid=1000,gid=1000,umask=022 0 0\n\u003c/code\u003e\u003c/pre\u003e","title":"s3fs"},{"content":"Generate a map of your live streaming viewers by placing of your viewer’s IP into a file and then using IPInfo’s map tool.\nvim ipList 54.0.0.1 54.0.0.2 54.0.0.3 To plot the IPs on a map, pipe them to IPinfo.io.\ncat ipList | curl -XPOST --data-binary @- \u0026#34;ipinfo.io/map?cli=1\u0026#34; The result is a URL of the map.\n","permalink":"http://uly.me/posts/ipinfo-io-map/","summary":"\u003cp\u003eGenerate a map of your live streaming viewers by placing of your viewer’s IP into a file and then using IPInfo’s map tool.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim ipList\n54.0.0.1\n54.0.0.2\n54.0.0.3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo plot the IPs on a map, pipe them to IPinfo.io.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat ipList | curl -XPOST --data-binary @- \u0026#34;ipinfo.io/map?cli=1\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe result is a URL of the map.\u003c/p\u003e","title":"ipinfo.io map"},{"content":"Install Speedtest CLI.\nsudo apt-get install gnupg1 apt-transport-https dirmngr export INSTALL_KEY=379CE192D401AB61 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY echo \u0026#34;deb https://ookla.bintray.com/debian generic main\u0026#34; | sudo tee /etc/apt/sources.list.d/speedtest.list sudo apt-get update sudo apt-get install speedtest To run.\nspeedtest Result.\n$ speedtest Speedtest by Ookla Server: City of Columbus - Columbus, OH (id = 40410) ISP: Spectrum Latency: 9.39 ms (0.63 ms jitter) Download: 117.74 Mbps (data used: 60.3 MB) Upload: 11.81 Mbps (data used: 5.6 MB) Packet Loss: 0.0% Result URL: https://www.speedtest.net/result/c/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx (redacted) ","permalink":"http://uly.me/posts/ubuntu-speedtest/","summary":"\u003cp\u003eInstall Speedtest CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install gnupg1 apt-transport-https dirmngr\nexport INSTALL_KEY=379CE192D401AB61\nsudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY\necho \u0026#34;deb https://ookla.bintray.com/debian generic main\u0026#34; | sudo tee  /etc/apt/sources.list.d/speedtest.list\nsudo apt-get update\nsudo apt-get install speedtest\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo run.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003espeedtest\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ speedtest\n   Speedtest by Ookla\n     Server: City of Columbus - Columbus, OH (id = 40410)\n        ISP: Spectrum\n    Latency:     9.39 ms   (0.63 ms jitter)\n   Download:   117.74 Mbps (data used: 60.3 MB)                               \n     Upload:    11.81 Mbps (data used: 5.6 MB)                               \nPacket Loss:     0.0%\n Result URL: https://www.speedtest.net/result/c/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx (redacted)\n\u003c/code\u003e\u003c/pre\u003e","title":"ubuntu speedtest"},{"content":"If you’re trying to access GCS (Google Cloud Storage) and you’re getting “Your credentials are invalid. Please run gcloud auth login”, you most likely have a previous key stored in the ~/.boto file. This happens if you previously configured gsutil with your own credentials, then switched over to Google SDK mode. To fix the invalid credentials, edit the ~/.boto file and comment out the auth key.\nvim ~/.boto Comment out.\n#gs_oauth2_refresh_token = \u0026lt;token redacted=\u0026#34;\u0026#34;\u0026gt; \u0026lt;/token\u0026gt; Rerun the gsutil ls command. It should work.\n","permalink":"http://uly.me/posts/invalid-credentials-with-gsutil/","summary":"\u003cp\u003eIf you’re trying to access GCS (Google Cloud Storage) and you’re getting “Your credentials are invalid. Please run gcloud auth login”, you most likely have a previous key stored in the ~/.boto file. This happens if you previously configured gsutil with your own credentials, then switched over to Google SDK mode. To fix the invalid credentials, edit the ~/.boto file and comment out the auth key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim ~/.boto\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eComment out.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#gs_oauth2_refresh_token = \u0026lt;token redacted=\u0026#34;\u0026#34;\u0026gt;\n\u0026lt;/token\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRerun the gsutil ls command. It should work.\u003c/p\u003e","title":"invalid credentials with gsutil"},{"content":"Install\nyum install sos Run sosreport\nsosreport Case number will be part of exported report located in /var/tmp.\ncd /var/tmp ","permalink":"http://uly.me/posts/sosreport/","summary":"\u003cp\u003eInstall\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install sos\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun sosreport\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esosreport\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCase number will be part of exported report located in /var/tmp.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /var/tmp\n\u003c/code\u003e\u003c/pre\u003e","title":"sosreport"},{"content":"If you get a WordPress “There has been a critical error on your website” error, you probably have an issue with a theme or plugin. The quickest way to troubleshoot is to rename the plugins directory since there’s no way to login. This technically disables all plugins. Rename it back to plugins and enable each plugin one by one.\nDisable all plugins.\nmv plugins plugins-backup Login and restore the plugins directory.\nmv plugins-backup plugins Enable each plugin one by one and check if the site is broken.\n","permalink":"http://uly.me/posts/wordpress-critical-error/","summary":"\u003cp\u003eIf you get a WordPress “There has been a critical error on your website” error, you probably have an issue with a theme or plugin. The quickest way to troubleshoot is to rename the plugins directory since there’s no way to login. This technically disables all plugins. Rename it back to plugins and enable each plugin one by one.\u003c/p\u003e\n\u003cp\u003eDisable all plugins.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv plugins plugins-backup\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLogin and restore the plugins directory.\u003c/p\u003e","title":"wordpress critical error"},{"content":"If you want to SSH to a Docker container, use the Docker exec command.\ndocker exec -it container_name bash docker exec -it --user root container_name /bin/bash I’m using a Git Bash terminal, so I have to prefix the docker command with winpty.\nwinpty docker exec -it container_name bash Result\nroot@681bbe3f65f1:/var/www/html# Ctrl-D to exit.\n","permalink":"http://uly.me/posts/docker-exec/","summary":"\u003cp\u003eIf you want to SSH to a Docker container, use the Docker exec command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker exec -it container_name bash\ndocker exec -it --user root container_name /bin/bash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI’m using a Git Bash terminal, so I have to prefix the docker command with winpty.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewinpty docker exec -it container_name bash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eroot@681bbe3f65f1:/var/www/html#\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCtrl-D to exit.\u003c/p\u003e","title":"docker exec"},{"content":"Here’s how to troubleshoot nameservers with dig.\ndig hostname dig domain.com To test a specific nameserver.\ndig @nameserver hostname dig @nameserver ip-address Other options.\ndig hostname.domain.com +short dig hostname.domain.com +noall +answer dig @nameserver MX domain.com dig @nameserver AAAA domain.com ","permalink":"http://uly.me/posts/troubleshoot-nameservers-with-dig/","summary":"\u003cp\u003eHere’s how to troubleshoot nameservers with dig.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edig hostname\ndig domain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo test a specific nameserver.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edig @nameserver hostname\ndig @nameserver ip-address\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOther options.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edig hostname.domain.com +short\ndig hostname.domain.com +noall +answer\ndig @nameserver MX domain.com\ndig @nameserver AAAA domain.com\n\u003c/code\u003e\u003c/pre\u003e","title":"troubleshoot nameservers with dig"},{"content":"Here’s how to run a script on bootup on Rhel 7 that’s running systemd.\nFirst create a script. It this case, it will create a file called test.txt.\n#!/bin/bash \u0026gt; /root/test.txt Make the script executable.\nchmod /root/test.sh Now create a service in /etc/systemd/system/test.service\n# vi /etc/systemd/system/test.service [Unit] Description=A test service After=network.target [Service] Type=simple ExecStart=/root/test.sh TimeoutStartSec=0 [Install] WantedBy=default.target Reload systemd.\nsystemctl daemon-reload Enable the service.\nsystemctl enable test.service Start the service.\nsystemctl start test.service Reboot and test.\nreboot Validate if the script ran. Check if the file was created.\n","permalink":"http://uly.me/posts/startup-script/","summary":"\u003cp\u003eHere’s how to run a script on bootup on Rhel 7 that’s running systemd.\u003c/p\u003e\n\u003cp\u003eFirst create a script. It this case, it will create a file called test.txt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\u0026gt; /root/test.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake the script executable.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echmod /root/test.sh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNow create a service in /etc/systemd/system/test.service\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# vi /etc/systemd/system/test.service\n[Unit]\nDescription=A test service\nAfter=network.target\n[Service]\nType=simple\nExecStart=/root/test.sh\nTimeoutStartSec=0\n[Install]\nWantedBy=default.target\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReload systemd.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl daemon-reload\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEnable the service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl enable test.service\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart the service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl start test.service\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot and test.\u003c/p\u003e","title":"startup script"},{"content":"Open Git Bash. Change to the root directory of Git Bash.\ncd ~ echo $PATH /bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin Edit .bash_profile or .bashrc. It was .bash_profile in my case. Showing a truncated path.\nAdd your custom path to the PATH variable. Save file. Exit Git Bash.\nPATH=\u0026#34;/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path\u0026#34; Open Git Bash again and check your updated Path.\necho $PATH Result.\n/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path ","permalink":"http://uly.me/posts/gitbash-path/","summary":"\u003cp\u003eOpen Git Bash. Change to the root directory of Git Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd ~\necho $PATH\n/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit .bash_profile or .bashrc. It was .bash_profile in my case. Showing a truncated path.\u003c/p\u003e\n\u003cp\u003eAdd your custom path to the PATH variable. Save file. Exit Git Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePATH=\u0026#34;/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOpen Git Bash again and check your updated Path.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $PATH\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path\n\u003c/code\u003e\u003c/pre\u003e","title":"gitbash path"},{"content":"It’s recommended to set the clock to UTC. In rare occasions, local time may be needed.\nHere’s how to set your server’s timezone permanently.\nCheck the date first.\ndate Backup localtime. Set it to US Eastern Time.\nmv /etc/localtime /etc/localtime.backup ln -s /usr/share/zoneinfo/America/New_York /etc/localtime Backup clock. Set it to US Eastern Time.\ncp -p /etc/sysconfig/clock /etc/sysconfig/clock.backup \u0026gt; /etc/sysconfig/clock echo ZONE=\\\u0026#34;America/New_York\\\u0026#34; \u0026gt; /etc/sysconfig/clock Run the date again to validate.\ndate ","permalink":"http://uly.me/posts/set-timezone-permanently/","summary":"\u003cp\u003eIt’s recommended to set the clock to UTC. In rare occasions, local time may be needed.\u003c/p\u003e\n\u003cp\u003eHere’s how to set your server’s timezone permanently.\u003c/p\u003e\n\u003cp\u003eCheck the date first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edate\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBackup localtime. Set it to US Eastern Time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv /etc/localtime /etc/localtime.backup\nln -s /usr/share/zoneinfo/America/New_York /etc/localtime\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBackup clock. Set it to US Eastern Time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecp -p /etc/sysconfig/clock /etc/sysconfig/clock.backup \n\u0026gt; /etc/sysconfig/clock\necho ZONE=\\\u0026#34;America/New_York\\\u0026#34; \u0026gt; /etc/sysconfig/clock\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun the date again to validate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edate\n\u003c/code\u003e\u003c/pre\u003e","title":"set timezone permanently"},{"content":"After logging in, I tried to run Terraform in GCP and received this error:\noauth2: cannot fetch token: 400 Bad Request Here’s the fix. Login using application-default.\ngcloud auth application-default login You can then Terraform.\nterraform apply ","permalink":"http://uly.me/posts/gcp-400-bad-request/","summary":"\u003cp\u003eAfter logging in, I tried to run Terraform in GCP and received this error:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eoauth2: cannot fetch token: 400 Bad Request\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the fix. Login using application-default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth application-default login\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can then Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform apply\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp 400 bad request"},{"content":"I changed password managers from LastPass to BitWarden the other day. Migrating your credentials requires exporting and importing a CSV file from one program to another. It was an easy transition. Everything seems to work. As you may be aware, LastPass decided to make their free account limited to just one device. Customers will need to choose which device to use, whether desktop or mobile. Not both. If you want it on multiple devices, you’ll need to fork up $3 per month. It is not that expensive, but there are other alternatives. A few recommend BitWarden. It will let you sync to all devices for free. It was an easy choice.\n","permalink":"http://uly.me/posts/bitwarden/","summary":"\u003cp\u003eI changed password managers from LastPass to \u003ca href=\"http://bitwarden.com\"\u003eBitWarden\u003c/a\u003e the other day. Migrating your credentials requires exporting and importing a CSV file from one program to another. It was an easy transition. Everything seems to work. As you may be aware, LastPass decided to make their free account limited to just one device. Customers will need to choose which device to use, whether desktop or mobile. Not both. If you want it on multiple devices, you’ll need to fork up $3 per month. It is not that expensive, but there are other alternatives. A few recommend BitWarden. It will let you sync to all devices for free. It was an easy choice.\u003c/p\u003e","title":"bitwarden"},{"content":"I had an issue with using the backspace in Vim in GCP’s Cloud Shell. Every time I’m in the insert mode and I want to edit using backspace, it doesn’t delete the characters. It shows these characters “^?” instead. Well, it turned out to be a backspace setting that you can set within .vimrc. So, here’s my working setup.\ncolo desert syntax on set backspace=indent,eol,start set nocompatible The first line uses the desert theme. The second line turns on syntax highlighting. It’s on by default. The third line fixes the backspace issue I mentioned above. ","permalink":"http://uly.me/posts/gcp-cloud-shell-vim-settings/","summary":"\u003cp\u003eI had an issue with using the backspace in Vim in GCP’s Cloud Shell. Every time I’m in the insert mode and I want to edit using backspace, it doesn’t delete the characters. It shows these characters “^?” instead. Well, it turned out to be a backspace setting that you can set within .vimrc. So, here’s my working setup.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecolo desert\nsyntax on\nset backspace=indent,eol,start\nset nocompatible\n\u003c/code\u003e\u003c/pre\u003e\u003cul\u003e\n\u003cli\u003eThe first line uses the desert theme.\u003c/li\u003e\n\u003cli\u003eThe second line turns on syntax highlighting. It’s on by default.\u003c/li\u003e\n\u003cli\u003eThe third line fixes the backspace issue I mentioned above.\u003c/li\u003e\n\u003c/ul\u003e","title":"gcp cloud shell vim settings"},{"content":"This script creates an AWS backup vault, adds a backup plan and a backup selection.\nSet up profile, region and Account ID first.\n#!/bin/bash profile=\u0026#34;default\u0026#34; region=\u0026#34;us-east-1\u0026#34; id=$(aws sts get-caller-identity --query Account --output text) Create a vault.\naws backup create-backup-vault \\ --backup-vault-name my-vault \\ --profile $profile \\ --region $region Create a backup plan.\naws backup create-backup-plan \\ --backup-plan file://back-plan.json \\ --profile $profile \\ --region $region backup-plan.json\n{ \u0026#34;BackupPlan\u0026#34;: { \u0026#34;BackupPlanName\u0026#34;: \u0026#34;efs-0000\u0026#34;, \u0026#34;Rules\u0026#34;: [ { \u0026#34;RuleName\u0026#34;: \u0026#34;efs-0000\u0026#34;, \u0026#34;TargetBackupVaultName\u0026#34;: \u0026#34;my-vault\u0026#34;, \u0026#34;ScheduleExpression\u0026#34;: \u0026#34;cron(0 0 ? * * *)\u0026#34;, \u0026#34;StartWindowMinutes\u0026#34;: 60, \u0026#34;CompletionWindowMinutes\u0026#34;: 10080, \u0026#34;Lifecycle\u0026#34;: { \u0026#34;DeleteAfterDays\u0026#34;: 7 } } ] } } Get the backup plan ID.\nplanid=$(aws backup list-backup-plans \\ --query \u0026#34;BackupPlansList[?BackupPlanName==\u0026#39;efs-0000\u0026#39;].BackupPlanId\u0026#34; \\ --profile $profile \\ --region $region \\ --output text) Create a backup selection.\n# Create a backup selection aws backup create-backup-selection \\ --backup-plan-id $planid \\ --cli-input-json file://backup-selection.json \\ --profile $profile \\ --region $region backup-selection.json\n{ \u0026#34;BackupSelection\u0026#34;: { \u0026#34;SelectionName\u0026#34;: \u0026#34;efs-0000\u0026#34;, \u0026#34;IamRoleArn\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxxxx:role/service-role/AWSBackupDefaultServiceRole\u0026#34;, \u0026#34;Resources\u0026#34;: [], \u0026#34;ListOfTags\u0026#34;: [ { \u0026#34;ConditionType\u0026#34;: \u0026#34;STRINGEQUALS\u0026#34;, \u0026#34;ConditionKey\u0026#34;: \u0026#34;aws-backup\u0026#34;, \u0026#34;ConditionValue\u0026#34;: \u0026#34;efs-0000\u0026#34; } ] } } The enable EFS backup, add a tag key of aws-backup with a value of efs-0000.\n","permalink":"http://uly.me/posts/aws-backup-setup/","summary":"\u003cp\u003eThis script creates an AWS backup vault, adds a backup plan and a backup selection.\u003c/p\u003e\n\u003cp\u003eSet up profile, region and Account ID first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nprofile=\u0026#34;default\u0026#34;\nregion=\u0026#34;us-east-1\u0026#34;\nid=$(aws sts get-caller-identity --query Account --output text)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a vault.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup create-backup-vault \\\n--backup-vault-name my-vault \\\n--profile $profile \\\n--region $region\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a backup plan.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup create-backup-plan \\\n--backup-plan file://back-plan.json \\ \n--profile $profile \\\n--region $region\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ebackup-plan.json\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;BackupPlan\u0026#34;: {\n        \u0026#34;BackupPlanName\u0026#34;: \u0026#34;efs-0000\u0026#34;,\n        \u0026#34;Rules\u0026#34;: [\n            {\n                \u0026#34;RuleName\u0026#34;: \u0026#34;efs-0000\u0026#34;,\n                \u0026#34;TargetBackupVaultName\u0026#34;: \u0026#34;my-vault\u0026#34;,\n                \u0026#34;ScheduleExpression\u0026#34;: \u0026#34;cron(0 0 ? * * *)\u0026#34;,\n                \u0026#34;StartWindowMinutes\u0026#34;: 60,\n                \u0026#34;CompletionWindowMinutes\u0026#34;: 10080,\n                \u0026#34;Lifecycle\u0026#34;: {\n                    \u0026#34;DeleteAfterDays\u0026#34;: 7\n                }\n            }\n        ]\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGet the backup plan ID.\u003c/p\u003e","title":"aws backup setup"},{"content":"Here’s a quick way to find the AWS Account ID via AWS CLI.\naws sts get-caller-identity --query Account --output text Output is a 12 digit number (redacted)\nxxxxxxxxxxxx AWS Account ID is a 12 digit number unique to each AWS account. Occasionally, there are scripts and policies that need the ID of the account. The command above is one way of querying the account ID so they can be used for policies that need them.\n","permalink":"http://uly.me/posts/aws-get-account-id/","summary":"\u003cp\u003eHere’s a quick way to find the AWS Account ID via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws sts get-caller-identity --query Account --output text\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput is a 12 digit number (redacted)\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003exxxxxxxxxxxx\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAWS Account ID is a 12 digit number unique to each AWS account. Occasionally, there are scripts and policies that need the ID of the account. The command above is one way of querying the account ID so they can be used for policies that need them.\u003c/p\u003e","title":"aws get account id"},{"content":"Here’s how to list AWS Backup vaults and plans. You can filter the output by specifying a vault.\naws backup list-backup-vaults --query \u0026#34;BackupVaultList[?BackupVaultName==\u0026#39;my-vault\u0026#39;]\u0026#34; --output json Output: (outputs are redacted for security reasons)\n[ { \u0026#34;BackupVaultName\u0026#34;: \u0026#34;my-vault\u0026#34;, \u0026#34;BackupVaultArn\u0026#34;: \u0026#34;arn:aws:backup:us-east-1:xxxxxxxxxxxx:backup-vault:my-vault\u0026#34;, \u0026#34;CreationDate\u0026#34;: \u0026#34;2019-02-10T11:38:42.556000-05:00\u0026#34;, \u0026#34;EncryptionKeyArn\u0026#34;: \u0026#34;arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;, \u0026#34;CreatorRequestId\u0026#34;: \u0026#34;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;, \u0026#34;NumberOfRecoveryPoints\u0026#34;: 3 } ] Display the BackupPlanId of a specific backup plan.\naws backup list-backup-plans --query \u0026#34;BackupPlansList[?BackupPlanName==\u0026#39;my-backup-plan\u0026#39;].BackupPlanId\u0026#34; Output: (outputs are redacted for security reasons)\n[ \u0026#34;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34; ] ","permalink":"http://uly.me/posts/aws-backup-vaults/","summary":"\u003cp\u003eHere’s how to list AWS Backup vaults and plans. You can filter the output by specifying a vault.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup list-backup-vaults --query \u0026#34;BackupVaultList[?BackupVaultName==\u0026#39;my-vault\u0026#39;]\u0026#34; --output json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput: (outputs are redacted for security reasons)\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[\n    {\n        \u0026#34;BackupVaultName\u0026#34;: \u0026#34;my-vault\u0026#34;,\n        \u0026#34;BackupVaultArn\u0026#34;: \u0026#34;arn:aws:backup:us-east-1:xxxxxxxxxxxx:backup-vault:my-vault\u0026#34;,\n        \u0026#34;CreationDate\u0026#34;: \u0026#34;2019-02-10T11:38:42.556000-05:00\u0026#34;,\n        \u0026#34;EncryptionKeyArn\u0026#34;: \u0026#34;arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;,\n        \u0026#34;CreatorRequestId\u0026#34;: \u0026#34;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;,\n        \u0026#34;NumberOfRecoveryPoints\u0026#34;: 3\n    }\n]\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay the BackupPlanId of a specific backup plan.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup list-backup-plans --query \u0026#34;BackupPlansList[?BackupPlanName==\u0026#39;my-backup-plan\u0026#39;].BackupPlanId\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput: (outputs are redacted for security reasons)\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[\n    \u0026#34;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#34;\n]\n\u003c/code\u003e\u003c/pre\u003e","title":"aws backup vaults"},{"content":"Here’s a simple little script that displays the number of characters in a string.\n#!/bin/bash if [[ $# -eq 0 ]] ; then echo \u0026#39;Missing arguments\u0026#39;; exit 0; fi var=$1 size=${#var} echo $size Command:\n./length.sh abcdefghijklmnopqrstuvwxyz Output:\n26 ","permalink":"http://uly.me/posts/count-string-characters/","summary":"\u003cp\u003eHere’s a simple little script that displays the number of characters in a string.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [[ $# -eq 0 ]] ; then echo \u0026#39;Missing arguments\u0026#39;; exit 0; fi\nvar=$1\nsize=${#var}\necho $size\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCommand:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e./length.sh abcdefghijklmnopqrstuvwxyz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e26\n\u003c/code\u003e\u003c/pre\u003e","title":"count string characters"},{"content":"Here’s how to copy an AMI to another region.\naws ec2 copy-image \\ --source-image-id ami-xxxxxxxxxxx \\ --source-region us-east-1 \\ --region us-east-2 \\ --name \u0026#34;My DR server\u0026#34; Output:\n{ \u0026#34;ImageId\u0026#34;: \u0026#34;ami-xxxxxxxxxxx\u0026#34; } ","permalink":"http://uly.me/posts/aws-copy-ami-to-another-region/","summary":"\u003cp\u003eHere’s how to copy an AMI to another region.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 copy-image \\\n  --source-image-id ami-xxxxxxxxxxx \\\n  --source-region us-east-1 \\\n  --region us-east-2 \\\n  --name \u0026#34;My DR server\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;ImageId\u0026#34;: \u0026#34;ami-xxxxxxxxxxx\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws copy ami to another region"},{"content":"If you need to copy a snapshot from one region to another, here’s the AWS CLI command.\naws ec2 copy-snapshot \\ --region us-east-1 \\ --source-region us-east-2 \\ --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \\ --description \u0026#34;This is the DR snapshot copy\u0026#34; Output:\n{ \u0026#34;SnapshotId\u0026#34;: \u0026#34;snap-xxxxxxxxxxxxxxxxx\u0026#34; } ","permalink":"http://uly.me/posts/aws-copy-snapshot-to-another-region/","summary":"\u003cp\u003eIf you need to copy a snapshot from one region to another, here’s the AWS CLI command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 copy-snapshot \\\n    --region us-east-1 \\\n    --source-region us-east-2 \\\n    --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \\\n    --description \u0026#34;This is the DR snapshot copy\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;SnapshotId\u0026#34;: \u0026#34;snap-xxxxxxxxxxxxxxxxx\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws copy snapshot to another region"},{"content":"Here’s how to add a new route in Google Cloud Platform.\ngcloud compute routes create name-of-new-route \\ --destination-range=200.20.0.0/15 \\ --next-hop-gateway=default-internet-gateway \\ --project=host-project \\ --network=\u0026#34;default\u0026#34; \\ --priority=900 ","permalink":"http://uly.me/posts/gcp-add-new-route/","summary":"\u003cp\u003eHere’s how to add a new route in Google Cloud Platform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute routes create name-of-new-route \\\n  --destination-range=200.20.0.0/15 \\\n  --next-hop-gateway=default-internet-gateway \\\n  --project=host-project \\\n  --network=\u0026#34;default\u0026#34; \\\n  --priority=900\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp add new route"},{"content":"Here’s another way to list projects in a shared VPC.\ngcloud compute shared-vpc list-associated-resources your-shared-host Output:\nproject1 PROJECT project2 PROJECT project3 PROJECT ... ","permalink":"http://uly.me/posts/gcp-list-of-projects/","summary":"\u003cp\u003eHere’s another way to list projects in a shared VPC.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute shared-vpc list-associated-resources your-shared-host\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eproject1  PROJECT\nproject2  PROJECT\nproject3  PROJECT\n...\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list of projects"},{"content":"Here’s how to list SQL instances within your GCP project.\ngcloud sql instances list --project your-project-id Output:\nNAME DATABASE_VERSION LOCATION TIER PRIMARY_ADDRESS PRIVATE_ADDRESS STATUS database1 SQLSERVER_2017_STANDARD us-central1-a db-n1-standard-1 - 10.10.10.11 RUNNABLE database2 SQLSERVER_2017_STANDARD us-central1-c db-n1-standard-1 - 10.10.10.12 RUNNABLE ","permalink":"http://uly.me/posts/gcp-list-of-sql-instances/","summary":"\u003cp\u003eHere’s how to list SQL instances within your GCP project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud sql instances list --project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eNAME             DATABASE_VERSION         LOCATION       TIER              PRIMARY_ADDRESS  PRIVATE_ADDRESS  STATUS\ndatabase1        SQLSERVER_2017_STANDARD  us-central1-a  db-n1-standard-1  -                10.10.10.11    RUNNABLE\ndatabase2        SQLSERVER_2017_STANDARD  us-central1-c  db-n1-standard-1  -                10.10.10.12    RUNNABLE\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list of sql instances"},{"content":"Here’s how to list AWS AMI (machine images) owned by yourself.\naws ec2 describe-images \\ --query \u0026#34;Images[*].[Name,PlatformDetails]\u0026#34; \\ --owners self \\ --profile default \\ --region us-east-1 \\ --output text Output:\nicecast-0.1 Linux/UNIX jekyll-0.3 Linux/UNIX docker-0.1 Linux/UNIX Specifying owners as self only display images owned by you.\n","permalink":"http://uly.me/posts/aws-list-machine-images/","summary":"\u003cp\u003eHere’s how to list AWS AMI (machine images) owned by yourself.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-images \\\n--query \u0026#34;Images[*].[Name,PlatformDetails]\u0026#34; \\\n--owners self \\\n--profile default \\\n--region us-east-1 \\\n--output text\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eicecast-0.1     Linux/UNIX\njekyll-0.3      Linux/UNIX\ndocker-0.1      Linux/UNIX\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSpecifying owners as self only display images owned by you.\u003c/p\u003e","title":"aws list machine images"},{"content":"Two years ago, WordPress introduced Gutenberg block editor together with the release of WordPress version 5.0. Gutenberg essentially became the default editor starting with WordPress version 5.0. While many people love the Gutenberg editor, some people hate it. If you’re one of the many people who hate the Gutenberg editor, you can simply disable it by installing a plugin called Disable Gutenberg. This plugin will revert back to the classic editor.\nOnce installed, you should be able to see the Classic editor.\nAfter working with Gutenberg for so long, I forgot the speed and agility of the classic editor. It’s much faster.\n","permalink":"http://uly.me/posts/disable-gutenberg/","summary":"\u003cp\u003eTwo years ago, WordPress introduced Gutenberg block editor together with the release of WordPress version 5.0. Gutenberg essentially became the default editor starting with WordPress version 5.0. While many people love the Gutenberg editor, some people hate it. If you’re one of the many people who hate the Gutenberg editor, you can simply disable it by installing a plugin called Disable Gutenberg. This plugin will revert back to the classic editor.\u003c/p\u003e","title":"disable gutenberg"},{"content":"I decided to log my commands for good record keeping. Here’s my script.\n#!/bin/bash if [[ $# -eq 0 ]] ; then echo \u0026#39;No arguments. Format: ./go.sh script.sh\u0026#39;; exit 0; fi log=log.txt echo \u0026#39;-------------------------------\u0026#39; \u0026gt;\u0026gt; $log date \u0026gt;\u0026gt; $log echo \u0026#39;---\u0026#39; \u0026gt;\u0026gt; $log cat $1 \u0026gt;\u0026gt; $log echo \u0026#39;---\u0026#39; \u0026gt;\u0026gt; $log /bin/bash $1 2\u0026gt;\u0026amp;1 | tee -a $log To run.\n./go.sh script.sh Line by line explanation.\nChecks for script to run. Exits if there’s no argument. Sets the log file. Prints dashes. Prints the date. Print 3 dashes. Prints the commands to the log file. Print 3 dashes. Run the command. Send error and standard out to log file. ","permalink":"http://uly.me/posts/logging-commands/","summary":"\u003cp\u003eI decided to log my commands for good record keeping. Here’s my script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [[ $# -eq 0 ]] ; then echo \u0026#39;No arguments. Format: ./go.sh script.sh\u0026#39;; exit 0; fi\nlog=log.txt\necho \u0026#39;-------------------------------\u0026#39; \u0026gt;\u0026gt; $log\ndate \u0026gt;\u0026gt; $log\necho \u0026#39;---\u0026#39; \u0026gt;\u0026gt; $log\ncat $1 \u0026gt;\u0026gt; $log\necho \u0026#39;---\u0026#39; \u0026gt;\u0026gt; $log\n/bin/bash $1 2\u0026gt;\u0026amp;1 | tee -a $log\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo run.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e./go.sh script.sh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLine by line explanation.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eChecks for script to run. Exits if there’s no argument.\u003c/li\u003e\n\u003cli\u003eSets the log file.\u003c/li\u003e\n\u003cli\u003ePrints dashes.\u003c/li\u003e\n\u003cli\u003ePrints the date.\u003c/li\u003e\n\u003cli\u003ePrint 3 dashes.\u003c/li\u003e\n\u003cli\u003ePrints the commands to the log file.\u003c/li\u003e\n\u003cli\u003ePrint 3 dashes.\u003c/li\u003e\n\u003cli\u003eRun the command. Send error and standard out to log file.\u003c/li\u003e\n\u003c/ol\u003e","title":"logging commands"},{"content":"I was getting this error when downloading a file from a S3 bucket.\nfatal error: An error occurred (403) when calling the HeadObject operation: Forbidden Turns out to be a permission issue. Use –acl bucket-owner-full-control.\n# UPLOAD aws s3 cp file.txt s3://bucket-name/dir/ --acl bucket-owner-full-control upload: .\\file.txt to s3://bucket-name/dir/fw.sh # DOWNLOAD aws s3 cp s3://bucket-name/dir/file.txt . --acl bucket-owner-full-control download: s3://bucket-name/dir/file.txt to .\\file.txt You need to do for both upload and download.\n","permalink":"http://uly.me/posts/aws-s3-bucket-permission/","summary":"\u003cp\u003eI was getting this error when downloading a file from a S3 bucket.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efatal error: An error occurred (403) when calling the HeadObject operation: Forbidden\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTurns out to be a permission issue. Use –acl bucket-owner-full-control.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# UPLOAD\naws s3 cp file.txt s3://bucket-name/dir/ --acl bucket-owner-full-control\nupload: .\\file.txt to s3://bucket-name/dir/fw.sh\n# DOWNLOAD\naws s3 cp s3://bucket-name/dir/file.txt . --acl bucket-owner-full-control\ndownload: s3://bucket-name/dir/file.txt to .\\file.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou need to do for both upload and download.\u003c/p\u003e","title":"aws s3 bucket permission"},{"content":"How to create a swap file.\nA 2GB swap file.\ndd if=/dev/zero of=/swapfile bs=1k count=2048k Activate.\nmkswap /swapfile chmod 0600 /swapfile systemctl daemon-reload swapon /swapfile To make swap permanent, add to /etc/fstab.\n/swapfile swap swap defaults 0 0 Check if swap is working.\ncat /proc/swaps free -h ","permalink":"http://uly.me/posts/create-a-swap-file/","summary":"\u003cp\u003eHow to create a swap file.\u003c/p\u003e\n\u003cp\u003eA 2GB swap file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edd if=/dev/zero of=/swapfile bs=1k count=2048k\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eActivate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkswap /swapfile\nchmod 0600 /swapfile\nsystemctl daemon-reload\nswapon /swapfile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo make swap permanent, add to /etc/fstab.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/swapfile  swap   swap    defaults   0 0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if swap is working.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat /proc/swaps\nfree -h\n\u003c/code\u003e\u003c/pre\u003e","title":"create a swap file"},{"content":"Here’s how to create a firewall from service account to service account.\ngcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\ --description=\u0026#34;firewall-description\u0026#34; \\ --priority \u0026#34;1000\u0026#34; \\ --direction INGRESS \\ --action allow \\ --network \u0026#34;network-name\u0026#34; \\ --source-service-accounts=\u0026#34;service@account.net\u0026#34; \\ --target-service-accounts=\u0026#34;service@account.net\u0026#34; \\ --rules tcp:9001 Instead of source-range, it’s using source-service-accounts.\n","permalink":"http://uly.me/posts/gcp-firewall-source-service-account/","summary":"\u003cp\u003eHere’s how to create a firewall from service account to service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\\n--description=\u0026#34;firewall-description\u0026#34; \\\n--priority \u0026#34;1000\u0026#34; \\\n--direction INGRESS \\\n--action allow \\\n--network \u0026#34;network-name\u0026#34; \\\n--source-service-accounts=\u0026#34;service@account.net\u0026#34; \\\n--target-service-accounts=\u0026#34;service@account.net\u0026#34; \\\n--rules tcp:9001\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstead of source-range, it’s using source-service-accounts.\u003c/p\u003e","title":"gcp firewall source service account"},{"content":"I have an AMI with docker installed. Here’s how I launch a spot instance using Terraform.\nHere’s my Terraform script.\nterraform { required_providers { aws = { source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_spot_instance_request\u0026#34; \u0026#34;docker\u0026#34; { ami = \u0026#34;ami-xxxxxxxxxxxxxxxx\u0026#34; spot_price = \u0026#34;0.0031\u0026#34; wait_for_fulfillment = \u0026#34;true\u0026#34; key_name = \u0026#34;servers\u0026#34; instance_type = \u0026#34;t3.micro\u0026#34; subnet_id = \u0026#34;subnet-xxxxxxxxxxxxxxxx\u0026#34; security_groups = [\u0026#34;sg-xxxxxxxxxxxxxxxxxx\u0026#34;] associate_public_ip_address = \u0026#34;true\u0026#34; user_data = I use \u0026ldquo;aws_ec2_tag\u0026rdquo; resource to tag the instance properly.\nIn addition, I use user_data to run a script, to set the hostname.\nTo launch via Terraform, I run the following commands.\nterraform init terraform apply When done, I could stop the instance to stop incurring charges. Or just simply destroy it via Terraform.\nterraform destroy It\u0026rsquo;s not bad deal for an instance that costs only $0.0031 per hour.\n","permalink":"http://uly.me/posts/aws-spot-instances-running-docker/","summary":"\u003cp\u003eI have an AMI with docker installed. Here’s how I launch a spot instance using Terraform.\u003c/p\u003e\n\u003cp\u003eHere’s my Terraform script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\nresource \u0026#34;aws_spot_instance_request\u0026#34; \u0026#34;docker\u0026#34; {\n  ami                           = \u0026#34;ami-xxxxxxxxxxxxxxxx\u0026#34;\n  spot_price                    = \u0026#34;0.0031\u0026#34;\n  wait_for_fulfillment          = \u0026#34;true\u0026#34;\n  key_name                      = \u0026#34;servers\u0026#34;\n  instance_type                 = \u0026#34;t3.micro\u0026#34;\n  subnet_id                     = \u0026#34;subnet-xxxxxxxxxxxxxxxx\u0026#34;\n  security_groups               = [\u0026#34;sg-xxxxxxxxxxxxxxxxxx\u0026#34;]\n  associate_public_ip_address   = \u0026#34;true\u0026#34;\n  user_data = \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI use \u0026ldquo;aws_ec2_tag\u0026rdquo; resource to tag the instance properly.\u003c/p\u003e","title":"aws spot instances running docker"},{"content":"How to reinstall the latest kernel and rebuild initramfs.\nFind the latest kernel.\nrpm -qa kernel kernel-3.10.0-1160.6.1.el7.x86_64 kernel-3.10.0-1160.11.1.el7.x86_64 Remove the kernel first, then reinstall.\nyum remove kernel-3.10.0-1160.6.1.el7.x86_64 yum install kernel-3.10.0-1160.6.1.el7.x86_64 ","permalink":"http://uly.me/posts/reinstall-kernel/","summary":"\u003cp\u003eHow to reinstall the latest kernel and rebuild initramfs.\u003c/p\u003e\n\u003cp\u003eFind the latest kernel.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa kernel\nkernel-3.10.0-1160.6.1.el7.x86_64\nkernel-3.10.0-1160.11.1.el7.x86_64\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemove the kernel first, then reinstall.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum remove kernel-3.10.0-1160.6.1.el7.x86_64\nyum install kernel-3.10.0-1160.6.1.el7.x86_64\n\u003c/code\u003e\u003c/pre\u003e","title":"reinstall kernel"},{"content":"Here are a few utilities that monitor disk I/O performance.\niostat -d 5 pidstat -dl 20 iotop --only The alternative is atop, which you can set to run every 10 seconds for 3 hours. The output can be viewed later.\natop -a -w logfile.atop 10 10800 \u0026amp; Use atop to read the log file.\natop -r /path/to/logfile.atop ","permalink":"http://uly.me/posts/monitor-disk-performance/","summary":"\u003cp\u003eHere are a few utilities that monitor disk I/O performance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eiostat -d 5\npidstat -dl 20\niotop --only\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe alternative is atop, which you can set to run every 10 seconds for 3 hours. The output can be viewed later.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eatop -a -w logfile.atop 10 10800 \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUse atop to read the log file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eatop -r /path/to/logfile.atop\n\u003c/code\u003e\u003c/pre\u003e","title":"monitor disk performance"},{"content":"Here’s a Terraform script for launching an instance in Google Cloud Platform.\nprovider \u0026#34;google\u0026#34; { project = \u0026#34;project-id\u0026#34; region = \u0026#34;us-central1\u0026#34; zone = \u0026#34;us-central1-a\u0026#34; } resource \u0026#34;google_compute_instance\u0026#34; \u0026#34;wiki\u0026#34; { name = \u0026#34;wiki\u0026#34; machine_type = \u0026#34;n2-standard-1\u0026#34; zone = \u0026#34;us-central1-a\u0026#34; tags = [\u0026#34;web-server\u0026#34;] labels = { name = \u0026#34;wiki\u0026#34; environment = \u0026#34;development\u0026#34; } boot_disk { initialize_params { image = \u0026#34;centos-7-v20210122\u0026#34; } } network_interface { network = \u0026#34;default\u0026#34; access_config { } } service_account { email = \u0026#34;service-account@email.com\u0026#34; scopes = [\u0026#34;cloud-platform\u0026#34;] } } Here’s a few Terraform commands.\nterraform init terraform plan terraform apply terraform destroy ","permalink":"http://uly.me/posts/terraform-gcp-instance/","summary":"\u003cp\u003eHere’s a Terraform script for launching an instance in Google Cloud Platform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;google\u0026#34; {\n  project = \u0026#34;project-id\u0026#34;\n  region  = \u0026#34;us-central1\u0026#34;\n  zone    = \u0026#34;us-central1-a\u0026#34;\n}\nresource \u0026#34;google_compute_instance\u0026#34; \u0026#34;wiki\u0026#34; {\n  name         = \u0026#34;wiki\u0026#34;\n  machine_type = \u0026#34;n2-standard-1\u0026#34;\n  zone         = \u0026#34;us-central1-a\u0026#34;\n  tags         = [\u0026#34;web-server\u0026#34;]\n  labels = {\n    name        = \u0026#34;wiki\u0026#34;\n    environment = \u0026#34;development\u0026#34;\n  }\n  boot_disk {\n    initialize_params {\n      image = \u0026#34;centos-7-v20210122\u0026#34;\n    }\n  }\n  network_interface {\n    network = \u0026#34;default\u0026#34;\n    access_config {\n    }\n  }\n  service_account {\n    email  = \u0026#34;service-account@email.com\u0026#34;\n    scopes = [\u0026#34;cloud-platform\u0026#34;]\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s a few Terraform commands.\u003c/p\u003e","title":"terraform gcp instance"},{"content":"If you have multiple AWS accounts, you can setup a customer-managed KMS (key management service) in the AWS Key Management Service, to secure requests or services between the two AWS accounts. The customer-managed KMS key is tied to an identity such as an IAM user or role. In addition to users and roles, other AWS accounts can be added to grant access. KMS can be symmetric or asymmetric. It’s symmetric be default. To grant access to the other account, you need to add the AWS Account Id to the key. It’s 12 digit number unique to each AWS account.\nOnce a key is created, the valid key ID can be used in a AWS SDK to access resources from the other AWS account.\n","permalink":"http://uly.me/posts/cross-account-kms-keys/","summary":"\u003cp\u003eIf you have multiple AWS accounts, you can setup a customer-managed KMS (key management service) in the AWS Key Management Service, to secure requests or services between the two AWS accounts. The customer-managed KMS key is tied to an identity such as an IAM user or role. In addition to users and roles, other AWS accounts can be added to grant access. KMS can be symmetric or asymmetric. It’s symmetric be default. To grant access to the other account, you need to add the AWS Account Id to the key. It’s 12 digit number unique to each AWS account.\u003c/p\u003e","title":"cross account kms keys"},{"content":"Here’s the script to install Jekyll on Amazon Linux 2.\n#!/bin/bash sudo hostnamectl set-hostname jekyll sudo yum update -y sudo amazon-linux-extras install ruby2.4 -y sudo yum install ruby ruby-devel -y sudo yum groupinstall \u0026#34;Development Tools\u0026#34; -y sudo gem install bundler sudo gem install rdoc sudo gem update --system sudo gem install jekyll jekyll new myblog To start the Jekyll server.\ncd mysite jekyll build jekyll serve --host 0.0.0.0 Open your browser and point it to the external IP of your instance on port 4000.\nhttp://xxx.xxx.xxx.xxx:4000 You may to edit your security group to allow ingress 4000 from 0.0.0.0/0.\n","permalink":"http://uly.me/posts/install-jekyll-on-amazon-linux-2/","summary":"\u003cp\u003eHere’s the script to install Jekyll on Amazon Linux 2.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nsudo hostnamectl set-hostname jekyll\nsudo yum update -y\nsudo amazon-linux-extras install ruby2.4 -y\nsudo yum install ruby ruby-devel -y\nsudo yum groupinstall \u0026#34;Development Tools\u0026#34; -y\nsudo gem install bundler \nsudo gem install rdoc\nsudo gem update --system\nsudo gem install jekyll\njekyll new myblog\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo start the Jekyll server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd mysite\njekyll build\njekyll serve --host 0.0.0.0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOpen your browser and point it to the external IP of your instance on port 4000.\u003c/p\u003e","title":"install jekyll on amazon linux 2"},{"content":"Check if package is on the system.\nrpm -q httpd httpd-2.4.6-97.el7.centos.x86_64 Check the history logs.\nyum history list Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 115 | System \u0026lt;unset\u0026gt; | 2021-02-01 03:40 | Update | 1 114 | System \u0026lt;unset\u0026gt; | 2021-02-01 02:03 | I, U | 10 113 | System \u0026lt;unset\u0026gt; | 2021-01-29 19:54 | Update | 1 112 | System \u0026lt;unset\u0026gt; | 2021-01-21 14:41 | Update | 1 \u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt; Check detail transaction id.\nyum history info 114 | grep python Updated python-perf-3.10.0-1160.6.1.el7.x86_64 @updates Updated python-sss-1.16.5-10.el7_9.5.x86_64 @your-repo Updated python-sssdconfig-1.16.5-10.el7_9.5.noarch @your-repo It looks like python was updated in transaction id #114.\n","permalink":"http://uly.me/posts/checking-yum-transaction-logs/","summary":"\u003cp\u003eCheck if package is on the system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -q httpd\nhttpd-2.4.6-97.el7.centos.x86_64\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck the history logs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum history list\nLoaded plugins: fastestmirror\nID     | Login user               | Date and time    | Action(s)      | Altered\n-------------------------------------------------------------------------------\n   115 | System \u0026lt;unset\u0026gt;           | 2021-02-01 03:40 | Update         |    1\n   114 | System \u0026lt;unset\u0026gt;           | 2021-02-01 02:03 | I, U           |   10\n   113 | System \u0026lt;unset\u0026gt;           | 2021-01-29 19:54 | Update         |    1\n   112 | System \u0026lt;unset\u0026gt;           | 2021-01-21 14:41 | Update         |    1\n\u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt;\u0026lt;/unset\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck detail transaction id.\u003c/p\u003e","title":"checking yum transaction logs"},{"content":"Here’s the installation instructions for OpenJDK 8.\nFor Fedora, Redhat and Oracle Linux.\nyum install java-1.8.0-openjdk For Debian and Ubuntu.\napt-get install openjdk-8-jre To see if the packages (symbolic links) are there, they can be found in /etc/alternatives/, at least in Redhat 7.\nls -l /etc/alternatives/ ","permalink":"http://uly.me/posts/install-openjdk-8/","summary":"\u003cp\u003eHere’s the installation instructions for OpenJDK 8.\u003c/p\u003e\n\u003cp\u003eFor Fedora, Redhat and Oracle Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install java-1.8.0-openjdk\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor Debian and Ubuntu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt-get install openjdk-8-jre\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo see if the packages (symbolic links) are there, they can be found in /etc/alternatives/, at least in Redhat 7.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003els -l /etc/alternatives/\n\u003c/code\u003e\u003c/pre\u003e","title":"install openjdk 8"},{"content":"If a Linux user is having an access problem with a NFS share, and particularly with key expiration, then check if the RPC GSSD service is up and running. NFS clients uses the RPCSEC_GSS protocol to establish security credentials with a NFS server using Kerberos authentication.\nHere’s an example of a key expire error due to a NFS client not authenticated properly.\ndf -h df: \u0026#39;/data/dir1\u0026#39;: Key has expired df: \u0026#39;/data/dir2\u0026#39;: Key has expired df: \u0026#39;/data/dir3\u0026#39;: Key has expired Check if RPC GSSD service is healthy. Restart the service if there are credential errors.\nservice rpc-gssd status Here’s one with an authentication issue.\n[root@server ~]# service rpc-gssd status Redirecting to /bin/systemctl status rpc-gssd.service ● rpc-gssd.service - RPC security service for NFS client and server Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled) Active: active (running) since Sun 2021-01-31 03:16:43 CST; 2h 14min ago Main PID: 710 (rpc.gssd) Memory: 1.6M CGroup: /system.slice/rpc-gssd.service └─710 /usr/sbin/rpc.gssd Jan 31 03:17:10 server.domain.com rpc.gssd[710]: ERROR: gssd_refresh_krb5_machine_credential: no usable keytab entry found Jan 31 03:17:10 server.domain.com rpc.gssd[710]: ERROR: No credentials found for connection to server nas.domain.com Jan 31 03:17:10 server.domain.com rpc.gssd[710]: ERROR: gssd_refresh_krb5_machine_credential: no usable keytab entry found Jan 31 03:17:10 server.domain.com rpc.gssd[710]: ERROR: No credentials found for connection to server nas.domain.com Restart the service.\nservice rpc-gssd stop service rpc-gssd start Here’s a service that’s healthy.\n[root@server ~]# service rpc-gssd status Redirecting to /bin/systemctl status rpc-gssd.service ● rpc-gssd.service - RPC security service for NFS client and server Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled) Active: active (running) since Sun 2021-01-31 05:33:54 CST; 28min ago Process: 9809 ExecStart=/usr/sbin/rpc.gssd $GSSDARGS (code=exited, status=0/SUCCESS) Main PID: 9810 (rpc.gssd) Memory: 804.0K CGroup: /system.slice/rpc-gssd.service └─9810 /usr/sbin/rpc.gssd Jan 31 05:33:54 server.domain.com systemd[1]: Starting RPC security service for NFS client and server... Jan 31 05:33:54 server.domain.com systemd[1]: Started RPC security service for NFS client and server. ","permalink":"http://uly.me/posts/restart-rpc-gssd-service/","summary":"\u003cp\u003eIf a Linux user is having an access problem with a NFS share, and particularly with key expiration, then check if the RPC GSSD service is up and running. NFS clients uses the RPCSEC_GSS protocol to establish security credentials with a NFS server using Kerberos authentication.\u003c/p\u003e\n\u003cp\u003eHere’s an example of a key expire error due to a NFS client not authenticated properly.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edf -h\ndf: \u0026#39;/data/dir1\u0026#39;: Key has expired\ndf: \u0026#39;/data/dir2\u0026#39;: Key has expired\ndf: \u0026#39;/data/dir3\u0026#39;: Key has expired\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if RPC GSSD service is healthy. Restart the service if there are credential errors.\u003c/p\u003e","title":"restart rpc gssd service"},{"content":"AWS EC2 Firewall rules are defined within security groups. Security groups are attached to an instance. An instance can have up to 5 security groups. Essentially, this script gathers all the security groups associated with an instance, loops through them, and then outputs the ingress and egress rules of each security group to a file in a text format.\n#!/bin/bash # set variables instanceid=\u0026#39;i-xxxxxxxxxxxxxxxx\u0026#39; region=\u0026#39;us-east-1\u0026#39; profile=\u0026#39;sample\u0026#39; # log and temp files output=\u0026#34;ec2-sg.log\u0026#34; tmpfil=\u0026#34;ec2-sg.tmp\u0026#34; # empty log at start \u0026gt; $output # get sg ids aws ec2 describe-instances \\ --instance-ids $instanceid \\ --region $region \\ --profile $profile \\ --query \u0026#39;Reservations[*].Instances[*].SecurityGroups[*].[GroupId]\u0026#39; --output text \u0026gt; $tmpfil while read -r id; do echo \u0026#39;============================================\u0026#39; \u0026gt;\u0026gt; $output echo $id \u0026gt;\u0026gt; $output echo \u0026#39;============================================\u0026#39; \u0026gt;\u0026gt; $output echo \u0026#39;---------------- INGRESS -------------------\u0026#39; \u0026gt;\u0026gt; $output aws ec2 describe-security-groups \\ --group-ids $id \\ --profile $profile \\ --region $region \\ --output text \\ --query \u0026#39;SecurityGroups[].IpPermissions[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]\u0026#39; \u0026gt;\u0026gt; $output echo \u0026#39;---------------- EGRESS --------------------\u0026#39; \u0026gt;\u0026gt; $output aws ec2 describe-security-groups \\ --group-ids $id \\ --profile $profile \\ --region $region \\ --output text \\ --query \u0026#39;SecurityGroups[].IpPermissionsEgress[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]\u0026#39; \u0026gt;\u0026gt; $output done Here\u0026rsquo;s a sample output.\n============================================ sg-xxxxxxxxxxxxxxx ============================================ ---------------- INGRESS ------------------- 5985 5985 tcp 10.0.0.220/32 10005 10005 tcp 10.0.0.164/32 ---------------- EGRESS -------------------- 80 80 tcp 10.0.0.14/32 40000 65535 udp 10.0.0.0/8 3389 3389 tcp 10.0.0.96/32 9389 9389 tcp 10.0.0.0/8 5985 5986 tcp 10.0.0.96/32 ","permalink":"http://uly.me/posts/aws-ec2-list-firewall-rules/","summary":"\u003cp\u003eAWS EC2 Firewall rules are defined within security groups. Security groups are attached to an instance. An instance can have up to 5 security groups. Essentially, this script gathers all the security groups associated with an instance, loops through them, and then outputs the ingress and egress rules of each security group to a file in a text format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# set variables\ninstanceid=\u0026#39;i-xxxxxxxxxxxxxxxx\u0026#39;\nregion=\u0026#39;us-east-1\u0026#39;\nprofile=\u0026#39;sample\u0026#39;\n# log and temp files\noutput=\u0026#34;ec2-sg.log\u0026#34;\ntmpfil=\u0026#34;ec2-sg.tmp\u0026#34;\n# empty log at start\n\u0026gt; $output\n# get sg ids\naws ec2 describe-instances \\\n--instance-ids $instanceid \\\n--region $region \\\n--profile $profile \\\n--query \u0026#39;Reservations[*].Instances[*].SecurityGroups[*].[GroupId]\u0026#39; --output text \u0026gt; $tmpfil\nwhile read -r id; do\n  echo \u0026#39;============================================\u0026#39; \u0026gt;\u0026gt; $output\n  echo $id \u0026gt;\u0026gt; $output\n  echo \u0026#39;============================================\u0026#39; \u0026gt;\u0026gt; $output\n  echo \u0026#39;---------------- INGRESS -------------------\u0026#39; \u0026gt;\u0026gt; $output\n  aws ec2 describe-security-groups \\\n  --group-ids $id \\\n  --profile $profile \\\n  --region $region \\\n  --output text \\\n  --query \u0026#39;SecurityGroups[].IpPermissions[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]\u0026#39; \u0026gt;\u0026gt; $output\n  echo \u0026#39;---------------- EGRESS --------------------\u0026#39; \u0026gt;\u0026gt; $output\n  aws ec2 describe-security-groups \\\n  --group-ids $id \\\n  --profile $profile \\\n  --region $region \\\n  --output text \\\n  --query \u0026#39;SecurityGroups[].IpPermissionsEgress[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]\u0026#39; \u0026gt;\u0026gt; $output\ndone \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere\u0026rsquo;s a sample output.\u003c/p\u003e","title":"aws ec2 list firewall rules"},{"content":"You can register multiple domains to a single SSL certificate. This is particularly useful if you are hosting multiple domains on one server. This command adds more domains to your existing certificate.\ncertbot --expand -d existing.com -d newdomain1.com -d newdomain2.com Check if the domains were added.\ncertbot certificates Certbot certificates are valid for 90 days, but they automatically renew themselves if expiration is less than 30 days. If you need to renew manually for some odd reason, you can run this command. You can also perform a dry-run before renewing.\ncertbot renew certbot renew --dry-run ","permalink":"http://uly.me/posts/adding-domains-in-certbot/","summary":"\u003cp\u003eYou can register multiple domains to a single SSL certificate. This is particularly useful if you are hosting multiple domains on one server. This command adds more domains to your existing certificate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecertbot --expand -d existing.com -d newdomain1.com -d newdomain2.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if the domains were added.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecertbot certificates\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCertbot certificates are valid for 90 days, but they automatically renew themselves if expiration is less than 30 days. If you need to renew manually for some odd reason, you can run this command. You can also perform a dry-run before renewing.\u003c/p\u003e","title":"adding domains in certbot"},{"content":"Here’s a regex using the pipe symbol as OR to allow only 6 possible values.\nregex=\u0026#34;efs-(00|04|08|12|16|20)00\u0026#34; Matches:\nefs-0000 efs-0400 efs-0800 efs-1200 efs-1600 efs-2000 No matches:\nefs-0100 efs-2200 efs-0600 efs-1400 efs-1800 efs-1110 111022 asdb023 2330asd 1200-efs 1205 abc $var is compared with $regex to find a match. $var is any of the variables above.\nif [[ $var != $regex ]]; then echo \u0026#34;Not a match\u0026#34; else echo \u0026#34;It\u0026#39;s a match\u0026#34; fi ","permalink":"http://uly.me/posts/using-or-on-regular-expressions/","summary":"\u003cp\u003eHere’s a regex using the pipe symbol as OR to allow only 6 possible values.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eregex=\u0026#34;efs-(00|04|08|12|16|20)00\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMatches:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eefs-0000\nefs-0400\nefs-0800\nefs-1200\nefs-1600\nefs-2000\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNo matches:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eefs-0100\nefs-2200\nefs-0600\nefs-1400\nefs-1800\nefs-1110\n111022\nasdb023\n2330asd\n1200-efs\n1205\nabc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e$var is compared with $regex to find a match. $var is any of the variables above.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [[ $var != $regex ]]; then\n  echo \u0026#34;Not a match\u0026#34;\nelse\n  echo \u0026#34;It\u0026#39;s a match\u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"using or on regular expressions"},{"content":"Here’s how to build an EFS file system using Terraform. Create a main.tf file.\nterraform { required_providers { aws = { version = \u0026#34;\u0026gt;= 3.22.0\u0026#34; source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_efs_file_system\u0026#34; \u0026#34;efs-test\u0026#34; { creation_token = \u0026#34;efs-test\u0026#34; performance_mode = \u0026#34;generalPurpose\u0026#34; throughput_mode = \u0026#34;bursting\u0026#34; encrypted = \u0026#34;true\u0026#34; tags = { Name = \u0026#34;efs-test\u0026#34; } } resource \u0026#34;aws_efs_mount_target\u0026#34; \u0026#34;efs-mt-example\u0026#34; { file_system_id = aws_efs_file_system.efs-test.id subnet_id = \u0026#34;subnet-xxxxxxxxxxxxxxxxx\u0026#34; security_groups = [\u0026#34;sg-xxxxxxxxxxxxxxxxxx\u0026#34;] } To launch, run terraform.\nterraform init terraform apply ","permalink":"http://uly.me/posts/aws-efs-create-terraform/","summary":"\u003cp\u003eHere’s how to build an EFS file system using Terraform. Create a main.tf file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      version = \u0026#34;\u0026gt;= 3.22.0\u0026#34;\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\nresource \u0026#34;aws_efs_file_system\u0026#34; \u0026#34;efs-test\u0026#34; {\n   creation_token = \u0026#34;efs-test\u0026#34;\n   performance_mode = \u0026#34;generalPurpose\u0026#34;\n   throughput_mode = \u0026#34;bursting\u0026#34;\n   encrypted = \u0026#34;true\u0026#34;\n tags = {\n     Name = \u0026#34;efs-test\u0026#34;\n   }\n}\nresource \u0026#34;aws_efs_mount_target\u0026#34; \u0026#34;efs-mt-example\u0026#34; {\n   file_system_id  = aws_efs_file_system.efs-test.id\n   subnet_id = \u0026#34;subnet-xxxxxxxxxxxxxxxxx\u0026#34;\n   security_groups = [\u0026#34;sg-xxxxxxxxxxxxxxxxxx\u0026#34;]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo launch, run terraform.\u003c/p\u003e","title":"aws efs create terraform"},{"content":"Here’s how to launch a LightSail instance using Terraform. Create a main.tf file.\nterraform { required_providers { aws = { version = \u0026gt;= 3.22.0\u0026#34; source = \u0026#34;hashicorp/aws\u0026#34; } } } provider \u0026#34;aws\u0026#34; { profile = \u0026#34;default\u0026#34; region = \u0026#34;us-east-1\u0026#34; } resource \u0026#34;aws_lightsail_instance\u0026#34; \u0026#34;yourinstance\u0026#34; { name = \u0026#34;yourinstance\u0026#34; availability_zone = \u0026#34;us-east-1a\u0026#34; blueprint_id = \u0026#34;amazon_linux_2\u0026#34; bundle_id = \u0026#34;nano_2_0\u0026#34; } To launch, run the following Terraform commands.\nterraform init terraform apply ","permalink":"http://uly.me/posts/aws-lightsail-create-terraform/","summary":"\u003cp\u003eHere’s how to launch a LightSail instance using Terraform. Create a main.tf file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform {\n  required_providers {\n    aws = {\n      version = \u0026gt;= 3.22.0\u0026#34;\n      source = \u0026#34;hashicorp/aws\u0026#34;\n    }\n  }\n}\nprovider \u0026#34;aws\u0026#34; {\n  profile = \u0026#34;default\u0026#34;\n  region  = \u0026#34;us-east-1\u0026#34;\n}\nresource \u0026#34;aws_lightsail_instance\u0026#34; \u0026#34;yourinstance\u0026#34; {\n  name              = \u0026#34;yourinstance\u0026#34;\n  availability_zone = \u0026#34;us-east-1a\u0026#34;\n  blueprint_id      = \u0026#34;amazon_linux_2\u0026#34;\n  bundle_id         = \u0026#34;nano_2_0\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo launch, run the following Terraform commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eterraform init\nterraform apply\n\u003c/code\u003e\u003c/pre\u003e","title":"aws lightsail create terraform"},{"content":"Here’s the script how to install Docker on Ubuntu 20.04 LTS.\n#!/bin/bash sudo apt-get update # install dependencies sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common # add the gpg key for docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # add the repository in the Linux mint 20 sudo add-apt-repository \u0026#34;deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo \u0026#34;$UBUNTU_CODENAME\u0026#34;) stable\u0026#34; sudo apt-get update # install docker e docker-compose sudo add-apt-repository \u0026#34;deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo \u0026#34;$UBUNTU_CODENAME\u0026#34;) stable\u0026#34; sudo apt-get -y install docker-ce docker-compose # add the user system to sudo group, no sudo command sudo usermod -aG docker $USER # prints docker version =) docker --version ","permalink":"http://uly.me/posts/install-docker-on-ubuntu-20-04-lts/","summary":"\u003cp\u003eHere’s the script how to install Docker on Ubuntu 20.04 LTS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nsudo apt-get update\n# install dependencies\nsudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common\n# add the gpg key for docker\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -\n# add the repository in the Linux mint 20\nsudo add-apt-repository \u0026#34;deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo \u0026#34;$UBUNTU_CODENAME\u0026#34;) stable\u0026#34;\nsudo apt-get update\n# install docker e docker-compose\nsudo add-apt-repository \u0026#34;deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo \u0026#34;$UBUNTU_CODENAME\u0026#34;) stable\u0026#34;\nsudo apt-get -y install docker-ce docker-compose\n# add the user system to sudo group, no sudo command\nsudo usermod -aG docker $USER\n# prints docker version =)\ndocker --version\n\u003c/code\u003e\u003c/pre\u003e","title":"install docker on ubuntu 20.04 lts"},{"content":"Here’s a script that scans all EFS systems in several AWS accounts and regions and randomly assigns backup tags to EFS systems that are missing backup tags. This is assuming EFS is using AWS Backup service using tags to apply backup policies. If there are no backup tags, an EFS gets assigned a randomly picked backup policy.\n#!/bin/bash # log file output=\u0026#34;test.log\u0026#34; tmpfil=\u0026#34;temp.txt\u0026#34; # empty file \u0026gt; $output # set random array arr[0]=\u0026#34;efs-0000\u0026#34; arr[1]=\u0026#34;efs-0400\u0026#34; arr[2]=\u0026#34;efs-0800\u0026#34; arr[3]=\u0026#34;efs-1200\u0026#34; arr[4]=\u0026#34;efs-1600\u0026#34; arr[5]=\u0026#34;efs-2000\u0026#34; rand=$[ $RANDOM %6 ] backup=${arr[$rand]} # set accounts and regions declare -a account=(\u0026#34;default\u0026#34; \u0026#34;one\u0026#34; \u0026#34;two\u0026#34; \u0026#34;three\u0026#34; \u0026#34;four\u0026#34; \u0026#34;five\u0026#34;) declare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;) for i in \u0026#34;${account[@]}\u0026#34;; do echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output echo $i \u0026gt;\u0026gt; $output echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output for j in \u0026#34;${region[@]}\u0026#34;; do echo $j \u0026gt;\u0026gt; $output aws efs describe-file-systems \\ --query \u0026#34;FileSystems[*].[FileSystemId,Tags[?Key==\u0026#39;aws-backup\u0026#39;]|[0].Value]\u0026#34; \\ --profile $i \\ --region $j \\ --output text \u0026gt; $tmpfil while read -r id tag; do if [[ $tag == \u0026#34;\u0026#34; ]]; then aws efs tag-resource \\ --resource-id $id \\ --tags Key=\u0026#34;aws-backup\u0026#34;,Value=${arr[$rand]} \\ --profile $i \\ --region $j \u0026gt;\u0026gt; $output echo \u0026#34;Added backup tag $backup to $id\u0026#34; \u0026gt;\u0026gt; $output elif [[ $tag == \u0026#34;no-backup\u0026#34; ]]; then echo \u0026#34;Backup tag is already set to no-backup on $id.\u0026#34; \u0026gt;\u0026gt; $output else echo \u0026#34;No backup tag changes applied to $id.\u0026#34; \u0026gt;\u0026gt; $output fi done ","permalink":"http://uly.me/posts/efs-tags-auto-assign-backup-tags/","summary":"\u003cp\u003eHere’s a script that scans all EFS systems in several AWS accounts and regions and randomly assigns backup tags to EFS systems that are missing backup tags. This is assuming EFS is using AWS Backup service using tags to apply backup policies. If there are no backup tags, an EFS gets assigned a randomly picked backup policy.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# log file\noutput=\u0026#34;test.log\u0026#34;\ntmpfil=\u0026#34;temp.txt\u0026#34;\n# empty file\n\u0026gt; $output\n# set random array\narr[0]=\u0026#34;efs-0000\u0026#34;\narr[1]=\u0026#34;efs-0400\u0026#34;\narr[2]=\u0026#34;efs-0800\u0026#34;\narr[3]=\u0026#34;efs-1200\u0026#34;\narr[4]=\u0026#34;efs-1600\u0026#34;\narr[5]=\u0026#34;efs-2000\u0026#34;\nrand=$[ $RANDOM %6 ]\nbackup=${arr[$rand]}\n# set accounts and regions\ndeclare -a account=(\u0026#34;default\u0026#34; \u0026#34;one\u0026#34; \u0026#34;two\u0026#34; \u0026#34;three\u0026#34; \u0026#34;four\u0026#34; \u0026#34;five\u0026#34;)\ndeclare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;)\nfor i in \u0026#34;${account[@]}\u0026#34;; do\n  echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output\n  echo $i \u0026gt;\u0026gt; $output\n  echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output\n  for j in \u0026#34;${region[@]}\u0026#34;; do\n    echo $j \u0026gt;\u0026gt; $output\n        aws efs describe-file-systems \\\n        --query \u0026#34;FileSystems[*].[FileSystemId,Tags[?Key==\u0026#39;aws-backup\u0026#39;]|[0].Value]\u0026#34; \\\n        --profile $i \\\n        --region $j \\\n        --output text \u0026gt; $tmpfil\n        while read -r id tag; do\n      if [[ $tag == \u0026#34;\u0026#34; ]]; then\n        aws efs tag-resource \\\n        --resource-id $id \\\n        --tags Key=\u0026#34;aws-backup\u0026#34;,Value=${arr[$rand]} \\\n        --profile $i \\\n        --region $j \u0026gt;\u0026gt; $output\n        echo \u0026#34;Added backup tag $backup to $id\u0026#34; \u0026gt;\u0026gt; $output\n      elif [[ $tag == \u0026#34;no-backup\u0026#34; ]]; then\n        echo \u0026#34;Backup tag is already set to no-backup on $id.\u0026#34; \u0026gt;\u0026gt; $output\n      else\n        echo \u0026#34;No backup tag changes applied to $id.\u0026#34; \u0026gt;\u0026gt; $output\n      fi\n    done\n\u003c/code\u003e\u003c/pre\u003e","title":"efs tags auto assign backup tags"},{"content":"The AWS CLI has a not so well-known comparison operator called “contains” which can be used to filter or query the output of your results. In this example, we want to show only instances that were not terminated.\nHere’s a query containing “?!contains().”\naws ec2 describe-instances \\ --query \u0026#39;Reservations[*].Instances[?!contains(State.Name, `terminated`)].{Instance:InstanceId}\u0026#39; --output text ","permalink":"http://uly.me/posts/aws-cli-contains/","summary":"\u003cp\u003eThe AWS CLI has a not so well-known comparison operator called “contains” which can be used to filter or query the output of your results. In this example, we want to show only instances that were not terminated.\u003c/p\u003e\n\u003cp\u003eHere’s a query containing “?!contains().”\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instances \\\n--query \u0026#39;Reservations[*].Instances[?!contains(State.Name, `terminated`)].{Instance:InstanceId}\u0026#39;\n--output text\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli contains"},{"content":"Logrotation is available in most Linux distros. If they are missing, you can easily install them. The logrotation main configuration file is located in /etc/logrotate.conf which is the default setting. The config file contains an include statement that pulls in other log configurations located in the /etc/logrotate.d/ directory. When setting up a log rotation, it’s best to add your log rotation configuration in this directory.\nHere’s a simple configuration in a file called webmon.\n/home/ubuntu/webmon.log { daily create 0640 ubuntu ubuntu dateext rotate 7 nocompress } The options above does the following:\nThe logs are rotated daily. The logs are rotated 7 times with no compression. The rotate log files will have dates appended to them. The log files are owned user ubuntu with permission of 0640. There are more options from the logrotate man pages which can be added.\n","permalink":"http://uly.me/posts/setup-log-rotation/","summary":"\u003cp\u003eLogrotation is available in most Linux distros. If they are missing, you can easily install them. The logrotation main configuration file is located in /etc/logrotate.conf which is the default setting. The config file contains an include statement that pulls in other log configurations located in the /etc/logrotate.d/ directory. When setting up a log rotation, it’s best to add your log rotation configuration in this directory.\u003c/p\u003e\n\u003cp\u003eHere’s a simple configuration in a file called webmon.\u003c/p\u003e","title":"setup log rotation"},{"content":"Here’s another way to add startup scripts to your instance during creation.\nUserData: Fn::Base64: !Sub | #cloud-config repo_upgrade: none runcmd: # Cloud init startup script - \u0026#34;bash /root/setup.sh\u0026#34; write_files: # Cloud init startup script - owner: root:root permissions: \u0026#39;0644\u0026#39; path: /root/setup.sh content: | #! /bin/bash -x write_files: # Cloud init startup script - owner: root:root permissions: \u0026#39;0644\u0026#39; path: /root/setup.sh content: | #! /bin/bash -x # run your bash commands here date \u0026gt; log.txt uptime \u0026gt;\u0026gt; log.txt The above script creates a file setup.sh and executes it during instance creation. The output is dumped to log.txt file.\n","permalink":"http://uly.me/posts/cloudformation-userdata/","summary":"\u003cp\u003eHere’s another way to add startup scripts to your instance during creation.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e      UserData:\n        Fn::Base64: !Sub |\n          #cloud-config\n          repo_upgrade: none\n\n          runcmd:\n            # Cloud init startup script\n            - \u0026#34;bash /root/setup.sh\u0026#34;\n            \n          write_files:\n            # Cloud init startup script\n            - owner: root:root\n              permissions: \u0026#39;0644\u0026#39;\n              path: /root/setup.sh\n              content: |\n                #! /bin/bash -x\n          write_files:\n            # Cloud init startup script\n            - owner: root:root\n              permissions: \u0026#39;0644\u0026#39;\n              path: /root/setup.sh\n              content: |\n                #! /bin/bash -x\n                # run your bash commands here\n                date \u0026gt; log.txt\n                uptime \u0026gt;\u0026gt;  log.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe above script creates a file setup.sh and executes it during instance creation. The output is dumped to log.txt file.\u003c/p\u003e","title":"cloudformation userdata"},{"content":"How to create an instance from a snapshot with alias IP and reserved IPs.\n#!/bin/bash gcloud beta compute instances create jump-server \\ --network-interface=aliases=10.128.1.0/24,private-network-ip=jump-server,subnet=default \\ --machine-type=n1-standard-1 \\`` --network-tier=PREMIUM \\ --maintenance-policy=MIGRATE \\ --service-account=xxxxxxxxxxxxx-compute@developer.gserviceaccount.com \\ --tags=int-webserver \\ --image=debian-10-buster-v20201216 \\ --image-project=debian-cloud \\ --boot-disk-size=20GB \\ --boot-disk-type=pd-standard \\ --boot-disk-device-name=jump-server-1 \\ --no-shielded-secure-boot \\ --shielded-vtpm \\ --shielded-integrity-monitoring \\ --labels=name=jump-server \\ --reservation-affinity=any \\ --zone=us-central1-a \\ --project=airy-totality-151318 The default command uses –private-network-ip and –subnet options separately.\n--private-network-ip 10.0.0.24 \\ --subnet=default \\ But when dealing with aliases, reserved IPs and subnets, use a single –network-interface option instead.\n--network-interface=aliases=10.128.1.0/24,private-network-ip=jump-server,subnet=default \\ ","permalink":"http://uly.me/posts/create-instance-with-alias-ip/","summary":"\u003cp\u003eHow to create an instance from a snapshot with alias IP and reserved IPs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ngcloud beta compute instances create jump-server \\\n--network-interface=aliases=10.128.1.0/24,private-network-ip=jump-server,subnet=default \\\n--machine-type=n1-standard-1 \\``\n--network-tier=PREMIUM \\\n--maintenance-policy=MIGRATE \\\n--service-account=xxxxxxxxxxxxx-compute@developer.gserviceaccount.com \\\n--tags=int-webserver \\\n--image=debian-10-buster-v20201216 \\\n--image-project=debian-cloud \\\n--boot-disk-size=20GB \\\n--boot-disk-type=pd-standard \\\n--boot-disk-device-name=jump-server-1 \\\n--no-shielded-secure-boot \\\n--shielded-vtpm \\\n--shielded-integrity-monitoring \\\n--labels=name=jump-server \\\n--reservation-affinity=any \\\n--zone=us-central1-a \\\n--project=airy-totality-151318\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe default command uses –private-network-ip and –subnet options separately.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e--private-network-ip 10.0.0.24 \\\n--subnet=default \\\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBut when dealing with aliases, reserved IPs and subnets, use a single –network-interface option instead.\u003c/p\u003e","title":"create instance with alias ip"},{"content":"While trying to recover a directory from backup, I ran into an issue with duplicate uuids when trying to mount a recovered volume. The problem was the recovered volume had the same uuid as boot.\nHere’s the original mount command I ran, but I was getting a wrong fs type error.\nmkdir mount -t xfs /dev/nvme3n1p2 /recover mount: wrong fs type, bad option, bad superblock on /dev/nvme3n1p2, missing codepage or helper program, or other error It turned out to be a duplicated uuid. To get around this problem, I ran -o nouuid.\nmount -t xfs -o nouuid /dev/nvme3n1p2 /recover Once the files were recovered, I unmounted volume and detached it from the instance.\n","permalink":"http://uly.me/posts/mounting-duplicate-uuids/","summary":"\u003cp\u003eWhile trying to recover a directory from backup, I ran into an issue with duplicate uuids when trying to mount a recovered volume. The problem was the recovered volume had the same uuid as boot.\u003c/p\u003e\n\u003cp\u003eHere’s the original mount command I ran, but I was getting a wrong fs type error.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir\nmount -t xfs /dev/nvme3n1p2 /recover\nmount: wrong fs type, bad option, bad superblock on /dev/nvme3n1p2,\n       missing codepage or helper program, or other error\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt turned out to be a duplicated uuid. To get around this problem, I ran -o nouuid.\u003c/p\u003e","title":"mounting duplicate uuids"},{"content":"Here’s how to move a VM instance from one zone to another. Moving an instance will involve destroying the instance from the source zone, and then recreating a replacement instance in the destination zone. To make the move easier, we will use a machine image to recreate the instance. We will also take advantage of the compute and IP address reservations to guarantee that we use the same IP address machine type. Some large machine types are hard to come by.\nGet a list of compute and IP reservations.\ngcloud compute addresses list gcloud compute reservations list Make reservations.\ngcloud compute addresses create centos-ip-reservation --addresses 10.128.15.216 --region us-central1 --subnet default gcloud compute reservations create centos-us-central1-b --machine-type=n1-standard-1 --vm-count=1 --zone us-central1-b Create a machine image.\ngcloud compute instances stop centos gcloud beta compute machine-images create centos-image-00 --source-instance centos Delete original instance.\ngcloud compute instances delete centos Create an instance from image in the new zone. Use the compute and ip reservations previously made.\ngcloud beta compute instances create centos \\ --no-address \\ --private-network-ip 10.128.15.216 \\ --source-machine-image=centos-image-00 \\ --subnet=https://www.googleapis.com/compute/v1/projects/airy-totality-151318/regions/us-central1/subnetworks/default \\ --machine-type=n1-standard-1 \\ --reservation-affinity=any \\ --reservation=centos-us-central1-b \\ --zone=us-central1-b Finally, clean it up once you are done.\ngcloud compute instances delete centos --zone us-central1-b gcloud compute addresses delete centos-ip-reservation gcloud compute reservations delete centos-us-central1-b --zone us-central1-b gcloud beta compute machine-images delete centos-image-00 ","permalink":"http://uly.me/posts/gcp-manually-move-instance/","summary":"\u003cp\u003eHere’s how to move a VM instance from one zone to another. Moving an instance will involve destroying the instance from the source zone, and then recreating a replacement instance in the destination zone. To make the move easier, we will use a machine image to recreate the instance. We will also take advantage of the compute and IP address reservations to guarantee that we use the same IP address machine type. Some large machine types are hard to come by.\u003c/p\u003e","title":"gcp manually move instance"},{"content":"When you run top on Linux with multiple processors, you can have processes with percentages higher than 100%. On a 4 core system, you can have a process that can run as high as 400%. To view it differently, press “shift i” while top is running. This will toggle the Irix mode to off. Pressing it again will turn it on. When the Irix mode is off, it will only show percentages divided by a total number of CPUs. This way, you get a true percentage of a process in a multiple core system.\nPressing 1 interestingly shows the breakdown of all CPUs.\n","permalink":"http://uly.me/posts/top-shift-i/","summary":"\u003cp\u003eWhen you run top on Linux with multiple processors, you can have processes with percentages higher than 100%. On a 4 core system, you can have a process that can run as high as 400%. To view it differently, press “shift i” while top is running. This will toggle the Irix mode to off. Pressing it again will turn it on. When the Irix mode is off, it will only show percentages divided by a total number of CPUs. This way, you get a true percentage of a process in a multiple core system.\u003c/p\u003e","title":"top shift i"},{"content":"After you created a backup vault, it’s time to create a backup plan. Here are a few examples.\naws backup create-backup-plan \\ --cli-input-json file://backup-plan.json \\ --profile default \\ --region us-east-1 File: backup-plan.json\n{ \u0026#34;BackupPlan\u0026#34;: { \u0026#34;BackupPlanName\u0026#34;: \u0026#34;efs-0123\u0026#34;, \u0026#34;Rules\u0026#34;: [ { \u0026#34;RuleName\u0026#34;: \u0026#34;efs-0123\u0026#34;, \u0026#34;TargetBackupVaultName\u0026#34;: \u0026#34;efs-vault\u0026#34;, \u0026#34;ScheduleExpression\u0026#34;: \u0026#34;cron(0 0 ? * * *)\u0026#34;, \u0026#34;StartWindowMinutes\u0026#34;: 60, \u0026#34;CompletionWindowMinutes\u0026#34;: 10080, \u0026#34;Lifecycle\u0026#34;: { \u0026#34;DeleteAfterDays\u0026#34;: 7 } } ] } } Finally, create a backup selection.\naws backup create-backup-selection \\ --backup-plan-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \\ --cli-input-json file://backup-selection.json \\ --profile poc \\ --region us-east-1 File: backup-selection.json\n{ \u0026#34;BackupSelection\u0026#34;: { \u0026#34;SelectionName\u0026#34;: \u0026#34;efs-0123\u0026#34;, \u0026#34;IamRoleArn\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxxxx:role/service-role/AWSBackupDefaultServiceRole\u0026#34;, \u0026#34;Resources\u0026#34;: [], \u0026#34;ListOfTags\u0026#34;: [ { \u0026#34;ConditionType\u0026#34;: \u0026#34;STRINGEQUALS\u0026#34;, \u0026#34;ConditionKey\u0026#34;: \u0026#34;aws-backup\u0026#34;, \u0026#34;ConditionValue\u0026#34;: \u0026#34;efs-0123\u0026#34; } ] } } ","permalink":"http://uly.me/posts/aws-create-backup-plan/","summary":"\u003cp\u003eAfter you created a backup vault, it’s time to create a backup plan. Here are a few examples.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup create-backup-plan \\\n--cli-input-json file://backup-plan.json \\\n--profile default \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFile: backup-plan.json\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;BackupPlan\u0026#34;: {\n        \u0026#34;BackupPlanName\u0026#34;: \u0026#34;efs-0123\u0026#34;,\n        \u0026#34;Rules\u0026#34;: [\n            {\n                \u0026#34;RuleName\u0026#34;: \u0026#34;efs-0123\u0026#34;,\n                \u0026#34;TargetBackupVaultName\u0026#34;: \u0026#34;efs-vault\u0026#34;,\n                \u0026#34;ScheduleExpression\u0026#34;: \u0026#34;cron(0 0 ? * * *)\u0026#34;,\n                \u0026#34;StartWindowMinutes\u0026#34;: 60,\n                \u0026#34;CompletionWindowMinutes\u0026#34;: 10080,\n                \u0026#34;Lifecycle\u0026#34;: {\n                    \u0026#34;DeleteAfterDays\u0026#34;: 7\n                }\n            }\n        ]\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally, create a backup selection.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup create-backup-selection \\\n--backup-plan-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx \\\n--cli-input-json file://backup-selection.json \\\n--profile poc \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFile: backup-selection.json\u003c/p\u003e","title":"aws create backup plan"},{"content":"Here’s how to create a backup vault in AWS Backup.\naws backup create-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1 To delete a vault, run this command.\naws backup delete-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1 ","permalink":"http://uly.me/posts/aws-create-backup-vault/","summary":"\u003cp\u003eHere’s how to create a backup vault in AWS Backup.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup create-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo delete a vault, run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws backup delete-backup-vault --backup-vault-name my-efs-vault --profile default --region us-east-1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws create backup vault"},{"content":"Here’s how to delete a Linux user.\nuserdel username Delete user and the home directory.\nuserdel -f username ","permalink":"http://uly.me/posts/linux-delete-user/","summary":"\u003cp\u003eHere’s how to delete a Linux user.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003euserdel username\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete user and the home directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003euserdel -f username\n\u003c/code\u003e\u003c/pre\u003e","title":"linux delete user"},{"content":"Vintela is a utility for allowing AD users to login to Linux. Here are some basic troubleshooting tips.\n#check version vastool -v # check status vastool status # start stop script /etc/init.d/vasd start/stop/restart # check user access vastool user checkaccess username # list users vastool list users # flush cache vastool flush # unjoin domain vastool unjoin -f -l # join domain vastool -u username@domain.com -w password join -f -c OU=Linux,OU=linux,OU=Servers,DC=domain.com,DC=net domain.com Important files.\n/etc/opt/quest/vas/host.keytab Encrypted host key /etc/opt/quest/vas/group-override Maps accounts to groups /etc/opt/quest/vas/users.allow Lists groups that are granted access to the server /etc/opt/quest/vas/xjoin.keytab File used to join server to domain /etc/opt/quest/vas/vas.conf Primary VAS configuration file /etc/opt/quest/vas/user-override Allows you to override specific user settings ","permalink":"http://uly.me/posts/vintela-troubleshooting/","summary":"\u003cp\u003eVintela is a utility for allowing AD users to login to Linux. Here are some basic troubleshooting tips.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#check version\nvastool -v\n# check status\nvastool status\n# start stop script\n/etc/init.d/vasd start/stop/restart\n# check user access\nvastool user checkaccess username\n# list users\nvastool list users\n# flush cache\nvastool flush\n# unjoin domain \nvastool unjoin -f -l\n# join domain\nvastool -u username@domain.com -w password join -f -c OU=Linux,OU=linux,OU=Servers,DC=domain.com,DC=net domain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eImportant files.\u003c/p\u003e","title":"vintela troubleshooting"},{"content":"This script add new tags if they are missing.\n#!/bin/bash log=\u0026#34;log.txt\u0026#34; id=$(aws efs describe-file-systems --query \u0026#34;FileSystems[*].[FileSystemId]\u0026#34; --output text --region us-east-1) tag=$(aws efs describe-file-systems --query \u0026#34;FileSystems[*].Tags[?Key==\u0026#39;aws-backup\u0026#39;].Value\u0026#34; --output text --region us-east-1 ) arr[0]=\u0026#34;efs-0000\u0026#34; arr[1]=\u0026#34;efs-0400\u0026#34; arr[2]=\u0026#34;efs-0800\u0026#34; arr[3]=\u0026#34;efs-1200\u0026#34; arr[4]=\u0026#34;efs-1600\u0026#34; arr[5]=\u0026#34;efs-2000\u0026#34; rand=$[ $RANDOM %6 ] backup=${arr[$rand]} if [[ $tag == \u0026#34;\u0026#34; ]]; then aws efs tag-resource --resource-id $id --tags Key=\u0026#34;aws-backup\u0026#34;,Value=${arr[$rand]} --profile default --region us-east-1 echo \u0026#34;Added backup tag $backup to $id\u0026#34; elif [[ $tag == \u0026#34;no-backup\u0026#34; ]]; then echo \u0026#34;No backup on $id.\u0026#34; else echo \u0026#34;No changes done to $id.\u0026#34; fi ","permalink":"http://uly.me/posts/aws-efs-tags/","summary":"\u003cp\u003eThis script add new tags if they are missing.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nlog=\u0026#34;log.txt\u0026#34;\nid=$(aws efs describe-file-systems --query \u0026#34;FileSystems[*].[FileSystemId]\u0026#34; --output text --region us-east-1)\ntag=$(aws efs describe-file-systems --query \u0026#34;FileSystems[*].Tags[?Key==\u0026#39;aws-backup\u0026#39;].Value\u0026#34; --output text --region us-east-1 )\n\narr[0]=\u0026#34;efs-0000\u0026#34;\narr[1]=\u0026#34;efs-0400\u0026#34;\narr[2]=\u0026#34;efs-0800\u0026#34;\narr[3]=\u0026#34;efs-1200\u0026#34;\narr[4]=\u0026#34;efs-1600\u0026#34;\narr[5]=\u0026#34;efs-2000\u0026#34;\n\nrand=$[ $RANDOM %6 ]\nbackup=${arr[$rand]}\n\nif [[ $tag == \u0026#34;\u0026#34; ]]; then\n  aws efs tag-resource --resource-id $id --tags Key=\u0026#34;aws-backup\u0026#34;,Value=${arr[$rand]} --profile default --region us-east-1\n  echo \u0026#34;Added backup tag $backup to $id\u0026#34; \nelif [[ $tag == \u0026#34;no-backup\u0026#34; ]]; then\n  echo \u0026#34;No backup on $id.\u0026#34;\nelse\n  echo \u0026#34;No changes done to $id.\u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"aws efs tags"},{"content":"This command lists the EC2 instance id and the tag name using query.\naws ec2 describe-instances \\ --query \u0026#39;Reservations[].Instances[].[InstanceId,Tags[?Key==Name]|[0].Value]\u0026#39; \\ --profile tfc \\ --region us-east-2 \\ --output text Output:\ni-xxxxxxxxxxxxxxxxx server-one i-xxxxxxxxxxxxxxxxx server-two i-xxxxxxxxxxxxxxxxx server-three |[0].Value insures output is one instance record per line.\n","permalink":"http://uly.me/posts/aws-cli-display-tags/","summary":"\u003cp\u003eThis command lists the EC2 instance id and the tag name using query.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instances \\\n--query \u0026#39;Reservations[].Instances[].[InstanceId,Tags[?Key==Name]|[0].Value]\u0026#39; \\\n--profile tfc \\\n--region us-east-2 \\\n--output text\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ei-xxxxxxxxxxxxxxxxx     server-one\ni-xxxxxxxxxxxxxxxxx     server-two\ni-xxxxxxxxxxxxxxxxx     server-three\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e|[0].Value insures output is one instance record per line.\u003c/p\u003e","title":"aws cli display tags"},{"content":"Amazon Lightsail offers a variety of OS blueprints, starting from Amazon Linux 2, Ubuntu 20, Windows Server 2019 to Debian 10 to name just a few. Blueprints are a curated selection of operating systems and software that are preinstalled for the creation of instances. For brevity, only a subset of blueprints are displayed below. The description and licenseUrl portions are truncated. To display an entire list of LightSail blueprints, run this command.\naws lightsail get-blueprints --region us-east-1 Output:\n{ \u0026#34;blueprints\u0026#34;: [ { \u0026#34;blueprintId\u0026#34;: \u0026#34;ubuntu_20_04\u0026#34;, \u0026#34;name\u0026#34;: \u0026#34;Ubuntu\u0026#34;, \u0026#34;group\u0026#34;: \u0026#34;ubuntu_20\u0026#34;, \u0026#34;type\u0026#34;: \u0026#34;os\u0026#34;, \u0026#34;description\u0026#34;: \u0026#34;Ubuntu 20.04 LTS - Focal. Lean, fast and powerful, Ubuntu Server delivers services reliably ...\u0026#34;, \u0026#34;isActive\u0026#34;: true, \u0026#34;minPower\u0026#34;: 0, \u0026#34;version\u0026#34;: \u0026#34;20.04 LTS\u0026#34;, \u0026#34;versionCode\u0026#34;: \u0026#34;1\u0026#34;, \u0026#34;productUrl\u0026#34;: \u0026#34;https://aws.amazon.com/marketplace/pp/B087QQNGF1\u0026#34;, \u0026#34;licenseUrl\u0026#34;: \u0026#34;https://d7umqicpi7263.cloudfront.net/eula/product/aced0818- ... .txt\u0026#34;, \u0026#34;platform\u0026#34;: \u0026#34;LINUX_UNIX\u0026#34; }, { \u0026#34;blueprintId\u0026#34;: \u0026#34;wordpress\u0026#34;, \u0026#34;name\u0026#34;: \u0026#34;WordPress\u0026#34;, \u0026#34;group\u0026#34;: \u0026#34;wordpress\u0026#34;, \u0026#34;type\u0026#34;: \u0026#34;app\u0026#34;, \u0026#34;description\u0026#34;: \u0026#34;Bitnami, the leaders in application packaging, and Automattic, the experts behind WordPress .... \u0026#34;, \u0026#34;isActive\u0026#34;: true, \u0026#34;minPower\u0026#34;: 0, \u0026#34;version\u0026#34;: \u0026#34;5.6.0\u0026#34;, \u0026#34;versionCode\u0026#34;: \u0026#34;1\u0026#34;, \u0026#34;productUrl\u0026#34;: \u0026#34;https://aws.amazon.com/marketplace/pp/B00NN8Y43U\u0026#34;, \u0026#34;licenseUrl\u0026#34;: \u0026#34;https://d7umqicpi7263.cloudfront.net/eula/product/7d426cb7- ... .txt\u0026#34;, \u0026#34;platform\u0026#34;: \u0026#34;LINUX_UNIX\u0026#34; } } In this example, I’m using the query option to display only the blueprints ids.\naws lightsail get-blueprints --query \u0026#39;blueprints[*].[blueprintId]\u0026#39; --output text --region us-east-1 Output:\nwindows_server_2019 windows_server_2016 windows_server_2012 windows_server_2016_sql_2016_express amazon_linux_2 amazon_linux ubuntu_20_04 ubuntu_18_04 ubuntu_16_04_2 debian_10 debian_9_5 debian_8_7 freebsd_12 opensuse_15_1 centos_7_1901_01 wordpress wordpress_multisite lamp_7 nodejs joomla magento mean drupal gitlab redmine nginx ghost_bitnami django_bitnami plesk_ubuntu_18_0_28 cpanel_whm_linux ","permalink":"http://uly.me/posts/aws-lightsail-blueprints/","summary":"\u003cp\u003e\u003ca href=\"https://aws.amazon.com/lightsail/\"\u003eAmazon Lightsail\u003c/a\u003e offers a variety of OS blueprints, starting from Amazon Linux 2, Ubuntu 20, Windows Server 2019 to Debian 10 to name just a few. Blueprints are a curated selection of operating systems and software that are preinstalled for the creation of instances. For brevity, only a subset of blueprints are displayed below. The description and licenseUrl portions are truncated. To display an entire list of LightSail blueprints, run this command.\u003c/p\u003e","title":"aws lightsail blueprints"},{"content":"Here’s how to perform SQL searches using the like operator.\n# Format SELECT column1, column2 FROM table_name WHERE column LIKE pattern; # Search for an entry starting with a \u0026#39;joe.\u0026#39; SELECT id,username,address FROM users WHERE username LIKE \u0026#39;joe%\u0026#39;; # Search for an entry ending with a \u0026#39;joe.\u0026#39; SELECT id,username,address FROM users WHERE username LIKE \u0026#39;%joe\u0026#39;; # Search for any entry with \u0026#39;joe\u0026#39; from any position. SELECT id,username,address FROM users WHERE username LIKE \u0026#39;%joe%\u0026#39;; # Finally, using \u0026#34;_\u0026#34; as wildcards. Find any field with \u0026#34;j\u0026#34; in the second position. SELECT id,username,address FROM users WHERE username LIKE \u0026#39;_j\u0026#39;; ","permalink":"http://uly.me/posts/mysql-select-like/","summary":"\u003cp\u003eHere’s how to perform SQL searches using the like operator.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Format\nSELECT column1, column2 FROM table_name WHERE column LIKE pattern;\n# Search for an entry starting with a \u0026#39;joe.\u0026#39;\nSELECT id,username,address FROM users WHERE username LIKE \u0026#39;joe%\u0026#39;;\n# Search for an entry ending with a \u0026#39;joe.\u0026#39; \nSELECT id,username,address FROM users WHERE username LIKE \u0026#39;%joe\u0026#39;;\n# Search for any entry with \u0026#39;joe\u0026#39; from any position. \nSELECT id,username,address FROM users WHERE username LIKE \u0026#39;%joe%\u0026#39;;\n# Finally, using \u0026#34;_\u0026#34; as wildcards. Find any field with \u0026#34;j\u0026#34; in the second position.\nSELECT id,username,address FROM users WHERE username LIKE \u0026#39;_j\u0026#39;;\n\u003c/code\u003e\u003c/pre\u003e","title":"mysql select like"},{"content":"AWS just added a new feature called CloudShell. It will give users who are logged in to the AWS console access to a VM where users can run AWS CLI commands. Permissions to AWS resources is based on the user’s permissions which are managed via IAM. CloudShell is similar to the cloud shells that Azure and GCP already offer. Here’s a snapshot of AWS CloudShell.\n","permalink":"http://uly.me/posts/aws-cloudshell/","summary":"\u003cp\u003eAWS just added a new feature called CloudShell. It will give users who are logged in to the AWS console access to a VM where users can run AWS CLI commands. Permissions to AWS resources is based on the user’s permissions which are managed via IAM. CloudShell is similar to the cloud shells that Azure and GCP already offer. Here’s a snapshot of AWS CloudShell.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://uly.me/wp-content/uploads/2020/12/cloudshell.png\"\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2020/12/cloudshell.png\"\u003e\u003c/a\u003e\u003c/p\u003e","title":"aws cloudshell"},{"content":"Here’s how to install a RPM locally. Download the RPM first.\nwget https://domain.com/path/to/file/rpmfile1.rpm wget https://domain.com/path/to/file/rpmfile2.rpm Then install RPM from a local file.\nyum localinstall /path/to/rpmfile1.rpm yum localinstall /path/to/rpmfile2.rpm ","permalink":"http://uly.me/posts/yum-localinstall/","summary":"\u003cp\u003eHere’s how to install a RPM locally. Download the RPM first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget https://domain.com/path/to/file/rpmfile1.rpm\nwget https://domain.com/path/to/file/rpmfile2.rpm\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThen install RPM from a local file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum localinstall /path/to/rpmfile1.rpm\nyum localinstall /path/to/rpmfile2.rpm\n\u003c/code\u003e\u003c/pre\u003e","title":"yum localinstall"},{"content":"Here’s an easy way to add Windows users in Powershell.\nnet user username \u0026#39;password\u0026#39; /add Passwords must meet requirements. While you are at it, give it Admin rights.\nnet localgroup Administrators username /add ","permalink":"http://uly.me/posts/adding-new-users-in-powershell/","summary":"\u003cp\u003eHere’s an easy way to add Windows users in Powershell.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enet user username \u0026#39;password\u0026#39; /add\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePasswords must meet \u003ca href=\"https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements\"\u003erequirements\u003c/a\u003e. While you are at it, give it Admin rights.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enet localgroup Administrators username /add\n\u003c/code\u003e\u003c/pre\u003e","title":"adding new users in powershell"},{"content":"Here’s a new script to reboot a Lightsail instance based on input.\n#!/bin/bash echo \u0026#39;Choose a server to reboot ...\u0026#39; echo \u0026#39;1) server-one\u0026#39; echo \u0026#39;2) server-two\u0026#39; echo \u0026#39;3) server-three\u0026#39; echo \u0026#39;4) server-four\u0026#39; echo \u0026#39;5) sever-five\u0026#39; echo \u0026#39;q) Quit\u0026#39; read -p \u0026#39;Choose a server to reboot: \u0026#39; server case $server in 1) echo \u0026#39;Rebooting server-one ...\u0026#39; aws lightsail reboot-instance --instance-name server-one echo \u0026#39;Done\u0026#39; ;; 2) echo \u0026#39;Rebooting server-two ...\u0026#39; aws lightsail reboot-instance --instance-name server-two echo \u0026#39;Done\u0026#39; ;; 3) echo \u0026#39;Rebooting server-three ...\u0026#39; aws lightsail reboot-instance --instance-name server-three echo \u0026#39;Done\u0026#39; ;; 4) echo \u0026#39;Rebooting server-four ...\u0026#39; aws lightsail reboot-instance --instance-name server-four echo \u0026#39;Done\u0026#39; ;; 5) echo \u0026#39;Rebooting server-five ...\u0026#39; aws lightsail reboot-instance --instance-name server-five echo \u0026#39;Done\u0026#39; ;; q) echo \u0026#39;Quit\u0026#39; ;; *) echo \u0026#39;Invalid option\u0026#39; $server ;; esac Assuming awscli is working and correct permission is granted to user.\n","permalink":"http://uly.me/posts/reboot-instance-script/","summary":"\u003cp\u003eHere’s a new script to reboot a Lightsail instance based on input.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\necho \u0026#39;Choose a server to reboot ...\u0026#39;\necho \u0026#39;1) server-one\u0026#39;\necho \u0026#39;2) server-two\u0026#39;\necho \u0026#39;3) server-three\u0026#39;\necho \u0026#39;4) server-four\u0026#39;\necho \u0026#39;5) sever-five\u0026#39;\necho \u0026#39;q) Quit\u0026#39;\nread -p \u0026#39;Choose a server to reboot: \u0026#39; server\ncase $server in \n\t1)\n\t\techo \u0026#39;Rebooting server-one ...\u0026#39;\n\t\taws lightsail reboot-instance --instance-name server-one\n\t\techo \u0026#39;Done\u0026#39;\n\t\t;;\n\t2)\n\t        echo \u0026#39;Rebooting server-two ...\u0026#39;\n\t\taws lightsail reboot-instance --instance-name server-two\n\t\techo \u0026#39;Done\u0026#39;\n\t\t;;\n\t3)\n\t\techo \u0026#39;Rebooting server-three ...\u0026#39;\n\t\taws lightsail reboot-instance --instance-name server-three\n\t\techo \u0026#39;Done\u0026#39;\n\t\t;;\n\t4)\n\t\techo \u0026#39;Rebooting server-four ...\u0026#39;\n\t\taws lightsail reboot-instance --instance-name server-four\n\t\techo \u0026#39;Done\u0026#39;\n\t\t;;\n\t5)\n\t\techo \u0026#39;Rebooting server-five ...\u0026#39;\n\t\taws lightsail reboot-instance --instance-name server-five\n\t\techo \u0026#39;Done\u0026#39;\n\t\t;;\n\tq)\n\t\techo \u0026#39;Quit\u0026#39;\n\t\t;;\n\t*)\n\t\techo \u0026#39;Invalid option\u0026#39; $server\n\t\t;;\nesac\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAssuming awscli is working and correct permission is granted to user.\u003c/p\u003e","title":"reboot instance script"},{"content":"Here are the commands to start, stop, enable and get the status of Apache on RHEL and CentOS.\nsystemctl enable httpd # enable on bootup systemctl status httpd # get status systemctl start httpd # start systemctl stop httpd # stop systemctl restart httpd # restart ","permalink":"http://uly.me/posts/httpd-on-redhat-centos/","summary":"\u003cp\u003eHere are the commands to start, stop, enable and get the status of Apache on RHEL and CentOS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl enable httpd  # enable on bootup\nsystemctl status httpd  # get status\nsystemctl start httpd   # start\nsystemctl stop httpd    # stop\nsystemctl restart httpd # restart\n\u003c/code\u003e\u003c/pre\u003e","title":"httpd on redhat and centos"},{"content":"Here’s how to add an existing user to a user group in Linux.\nusermod -a -G groupname username usermod -a -G www-data john List all users belonging to a group.\nlid -g www-data List all the groups the user belongs to.\ngroups john ","permalink":"http://uly.me/posts/add-existing-user-to-a-group/","summary":"\u003cp\u003eHere’s how to add an existing user to a user group in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eusermod -a -G groupname username\nusermod -a -G www-data john\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList all users belonging to a group.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elid -g www-data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList all the groups the user belongs to.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egroups john\n\u003c/code\u003e\u003c/pre\u003e","title":"add existing user to a group"},{"content":"If you have an existing EFS that’s unencrypted, you can encrypt it be creating a snapshot using AWS Backup, and then restoring the file system to a new EFS with encryption. If you choose to restore in a directory in the same file system, it will not be encrypted. It has to be a new EFS. In addition, you’ll be asked to select which encryption key to use. The default key will work, unless you have your own.\n","permalink":"http://uly.me/posts/efs-encryption/","summary":"\u003cp\u003eIf you have an existing EFS that’s unencrypted, you can encrypt it be creating a snapshot using AWS Backup, and then restoring the file system to a new EFS with encryption. If you choose to restore in a directory in the same file system, it will not be encrypted. It has to be a new EFS. In addition, you’ll be asked to select which encryption key to use. The default key will work, unless you have your own.\u003c/p\u003e","title":"efs encryption"},{"content":"If you need to perform backup or replicate a database, you can lock up the database by doing a global read block to make it read-only.\nThe process is:\nMake the server read-only, so that it processes only retrievals and blocks updates. You can then perform the backup. Change the server back to its normal read/write state. Read only.\nFLUSH TABLES WITH READ LOCK; SET GLOBAL read_only = ON; Back to normal mode.\nSET GLOBAL read_only = OFF; UNLOCK TABLES; You can run these MySQL commands within MySQL or via a bash terminal. Check out my previous post.\n","permalink":"http://uly.me/posts/mysql-read-only-2/","summary":"\u003cp\u003eIf you need to perform backup or replicate a database, you can lock up the database by doing a global read block to make it read-only.\u003c/p\u003e\n\u003cp\u003eThe process is:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eMake the server read-only, so that it processes only retrievals and blocks updates.\u003c/li\u003e\n\u003cli\u003eYou can then perform the backup.\u003c/li\u003e\n\u003cli\u003eChange the server back to its normal read/write state.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eRead only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFLUSH TABLES WITH READ LOCK;\nSET GLOBAL read_only = ON;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBack to normal mode.\u003c/p\u003e","title":"mysql read only"},{"content":"This is a very simple command to run. Login to MySQL first and run the following the command line.\nALTER USER username IDENTIFIED BY \u0026#39;password\u0026#39;; Flush privileges for changes to take effect.\nflush privileges; ","permalink":"http://uly.me/posts/change-mysql-user-password/","summary":"\u003cp\u003eThis is a very simple command to run. Login to MySQL first and run the following the command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eALTER USER username IDENTIFIED BY \u0026#39;password\u0026#39;;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFlush privileges for changes to take effect.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eflush privileges;\n\u003c/code\u003e\u003c/pre\u003e","title":"change mysql user password"},{"content":"You can run MySQL commands from the terminal by using -e switch. Here are a few examples.\nmysql -u username -p -e \u0026#34;create database mydb\u0026#34; mysql -u username -p -e \u0026#34;use mydb\u0026#34; mysql -u username -p database -e \u0026#34;select * from mytable\u0026#34; If you have .mycnf configured, you can omit the username and password.\nmysql -e \u0026#34;create database mydb\u0026#34; mysql -e \u0026#34;use mydb\u0026#34; mysql -e \u0026#34;select * from mytable\u0026#34; To run multiple commands from a single line, separate the commands using a semicolon.\nmysql -e \u0026#34;create database somedb; use mydb; select * from mytable;\u0026#34; ","permalink":"http://uly.me/posts/test-2/","summary":"\u003cp\u003eYou can run MySQL commands from the terminal by using -e switch. Here are a few examples.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -u username -p -e \u0026#34;create database mydb\u0026#34;\nmysql -u username -p -e \u0026#34;use mydb\u0026#34;\nmysql -u username -p database -e \u0026#34;select * from mytable\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have .mycnf configured, you can omit the username and password.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -e \u0026#34;create database mydb\u0026#34;\nmysql -e \u0026#34;use mydb\u0026#34;\nmysql -e \u0026#34;select * from mytable\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo run multiple commands from a single line, separate the commands using a semicolon.\u003c/p\u003e","title":"running mysql commands from the terminal"},{"content":"Here’s how to create a WordPress site that’s read only. You will not be able to create, update and delete posts.\nLogin to MySQL or MariaDB. Choose mysql database. Create a new user called ‘wpro’ for WordPress read only. Grant select permissions to all tables in ‘wordpress’ database. Flush privileges to commit your changes. mariadb -u root -p use mysql; create user \u0026#39;wpro\u0026#39;@\u0026#39;localhost\u0026#39; identified by \u0026#39;yourpassword\u0026#39;; grant select on wordpress.* to \u0026#39;wpro\u0026#39;@\u0026#39;localhost\u0026#39;; flush privileges; In MySQL or MariaDB, you have to terminate all commands with a semicolon.\nNow edit your WordPress wp-config.php file. vim /var/www/wordpress/wp-config.php.\n/** MySQL database username */ define(\u0026#39;DB_USER\u0026#39;, \u0026#39;wpro\u0026#39;); /** MySQL database password */ define(\u0026#39;DB_PASSWORD\u0026#39;, \u0026#39;yourpassword\u0026#39;); After saving the wp-config.php file, everything should work just like before, except that you will not be able to save, publish or delete posts, pages, or add or delete media files to your WordPress site. It’s working as intended.\n","permalink":"http://uly.me/posts/test/","summary":"\u003cp\u003eHere’s how to create a WordPress site that’s read only. You will not be able to create, update and delete posts.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eLogin to MySQL or MariaDB.\u003c/li\u003e\n\u003cli\u003eChoose mysql database.\u003c/li\u003e\n\u003cli\u003eCreate a new user called ‘wpro’ for WordPress read only.\u003c/li\u003e\n\u003cli\u003eGrant select permissions to all tables in ‘wordpress’ database.\u003c/li\u003e\n\u003cli\u003eFlush privileges to commit your changes.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emariadb -u root -p\nuse mysql;\ncreate user \u0026#39;wpro\u0026#39;@\u0026#39;localhost\u0026#39; identified by \u0026#39;yourpassword\u0026#39;;\ngrant select on wordpress.* to \u0026#39;wpro\u0026#39;@\u0026#39;localhost\u0026#39;;\nflush privileges;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn MySQL or MariaDB, you have to terminate all commands with a semicolon.\u003c/p\u003e","title":"wordpress read only"},{"content":"Here’s how to copy a symbolic link which is also known as a soft link from one directory to another. A regular copy command will not work. You will need to use the -P option to copy the symbolic link from one directory to another. If omitted, the symbolic links will not be copied.\ncp -P /directory1/* /directory2/ How to create a symbolic link.\nln -s sourcefile myfile ln -s /path/to/file myfile Here are the man pages for ln and for cp.\n","permalink":"http://uly.me/posts/copy-a-symbolic-link/","summary":"\u003cp\u003eHere’s how to copy a symbolic link which is also known as a soft link from one directory to another. A regular copy command will not work. You will need to use the -P option to copy the symbolic link from one directory to another. If omitted, the symbolic links will not be copied.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecp -P /directory1/* /directory2/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to create a symbolic link.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eln -s sourcefile myfile\nln -s /path/to/file myfile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere are the man pages for \u003ca href=\"https://man7.org/linux/man-pages/man1/ln.1.html\"\u003eln\u003c/a\u003e and for \u003ca href=\"https://linux.die.net/man/1/cp\"\u003ecp\u003c/a\u003e.\u003c/p\u003e","title":"copy a symbolic link"},{"content":"Promiscuous mode is a mode for a network interface where the controller to passes all traffic it receives to the CPU instead of passing the frames to the controller. This is helpful if you want to capture all traffic as part of troubleshooting. The question is, how can you tell if your network interface is in a promiscuous mode? Here’s a couple of commands.\nHere’s the default mode.\nsudo ip link show eth0 2: eth0: \u0026lt;broadcast\u0026gt; mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff \u0026lt;/broadcast\u0026gt; Here’s promiscuous mode. Look for PROMISC.\nsudo ip link show eth0 2: eth0: \u0026lt;broadcast\u0026gt; mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff \u0026lt;/broadcast\u0026gt; The other command is netstat. Look for P flag.\nnetstat -i Kernel Interface table Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1460 21895816 0 0 0 22645756 0 0 0 BMPRU lo 65536 44129 0 0 0 44129 0 0 0 LRU Finally, if you want to enable promiscuous mode, run one of these commands.\nsudo ip link set eth0 promisc on ifconfig eth0 promisc To disable, use ifconfig.\nifconfig eth0 -promisc ","permalink":"http://uly.me/posts/check-network-promiscuous-mode/","summary":"\u003cp\u003ePromiscuous mode is a mode for a network interface where the controller to passes all traffic it receives to the CPU instead of passing the frames to the controller. This is helpful if you want to capture all traffic as part of troubleshooting. The question is, how can you tell if your network interface is in a promiscuous mode? Here’s a couple of commands.\u003c/p\u003e\n\u003cp\u003eHere’s the default mode.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo ip link show eth0\n2: eth0: \u0026lt;broadcast\u0026gt; mtu 1460 qdisc mq state UP mode DEFAULT group default qlen 1000\nlink/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff\n\u0026lt;/broadcast\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s promiscuous mode. Look for PROMISC.\u003c/p\u003e","title":"check network promiscuous mode"},{"content":"iotop is a Linux command similar to top but instead of CPU and memory it will display and monitor your disk IO usage.\nTo install, run the following command based on your Linux ditro.\nyum install iotop apt install iotop dnf install iotop To use.\niotop iotop -o Output:\n","permalink":"http://uly.me/posts/iotop/","summary":"\u003cp\u003eiotop is a Linux command similar to top but instead of CPU and memory it will display and monitor your disk IO usage.\u003c/p\u003e\n\u003cp\u003eTo install, run the following command based on your Linux ditro.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install iotop\napt install iotop\ndnf install iotop\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo use.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eiotop\niotop -o\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2020/11/iotop.png\"\u003e\u003c/p\u003e","title":"iotop"},{"content":"Here’s how to make a MySQL database read only.\nmysql\u0026gt; FLUSH TABLES WITH READ LOCK; mysql\u0026gt; SET GLOBAL read_only = ON; It’s very useful if creating a replica database.\n","permalink":"http://uly.me/posts/mysql-read-only/","summary":"\u003cp\u003eHere’s how to make a MySQL database read only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql\u0026gt; FLUSH TABLES WITH READ LOCK;\nmysql\u0026gt; SET GLOBAL read_only = ON;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s very useful if creating a replica database.\u003c/p\u003e","title":"mysql read only"},{"content":"Here’s one way to display block devices, mountpoints and size using lsblk.\nlsblk -a -p -n -d -e 230 -o NAME,MOUNTPOINT,SIZE Here are the options.\n-a = list all empty devices -p = print full device paths -d = do not print holder devices or slaves -e = exclude devices as by a comma-separate list -o = specify which columns to print, e.g. NAME,MOUNTPOINT,SIZE The output.\n/dev/sda 30G /dev/sdb /data 50G Here’s the man page.\n","permalink":"http://uly.me/posts/filter-output-of-lsblk/","summary":"\u003cp\u003eHere’s one way to display block devices, mountpoints and size using lsblk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk -a -p -n -d -e 230 -o NAME,MOUNTPOINT,SIZE\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere are the options.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e-a = list all empty devices\u003c/li\u003e\n\u003cli\u003e-p = print full device paths\u003c/li\u003e\n\u003cli\u003e-d = do not print holder devices or slaves\u003c/li\u003e\n\u003cli\u003e-e = exclude devices as by a comma-separate list\u003c/li\u003e\n\u003cli\u003e-o = specify which columns to print, e.g. NAME,MOUNTPOINT,SIZE\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe output.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/dev/sda             30G\n/dev/sdb /data       50G\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the \u003ca href=\"https://linux.die.net/man/8/lsblk\"\u003eman page\u003c/a\u003e.\u003c/p\u003e","title":"filter output of lsblk"},{"content":"If your instance is not configured to send out email, you have several options to choose from. One option is to use a service called SendGrid. You can sign up on their site and obtain an API key. To start using with WordPress, you simply install a plugin called WP Mail SMTP and supply the API key on the plugin and off you go. I use Contact Form 7 to send out email from a form. There are no issues using Contact Form 7 and SendGrid. In addition to SendGrid, the plugin also works with other email providers such as AWS, Gmail, Outlook, Zoho, Mailgun to name just a few.\n","permalink":"http://uly.me/posts/sendgrid-with-wordpress/","summary":"\u003cp\u003eIf your instance is not configured to send out email, you have several options to choose from. One option is to use a service called SendGrid. You can sign up on their site and obtain an API key. To start using with WordPress, you simply install a plugin called WP Mail SMTP and supply the API key on the plugin and off you go. I use Contact Form 7 to send out email from a form. There are no issues using Contact Form 7 and SendGrid. In addition to SendGrid, the plugin also works with other email providers such as AWS, Gmail, Outlook, Zoho, Mailgun to name just a few.\u003c/p\u003e","title":"sendgrid with wordpress"},{"content":"Here’s how to turn on Samba encryption on a share.\nEdit /etc/samba/smb.conf on the Samba server.\n[global] server max protocol = SMB3 smb encrypt = required lanman auth = no Edit /etc/samba/smb.conf on the Samba clients.\n[global] smb encrypt = required client min protocol = SMB2 client max protocol = SMB3 To connect.\nsmbclient -e -m SMB3 //xxx.xxx.xxx.xxx/share-name -U username ","permalink":"http://uly.me/posts/encrypt-samba-share/","summary":"\u003cp\u003eHere’s how to turn on Samba encryption on a share.\u003c/p\u003e\n\u003cp\u003eEdit /etc/samba/smb.conf on the Samba server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[global]\nserver max protocol = SMB3\nsmb encrypt = required \nlanman auth = no\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit /etc/samba/smb.conf on the Samba clients.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[global]\nsmb encrypt = required\nclient min protocol = SMB2\nclient max protocol = SMB3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo connect.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esmbclient -e -m SMB3 //xxx.xxx.xxx.xxx/share-name -U username\n\u003c/code\u003e\u003c/pre\u003e","title":"encrypt samba share"},{"content":"When running CloudFormation, all the resources are being created with no problem. However it seems to be getting stuck at creating or mounting a volume. The CloudFormation fails and initiates a rollback. This is the error I am getting.\nVolume attachment between volume-id vol-xxxxxxxx and instance-id i-xxxxxxx at device /dev/xvda is attaching This turned out to be a conflict on HVM EC2 instances because /dev/sda1 is being remapped to /dev/xvda. My second drive is also mapped to /dev/xvda. The fix was to simply to map it slightly different to avoid mapping conflict.\nHere’s the original mapping.\nBoot: /dev/xvda Device: /dev/xvda Device: /dev/xvdb Here’s the fix.\nBoot: /dev/xvda Device: /dev/xvdb Device: /dev/xvdc ","permalink":"http://uly.me/posts/ebs-volume-stuck-in-cloudformation/","summary":"\u003cp\u003eWhen running CloudFormation, all the resources are being created with no problem. However it seems to be getting stuck at creating or mounting a volume. The CloudFormation fails and initiates a rollback. This is the error I am getting.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eVolume attachment between volume-id vol-xxxxxxxx and instance-id i-xxxxxxx at device /dev/xvda is attaching\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis turned out to be a conflict on HVM EC2 instances because /dev/sda1 is being remapped to /dev/xvda. My second drive is also mapped to /dev/xvda. The fix was to simply to map it slightly different to avoid mapping conflict.\u003c/p\u003e","title":"ebs volume stuck in cloudformation"},{"content":"Instead of using AWS and JQ to get the snapshot names, you can do it with a single command using –query.\nHere are the previous commands.\n/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default \u0026gt; $snaps cat $snaps | jq -r \u0026#39;.instanceSnapshots[] | .name\u0026#39; \u0026gt; $names Using query.\naws lightsail get-instance-snapshots \\ --query \u0026#39;instanceSnapshots[*].[name]\u0026#39; \\ --region us-east-1 \\ --profile default \\ --output text \u0026gt; $names ","permalink":"http://uly.me/posts/aws-cli-using-query/","summary":"\u003cp\u003eInstead of using AWS and JQ to get the snapshot names, you can do it with a single command using –query.\u003c/p\u003e\n\u003cp\u003eHere are the previous commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default \u0026gt; $snaps\ncat $snaps | jq -r \u0026#39;.instanceSnapshots[] | .name\u0026#39; \u0026gt; $names\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUsing query.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail get-instance-snapshots \\\n--query \u0026#39;instanceSnapshots[*].[name]\u0026#39; \\\n--region us-east-1 \\\n--profile default \\\n--output text \u0026gt; $names\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli using query"},{"content":"Here’s the Crowdstrike Falcon Sensor checks.\n#!/bin/bash if [ -e /etc/redhat-release ] ; then if egrep -q \u0026#39;Ootpa|CentOS Linux release 8\u0026#39; /etc/redhat-release ; then OSver=\u0026#34;el8\u0026#34; elif egrep -q \u0026#39;Maipo|CentOS Linux release 7\u0026#39; /etc/redhat-release ; then OSver=\u0026#34;el7\u0026#34; elif egrep -q \u0026#39;Santiago|CentOS release 6\u0026#39; /etc/redhat-release ; then OSver=\u0026#34;el6\u0026#34; fi fi if [ -e /etc/os-release ] ; then if grep VERSION /etc/os-release | grep -q 15 ; then OSver=\u0026#34;suse15\u0026#34; elif grep VERSION /etc/os-release | grep -q 12 ; then OSver=\u0026#34;suse12\u0026#34; elif grep VERSION /etc/os-release | grep -q 11 ; then OSver=\u0026#34;suse11\u0026#34; elif grep -q \u0026#39;Linux 2\u0026#39; /etc/os-release ; then OSver=\u0026#34;amzn2\u0026#34; elif grep -q \u0026#39;AMI\u0026#39; /etc/os-release ; then OSver=\u0026#34;amzn1\u0026#34; fi fi if [[ -f \u0026#34;/opt/CrowdStrike/falconctl\u0026#34; ]]; then case $OSver in suse15) if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; suse12) if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; suse11) if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; el8) if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; el7) if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; el6) if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; amzn2) if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; amzn1) if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi ;; *) ;; esac else message=\u0026#34;Not installed\u0026#34; fi if [[ -f \u0026#34;/opt/CrowdStrike/falconctl\u0026#34; ]]; then version=$(/opt/CrowdStrike/falconctl -g --version | awk \u0026#39;{print $3}\u0026#39;) else version=\u0026#34;Not installed\u0026#34; fi if [ \u0026#34;$version\u0026#34; == \u0026#34;Not installed\u0026#34; ]; then status=\u0026#34;Not installed\u0026#34;; fi echo $version \u0026#39;|\u0026#39; $status \u0026#39;|\u0026#39; $message ","permalink":"http://uly.me/posts/sensor-checks-for-crowdstrike/","summary":"\u003cp\u003eHere’s the Crowdstrike Falcon Sensor checks.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [ -e /etc/redhat-release ] ; then\n  if egrep -q \u0026#39;Ootpa|CentOS Linux release 8\u0026#39; /etc/redhat-release ; then\n    OSver=\u0026#34;el8\u0026#34;\n  elif egrep -q \u0026#39;Maipo|CentOS Linux release 7\u0026#39; /etc/redhat-release ; then\n    OSver=\u0026#34;el7\u0026#34;\n  elif egrep -q \u0026#39;Santiago|CentOS release 6\u0026#39; /etc/redhat-release ; then\n    OSver=\u0026#34;el6\u0026#34;\n  fi\nfi\nif [ -e /etc/os-release ] ; then\n  if grep VERSION /etc/os-release | grep -q 15 ; then\n    OSver=\u0026#34;suse15\u0026#34;\n  elif grep VERSION /etc/os-release | grep -q 12 ; then\n    OSver=\u0026#34;suse12\u0026#34;\n  elif grep VERSION /etc/os-release | grep -q 11 ; then\n    OSver=\u0026#34;suse11\u0026#34;\n  elif grep -q \u0026#39;Linux 2\u0026#39; /etc/os-release ; then\n    OSver=\u0026#34;amzn2\u0026#34;\n  elif grep -q \u0026#39;AMI\u0026#39; /etc/os-release ; then\n    OSver=\u0026#34;amzn1\u0026#34;\n  fi\nfi\nif [[ -f \u0026#34;/opt/CrowdStrike/falconctl\u0026#34; ]]; then\n  case $OSver in\n    suse15)\n      if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi  \n      ;;\n    suse12)\n      if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi  \n      ;;\n    suse11)\n      if [ -z \u0026#34;$(ss -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi\n      ;;\n    el8)\n      if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi\n      ;;\n    el7)\n      if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi  \n      ;;\n    el6)\n      if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi  \n      ;;\n    amzn2)\n      if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if systemctl is-active --quiet falcon-sensor; then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi  \n      ;;\n    amzn1)\n      if [ -z \u0026#34;$(netstat -tapn | grep falcon)\u0026#34; ]; then message=\u0026#34;Not Connected\u0026#34;; else message=\u0026#34;Connected\u0026#34;; fi\n      if (( $(ps -ef | grep -v grep | grep falcon-sensor | wc -l) \u0026gt; 0 )); then status=\u0026#34;Running\u0026#34;; else status=\u0026#34;Stopped\u0026#34;; fi\n      ;;\n    *)\n      ;;\n  esac\nelse\n    message=\u0026#34;Not installed\u0026#34;\nfi\nif [[ -f \u0026#34;/opt/CrowdStrike/falconctl\u0026#34; ]]; then\n    version=$(/opt/CrowdStrike/falconctl -g --version | awk \u0026#39;{print $3}\u0026#39;)\nelse\n    version=\u0026#34;Not installed\u0026#34;\nfi\nif [ \u0026#34;$version\u0026#34; == \u0026#34;Not installed\u0026#34; ]; then status=\u0026#34;Not installed\u0026#34;; fi\necho $version \u0026#39;|\u0026#39; $status \u0026#39;|\u0026#39; $message\n\u003c/code\u003e\u003c/pre\u003e","title":"sensor checks for crowdstrike"},{"content":"The /var/log/audit/audit.log files were not being rotated. The files in the directory grew so large that it created disk space issues on /. Here’s the fix. In the /etc/audit/auditd.conf file, change max_log_file_action from “ignore” to “rotate.” Instead of hundreds of files being kept, it will be rotated up to 5 files.\nmax_log_file_action = rotate num_logs = 5 Restart service to take effect. The old files will be deleted.\nservice auditd stop service auditd start service auditd status Disk space went from 82% down to 25%.\n","permalink":"http://uly.me/posts/audit-log-files/","summary":"\u003cp\u003eThe /var/log/audit/audit.log files were not being rotated. The files in the directory grew so large that it created disk space issues on /. Here’s the fix. In the /etc/audit/auditd.conf file, change max_log_file_action from “ignore” to “rotate.” Instead of hundreds of files being kept, it will be rotated up to 5 files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emax_log_file_action = rotate\nnum_logs = 5\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart service to take effect. The old files will be deleted.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice auditd stop\nservice auditd start\nservice auditd status\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisk space went from 82% down to 25%.\u003c/p\u003e","title":"audit log files"},{"content":"Here’s how to install a LAMP server on the latest Ubuntu 20.04 LTS.\nInstall Apache.\napt install apache2 systemctl status apache2 systemctl is-enabled apache2 Install MariaDB.\napt install mariadb-server mariadb-client systemctl status mariadb systemctl is-enabled mariadb mysql_secure_installation Install PHP.\napt install php libapache2-mod-php php-mysql systemctl restart apache2 Enable ssl and mod_rewrite.\na2enmod ssl a2enmod rewrite systemctl restart apache2 ","permalink":"http://uly.me/posts/ubuntu-20-04-lts-lamp-server/","summary":"\u003cp\u003eHere’s how to install a LAMP server on the latest Ubuntu 20.04 LTS.\u003c/p\u003e\n\u003cp\u003eInstall Apache.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install apache2\nsystemctl status apache2\nsystemctl is-enabled apache2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall MariaDB.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install mariadb-server mariadb-client\nsystemctl status mariadb\nsystemctl is-enabled mariadb\nmysql_secure_installation\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall PHP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install php libapache2-mod-php php-mysql\nsystemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEnable ssl and mod_rewrite.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ea2enmod ssl\na2enmod rewrite\nsystemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e","title":"ubuntu 20.04 lts lamp server"},{"content":"Here’s another way of creating a tar ball from a list of files.\ntar -cvf backup.tar.gz a.txt b.txt c.txt d.txt e.txt Here’s how to view files in a tarball.\ntar -tvf backup.tar.gz ","permalink":"http://uly.me/posts/tar-list-of-files/","summary":"\u003cp\u003eHere’s another way of creating a tar ball from a list of files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -cvf backup.tar.gz a.txt b.txt c.txt d.txt e.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to view files in a tarball.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -tvf backup.tar.gz\n\u003c/code\u003e\u003c/pre\u003e","title":"tar list of files"},{"content":"Here’s how to create a regional SSL Certificate.\ngcloud compute ssl-certificates create my-ssl-cert \\ --description \u0026#34;describe ssl certificate\u0026#34; \\ --domains=domain1.com,domain2.com \\ --certificate=cert.pem \\ --private-key=private.key \\ --region=us-central1 List the SSL certificates.\ngcloud compute ssl-certificates list --project=project-id Describe the SSL certificate.\ngcloud compute ssl-certificates describe my-ssl-cert \\ --region=us-central1 \\ --project=project-id Delete SSL certificate.\ngcloud compute ssl-certificates delete my-ssl-cert \\ --region=us-central1 \\ --project=project-id ","permalink":"http://uly.me/posts/gcp-ssl-certificates/","summary":"\u003cp\u003eHere’s how to create a regional SSL Certificate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssl-certificates create my-ssl-cert \\\n--description \u0026#34;describe ssl certificate\u0026#34; \\\n--domains=domain1.com,domain2.com \\\n--certificate=cert.pem \\\n--private-key=private.key \\\n--region=us-central1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList the SSL certificates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssl-certificates list --project=project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDescribe the SSL certificate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssl-certificates describe my-ssl-cert \\\n--region=us-central1 \\\n--project=project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete SSL certificate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute ssl-certificates delete my-ssl-cert \\\n--region=us-central1 \\\n--project=project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp ssl certificates"},{"content":"Here’s the command to check if instance is domain joined.\nrealm discover domain.com To check if AD user is working.\nid user@ad.example.com To check if AD group is working.\ngetent group ad-group ","permalink":"http://uly.me/posts/check-if-domain-joined/","summary":"\u003cp\u003eHere’s the command to check if instance is domain joined.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erealm discover domain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo check if AD user is working.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eid user@ad.example.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo check if AD group is working.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egetent group ad-group\n\u003c/code\u003e\u003c/pre\u003e","title":"check if domain joined"},{"content":"SCP is a secure copy utility in Linux. You’ll need access to your system. In this example, a pem key is used to authenticate to a host. SCP copies filename.ext to the home directory of ec2-user. It’s important to add the target directory, otherwise it will not work.\nHere’s how to use SCP with a key from local to server.\nscp -i key.pem filename.ext user@server:/home/user From server to local. Run the command from local machine.\nscp user@server:/home/user/file.txt /local/directory ","permalink":"http://uly.me/posts/scp-with-a-key/","summary":"\u003cp\u003eSCP is a secure copy utility in Linux. You’ll need access to your system. In this example, a pem key is used to authenticate to a host. SCP copies filename.ext to the home directory of ec2-user. It’s important to add the target directory, otherwise it will not work.\u003c/p\u003e\n\u003cp\u003eHere’s how to use SCP with a key from local to server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escp -i key.pem filename.ext user@server:/home/user\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFrom server to local. Run the command from local machine.\u003c/p\u003e","title":"scp with a key"},{"content":"Copy object or file to S3 bucket.\naws s3 cp filename.ext s3://bucketname/ --profile your-profile To make it publicly available, run this command.\naws s3api put-object-acl \\ --bucket bucket-name \\ --key filename.ext \\ --acl public-read \\ --profile your-profile ","permalink":"http://uly.me/posts/aws-s3-make-object-public/","summary":"\u003cp\u003eCopy object or file to S3 bucket.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 cp filename.ext s3://bucketname/ --profile your-profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo make it publicly available, run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3api put-object-acl \\\n--bucket bucket-name \\\n--key filename.ext \\\n--acl public-read \\\n--profile your-profile\n\u003c/code\u003e\u003c/pre\u003e","title":"aws s3 make object public"},{"content":"Here’s how to upgrade to OpenSSL 1.1 on Redhat/Centos.\n# check openssl version yum info openssl # download and install cd /usr/local/src wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz tar -zxf openssl-1.0.2-latest.tar.gz # compile cd openssl-1.0.2a ./config make make test make install # update softlink mv /usr/bin/openssl /root/ ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl # verify new version openssl version ","permalink":"http://uly.me/posts/openssl-upgrade/","summary":"\u003cp\u003eHere’s how to upgrade to OpenSSL 1.1 on Redhat/Centos.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check\nopenssl version\nyum info openssl\n# download and install\ncd /usr/local/src\nwget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz\ntar -zxf openssl-1.0.2-latest.tar.gz\n# compile\ncd openssl-1.0.2a\n./config\nmake\nmake test\nmake install\n# update softlink\nmv /usr/bin/openssl /root/\nln -s /usr/local/ssl/bin/openssl /usr/bin/openssl\n# verify new version\nopenssl version\n\u003c/code\u003e\u003c/pre\u003e","title":"openssl upgrade"},{"content":"Here’s my custom ssh script named login.sh using multiple arguments.\n#!/bin/bash if [ $# -eq 0 ] then echo \u0026#39;no server supplied\u0026#39; exit 1 fi INPUT=$2 case \u0026#34;$INPUT\u0026#34; in abc) ssh user1@$1 ;; def) ssh user2@$1 ;; *) ssh user3@$1 ;; esac How to use with expected outputs.\n./login.sh no server supplied ./login.sh server3 abc ssh user1@server3 ./login.sh server2 def ssh user2@server2 ./login.sh server1 ssh user3@server1 ","permalink":"http://uly.me/posts/ssh-script/","summary":"\u003cp\u003eHere’s my custom ssh script named login.sh using multiple arguments.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [ $# -eq 0 ]\n  then\n    echo \u0026#39;no server supplied\u0026#39;\n        exit 1\nfi\nINPUT=$2\ncase \u0026#34;$INPUT\u0026#34; in\n  abc)\n    ssh user1@$1\n    ;;\n  def)\n    ssh user2@$1\n    ;;\n  *)\n    ssh user3@$1\n    ;;\nesac\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to use with expected outputs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e./login.sh\nno server supplied\n./login.sh server3 abc\nssh user1@server3\n./login.sh server2 def\nssh user2@server2\n./login.sh server1\nssh user3@server1\n\u003c/code\u003e\u003c/pre\u003e","title":"ssh script"},{"content":"When changing machine types, you may be asked to enable the latest ENA driver for Enhanced Network Support on an Amazon EC2 instance. There are several instructions depending on the Linux OS flavor. Here are the instructions to enable. In some cases, you may need to rebuild the kernel module. To verify that the ena module is installed, use the modinfo command as shown in the following example.\nmodinfo ena You also may have to enable the enhanced networking attribute on the instance.\naws ec2 modify-instance-attribute --instance-id instance_id --ena-support ","permalink":"http://uly.me/posts/aws-enable-enhance-network-support/","summary":"\u003cp\u003eWhen changing machine types, you may be asked to enable the latest ENA driver for Enhanced Network Support on an Amazon EC2 instance. There are several instructions depending on the Linux OS flavor. Here are the instructions to \u003ca href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking-ena.html#enhanced-networking-ena-linux\"\u003eenable\u003c/a\u003e. In some cases, you may need to \u003ca href=\"https://aws.amazon.com/premiumsupport/knowledge-center/install-ena-driver-rhel-ec2/\"\u003erebuild the kernel module\u003c/a\u003e. To verify that the ena module is installed, use the modinfo command as shown in the following example.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emodinfo ena\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou also may have to enable the enhanced networking attribute on the instance.\u003c/p\u003e","title":"aws enable enhance network support"},{"content":"Here is how to enable Amazon S3 Transfer Acceleration on a S3 bucket.\naws s3api put-bucket-accelerate-configuration \\ --bucket bucketname \\ --accelerate-configuration Status=Enabled \\ --region us-east-1 Use an accelerate endpoint.\naws configure set default.s3.use_accelerate_endpoint true To copy files to S3 you can use the default copy.\naws s3 cp file.txt s3://bucketname/keyname \\ --region us-east-1 Or use the acceleration endpoint.\naws configure set s3.addressing_style virtual aws s3 cp file.txt s3://bucketname/keyname \\ --endpoint-url http://s3-accelerate.amazonaws.com \\ --region us-east-1 ","permalink":"http://uly.me/posts/aws-s3-acceleration-cli/","summary":"\u003cp\u003eHere is how to enable Amazon S3 Transfer Acceleration on a S3 bucket.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3api put-bucket-accelerate-configuration \\\n--bucket bucketname \\\n--accelerate-configuration Status=Enabled \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUse an accelerate endpoint.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws configure set default.s3.use_accelerate_endpoint true\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo copy files to S3 you can use the default copy.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 cp file.txt s3://bucketname/keyname \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr use the acceleration endpoint.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws configure set s3.addressing_style virtual\naws s3 cp file.txt s3://bucketname/keyname \\\n--endpoint-url http://s3-accelerate.amazonaws.com \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws s3 acceleration cli"},{"content":"Here’s how to update AWS Certificate Manager SSL Cert.\n#!/bin/bash cd /etc/letsencrypt/live/domain.com/ arn=\u0026#39;arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#39; aws acm import-certificate \\ --certificate fileb://cert.pem \\ --certificate-chain fileb://chain.pem \\ --private-key fileb://privkey.pem \\ --certificate-arn $arn \\ --region us-east-1 You can run this every time certbot updates your certificate. Or you can schedule it in crontab.\n","permalink":"http://uly.me/posts/aws-update-acm-certs/","summary":"\u003cp\u003eHere’s how to update AWS Certificate Manager SSL Cert.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ncd /etc/letsencrypt/live/domain.com/\n\narn=\u0026#39;arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\u0026#39;\n\naws acm import-certificate \\\n--certificate fileb://cert.pem \\\n--certificate-chain fileb://chain.pem \\\n--private-key fileb://privkey.pem \\\n--certificate-arn $arn \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can run this every time certbot updates your certificate. Or you can schedule it in crontab.\u003c/p\u003e","title":"aws update acm certs"},{"content":"Just like in S3, you can have to up to 92% in savings if you use Infrequent Access or IA with AWS EFS (Elastic File Storage). You can create a lifecycle policy to move data from standard storage to infrequent access. Files that are not being used after x number of days are then moved to Infrequent Access. The downside is, the data in IA do not count towards gaining burst credits. You will need to keep a certain amount of standard storage to prevent depleting your burst credits.\naws efs put-lifecycle-configuration \\ --file-system-id fs-xxxxxxxx \\ --lifecycle-policies TransitionToIA=AFTER_30_DAYS \\ --region us-east-1 ","permalink":"http://uly.me/posts/efs-infrequent-access/","summary":"\u003cp\u003eJust like in S3, you can have to up to 92% in savings if you use Infrequent Access or IA with AWS EFS (Elastic File Storage). You can create a lifecycle policy to move data from standard storage to infrequent access. Files that are not being used after x number of days are then moved to Infrequent Access. The downside is, the data in IA do not count towards gaining burst credits. You will need to keep a certain amount of standard storage to prevent depleting your burst credits.\u003c/p\u003e","title":"efs infrequent access"},{"content":"Here’s how to create an internal IP reservation in GCP.\ngcloud compute addresses create my-private-ip-reservation \\ --addresses 10.128.0.15 \\ --region us-central1 \\ --subnet default \\ --project project-id To list your reserved IPs.\ngcloud compute addresses list \\ --project project-id ","permalink":"http://uly.me/posts/gcp-create-internal-ip-reservation/","summary":"\u003cp\u003eHere’s how to create an internal IP reservation in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses create my-private-ip-reservation \\\n--addresses 10.128.0.15 \\\n--region us-central1 \\\n--subnet default \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo list your reserved IPs.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses list \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create internal ip reservation"},{"content":"Here’s how to list GCP instances with a specific service account.\ngcloud compute instances list \\ --project your-project-id \\ --format=\u0026#34;value(name,serviceAccounts[].email)\u0026#34; \\ --filter=\u0026#34;serviceAccounts.email=your-service-account@email.com AND name~\\bwp\u0026#34; I’m using filters to look for a specific service account, and any instance starting with ‘wp.’ \\b means begins with.\n","permalink":"http://uly.me/posts/gcp-list-instances-with-service-account/","summary":"\u003cp\u003eHere’s how to list GCP instances with a specific service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances list \\\n--project your-project-id \\\n--format=\u0026#34;value(name,serviceAccounts[].email)\u0026#34; \\\n--filter=\u0026#34;serviceAccounts.email=your-service-account@email.com AND name~\\bwp\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI’m using filters to look for a specific service account, and any instance starting with ‘wp.’ \\b means begins with.\u003c/p\u003e","title":"gcp list instances with service account"},{"content":"I’ve been using this keyboard for a few years, but never knew how to use page and page down. It’s …\nfn + up arrow = page up fn + down arrow = page down ","permalink":"http://uly.me/posts/logitech-k811-page-up-and-down/","summary":"\u003cp\u003eI’ve been using this keyboard for a few years, but never knew how to use page and page down. It’s …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efn + up arrow = page up\nfn + down arrow = page down\n\u003c/code\u003e\u003c/pre\u003e","title":"logitech k811 page up and down"},{"content":"Here’s how to list reservations in GCP.\ngcloud compute reservations list --project project-id Specify a zone.\ngcloud compute reservations list \\ --filter=\u0026#34;zone:(\u0026#39;us-central1-a\u0026#39;)\u0026#34; \\ --project project-id ","permalink":"http://uly.me/posts/gcp-listing-reservations/","summary":"\u003cp\u003eHere’s how to list reservations in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute reservations list --project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSpecify a zone.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute reservations list \\\n--filter=\u0026#34;zone:(\u0026#39;us-central1-a\u0026#39;)\u0026#34; \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp listing reservations"},{"content":"In Windows a new line, is a CR (carriage return) followed by LF (line feed). In Linux, it’s just LF. If you bring over a text file from Windows to Linux, sometimes you’ll end up with a file with a bunch of ^M at the end of each line, which will breaks a lot of things. To fix, just run dos2unix.\ndos2unix file.txt ","permalink":"http://uly.me/posts/dos2unix/","summary":"\u003cp\u003eIn Windows a new line, is a CR (carriage return) followed by LF (line feed). In Linux, it’s just LF. If you bring over a text file from Windows to Linux, sometimes you’ll end up with a file with a bunch of ^M at the end of each line, which will breaks a lot of things. To fix, just run dos2unix.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edos2unix file.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"dos2unix"},{"content":"Here’s how to identify your disks on the system to cross check with GCP Dashboard.\nls -l /dev/disk/by-id Result:\n[root@servername ~]# ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 google-boot -\u0026gt; ../../sda lrwxrwxrwx. 1 root root 10 Sep 15 05:30 google-boot-part1 -\u0026gt; ../../sda1 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 google-persistent-disk-1 -\u0026gt; ../../sdb lrwxrwxrwx. 1 root root 9 Sep 15 05:30 scsi-0Google_PersistentDisk_boot -\u0026gt; ../../sda lrwxrwxrwx. 1 root root 10 Sep 15 05:30 scsi-0Google_PersistentDisk_boot-part1 -\u0026gt; ../../sda1 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 scsi-0Google_PersistentDisk_persistent-disk-1 -\u0026gt; ../../sdb ","permalink":"http://uly.me/posts/gcp-identify-your-disks/","summary":"\u003cp\u003eHere’s how to identify your disks on the system to cross check with GCP Dashboard.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003els -l /dev/disk/by-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[root@servername ~]# ls -l /dev/disk/by-id\ntotal 0\nlrwxrwxrwx. 1 root root  9 Sep 15 05:30 google-boot -\u0026gt; ../../sda\nlrwxrwxrwx. 1 root root 10 Sep 15 05:30 google-boot-part1 -\u0026gt; ../../sda1\nlrwxrwxrwx. 1 root root  9 Sep 15 05:30 google-persistent-disk-1 -\u0026gt; ../../sdb\nlrwxrwxrwx. 1 root root  9 Sep 15 05:30 scsi-0Google_PersistentDisk_boot -\u0026gt; ../../sda\nlrwxrwxrwx. 1 root root 10 Sep 15 05:30 scsi-0Google_PersistentDisk_boot-part1 -\u0026gt; ../../sda1\nlrwxrwxrwx. 1 root root  9 Sep 15 05:30 scsi-0Google_PersistentDisk_persistent-disk-1 -\u0026gt; ../../sdb\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp identify your disks"},{"content":"Here’s how to display a list the disks attached to an instance.\ngcloud compute instances describe instance-name \\ --project project-id \\ --zone us-central1-c \\ --format=\u0026#39;yaml(disks[].source)\u0026#39; ","permalink":"http://uly.me/posts/gcp-disks-attach-to-an-instance/","summary":"\u003cp\u003eHere’s how to display a list the disks attached to an instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances describe instance-name \\\n--project project-id \\\n--zone us-central1-c \\\n--format=\u0026#39;yaml(disks[].source)\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp disks attach to an instance"},{"content":"Here’s how to create an instance with CUD (committed used discounts) reservations.\ngcloud compute instances create instance-name \\ --no-address \\ --private-network-ip 10.0.0.24 \\ --source-machine-image=projects/project-id/global/machineImages/image-name \\ --subnet=https://www.googleapis.com/compute/v1/projects/your-project/regions/us-central1/subnetworks/your-sub-network \\ --machine-type=n1-standard-4 \\ --reservation-affinity=specific \\ --reservation=your-reservation-name \\ --zone=us-central1-a \\ --project=your-project-id ","permalink":"http://uly.me/posts/gcp-create-instance-with-reservations/","summary":"\u003cp\u003eHere’s how to create an instance with CUD (committed used discounts) reservations.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances create instance-name \\\n--no-address \\\n--private-network-ip 10.0.0.24 \\\n--source-machine-image=projects/project-id/global/machineImages/image-name \\\n--subnet=https://www.googleapis.com/compute/v1/projects/your-project/regions/us-central1/subnetworks/your-sub-network \\\n--machine-type=n1-standard-4 \\\n--reservation-affinity=specific \\\n--reservation=your-reservation-name \\\n--zone=us-central1-a \\\n--project=your-project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create instance with reservations"},{"content":"I’ve customized my breadcrumbs. Add code to functions.php.\nadd_filter(\u0026#39;genesis_breadcrumb_args\u0026#39;, \u0026#39;customize_breadcrumbs\u0026#39;); function customize_breadcrumbs($args) { $args[\u0026#39;labels\u0026#39;][\u0026#39;prefix\u0026#39;] = \u0026#39;Home\u0026#39;; $args[\u0026#39;home\u0026#39;] = \u0026#39;\u0026#39;; $args[\u0026#39;sep\u0026#39;] = \u0026#39;/\u0026#39;; return $args; } Now it doesn’t say Home/Home on the front page.\n","permalink":"http://uly.me/posts/custom-breadcrumbs/","summary":"\u003cp\u003eI’ve customized my breadcrumbs. Add code to functions.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eadd_filter(\u0026#39;genesis_breadcrumb_args\u0026#39;, \u0026#39;customize_breadcrumbs\u0026#39;);\nfunction customize_breadcrumbs($args) {\n    $args[\u0026#39;labels\u0026#39;][\u0026#39;prefix\u0026#39;] = \u0026#39;Home\u0026#39;;\n    $args[\u0026#39;home\u0026#39;] = \u0026#39;\u0026#39;;\n    $args[\u0026#39;sep\u0026#39;] = \u0026#39;/\u0026#39;;\n    return $args;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNow it doesn’t say Home/Home on the front page.\u003c/p\u003e","title":"custom breadcrumbs"},{"content":"Here’s how to disable the post title in Genesis WordPress themes. Add code in themes.php.\nadd_filter( \u0026#39;genesis_link_post_title\u0026#39;, \u0026#39;__return_false\u0026#39; ); ","permalink":"http://uly.me/posts/disable-post-title-in-genesis/","summary":"\u003cp\u003eHere’s how to disable the post title in Genesis WordPress themes. Add code in themes.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eadd_filter( \u0026#39;genesis_link_post_title\u0026#39;, \u0026#39;__return_false\u0026#39; );\n\u003c/code\u003e\u003c/pre\u003e","title":"disable post title in genesis"},{"content":"This will create a CUD (Committed Used Discounts) Reservation in GCP.\ngcloud compute reservations create reservation-name-us-central1-a \\ --machine-type=n1-standard-4 \\ --vm-count=1 \\ --zone=us-central1-a \\ --require-specific-reservation This creates a specific reservation instead of an open reservation.\n","permalink":"http://uly.me/posts/gcp-create-cud-reservations/","summary":"\u003cp\u003eThis will create a CUD (Committed Used Discounts) Reservation in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute reservations create reservation-name-us-central1-a \\\n--machine-type=n1-standard-4 \\\n--vm-count=1 \\\n--zone=us-central1-a \\\n--require-specific-reservation\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis creates a specific reservation instead of an open reservation.\u003c/p\u003e","title":"gcp create cud reservations"},{"content":"Here’s the command to extend your regional persistent disks.\ngcloud compute disks resize disk-name \\ --size 100 \\ --project project-id \\ --region us-central1 Or you can specify by zone.\ngcloud compute disks resize disk-name \\ --size 100 \\ --project project-id \\ --zone us-central1-c Display the updated disk details.\ngcloud compute disks list \\ --filter=\u0026#34;name=disk-name\u0026#34; \\ --project project-id Although you’ve increased disk size, the file system doesn’t know the extra space. Run this (for XFS).\nxfs_growfs /dev/sdb ","permalink":"http://uly.me/posts/extend-regional-persistent-disks/","summary":"\u003cp\u003eHere’s the command to extend your regional persistent disks.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks resize disk-name \\\n--size 100 \\\n--project project-id \\\n--region us-central1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr you can specify by zone.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks resize disk-name \\\n--size 100 \\\n--project project-id \\\n--zone us-central1-c\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay the updated disk details.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks list \\\n--filter=\u0026#34;name=disk-name\u0026#34; \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAlthough you’ve increased disk size, the file system doesn’t know the extra space. Run this (for XFS).\u003c/p\u003e","title":"extend regional persistent disks"},{"content":"Here’s a command that will compare two files and display the only entries in the first file that are missing in the second file. To do this, there’s a compare command in Linux Bash called comm that comes with several options. The option we are interested in is the comm -23 which exactly does that. Let me demonstrate.\nLet’s say file a.txt contains:\none two three four five six seven eight nine ten And file b.txt contains:\none three four five nine We then run comm command using the option -23.\ncomm -23 a.txt b.txt \u0026gt; c.txt The contents of c.txt is:\ntwo six seven eight ten ","permalink":"http://uly.me/posts/compare-files-with-comm/","summary":"\u003cp\u003eHere’s a command that will compare two files and display the only entries in the first file that are missing in the second file. To do this, there’s a compare command in Linux Bash called comm that comes with several options. The option we are interested in is the comm -23 which exactly does that. Let me demonstrate.\u003c/p\u003e\n\u003cp\u003eLet’s say file a.txt contains:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eone\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnd file b.txt contains:\u003c/p\u003e","title":"compare files with comm"},{"content":"Here’s how to set the instance scope in GCP. Stop the server.\ngcloud compute instances stop server-name Default scopes.\ngcloud beta compute instances set-scopes server-name \\ --service-account=your-service-account@gserviceaccount.com \\ --scopes=default \\ --project your-project-id \\ --zone=us-central1-a Change scopes by adding storage-rw to default.\ngcloud alpha compute instances set-scopes servername \\ --service-account=your-service-account@gserviceaccount.com \\ --scopes=default,storage-rw \\ --project your-project-id \\ --zone=us-central1-c Start the server.\ngcloud compute instances start server-name Possible scope values.\ndefault cloud-platform storage-rw and more ","permalink":"http://uly.me/posts/gcp-set-scopes/","summary":"\u003cp\u003eHere’s how to set the instance scope in GCP. Stop the server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances stop server-name\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDefault scopes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta compute instances set-scopes server-name \\\n--service-account=your-service-account@gserviceaccount.com \\\n--scopes=default \\\n--project your-project-id \\\n--zone=us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange scopes by adding storage-rw to default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud alpha compute instances set-scopes servername \\\n--service-account=your-service-account@gserviceaccount.com \\\n--scopes=default,storage-rw \\\n--project your-project-id \\\n--zone=us-central1-c\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStart the server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances start server-name\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePossible scope values.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003edefault\u003c/li\u003e\n\u003cli\u003ecloud-platform\u003c/li\u003e\n\u003cli\u003estorage-rw\u003c/li\u003e\n\u003cli\u003eand \u003ca href=\"https://cloud.google.com/sdk/gcloud/reference/alpha/compute/instances/set-scopes\"\u003emore\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e","title":"gcp set scopes"},{"content":"Here’s how to keep your SSH timeout alive for a longer period.\nEdit /etc/ssh/sshd_config. Adjust interval and count max.\nClientAliveInterval 1200 ClientAliveCountMax 3 ClientAliveInterval is set to 1200 and ClientAliveCountMax is set to the default which is 3. This means unresponsive SSH clients will be disconnected after approximately 3600 seconds or 1 hour.\n","permalink":"http://uly.me/posts/increase-ssh-timeout/","summary":"\u003cp\u003eHere’s how to keep your SSH timeout alive for a longer period.\u003c/p\u003e\n\u003cp\u003eEdit /etc/ssh/sshd_config. Adjust interval and count max.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eClientAliveInterval 1200\nClientAliveCountMax 3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eClientAliveInterval is set to 1200 and ClientAliveCountMax is set to the default which is 3. This means unresponsive SSH clients will be disconnected after approximately 3600 seconds or 1 hour.\u003c/p\u003e","title":"increase ssh timeout"},{"content":"Here’s how to add or edit the PATH in Git Bash. Edit your bash_profile.\nvi ~/.bash_profile Set your path by adding the new path at the end.\nPATH=\u0026#34;/c/WINDOWS/system32:/c/Users/firstname.lastname/google-cloud-sdk/bin\u0026#34; The example path listed above is truncated for brevity.\n","permalink":"http://uly.me/posts/git-bash-path/","summary":"\u003cp\u003eHere’s how to add or edit the PATH in Git Bash. Edit your bash_profile.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evi ~/.bash_profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSet your path by adding the new path at the end.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePATH=\u0026#34;/c/WINDOWS/system32:/c/Users/firstname.lastname/google-cloud-sdk/bin\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe example path listed above is truncated for brevity.\u003c/p\u003e","title":"git bash path"},{"content":"Here’s how to display a list of application load balancers.\naws elbv2 describe-load-balancers --profile --region us-east-1 Here’s how to display classic load balancers.\naws elb describe-load-balancers --profile --region us-east-1 ","permalink":"http://uly.me/posts/aws-list-of-application-lb/","summary":"\u003cp\u003eHere’s how to display a list of application load balancers.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elbv2 describe-load-balancers --profile --region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to display classic load balancers.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elb describe-load-balancers --profile --region us-east-1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws list of application lb"},{"content":"I was getting an error when launching Audacity.\nThe error was:\n“The system has detected that another copy of Audacity is running.”\nHowever, Audacity wasn’t running at all. Not one process. It turned out to be just a locked file located in /var/tmp/audacity-[your-username].\nAll you have to do is delete the entire directory and rerun Audacity.\nrm -rf /var/tmp/audacity=[your-username]/ Once deleted, Audacity starts right up with no issues.\n","permalink":"http://uly.me/posts/audacity-copy/","summary":"\u003cp\u003eI was getting an error when launching Audacity.\u003c/p\u003e\n\u003cp\u003eThe error was:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003e“The system has detected that another copy of Audacity is running.”\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eHowever, Audacity wasn’t running at all. Not one process. It turned out to be just a locked file located in /var/tmp/audacity-[your-username].\u003c/p\u003e\n\u003cp\u003eAll you have to do is delete the entire directory and rerun Audacity.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erm -rf /var/tmp/audacity=[your-username]/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce deleted, Audacity starts right up with no issues.\u003c/p\u003e","title":"audacity copy"},{"content":"Who is accessing a particular directory? There’s a Linux command called fuser which will tell you who’s running processes in that directory.\nfuser /etc/apache/ fuser /home/john/ Verbose.\nfuser /data/exports/ -v Check out the fuser man page.\n","permalink":"http://uly.me/posts/linux-fuser/","summary":"\u003cp\u003eWho is accessing a particular directory? There’s a Linux command called fuser which will tell you who’s running processes in that directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efuser /etc/apache/\nfuser /home/john/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVerbose.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efuser /data/exports/ -v\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck out the \u003ca href=\"https://www.man7.org/linux/man-pages/man1/fuser.1.html\"\u003efuser\u003c/a\u003e man page.\u003c/p\u003e","title":"linux fuser"},{"content":"Typically you will run Ansible using playbooks, just like the playbook that I ran from the previous post to patch a bunch of servers all at once. In addition to running playbooks, you can also run single ad hoc commands to a server or to a group of servers. Below are a few examples of that.\nFirst, here’s my /etc/ansible/hosts file.\n[servers] server1 server2 [webservers] server3 server4 [appservers] server5 server6 [dbservers] server7 server8 Here are the commands.\nansible servers -m ping ansible webservers -m command -a \u0026#34;df -h\u0026#34; ansible appservers -m command -a \u0026#34;crontab -l\u0026#34; ansible dbservers -m command -a \u0026#34;cat /etc/hosts\u0026#34; ansible all -m command -a \u0026#34;cat /etc/passwd\u0026#34; ansible webservers -m command -a \u0026#34;systemctl status apache2\u0026#34; ansible appservers -m command -a \u0026#39;uptime\u0026#39; The first command runs ping on server1 and server2. The second command displays disk information of server3 and server4. The third command displays the crontab of server5 and server6, and so on and on. You get the drift.\n","permalink":"http://uly.me/posts/ansible-run-commands/","summary":"\u003cp\u003eTypically you will run Ansible using playbooks, just like the playbook that I ran from the previous post to patch a bunch of servers all at once. In addition to running playbooks, you can also run single ad hoc commands to a server or to a group of servers. Below are a few examples of that.\u003c/p\u003e\n\u003cp\u003eFirst, here’s my /etc/ansible/hosts file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[servers]\nserver1\nserver2\n[webservers]\nserver3\nserver4\n[appservers]\nserver5\nserver6\n[dbservers]\nserver7\nserver8\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere are the commands.\u003c/p\u003e","title":"ansible run commands"},{"content":"I have an Ansible playbook that will patch all Ansible clients defined in the Ansible hosts file. The following are contents of my hosts file, and the update playbook.\nFile: /etc/ansible/hosts\n[all:vars] ansible_user=\u0026#39;ubuntu\u0026#39; ansible_become=yes ansible_become_method=sudo ansible_python_interpreter=\u0026#39;/usr/bin/env python3\u0026#39; [servers] server1 server2 server3 [servers:vars] ansible_python_interpreter=/usr/bin/python3 File: /etc/ansible/update.yml\n--- - hosts: servers become: true become_user: root tasks: - name: Update apt repo and cache on all Debian/Ubuntu boxes apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 - name: Upgrade all packages on servers apt: upgrade=dist force_apt_get=yes - name: Check if a reboot is needed on all servers register: reboot_required_file stat: path=/var/run/reboot-required get_md5=no - name: Reboot the box if kernel updated reboot: msg: \u0026#34;Reboot initiated by Ansible for kernel updates\u0026#34; connect_timeout: 5 reboot_timeout: 300 pre_reboot_delay: 0 post_reboot_delay: 30 test_command: uptime when: reboot_required_file.stat.exist Here’s how I run my Ansible update playbook.\nansible-playbook -i /etc/ansible/hosts /etc/ansible/update.yml The advantage of using Ansible is, I can run a single playbook to update dozens of servers. It’s also a great tool for rolling out software as well as executing commands to a group of servers.\n","permalink":"http://uly.me/posts/ansible-update-playbook/","summary":"\u003cp\u003eI have an Ansible playbook that will patch all Ansible clients defined in the Ansible hosts file. The following are contents of my hosts file, and the update playbook.\u003c/p\u003e\n\u003cp\u003eFile: /etc/ansible/hosts\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[all:vars]\nansible_user=\u0026#39;ubuntu\u0026#39;\nansible_become=yes\nansible_become_method=sudo\nansible_python_interpreter=\u0026#39;/usr/bin/env python3\u0026#39;\n[servers]\nserver1\nserver2\nserver3\n[servers:vars]\nansible_python_interpreter=/usr/bin/python3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFile: /etc/ansible/update.yml\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e---\n- hosts: servers\n  become: true\n  become_user: root\n  tasks:\n    - name: Update apt repo and cache on all Debian/Ubuntu boxes\n      apt: update_cache=yes force_apt_get=yes cache_valid_time=3600\n\n    - name: Upgrade all packages on servers\n      apt: upgrade=dist force_apt_get=yes\n\n    - name: Check if a reboot is needed on all servers\n      register: reboot_required_file\n      stat: path=/var/run/reboot-required get_md5=no\n\n    - name: Reboot the box if kernel updated\n      reboot:\n        msg: \u0026#34;Reboot initiated by Ansible for kernel updates\u0026#34;\n        connect_timeout: 5\n        reboot_timeout: 300\n        pre_reboot_delay: 0\n        post_reboot_delay: 30\n        test_command: uptime\n      when: reboot_required_file.stat.exist\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how I run my Ansible update playbook.\u003c/p\u003e","title":"ansible update playbook"},{"content":"Here’s how to center the Search widget in a WordPress Page or a post. This applies only if you’re using the default Search Widget. Div classes may vary based on theme being used. The CSS example below may not work for your theme. Check your theme’s source code to be sure.\n.entry-content .wp-block-search { display:block; margin-left:auto; margin-right:auto; text-align: center; } .entry-content .wp-block-search label { display:none; } .entry-content .wp-block-search input { width:250px; } The CSS above centers the search block. It suppresses the search label, and finally sets the form’s input to a fixed width of 250px.\n","permalink":"http://uly.me/posts/center-search-widget/","summary":"\u003cp\u003eHere’s how to center the Search widget in a WordPress Page or a post. This applies only if you’re using the default Search Widget. Div classes may vary based on theme being used. The CSS example below may not work for your theme. Check your theme’s source code to be sure.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e.entry-content .wp-block-search {\n  display:block;\n  margin-left:auto;\n  margin-right:auto;\n  text-align: center;\n}\n.entry-content .wp-block-search label {\n  display:none;\n}\n.entry-content .wp-block-search input {\n  width:250px;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe CSS above centers the search block. It suppresses the search label, and finally sets the form’s input to a fixed width of 250px.\u003c/p\u003e","title":"center search widget"},{"content":"Here’s how to give AWS IAM users the ability to manage their own (MFA) Multi Factor Authentication. MFA makes your AWS console secure. AWS IAM users will be able to turn on MFA, using virtual devices such as Google Authenticator to secure their cloud accounts. Here’s the policy.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;AllowViewAccountInfo\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;iam:ListVirtualMFADevices\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnVirtualMFADevice\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:CreateVirtualMFADevice\u0026#34;, \u0026#34;iam:DeleteVirtualMFADevice\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:mfa/${aws:username}\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnUserMFA\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:DeactivateMFADevice\u0026#34;, \u0026#34;iam:EnableMFADevice\u0026#34;, \u0026#34;iam:ListUsers\u0026#34;, \u0026#34;iam:GetUser\u0026#34;, \u0026#34;iam:ListMFADevices\u0026#34;, \u0026#34;iam:ResyncMFADevice\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-iam-mfa/","summary":"\u003cp\u003eHere’s how to give AWS IAM users the ability to manage their own (MFA) Multi Factor Authentication. MFA makes your AWS console secure. AWS IAM users will be able to turn on MFA, using virtual devices such as Google Authenticator to secure their cloud accounts. Here’s the policy.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n  \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n  \u0026#34;Statement\u0026#34;: [\n    {\n      \u0026#34;Sid\u0026#34;: \u0026#34;AllowViewAccountInfo\u0026#34;,\n      \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n      \u0026#34;Action\u0026#34;: \u0026#34;iam:ListVirtualMFADevices\u0026#34;,\n      \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;\n    },\n    {\n      \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnVirtualMFADevice\u0026#34;,\n      \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n      \u0026#34;Action\u0026#34;: [\n        \u0026#34;iam:CreateVirtualMFADevice\u0026#34;,\n        \u0026#34;iam:DeleteVirtualMFADevice\u0026#34;\n      ],\n      \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:mfa/${aws:username}\u0026#34;\n    },\n    {\n      \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnUserMFA\u0026#34;,\n      \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n      \u0026#34;Action\u0026#34;: [\n        \u0026#34;iam:DeactivateMFADevice\u0026#34;,\n        \u0026#34;iam:EnableMFADevice\u0026#34;,\n        \u0026#34;iam:ListUsers\u0026#34;,\n        \u0026#34;iam:GetUser\u0026#34;,\n        \u0026#34;iam:ListMFADevices\u0026#34;,\n        \u0026#34;iam:ResyncMFADevice\u0026#34;\n      ],\n      \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n    }\n  ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws iam mfa"},{"content":"Here’s the permission needed for an AWS user to manage their own IAM account. The policy allows them to view their own account information, change their own passwords, rotate access keys and certificates, and manage their own git credentials.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;AllowViewAccountInfo\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:GetAccountPasswordPolicy\u0026#34;, \u0026#34;iam:GetAccountSummary\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnPasswords\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:ChangePassword\u0026#34;, \u0026#34;iam:GetUser\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnAccessKeys\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:CreateAccessKey\u0026#34;, \u0026#34;iam:DeleteAccessKey\u0026#34;, \u0026#34;iam:GetAccessKeyLastUsed\u0026#34;, \u0026#34;iam:ListAccessKeys\u0026#34;, \u0026#34;iam:UpdateAccessKey\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnSigningCertificates\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:DeleteSigningCertificate\u0026#34;, \u0026#34;iam:ListSigningCertificates\u0026#34;, \u0026#34;iam:UpdateSigningCertificate\u0026#34;, \u0026#34;iam:UploadSigningCertificate\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnSSHPublicKeys\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:DeleteSSHPublicKey\u0026#34;, \u0026#34;iam:GetSSHPublicKey\u0026#34;, \u0026#34;iam:ListSSHPublicKeys\u0026#34;, \u0026#34;iam:UpdateSSHPublicKey\u0026#34;, \u0026#34;iam:UploadSSHPublicKey\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; }, { \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnGitCredentials\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;iam:CreateServiceSpecificCredential\u0026#34;, \u0026#34;iam:DeleteServiceSpecificCredential\u0026#34;, \u0026#34;iam:ListServiceSpecificCredentials\u0026#34;, \u0026#34;iam:ResetServiceSpecificCredential\u0026#34;, \u0026#34;iam:UpdateServiceSpecificCredential\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-iam-self-manage-policy/","summary":"\u003cp\u003eHere’s the permission needed for an AWS user to manage their own IAM account. The policy allows them to view their own account information, change their own passwords, rotate access keys and certificates, and manage their own git credentials.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowViewAccountInfo\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:GetAccountPasswordPolicy\u0026#34;,\n                \u0026#34;iam:GetAccountSummary\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnPasswords\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:ChangePassword\u0026#34;,\n                \u0026#34;iam:GetUser\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnAccessKeys\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:CreateAccessKey\u0026#34;,\n                \u0026#34;iam:DeleteAccessKey\u0026#34;,\n                \u0026#34;iam:GetAccessKeyLastUsed\u0026#34;,\n                \u0026#34;iam:ListAccessKeys\u0026#34;,\n                \u0026#34;iam:UpdateAccessKey\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnSigningCertificates\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:DeleteSigningCertificate\u0026#34;,\n                \u0026#34;iam:ListSigningCertificates\u0026#34;,\n                \u0026#34;iam:UpdateSigningCertificate\u0026#34;,\n                \u0026#34;iam:UploadSigningCertificate\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnSSHPublicKeys\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:DeleteSSHPublicKey\u0026#34;,\n                \u0026#34;iam:GetSSHPublicKey\u0026#34;,\n                \u0026#34;iam:ListSSHPublicKeys\u0026#34;,\n                \u0026#34;iam:UpdateSSHPublicKey\u0026#34;,\n                \u0026#34;iam:UploadSSHPublicKey\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;AllowManageOwnGitCredentials\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;iam:CreateServiceSpecificCredential\u0026#34;,\n                \u0026#34;iam:DeleteServiceSpecificCredential\u0026#34;,\n                \u0026#34;iam:ListServiceSpecificCredentials\u0026#34;,\n                \u0026#34;iam:ResetServiceSpecificCredential\u0026#34;,\n                \u0026#34;iam:UpdateServiceSpecificCredential\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:iam::*:user/${aws:username}\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws iam self manage policy"},{"content":"Ubuntu and Linux Mint use nano as their default editor. You’ll see it if you try to edit crontab or visudo. Now, there’s nothing wrong with nano, but I prefer using vim instead. Here’s how to change the default editor.\nsudo update-alternatives --config editor You’ll be prompted to change the default editor.\nThere are 4 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ 0 /bin/nano 40 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode * 3 /usr/bin/vim.basic 30 manual mode 4 /usr/bin/vim.tiny 15 manual mode Press \u0026lt;enter\u0026gt; to keep the current choice[*], or type selection number: \u0026lt;/enter\u0026gt; Type 3 to choose vim basic.\n","permalink":"http://uly.me/posts/change-default-editor/","summary":"\u003cp\u003eUbuntu and Linux Mint use nano as their default editor. You’ll see it if you try to edit crontab or visudo. Now, there’s nothing wrong with nano, but I prefer using vim instead. Here’s how to change the default editor.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo update-alternatives --config editor\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou’ll be prompted to change the default editor.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eThere are 4 choices for the alternative editor (providing /usr/bin/editor).\n\n  Selection    Path                Priority   Status\n------------------------------------------------------------\n  0            /bin/nano            40        auto mode\n  1            /bin/ed             -100       manual mode\n  2            /bin/nano            40        manual mode\n* 3            /usr/bin/vim.basic   30        manual mode\n  4            /usr/bin/vim.tiny    15        manual mode\n\nPress \u0026lt;enter\u0026gt; to keep the current choice[*], or type selection number: \n\u0026lt;/enter\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eType 3 to choose vim basic.\u003c/p\u003e","title":"change default editor"},{"content":"Removing sudo password is typically not a good practice. If you’re a seasoned system administrator, or you’re the only one using your own desktop, being prompted for a sudo password can get really annoying. Here’s how to stop getting prompted every time you run sudo.\nRun visudo.\nsudo visudo Edit the sudo line and set to below.\n%sudo ALL=(ALL) NOPASSWD: ALL Save file.\n","permalink":"http://uly.me/posts/remove-sudo-password/","summary":"\u003cp\u003eRemoving sudo password is typically not a good practice. If you’re a seasoned system administrator, or you’re the only one using your own desktop, being prompted for a sudo password can get really annoying. Here’s how to stop getting prompted every time you run sudo.\u003c/p\u003e\n\u003cp\u003eRun visudo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo visudo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit the sudo line and set to below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e%sudo ALL=(ALL) NOPASSWD: ALL\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSave file.\u003c/p\u003e","title":"remove sudo password"},{"content":"AWS LightSail now has the ability to restrict IP addresses in their firewall rules. LightSail instances can now be secured by limiting firewall rules from an IP CIDR block or a single IP address. For example, you can restrict who can SSH into your instance by limiting it to just your IP address, so only you can SSH into your machine. Another feature AWS added in their LightSail firewall is support for ping, which could be helpful for monitoring and checks.\n","permalink":"http://uly.me/posts/aws-lightsail-restrict-ip-address/","summary":"\u003cp\u003eAWS LightSail now has the ability to restrict IP addresses in their firewall rules. LightSail instances can now be secured by limiting firewall rules from an IP CIDR block or a single IP address. For example, you can restrict who can SSH into your instance by limiting it to just your IP address, so only you can SSH into your machine. Another feature AWS added in their LightSail firewall is support for ping, which could be helpful for monitoring and checks.\u003c/p\u003e","title":"aws lightsail restrict ip address"},{"content":"Here’s a script that will rotate AWS IAM keys.\n#!/bin/bash # set files user=\u0026#39;johndoe\u0026#39; newkey=\u0026#39;/root/new-access-key.json\u0026#39; oldkey=\u0026#39;/root/old-access-key.json\u0026#39; credentials=\u0026#39;/root/.aws/credentials\u0026#39; # get old credentials aws iam list-access-keys --user-name $user \u0026gt; $oldkey okey=$(jq .AccessKeyMetadata[0].AccessKeyId $oldkey | tr -d \\\u0026#34;) # create new key aws iam create-access-key --user-name $user \u0026gt; $newkey # get new access keys and new secret nkey=$(jq .AccessKey.AccessKeyId $newkey | tr -d \\\u0026#34;) nsecret=$(jq .AccessKey.SecretAccessKey $newkey | tr -d \\\u0026#34;) # backup old credentials cp /root/.aws/credentials /root/.aws/credentials-backup # store the new key echo \u0026#39;[default]\u0026#39; \u0026gt; $credentials echo \u0026#39;aws_access_key_id = \u0026#39; $nkey \u0026gt;\u0026gt; $credentials echo \u0026#39;aws_secret_access_key = \u0026#39;$nsecret \u0026gt;\u0026gt; $credentials sleep 10 # delete old key aws iam delete-access-key --user-name $user --access-key-id $okey rm $newkey rm $oldkey The script performs the following:\nRetrieves the current key Creates a new key Backup the current credentials file Create a new credentials file Deletes the old key Deletes the temp files Done ","permalink":"http://uly.me/posts/aws-rotate-iam-keys/","summary":"\u003cp\u003eHere’s a script that will rotate AWS IAM keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# set files\nuser=\u0026#39;johndoe\u0026#39;\nnewkey=\u0026#39;/root/new-access-key.json\u0026#39;\noldkey=\u0026#39;/root/old-access-key.json\u0026#39;\ncredentials=\u0026#39;/root/.aws/credentials\u0026#39;\n# get old credentials\naws iam list-access-keys --user-name $user \u0026gt; $oldkey\nokey=$(jq .AccessKeyMetadata[0].AccessKeyId $oldkey | tr -d \\\u0026#34;)\n# create new key\naws iam create-access-key --user-name $user \u0026gt; $newkey\n# get new access keys and new secret\nnkey=$(jq .AccessKey.AccessKeyId $newkey | tr -d \\\u0026#34;)\nnsecret=$(jq .AccessKey.SecretAccessKey $newkey | tr -d \\\u0026#34;)\n# backup old credentials\ncp /root/.aws/credentials /root/.aws/credentials-backup\n# store the new key\necho \u0026#39;[default]\u0026#39; \u0026gt; $credentials\necho \u0026#39;aws_access_key_id = \u0026#39; $nkey \u0026gt;\u0026gt; $credentials\necho \u0026#39;aws_secret_access_key = \u0026#39;$nsecret \u0026gt;\u0026gt; $credentials\nsleep 10\n# delete old key\naws iam delete-access-key --user-name $user --access-key-id $okey\nrm $newkey\nrm $oldkey\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe script performs the following:\u003c/p\u003e","title":"aws rotate iam keys"},{"content":"Here’s the command to remove quotes from a string in Bash by using the tr -d command. I’m using jq tool to extract the access key from a json file. Bash returns a string surrounded by quotes. To remove the quotes, just pipe the string to the tr -d command.\njq .AccessKey.AccessKeyId key.json Result:\n\u0026#34;ASDFSDFSDFASDFSDFSDFGHGDF\u0026#34; Using tr -d.\njq .AccessKey.AccessKeyId key.json | tr -d \\\u0026#34; Result:\nASDFSDFSDFASDFSDFSDFGHGDF ","permalink":"http://uly.me/posts/remove-quotes-from-strings/","summary":"\u003cp\u003eHere’s the command to remove quotes from a string in Bash by using the tr -d command. I’m using jq tool to extract the access key from a json file. Bash returns a string surrounded by quotes. To remove the quotes, just pipe the string to the tr -d command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ejq .AccessKey.AccessKeyId key.json \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026#34;ASDFSDFSDFASDFSDFSDFGHGDF\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUsing tr -d.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ejq .AccessKey.AccessKeyId key.json | tr -d \\\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eASDFSDFSDFASDFSDFSDFGHGDF\n\u003c/code\u003e\u003c/pre\u003e","title":"remove quotes from strings"},{"content":"I’m now using the Revolution theme from StudioPress. It’s a minimal design with lots of whitespace. The default font is Playfair Display which highlights headlines and blockquotes. The Playfair Display is available from Google Fonts if you’re interested. I think it’s a perfect theme for a photography blog. Although the theme seems to invite you to write more, something I haven’t been doing lately. And before I sign off, let’s take a look at what a blockquote looks like. Not bad at all. A beautiful theme.\nIt’s a minimal design with lots of whitespace.\nBy Studiopress\n","permalink":"http://uly.me/posts/revolution-theme/","summary":"\u003cp\u003eI’m now using the Revolution theme from StudioPress. It’s a minimal design with lots of whitespace. The default font is Playfair Display which highlights headlines and blockquotes. The Playfair Display is available from Google Fonts if you’re interested. I think it’s a perfect theme for a photography blog. Although the theme seems to invite you to write more, something I haven’t been doing lately. And before I sign off, let’s take a look at what a blockquote looks like. Not bad at all. A beautiful theme.\u003c/p\u003e","title":"revolution theme"},{"content":"Here’s how to tell if you’re running Cinnamon or Mate.\ninxi -Fxz Result.\nSystem: Kernel: 5.4.0-40-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: Cinnamon 4.6.6 Distro: Linux Mint 20 Ulyana base: Ubuntu 20.04 focal ... ","permalink":"http://uly.me/posts/cinnamon-or-mate/","summary":"\u003cp\u003eHere’s how to tell if you’re running Cinnamon or Mate.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003einxi -Fxz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eSystem: Kernel: 5.4.0-40-generic x86_64 \nbits: 64 \ncompiler: gcc v: 9.3.0 \nDesktop: Cinnamon 4.6.6 \nDistro: Linux Mint 20 Ulyana \nbase: Ubuntu 20.04 focal\n...\n\u003c/code\u003e\u003c/pre\u003e","title":"cinnamon or mate?"},{"content":"Here’s how to find if clients are connected to Apache or Nginx service.\nnetstat -tn src: 80 netstat -tn src: 443 ","permalink":"http://uly.me/posts/clients-connected-to-apache/","summary":"\u003cp\u003eHere’s how to find if clients are connected to Apache or Nginx service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enetstat -tn src: 80\nnetstat -tn src: 443\n\u003c/code\u003e\u003c/pre\u003e","title":"clients connected to apache"},{"content":"Here’s how to display Copyright years in the footer section if you’re using the Genesis theme.\n© 2002–2023 Result:\nCopyright © 2002–2020 The current year is dynamic. It will display 2021 a year from now. The first year is always fixed.\n","permalink":"http://uly.me/posts/genesis-footer/","summary":"\u003cp\u003eHere’s how to display Copyright years in the footer section if you’re using the Genesis theme.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e© 2002–2023\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCopyright © 2002–2020\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe current year is dynamic. It will display 2021 a year from now. The first year is always fixed.\u003c/p\u003e","title":"genesis footer"},{"content":"Interesting facts between GB and GiB.\nGB uses base 1000. GiB uses base 1024. 1GB is 1,000,000,000 bytes. 1GiB is 1,073,741,824 bytes. A 1TB drive is 1,000 GB. Or 931 GiB. A 1TiB drive is 1000 GiB. Or 1099 GB. To convert GB to GiB, multiply by (1000 / 1024). To convert GiB to GB, divide by (1000 / 1024). ","permalink":"http://uly.me/posts/gb-vs-gib/","summary":"\u003cp\u003eInteresting facts between GB and GiB.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eGB uses base 1000. GiB uses base 1024.\u003c/li\u003e\n\u003cli\u003e1GB is 1,000,000,000 bytes. 1GiB is 1,073,741,824 bytes.\u003c/li\u003e\n\u003cli\u003eA 1TB drive is 1,000 GB. Or 931 GiB.\u003c/li\u003e\n\u003cli\u003eA 1TiB drive is 1000 GiB. Or 1099 GB.\u003c/li\u003e\n\u003cli\u003eTo convert GB to GiB, multiply by (1000 / 1024).\u003c/li\u003e\n\u003cli\u003eTo convert GiB to GB, divide by (1000 / 1024).\u003c/li\u003e\n\u003c/ul\u003e","title":"gb vs gib"},{"content":"Here’s how to format a USB drive on Linux.\nPlug in the USB drive to see mount point.\n# scan for all drives df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sdc1 fuseblk 30G 66M 30G 1% /media/ulysses/451B99AF225B48EC Unmount USB drive.\numount /dev/sdc1 Choose a file system type and run the appropriate format command.\n# nfts format mkfs.ntfs /dev/sdc1 # vfat format mkfs.vfat /dev/sdc1 # ext4 format mkfs.ext4 /dev/sdc1 ","permalink":"http://uly.me/posts/linux-format-usb-drive/","summary":"\u003cp\u003eHere’s how to format a USB drive on Linux.\u003c/p\u003e\n\u003cp\u003ePlug in the USB drive to see mount point.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# scan for all drives\ndf -Th\nFilesystem     Type     Size  Used Avail Use% Mounted on\n/dev/sdc1      fuseblk   30G   66M   30G   1% /media/ulysses/451B99AF225B48EC\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUnmount USB drive.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eumount /dev/sdc1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChoose a file system type and run the appropriate format command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# nfts format\nmkfs.ntfs /dev/sdc1\n# vfat format\nmkfs.vfat /dev/sdc1\n# ext4 format\nmkfs.ext4 /dev/sdc1\n\u003c/code\u003e\u003c/pre\u003e","title":"linux format usb drive"},{"content":"Snap is cool, but not for everyone. To remove, follow these steps.\n# get list snap list # remove snaps. repeat for each app. snap remove chromium # remove snapd apt purge snapd # remove snap from home rm -rf ~/snap # clean up cache rm -rf /var/cache/snapd apt purge snapd ","permalink":"http://uly.me/posts/how-to-remove-snap/","summary":"\u003cp\u003eSnap is cool, but not for everyone. To remove, follow these steps.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# get list\nsnap list\n# remove snaps. repeat for each app.\nsnap remove chromium\n# remove snapd\napt purge snapd\n# remove snap from home\nrm -rf ~/snap\n# clean up cache\nrm -rf /var/cache/snapd\napt purge snapd\n\u003c/code\u003e\u003c/pre\u003e","title":"how to remove snap"},{"content":"There are times you just want to print directly from the command line.\n# check your printing options lpotions lpinfo -v # what\u0026#39;s your default printer lpinfo -p -d # use lp to print lp notes.txt # use -n print multiple copies lp -n 2 notes.txt # check the printer queue lp -q # use the job number to cancel print jobs if needed cancel 123 ","permalink":"http://uly.me/posts/printing-from-a-terminal/","summary":"\u003cp\u003eThere are times you just want to print directly from the command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check your printing options\nlpotions\nlpinfo -v\n# what\u0026#39;s your default printer\nlpinfo -p -d\n# use lp to print\nlp notes.txt\n# use -n print multiple copies\nlp -n 2 notes.txt\n# check the printer queue\nlp -q\n# use the job number to cancel print jobs if needed\ncancel 123\n\u003c/code\u003e\u003c/pre\u003e","title":"printing from a terminal"},{"content":"If you use LightSail, AWS provides an easy way for you to connect to LightSail instances via Web SSH. I normally use a terminal (ssh client) to connect to LightSail instances, but using Web SSH is very convenient. If you try to do an OS upgrade, for example from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS, you will break Web SSH. AWS has added a special Web SSH configuration on LightSail base images. The error you’ll get is “Upstream Error 515.” The only way to fix this is to get AWS Support to help you apply the fix. It’s not a make or break it deal, but it can be a nuisance if you prefer to use AWS Web SSH instead of a terminal. If you need a more secure SSH connection, consider uploading your ssh-key to the server, and disable password login.\n","permalink":"http://uly.me/posts/lightsail-upstream-error-515/","summary":"\u003cp\u003eIf you use LightSail, AWS provides an easy way for you to connect to LightSail instances via Web SSH. I normally use a terminal (ssh client) to connect to LightSail instances, but using Web SSH is very convenient. If you try to do an OS upgrade, for example from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS, you will break Web SSH. AWS has added a special Web SSH configuration on LightSail base images. The error you’ll get is “Upstream Error 515.” The only way to fix this is to get AWS Support to help you apply the fix. It’s not a make or break it deal, but it can be a nuisance if you prefer to use AWS Web SSH instead of a terminal. If you need a more secure SSH connection, consider uploading your ssh-key to the server, and disable password login.\u003c/p\u003e","title":"lightsail upstream error 515"},{"content":"I upgraded my desktop to Linux Mint 20 Ulyana over the weekend.\nEdit your package repository. Replace tricia with ulyana, and bionic with focal.\nvim /etc/apt/sources.list.d/official-package-repositories.list Run update first.\napt update -y apt upgrade -y Perform upgrade to Linux Mint 20. When prompted, choose default.\napt dist-upgrade Reboot.\nreboot cat /etc/os-release.\nulysses@penguin:~/Code$ cat /etc/os-release NAME=\u0026#34;Linux Mint\u0026#34; VERSION=\u0026#34;20 (Ulyana)\u0026#34; ID=linuxmint ID_LIKE=ubuntu PRETTY_NAME=\u0026#34;Linux Mint 20\u0026#34; VERSION_ID=\u0026#34;20\u0026#34; HOME_URL=\u0026#34;https://www.linuxmint.com/\u0026#34; SUPPORT_URL=\u0026#34;https://forums.ubuntu.com/\u0026#34; BUG_REPORT_URL=\u0026#34;http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/\u0026#34; PRIVACY_POLICY_URL=\u0026#34;https://www.linuxmint.com/\u0026#34; VERSION_CODENAME=ulyana UBUNTU_CODENAME=focal ","permalink":"http://uly.me/posts/linux-mint-20-ulyana/","summary":"\u003cp\u003eI upgraded my desktop to Linux Mint 20 Ulyana over the weekend.\u003c/p\u003e\n\u003cp\u003eEdit your package repository. Replace tricia with ulyana, and bionic with focal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim /etc/apt/sources.list.d/official-package-repositories.list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun update first.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt update -y\napt upgrade -y\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePerform upgrade to Linux Mint 20. When prompted, choose default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt dist-upgrade\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ereboot\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ecat /etc/os-release.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eulysses@penguin:~/Code$ cat /etc/os-release\nNAME=\u0026#34;Linux Mint\u0026#34;\nVERSION=\u0026#34;20 (Ulyana)\u0026#34;\nID=linuxmint\nID_LIKE=ubuntu\nPRETTY_NAME=\u0026#34;Linux Mint 20\u0026#34;\nVERSION_ID=\u0026#34;20\u0026#34;\nHOME_URL=\u0026#34;https://www.linuxmint.com/\u0026#34;\nSUPPORT_URL=\u0026#34;https://forums.ubuntu.com/\u0026#34;\nBUG_REPORT_URL=\u0026#34;http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/\u0026#34;\nPRIVACY_POLICY_URL=\u0026#34;https://www.linuxmint.com/\u0026#34;\nVERSION_CODENAME=ulyana\nUBUNTU_CODENAME=focal\n\u003c/code\u003e\u003c/pre\u003e","title":"linux mint 20 ulyana"},{"content":"The script command records all your keystrokes and output into a file called typescript.\nYou can start recording by simply typing script.\nscript Script started, file is typescript df -h ls -l exit Typing exit stops the recording. Just cat typescript to see your recording.\ncat typescript ","permalink":"http://uly.me/posts/linux-script/","summary":"\u003cp\u003eThe script command records all your keystrokes and output into a file called typescript.\u003c/p\u003e\n\u003cp\u003eYou can start recording by simply typing script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escript\nScript started, file is typescript\ndf -h\nls -l\nexit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTyping exit stops the recording. Just cat typescript to see your recording.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat typescript\n\u003c/code\u003e\u003c/pre\u003e","title":"linux script"},{"content":"How to install AWS CLI version 2.\ncurl \u0026#34;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\u0026#34; -o \u0026#34;awscliv2.zip\u0026#34; unzip awscliv2.zip sudo ./aws/install ","permalink":"http://uly.me/posts/aws-cli-v2/","summary":"\u003cp\u003eHow to install AWS CLI version 2.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl \u0026#34;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\u0026#34; -o \u0026#34;awscliv2.zip\u0026#34;\nunzip awscliv2.zip\nsudo ./aws/install\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli v2"},{"content":"Here are steps I took to upgrade from PHP 7.0 to 7.4 on Ubuntu 18.04 LTS.\nLogin as root, otherwise use sudo for all commands.\n# use 3rd party ppa repo add-apt-repository ppa:ondrej/php apt -y update apt -y upgrade # install php-core apt install php7.4 php7.4-common php7.4-cli # add all the php extenstions your app needs apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring apt install php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-xml apt install php7.4-readline php7.4-zip php7.4-mysql # I\u0026#39;m using apache prefork MPM, so install it apt install libapache2-mod-php7.4 a2enmod php7.4 # check version. Success! php -v # for good measure, reboot apache systemctl restart apache2.service # Finally, purge the old PHP versions apt purge php7.0 libapache2-mod-php7.0 Finally, run update on more time to get all the latest updates.\napt -y update apt -y upgrade apt -y autoremove apt-get --with-new-pkgs upgrade ","permalink":"http://uly.me/posts/php-7-0-to-7-4-upgrade/","summary":"\u003cp\u003eHere are steps I took to upgrade from PHP 7.0 to 7.4 on Ubuntu 18.04 LTS.\u003c/p\u003e\n\u003cp\u003eLogin as root, otherwise use sudo for all commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# use 3rd party ppa repo\nadd-apt-repository ppa:ondrej/php\napt -y update\napt -y upgrade\n# install php-core\napt install php7.4 php7.4-common php7.4-cli\n# add all the php extenstions your app needs\napt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring\napt install php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-xml\napt install php7.4-readline php7.4-zip php7.4-mysql\n# I\u0026#39;m using apache prefork MPM, so install it\napt install libapache2-mod-php7.4\na2enmod php7.4\n# check version. Success!\nphp -v\n# for good measure, reboot apache\nsystemctl restart apache2.service\n# Finally, purge the old PHP versions\napt purge php7.0 libapache2-mod-php7.0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally, run update on more time to get all the latest updates.\u003c/p\u003e","title":"php 7.0 to 7.4 upgrade"},{"content":"Here’s how to read Bash variables from another file.\nContents of config.sh\n#!/bin/bash var1=\u0026#39;thisisvariableone\u0026#39; var2=\u0026#39;thisisvariabletwo\u0026#39; Call config.sh from another script.\n#!/bin/bash source config.sh echo var1 echo var2 This is extremely helpful if you have multiple scripts using a common variable. You just to update one file instead of multiple files. All the other scripts will read and pick up the same variables from a config file. You can use this to setup your global variables.\n","permalink":"http://uly.me/posts/bash-variables/","summary":"\u003cp\u003eHere’s how to read Bash variables from another file.\u003c/p\u003e\n\u003cp\u003eContents of config.sh\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nvar1=\u0026#39;thisisvariableone\u0026#39;\nvar2=\u0026#39;thisisvariabletwo\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCall config.sh from another script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nsource config.sh\necho var1\necho var2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is extremely helpful if you have multiple scripts using a common variable. You just to update one file instead of multiple files. All the other scripts will read and pick up the same variables from a config file. You can use this to setup your global variables.\u003c/p\u003e","title":"bash variables"},{"content":"My internet has been flaky lately. I wrote a script that logs my internet connection.\nI’m running it in cron every minute.\n#!/bin/bash log=\u0026#39;/home/ulysses/Code/spectrum.log\u0026#39; if nc -zw1 google.com 443; then echo \u0026#39;Spectrum is up\u0026#39; $(date) \u0026gt;\u0026gt; $log else echo \u0026#39;Spectrum is down\u0026#39; $(date) \u0026gt;\u0026gt; $log fi To view, just cat the log.\ncat spectrum.log Spectrum is up Fri Jun 26 15:14:01 EDT 2020 Spectrum is up Fri Jun 26 15:15:01 EDT 2020 Spectrum is up Fri Jun 26 15:16:01 EDT 2020 Spectrum is up Fri Jun 26 15:17:01 EDT 2020 Spectrum is up Fri Jun 26 15:18:01 EDT 2020 So, I now have a record when it was up or down.\n","permalink":"http://uly.me/posts/internet-test/","summary":"\u003cp\u003eMy internet has been flaky lately. I wrote a script that logs my internet connection.\u003c/p\u003e\n\u003cp\u003eI’m running it in cron every minute.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nlog=\u0026#39;/home/ulysses/Code/spectrum.log\u0026#39;\nif nc -zw1 google.com 443;\nthen \n  echo \u0026#39;Spectrum is up\u0026#39; $(date) \u0026gt;\u0026gt; $log\nelse \n  echo \u0026#39;Spectrum is down\u0026#39; $(date) \u0026gt;\u0026gt; $log\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo view, just cat the log.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecat spectrum.log \nSpectrum is up Fri Jun 26 15:14:01 EDT 2020\nSpectrum is up Fri Jun 26 15:15:01 EDT 2020\nSpectrum is up Fri Jun 26 15:16:01 EDT 2020\nSpectrum is up Fri Jun 26 15:17:01 EDT 2020\nSpectrum is up Fri Jun 26 15:18:01 EDT 2020\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSo, I now have a record when it was up or down.\u003c/p\u003e","title":"internet test"},{"content":"Here’s the command to find the largest files and directories in Linux.\ndu -a /var | sort -n -r | head -n 20 ","permalink":"http://uly.me/posts/largest-files-and-directories/","summary":"\u003cp\u003eHere’s the command to find the largest files and directories in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edu -a /var | sort -n -r | head -n 20\n\u003c/code\u003e\u003c/pre\u003e","title":"largest files and directories"},{"content":"Here’s another way of setting your server’s timezone. See all the options under North America.\ntimedatectl list-timezones | grep -i America Set timezone.\ntimedatectl set-timezone America/New_York To check.\ndate Restart cron if needed.\nsystemctl restart cron.service ","permalink":"http://uly.me/posts/timedatectl/","summary":"\u003cp\u003eHere’s another way of setting your server’s timezone. See all the options under North America.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etimedatectl list-timezones | grep -i America\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSet timezone.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etimedatectl set-timezone America/New_York\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo check.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edate\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart cron if needed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart cron.service\n\u003c/code\u003e\u003c/pre\u003e","title":"timedatectl"},{"content":"Go to Logging \u0026gt; Logs Viewer to monitor a GCP Load Balancer.\nresource.type=\u0026#34;http_load_balancer\u0026#34; AND resource.labels.url_map_name=\u0026#34;your-lb\u0026#34; AND resource.labels.project_id=\u0026#34;your-project-id\u0026#34; ","permalink":"http://uly.me/posts/gcp-load-balancer-logging/","summary":"\u003cp\u003eGo to Logging \u0026gt; Logs Viewer to monitor a GCP Load Balancer.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eresource.type=\u0026#34;http_load_balancer\u0026#34; AND resource.labels.url_map_name=\u0026#34;your-lb\u0026#34; AND resource.labels.project_id=\u0026#34;your-project-id\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp load balancer logging"},{"content":"If your audio is out of sync, you can fix using ffmpeg.\nffmpeg -i source.mp4 \\ -i livestream.mp4 \\ -map 0:0 -map 1:1 \\ -acodec copy \\ -vcodec copy \\ -itsoffset 0.100 \\ output.mp4 The ffmpeg fix is fast. A 1GB file took less than 30 seconds to run. Adjust -tsoffset until you find the sweet spot.\n","permalink":"http://uly.me/posts/ffmpeg-offset-audio/","summary":"\u003cp\u003eIf your audio is out of sync, you can fix using ffmpeg.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i source.mp4 \\\n-i livestream.mp4 \\\n-map 0:0 -map 1:1 \\\n-acodec copy \\\n-vcodec copy \\\n-itsoffset 0.100 \\\noutput.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe ffmpeg fix is fast. A 1GB file took less than 30 seconds to run. Adjust -tsoffset until you find the sweet spot.\u003c/p\u003e","title":"ffmpeg offset audio"},{"content":"Here’s a simple adhoc to run updates on systems in Ansible.\nansible servers -m apt -a \u0026#34;upgrade=yes update_cache=yes\u0026#34; -b Results:\nserver | SUCCESS =\u0026gt; { \u0026#34;changed\u0026#34;: false, \u0026#34;msg\u0026#34;: \u0026#34;Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34;, \u0026#34;stderr\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;stderr_lines\u0026#34;: [], \u0026#34;stdout\u0026#34;: \u0026#34;Reading package lists... Building dependency tree... Reading state information... Calculating upgrade... 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34;, \u0026#34;stdout_lines\u0026#34;: [ \u0026#34;Reading package lists...\u0026#34;, \u0026#34;Building dependency tree...\u0026#34;, \u0026#34;Reading state information...\u0026#34;, \u0026#34;Calculating upgrade...\u0026#34;, \u0026#34;0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34; ] } If you want to reboot a remote server.\nansible servers -m \u0026#34;reboot\u0026#34; -b ","permalink":"http://uly.me/posts/ansible-run-updates/","summary":"\u003cp\u003eHere’s a simple adhoc to run updates on systems in Ansible.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eansible servers -m apt -a \u0026#34;upgrade=yes update_cache=yes\u0026#34; -b\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResults:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserver | SUCCESS =\u0026gt; {\n    \u0026#34;changed\u0026#34;: false, \n    \u0026#34;msg\u0026#34;: \u0026#34;Reading package lists...\n     Building dependency tree...\n     Reading state information...\n     Calculating upgrade...\n     0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34;, \n    \u0026#34;stderr\u0026#34;: \u0026#34;\u0026#34;, \n    \u0026#34;stderr_lines\u0026#34;: [], \n    \u0026#34;stdout\u0026#34;: \u0026#34;Reading package lists...\n     Building dependency tree...\n     Reading state information...\n     Calculating upgrade...\n     0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34;, \n    \u0026#34;stdout_lines\u0026#34;: [\n        \u0026#34;Reading package lists...\u0026#34;, \n        \u0026#34;Building dependency tree...\u0026#34;, \n        \u0026#34;Reading state information...\u0026#34;, \n        \u0026#34;Calculating upgrade...\u0026#34;, \n        \u0026#34;0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\u0026#34;\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want to reboot a remote server.\u003c/p\u003e","title":"ansible run updates"},{"content":"How to turn on post revisions in WordPress. Edit wp-config.php.\n/** WordPress Revisions */ define(\u0026#39;WP_POST_REVISIONS\u0026#39;, false); Change to:\n/** WordPress Revisions */ define(\u0026#39;WP_POST_REVISIONS\u0026#39;, 10); 10 is the number of revisions you want to keep.\n","permalink":"http://uly.me/posts/wordpress-posts-revision/","summary":"\u003cp\u003eHow to turn on post revisions in WordPress. Edit wp-config.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/** WordPress Revisions */\ndefine(\u0026#39;WP_POST_REVISIONS\u0026#39;, false);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange to:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/** WordPress Revisions */\ndefine(\u0026#39;WP_POST_REVISIONS\u0026#39;, 10);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e10 is the number of revisions you want to keep.\u003c/p\u003e","title":"wordpress posts revision"},{"content":"Here’s the command to copy a secret key to a remote server.\nssh-copy-id user@servername This assumes you already generated a key.\n","permalink":"http://uly.me/posts/copy-ssh-key-to-server/","summary":"\u003cp\u003eHere’s the command to copy a secret key to a remote server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh-copy-id user@servername\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis assumes you already generated a key.\u003c/p\u003e","title":"copy ssh key to server"},{"content":"Here’s the command to add a Linux user.\nuseradd -m -s $(which bash) -G sudo ulysses -m creates a home directory. -s selects a shell. -G adds user to a sudo group.\n","permalink":"http://uly.me/posts/linux-useradd/","summary":"\u003cp\u003eHere’s the command to add a Linux user.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003euseradd -m -s $(which bash) -G sudo ulysses\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e-m creates a home directory. -s selects a shell. -G adds user to a sudo group.\u003c/p\u003e","title":"linux useradd"},{"content":"Here’s the command to run the Ansible playbook.\nansible-playbook -t hosts playbook.yml Or simply run it like this.\nansible-playbook playbook.yml ","permalink":"http://uly.me/posts/run-ansible-playbook/","summary":"\u003cp\u003eHere’s the command to run the Ansible playbook.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eansible-playbook -t hosts playbook.yml\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr simply run it like this.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eansible-playbook playbook.yml\n\u003c/code\u003e\u003c/pre\u003e","title":"run ansible playbook"},{"content":"Here’s the command to test a network connection in Powershell.\nC:\u0026gt; Test-NetConnection -ComputerName server -Port 443 Result:\nComputerName : server RemoteAddress : 10.0.0.5 RemotePort : 443 InterfaceAlias : Ethernet 0 SourceAddress : 10.1.1.34 TcpTestSucceeded : True ","permalink":"http://uly.me/posts/powershell-test-network-connection/","summary":"\u003cp\u003eHere’s the command to test a network connection in Powershell.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eC:\u0026gt; Test-NetConnection -ComputerName server -Port 443\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eComputerName     : server\nRemoteAddress    : 10.0.0.5\nRemotePort       : 443\nInterfaceAlias   : Ethernet 0\nSourceAddress    : 10.1.1.34\nTcpTestSucceeded : True\n\u003c/code\u003e\u003c/pre\u003e","title":"powershell test network connection"},{"content":"If you have a video with audio sync issues, you can easily fix it using ffmpeg. It takes 2 inputs: the filename and delay: 0.100 is 100 ms or 0.1 seconds. Output file has -fixed appended to it. It’s fast. Only takes 2-3 seconds to process a 1.5 hour recording.\nHere’s the script.\nffmpeg -i livestream.mp4 \\ -itsoffset 0.100 \\ -i livestream.mp4 \\ -map 0:0 -map 1:1 \\ -acodec copy \\ -vcodec copy \\ livestream-fixed.mp4 ","permalink":"http://uly.me/posts/ffmpeg-fix-audio-sync/","summary":"\u003cp\u003eIf you have a video with audio sync issues, you can easily fix it using ffmpeg. It takes 2 inputs: the filename and delay: 0.100 is 100 ms or 0.1 seconds. Output file has -fixed appended to it. It’s fast. Only takes 2-3 seconds to process a 1.5 hour recording.\u003c/p\u003e\n\u003cp\u003eHere’s the script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i livestream.mp4 \\\n-itsoffset 0.100 \\\n-i livestream.mp4 \\\n-map 0:0 -map 1:1 \\\n-acodec copy \\\n-vcodec copy \\\nlivestream-fixed.mp4\n\u003c/code\u003e\u003c/pre\u003e","title":"ffmpeg fix audio sync"},{"content":"In order to restore a MySQL database to another database, use routines and triggers.\nmysqldump -p user -p --routines --triggers db1 \u0026gt; db1.sql To restore to another database, just use the normal command.\nmysql -u user -p db2 ","permalink":"http://uly.me/posts/mysql-restore-to-another-db/","summary":"\u003cp\u003eIn order to restore a MySQL database to another database, use routines and triggers.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysqldump -p user -p --routines --triggers db1 \u0026gt; db1.sql\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo restore to another database, just use the normal command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -u user -p db2 \n\u003c/code\u003e\u003c/pre\u003e","title":"mysql restore to another db"},{"content":"When trying to boot from a disk created from snapshot and you’re getting an “UEFI feature is not available for this project” error, you’ll need to create a boot image with the –guest-os-features option set to “UEFI_COMPATIBLE.”\ngcloud compute disks create new-server-disk-2 \\ --project=project-name \\ --source-snapshot=server-disk-2 \\ --zone=us-central1-b \\ --guest-os-features=\u0026#34;UEFI_COMPATIBLE\u0026#34; It’s about enabling guest operating system features on custom images. The guest operating system features let you configure networking, security, storage, and operating system options on custom images to be used on boot disks.\n","permalink":"http://uly.me/posts/gcp-uefi-compatible/","summary":"\u003cp\u003eWhen trying to boot from a disk created from snapshot and you’re getting an “UEFI feature is not available for this project” error, you’ll need to create a boot image with the –guest-os-features option set to “UEFI_COMPATIBLE.”\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create new-server-disk-2 \\\n--project=project-name \\\n--source-snapshot=server-disk-2 \\\n--zone=us-central1-b \\\n--guest-os-features=\u0026#34;UEFI_COMPATIBLE\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s about enabling guest operating system features on custom images. The guest operating system features let you configure networking, security, storage, and operating system options on custom images to be used on boot disks.\u003c/p\u003e","title":"gcp uefi compatible"},{"content":"If you see packages are being kept back in Ubuntu, you can run the following to force an update.\nsudo apt-get --with-new-pkgs upgrade ","permalink":"http://uly.me/posts/ubuntu-packages-kept-back/","summary":"\u003cp\u003eIf you see packages are being kept back in Ubuntu, you can run the following to force an update.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get --with-new-pkgs upgrade\n\u003c/code\u003e\u003c/pre\u003e","title":"ubuntu packages kept back"},{"content":"Here’s how to get a list of certificates in AWS Certificate Manager.\naws acm list-certificates \\ --profile default \\ --region us-east-1 \\ --output text \\ --query \u0026#39;CertificateSummaryList[*].{ARN:CertificateArn,Domain:DomainName}\u0026#39; ","permalink":"http://uly.me/posts/aws-certificate-list/","summary":"\u003cp\u003eHere’s how to get a list of certificates in AWS Certificate Manager.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm list-certificates \\\n--profile default \\\n--region us-east-1 \\\n--output text \\\n--query \u0026#39;CertificateSummaryList[*].{ARN:CertificateArn,Domain:DomainName}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws certificate list"},{"content":"To install 7zip.\nyum install 7za apt install p7zip To extract.\n7za e compressedfile.7z To archive.\n7za a myarchive.7z myfiles/ ","permalink":"http://uly.me/posts/7zip-in-linux/","summary":"\u003cp\u003eTo install 7zip.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install 7za\napt install p7zip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo extract.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e7za e compressedfile.7z\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo archive.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e7za a myarchive.7z myfiles/\n\u003c/code\u003e\u003c/pre\u003e","title":"7zip in linux"},{"content":"Here’s how to display a list of Google Cloud forwarding rules.\ngcloud compute forwarding-rules list If you want global only.\ngcloud compute forwarding-rules --global Or just local regions only.\ngcloud compute forwarding-rules --filter=\u0026#34;region:( us-central us-west1 )\u0026#34; ","permalink":"http://uly.me/posts/gcp-display-forwarding-rules/","summary":"\u003cp\u003eHere’s how to display a list of Google Cloud forwarding rules.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute forwarding-rules list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want global only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute forwarding-rules --global\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr just local regions only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute forwarding-rules --filter=\u0026#34;region:( us-central us-west1 )\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp display forwarding rules"},{"content":"How to convert MP3 to OGG audio format.\nffmpeg -i in.mp3 -ar 48000 -vn -c:a libvorbis out.ogg If you have sample rate errors, use -vn.\n","permalink":"http://uly.me/posts/ffmpeg-convert-mp3-to-ogg/","summary":"\u003cp\u003eHow to convert MP3 to OGG audio format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i in.mp3 -ar 48000 -vn -c:a libvorbis out.ogg\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have sample rate errors, use -vn.\u003c/p\u003e","title":"ffmpeg convert mp3 to ogg"},{"content":"Here’s another way to create a firewall in GCP using network tag as targets.\ngcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\ --description=\u0026#34;egress rule to allow port 8000 to destination\u0026#34; \\ --priority \u0026#34;1000\u0026#34; \\ --direction EGRESS \\ --action allow \\ --network \u0026#34;your-network\u0026#34; \\ --target-tags=\u0026#34;your-network-tag\u0026#34; \\ --destination-ranges=\u0026#34;10.0.0.1/32\u0026#34; \\ --rules tcp:8000 ","permalink":"http://uly.me/posts/gcp-create-firewall-with-tags/","summary":"\u003cp\u003eHere’s another way to create a firewall in GCP using network tag as targets.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\\n    --description=\u0026#34;egress rule to allow port 8000 to destination\u0026#34; \\\n    --priority \u0026#34;1000\u0026#34; \\\n    --direction EGRESS \\\n    --action allow \\\n    --network \u0026#34;your-network\u0026#34; \\\n    --target-tags=\u0026#34;your-network-tag\u0026#34; \\\n    --destination-ranges=\u0026#34;10.0.0.1/32\u0026#34; \\\n    --rules tcp:8000\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create firewall with tags"},{"content":"When you stand up an AWS instance, it’s only accessible via SSH key using the default user, typically ec2-user.\nAdd password to ec2-user, then enable password authentication to ‘yes’ in SSH.\n# Add password to ec2-user sudo passwd ec2-user # edit ssh config vim /etc/ssh/sshd_config # enable password authentication PasswordAuthentication yes # save file and exit Restart SSH service.\nsystemctl restart sshd.service ","permalink":"http://uly.me/posts/ec2-password-authentication/","summary":"\u003cp\u003eWhen you stand up an AWS instance, it’s only accessible via SSH key using the default user, typically ec2-user.\u003c/p\u003e\n\u003cp\u003eAdd password to ec2-user, then enable password authentication to ‘yes’ in SSH.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Add password to ec2-user\nsudo passwd ec2-user\n# edit ssh config\nvim /etc/ssh/sshd_config\n# enable password authentication\nPasswordAuthentication yes\n# save file and exit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart SSH service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart sshd.service\n\u003c/code\u003e\u003c/pre\u003e","title":"ec2 password authentication"},{"content":"This is a Bash script to restart a service.\n#!/bin/bash SERVICE=google_osconfig_agent AGENT=google-osconfig-agent if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) \u0026gt; 0 )) then echo \u0026#34;$AGENT service running, everything is fine\u0026#34; else echo \u0026#34;$AGENT is not running\u0026#34; echo \u0026#34;Restarting service\u0026#34; systemctl start $AGENT sleep 5s if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) \u0026gt; 0 )) then sleep 2s echo \u0026#34;$AGENT service is now running\u0026#34; fi fi ","permalink":"http://uly.me/posts/gce-agent-bash/","summary":"\u003cp\u003eThis is a Bash script to restart a service.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\nSERVICE=google_osconfig_agent\nAGENT=google-osconfig-agent\n\nif (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) \u0026gt; 0 ))\nthen\n    echo \u0026#34;$AGENT service running, everything is fine\u0026#34;\nelse\n    echo \u0026#34;$AGENT is not running\u0026#34;\n    echo \u0026#34;Restarting service\u0026#34;\n    systemctl start $AGENT\n    sleep 5s\n    if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) \u0026gt; 0 ))\n    then\n      sleep 2s\n      echo \u0026#34;$AGENT service is now running\u0026#34;\n    fi\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"gce agent bash"},{"content":"This is a Powershell script to restart a service if it’s down.\n$ServiceName = \u0026#39;GCEAgent\u0026#39; $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne \u0026#39;Running\u0026#39;) { Start-Service $ServiceName write-host $arrService.status write-host \u0026#39;Service starting\u0026#39; Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq \u0026#39;Running\u0026#39;) { Write-Host \u0026#39;GCE Agent Service is now Running\u0026#39; } } else { Write-Host \u0026#39;GCE Agent Service is Running\u0026#39; } ","permalink":"http://uly.me/posts/gce-agent-powershell/","summary":"\u003cp\u003eThis is a Powershell script to restart a service if it’s down.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ServiceName = \u0026#39;GCEAgent\u0026#39;\n$arrService = Get-Service -Name $ServiceName\n\nif ($arrService.Status -ne \u0026#39;Running\u0026#39;)\n{\n\n    Start-Service $ServiceName\n    write-host $arrService.status\n    write-host \u0026#39;Service starting\u0026#39;\n    Start-Sleep -seconds 60\n    $arrService.Refresh()\n    if ($arrService.Status -eq \u0026#39;Running\u0026#39;)\n    {\n        Write-Host \u0026#39;GCE Agent Service is now Running\u0026#39;\n    }\n\n}\nelse\n{\n    Write-Host \u0026#39;GCE Agent Service is Running\u0026#39;\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"gce agent powershell"},{"content":"Here’s how to describe snapshots using query with tags.\naws ec2 describe-snapshots \\ --owner-ids xxxxxxxxxxx \\ --profile default \\ --region us-east-2 \\ --output text \\ --query \u0026#34;Snapshots[*].[SnapshotId,Tags[?Key==\u0026#39;Name\u0026#39;].Value[] | [0]]\u0026#34; Result.\nsnap-xxxxxxxxxxxxxxxxx\tServer1 snap-xxxxxxxxxxxxxxxxx\tServer2 ","permalink":"http://uly.me/posts/aws-ec2-describe-snapshots/","summary":"\u003cp\u003eHere’s how to describe snapshots using query with tags.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-snapshots \\\n--owner-ids xxxxxxxxxxx \\\n--profile default \\\n--region us-east-2 \\\n--output text \\\n--query \u0026#34;Snapshots[*].[SnapshotId,Tags[?Key==\u0026#39;Name\u0026#39;].Value[] | [0]]\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esnap-xxxxxxxxxxxxxxxxx\tServer1\nsnap-xxxxxxxxxxxxxxxxx\tServer2\n\u003c/code\u003e\u003c/pre\u003e","title":"aws ec2 describe snapshots"},{"content":"If you don’t have it installed.\nyum install screen apt install screen Before you run a process, run screen, and detach.\nscreen # run the command ping yahoo.com # ctrl-a and ctrl-d to detach To reattach, get a list of screen sessions, and attach to it.\nscreen -ls # result is somewhat similar to below 4452.hostname # attach to it screen -dr 4452.hostname To stop, just type exit from the screen terminal.\n","permalink":"http://uly.me/posts/linux-screen/","summary":"\u003cp\u003eIf you don’t have it installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install screen\napt install screen\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBefore you run a process, run screen, and detach.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escreen\n# run the command\nping yahoo.com\n# ctrl-a and ctrl-d to detach\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo reattach, get a list of screen sessions, and attach to it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escreen -ls\n# result is somewhat similar to below\n4452.hostname\n# attach to it\nscreen -dr 4452.hostname\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo stop, just type exit from the screen terminal.\u003c/p\u003e","title":"linux screen"},{"content":"Here are some missing PHP modules on my WordPress install.\napt install php-gd php-dom php-mbstring php-imagick php-zip Reboot Apache after the install.\nsystemctl restart apache2 ","permalink":"http://uly.me/posts/php-modules/","summary":"\u003cp\u003eHere are some missing PHP modules on my WordPress install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install php-gd php-dom php-mbstring php-imagick php-zip\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot Apache after the install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e","title":"php modules"},{"content":"Here’s how to unjoin or leave the domain via SSSD.\nrealm leave domain.com ","permalink":"http://uly.me/posts/sssd-leave-domain/","summary":"\u003cp\u003eHere’s how to unjoin or leave the domain via SSSD.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erealm leave domain.com\n\u003c/code\u003e\u003c/pre\u003e","title":"sssd leave domain"},{"content":"Here’s how to sync S3 buckets between 2 different AWS accounts. Assuming buckets are already created.\nSetup bucket permissions in Account A Setup IAM user with permissions in Account B Setup bucket permissions in Account B Run S3 sync from Account B. Account A bucket permissions. Account and user are from Account B.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;DelegateS3Access\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Principal\u0026#34;: {\u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::222222222222:user/Jane\u0026#34;}, \u0026#34;Action\u0026#34;: [\u0026#34;s3:ListBucket\u0026#34;,\u0026#34;s3:GetObject\u0026#34;], \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:s3:::awsexamplesourcebucket/*\u0026#34;, \u0026#34;arn:aws:s3:::awsexamplesourcebucket\u0026#34; ] } ] } Create IAM user (Jane) in Account B\naws iam create-user --user-name Jane Give IAM user (Jane) access to both buckets.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;s3:ListBucket\u0026#34;, \u0026#34;s3:GetObject\u0026#34; ], \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:s3:::awsexamplesourcebucket\u0026#34;, \u0026#34;arn:aws:s3:::awsexamplesourcebucket/*\u0026#34; ] }, { \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;s3:ListBucket\u0026#34;, \u0026#34;s3:PutObject\u0026#34;, \u0026#34;s3:PutObjectAcl\u0026#34; ], \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:s3:::awsexampledestinationbucket\u0026#34;, \u0026#34;arn:aws:s3:::awsexampledestinationbucket/*\u0026#34; ] } ] } Sync the buckets\naws s3 sync s3://awsexamplesourcebucket s3://awsexampledestinationbucket ","permalink":"http://uly.me/posts/aws-s3-sync-between-accounts/","summary":"\u003cp\u003eHere’s how to sync S3 buckets between 2 different AWS accounts. Assuming buckets are already created.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eSetup bucket permissions in Account A\u003c/li\u003e\n\u003cli\u003eSetup IAM user with permissions in Account B\u003c/li\u003e\n\u003cli\u003eSetup bucket permissions in Account B\u003c/li\u003e\n\u003cli\u003eRun S3 sync from Account B.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eAccount A bucket permissions. Account and user are from Account B.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;DelegateS3Access\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Principal\u0026#34;: {\u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::222222222222:user/Jane\u0026#34;},\n            \u0026#34;Action\u0026#34;: [\u0026#34;s3:ListBucket\u0026#34;,\u0026#34;s3:GetObject\u0026#34;],\n            \u0026#34;Resource\u0026#34;: [\n                \u0026#34;arn:aws:s3:::awsexamplesourcebucket/*\u0026#34;,\n                \u0026#34;arn:aws:s3:::awsexamplesourcebucket\u0026#34;\n            ]\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate IAM user (Jane) in Account B\u003c/p\u003e","title":"aws s3 sync between accounts"},{"content":"Here’s the AWS CLI command to set the Auto Scaling Group to a certain number for the minimum, maximum, and desired number of instances.\n#!/bin/bash # Format: # ./autoscaling.sh 3 # ./autoscaling.sh 0 int=$1 aws autoscaling update-auto-scaling-group \\ --auto-scaling-group-name your-auto-scaling-group \\ --min-size $int \\ --max-size $int \\ --desired-capacity $int \\ --region us-east-2 Format:\n./autoscaling.sh 0 ./autoscaling.sh 3 ","permalink":"http://uly.me/posts/aws-cli-autoscaler-update/","summary":"\u003cp\u003eHere’s the AWS CLI command to set the Auto Scaling Group to a certain number for the minimum, maximum, and desired number of instances.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# Format:  \n# ./autoscaling.sh 3\n# ./autoscaling.sh 0\nint=$1\naws autoscaling update-auto-scaling-group \\\n--auto-scaling-group-name your-auto-scaling-group \\\n--min-size $int \\\n--max-size $int \\\n--desired-capacity $int \\\n--region us-east-2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFormat:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e./autoscaling.sh 0\n./autoscaling.sh 3\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli autoscaler update"},{"content":"The standard way to connect to MySQL is:\nmysql -h hostname -u user -p Here’s how to connect to MySQL with SSL encryption.\nmysql -h hostname -u user -p \\ --ssl-ca=server-ca.pem \\ --ssl-cert=client-cert.pem \\ --ssl-key=client-key.pem Generate the SSL keys from the MySQL server. Download it to the client.\n","permalink":"http://uly.me/posts/mysql-ssl-connection/","summary":"\u003cp\u003eThe standard way to connect to MySQL is:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -h hostname -u user -p\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to connect to MySQL with SSL encryption.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -h hostname -u user -p \\\n--ssl-ca=server-ca.pem \\\n--ssl-cert=client-cert.pem \\\n--ssl-key=client-key.pem\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGenerate the SSL keys from the MySQL server. Download it to the client.\u003c/p\u003e","title":"mysql ssl connection"},{"content":"Here’s how to restore a MySQL database from mysqldump.\nmysql -u user -p mysql\u0026gt; drop database databasename; mysql\u0026gt; quit; Bye mysql -u user -p databasename Drop database first, then import the SQL file.\n","permalink":"http://uly.me/posts/mysql-restore/","summary":"\u003cp\u003eHere’s how to restore a MySQL database from mysqldump.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -u user -p\nmysql\u0026gt; drop database databasename;\nmysql\u0026gt; quit;\nBye\nmysql -u user -p databasename \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDrop database first, then import the SQL file.\u003c/p\u003e","title":"mysql restore"},{"content":"Now that Ubuntu 20.04 LTS (Long Term Support) is out, here’s a quick guide to upgrade to Ubuntu 20.04 LTS. You can ONLY upgrade from either Ubuntu 18.04 LTS or 19.10. If you have older versions of Ubuntu, it may not work. I suggest you back up your VM before running the upgrade, so you can quicky recover if something goes awry. This upgrade process will require sudo access.\n# login as root sudo -i # check your current version lsb_release -a # update packages apt update -y apt upgrade -y # reboot server reboot # remove old kernels apt --purge autoremove # install update manager core apt install update-manager-core # finally, perform the upgrade do-release-upgrade -d # reboot the server reboot # after reboot confirm lsb_release -a ","permalink":"http://uly.me/posts/upgrade-to-ubuntu-20-04-lts/","summary":"\u003cp\u003eNow that Ubuntu 20.04 LTS (Long Term Support) is out, here’s a quick guide to upgrade to Ubuntu 20.04 LTS. You can ONLY upgrade from either Ubuntu 18.04 LTS or 19.10. If you have older versions of Ubuntu, it may not work. I suggest you back up your VM before running the upgrade, so you can quicky recover if something goes awry. This upgrade process will require sudo access.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# login as root\nsudo -i\n# check your current version\nlsb_release -a\n# update packages\napt update -y\napt upgrade -y\n# reboot server\nreboot\n# remove old kernels\napt --purge autoremove\n# install update manager core\napt install update-manager-core\n# finally, perform the upgrade\ndo-release-upgrade -d\n# reboot the server\nreboot\n# after reboot confirm\nlsb_release -a\n\u003c/code\u003e\u003c/pre\u003e","title":"upgrade to ubuntu 20.04 lts"},{"content":"Here’s how to convert SSL certificate from PFX to PEM format.\n#!/bin/bash echo \u0026#34;This script converts SSL certificates from PFX to PEM.\u0026#34; read -p \u0026#39;Enter PFX Certificate Name : \u0026#39; cert_pfx read -p \u0026#39;Enter the Import Passphrase : \u0026#39; import_passphrase openssl pkcs12 -in $cert_pfx -nocerts -out cert-key.pem -passin pass:$import_passphrase -passout pass:$import_passphrase openssl pkcs12 -in $cert_pfx -clcerts -nokeys -out cert-body.pem -passin pass:$import_passphrase -passout pass:$import_passphrase openssl pkcs12 -in $cert_pfx -nodes -nokeys -out cert-chain.pem -passin pass:$import_passphrase -passout pass:$import_passphrase sleep 3 openssl rsa -in key.pem -out cert-private.key -passin pass:$import_passphrase -passout pass:$import_passphrase This was covered in an earlier post, but this script prompts you for the passphrase.\nHere’s the expected output.\ncert-key.pem cert-body.pem cert-chain.pem cert-private.key ","permalink":"http://uly.me/posts/pfx-to-pem/","summary":"\u003cp\u003eHere’s how to convert SSL certificate from PFX to PEM format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\necho \u0026#34;This script converts SSL certificates from PFX to PEM.\u0026#34;\nread -p \u0026#39;Enter PFX Certificate Name  : \u0026#39; cert_pfx\nread -p \u0026#39;Enter the Import Passphrase : \u0026#39; import_passphrase\n\nopenssl pkcs12 -in $cert_pfx -nocerts -out cert-key.pem -passin pass:$import_passphrase -passout pass:$import_passphrase\nopenssl pkcs12 -in $cert_pfx -clcerts -nokeys -out cert-body.pem -passin pass:$import_passphrase -passout pass:$import_passphrase\nopenssl pkcs12 -in $cert_pfx -nodes -nokeys -out cert-chain.pem -passin pass:$import_passphrase -passout pass:$import_passphrase\nsleep 3\nopenssl rsa -in key.pem -out cert-private.key -passin pass:$import_passphrase -passout pass:$import_passphrase\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis was covered in an \u003ca href=\"https://uly.me/convert-pfx-to-pem-format/\"\u003eearlier post\u003c/a\u003e, but this script prompts you for the passphrase.\u003c/p\u003e","title":"pfx to pem"},{"content":"Here’s the CloudFormation template for creating a WAF.\nHere are some options that you’ll be asked during creation.\nActivate SQL Injection Protection ( yes | no ) Activate Cross-site Scripting Protection ( yes | no ) Activate HTTP Flood Protection ( WAF rate | Lambda log parser | Athena log parser | no ) Activate Scanner \u0026amp; Probe Protection ( Lambda log parser | Athena log parser | no ) Activate Reputation List Protection ( yes | no ) Activate Bad Bot Protection ( yes | no ) Endpoint Type (CloudFront or ALB) Application Access Log Bucket Name ( Leave blank if no S3 bucket) The template creates 2 CloudFormation stacks.\n","permalink":"http://uly.me/posts/waf-cloudformation-template/","summary":"\u003cp\u003eHere’s the \u003ca href=\"https://docs.aws.amazon.com/solutions/latest/aws-waf-security-automations/template.html\"\u003eCloudFormation template\u003c/a\u003e for creating a WAF.\u003c/p\u003e\n\u003cp\u003eHere are some options that you’ll be asked during creation.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eActivate SQL Injection Protection ( yes | no )\u003c/li\u003e\n\u003cli\u003eActivate Cross-site Scripting Protection ( yes | no )\u003c/li\u003e\n\u003cli\u003eActivate HTTP Flood Protection ( WAF rate | Lambda log parser | Athena log parser | no )\u003c/li\u003e\n\u003cli\u003eActivate Scanner \u0026amp; Probe Protection ( Lambda log parser | Athena log parser | no )\u003c/li\u003e\n\u003cli\u003eActivate Reputation List Protection ( yes | no )\u003c/li\u003e\n\u003cli\u003eActivate Bad Bot Protection ( yes | no )\u003c/li\u003e\n\u003cli\u003eEndpoint Type (CloudFront or ALB)\u003c/li\u003e\n\u003cli\u003eApplication Access Log Bucket Name ( Leave blank if no S3 bucket)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe template creates 2 CloudFormation stacks.\u003c/p\u003e","title":"waf cloudformation template"},{"content":"Here’s how to get the WAF rule.\naws waf-regional get-rule \\ --rule-id xxxxxxxxxxxxxxxxxxxxxxxxxxx Here’s how to get the AWS WAF IP set.\naws waf-regional get-ip-set \\ --ip-set-id xxxxxxxxxxxxxxxxxxx \\ --region us-east-1 \\ --profile your-profile Here’s how to get the latest token.\naws waf-regional get-change-token Result is similar to this.\n{ \u0026#34;ChangeToken\u0026#34;: \u0026#34;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u0026#34; } Create a JSON file called “change.json” to be used for updating the IP set. We will insert and delete an IP set.\n[ { \u0026#34;Action\u0026#34;: \u0026#34;INSERT\u0026#34;, \u0026#34;IPSetDescriptor\u0026#34;: { \u0026#34;Type\u0026#34;: \u0026#34;IPV4\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;12.34.56.78/24\u0026#34; } }, { \u0026#34;Action\u0026#34;: \u0026#34;DELETE\u0026#34;, \u0026#34;IPSetDescriptor\u0026#34;: { \u0026#34;Type\u0026#34;: \u0026#34;IPV6\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;1111:0000:0000:0000:0000:0000:0000:0111/128\u0026#34; } } ] Finally, here’s how to update the IP set.\naws waf-regional update-ip-set \\ --ip-set-id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \\ --change-token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \\ --region us-east-1 \\ --profile default \\ --updates file://change.json ","permalink":"http://uly.me/posts/aws-waf-ip-set/","summary":"\u003cp\u003eHere’s how to get the WAF rule.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws waf-regional get-rule \\\n--rule-id xxxxxxxxxxxxxxxxxxxxxxxxxxx\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to get the AWS WAF IP set.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws waf-regional get-ip-set \\\n--ip-set-id xxxxxxxxxxxxxxxxxxx \\\n--region us-east-1 \\\n--profile your-profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to get the latest token.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws waf-regional get-change-token\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult is similar to this.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;ChangeToken\u0026#34;: \u0026#34;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u0026#34;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a JSON file called “change.json” to be used for updating the IP set. We will insert and delete an IP set.\u003c/p\u003e","title":"aws waf ip set"},{"content":"Here’s how to get a list of GCP instances using a specific service account.\ngcloud compute instances list \\ --filter=\u0026#34;serviceAccounts.email=service-account@domain.com\u0026#34; \\ --project project-id To display all instances and their service accounts in JSON format.\ngcloud compute instances list \\ --format=\u0026#34;json(name,serviceAccounts[].email)\u0026#34; \\ --project your-project-id Display in YAML which is also the Default.\ngcloud compute instances list \\ --format=\u0026#34;default(name,serviceAccounts[].email)\u0026#34; \\ --project your-project-id ","permalink":"http://uly.me/posts/gcp-instances-by-service-account/","summary":"\u003cp\u003eHere’s how to get a list of GCP instances using a specific service account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances list \\\n--filter=\u0026#34;serviceAccounts.email=service-account@domain.com\u0026#34; \\\n--project project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo display all instances and their service accounts in JSON format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances list \\\n--format=\u0026#34;json(name,serviceAccounts[].email)\u0026#34; \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisplay in YAML which is also the Default.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances list \\\n--format=\u0026#34;default(name,serviceAccounts[].email)\u0026#34; \\\n--project your-project-id\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp instances by service account"},{"content":"S3 Browser is a free Windows client for accessing AWS S3 buckets. You can access S3 buckets with an interface similar to File Manager. A typical setup requires that you use access and secret keys to connect to the S3 browser. However, if the server is in the cloud, it’s better that use a machine profile with an assume role. The assume role gets temporary credentials until they expire. They are automatically rotated by AWS behind the scenes for you. This is much safer process than storing key credentials in the cloud. The good news is, S3 Browser support IAM assume roles. Here’s the setup instructions to get your S3 Browser configured using IAM assume role. Here’s IAM role explained.\n","permalink":"http://uly.me/posts/s3-browser-iam-assume-role/","summary":"\u003cp\u003eS3 Browser is a free Windows client for accessing AWS S3 buckets. You can access S3 buckets with an interface similar to File Manager. A typical setup requires that you use access and secret keys to connect to the S3 browser. However, if the server is in the cloud, it’s better that use a machine profile with an assume role. The assume role gets temporary credentials until they expire. They are automatically rotated by AWS behind the scenes for you. This is much safer process than storing key credentials in the cloud. The good news is, S3 Browser support IAM assume roles. Here’s the setup instructions to get your \u003ca href=\"https://s3browser.com/amazon-s3-via-assume-role.aspx\"\u003eS3 Browser configured\u003c/a\u003e using IAM assume role. Here’s IAM role \u003ca href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html\"\u003eexplained\u003c/a\u003e.\u003c/p\u003e","title":"s3 browser iam assume role"},{"content":"Due to the Covid-19 lockdown, here are several video conferencing options.\nMicrosoft Skype – been around for a long time. Microsoft Teams – Microsoft wants everyone to switch to Teams. Google Meet – Uses the webRTC protocol. Video calls up to 10 people. Discord – Popular with gamers. Video chat capable up to 9 people. Zoom – Got really hot, then took a dive due to zoombombing. Chime – Amazon Web Services video chat. Webex – Cisco’s video conferencing. This is not an extensive list, but are the popular options.\nBelieve it or not, I have all on my work laptop except for Discord.\n","permalink":"http://uly.me/posts/video-conferencing/","summary":"\u003cp\u003eDue to the Covid-19 lockdown, here are several video conferencing options.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://www.skype.com/en/\"\u003eMicrosoft Skype\u003c/a\u003e – been around for a long time.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://products.office.com/en-us/microsoft-teams/group-chat-software\"\u003eMicrosoft Teams\u003c/a\u003e – Microsoft wants everyone to switch to Teams.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://meet.google.com/?authuser=1\"\u003eGoogle Meet\u003c/a\u003e – Uses the webRTC protocol. Video calls up to 10 people.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://discordapp.com/\"\u003eDiscord\u003c/a\u003e – Popular with gamers. Video chat capable up to 9 people.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://zoom.us/\"\u003eZoom\u003c/a\u003e – Got really hot, then took a dive due to zoombombing.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://aws.amazon.com/chime/?chime-blog-posts.sort-by=item.additionalFields.createdDate\u0026amp;chime-blog-posts.sort-order=desc\"\u003eChime\u003c/a\u003e – Amazon Web Services video chat.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.webex.com/\"\u003eWebex\u003c/a\u003e – Cisco’s video conferencing.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThis is not an extensive list, but are the popular options.\u003c/p\u003e","title":"video conferencing"},{"content":"Here’s how to list S3 files recursively.\naws s3 ls s3://mybucket --recursive | awk \u0026#39;{print $4}\u0026#39; By default, the results display date, time, disk size and filename. Use awk to display the filename only.\n","permalink":"http://uly.me/posts/aws-s3-ls-recursive/","summary":"\u003cp\u003eHere’s how to list S3 files recursively.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 ls s3://mybucket --recursive | awk \u0026#39;{print $4}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBy default, the results display date, time, disk size and filename. Use awk to display the filename only.\u003c/p\u003e","title":"aws s3 ls recursive"},{"content":"Here’s how to disable plugin in Yum repos.\n# check which plugins are enabled yum repolist # disable plugins yum update --disableplugin=product-id,subscription-manager # check agin yum repolist If that doesn’t work, check the individual config files of each plugin.\ncd /etc/yum/pluginconf.d/ vim product-id.conf vim subscription-manager.conf Disable it.\n[main] enable=0 ","permalink":"http://uly.me/posts/yum-repo-plugins/","summary":"\u003cp\u003eHere’s how to disable plugin in Yum repos.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check which plugins are enabled\nyum repolist\n# disable plugins\nyum update --disableplugin=product-id,subscription-manager\n# check agin\nyum repolist\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf that doesn’t work, check the individual config files of each plugin.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /etc/yum/pluginconf.d/\nvim product-id.conf\nvim subscription-manager.conf\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[main]\nenable=0\n\u003c/code\u003e\u003c/pre\u003e","title":"yum repo plugins"},{"content":"Here’s how to find your GitBash .bashrc.\n# cd takes you to gitbash home cd # edit .bashrc vim ~/.bashrc You can add aliases, change prompt styles, etc.\nexport PS1=\u0026#34;\\w: $ \u0026#34; alias gcloud=\u0026#34;gcloud.cmd\u0026#34; alias gsutil=\u0026#34;gsutil.cmd\u0026#34; alias code=\u0026#34;cd ~/Code\u0026#34; cd Code ","permalink":"http://uly.me/posts/gitbash-bashrc/","summary":"\u003cp\u003eHere’s how to find your GitBash .bashrc.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# cd takes you to gitbash home\ncd \n# edit .bashrc\nvim ~/.bashrc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can add aliases, change prompt styles, etc.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eexport PS1=\u0026#34;\\w: $ \u0026#34;\nalias gcloud=\u0026#34;gcloud.cmd\u0026#34;\nalias gsutil=\u0026#34;gsutil.cmd\u0026#34;\nalias code=\u0026#34;cd ~/Code\u0026#34;\ncd Code\n\u003c/code\u003e\u003c/pre\u003e","title":"gitbash .bashrc"},{"content":"Here’s how to setup a XFS volume.\nfile -s /dev/nvme2n1 mkfs -t xfs /dev/nvme2n1 Mount to /data.\nmkdir /data mount /dev/nvme2n1 /data Add to /etc/fstab.\nvim /etc/fstab # # UUID=xxxxxxxxxxxxxxxxxxxxxx /data xfs defaults 0 0 ","permalink":"http://uly.me/posts/aws-xfs-volume-setup/","summary":"\u003cp\u003eHere’s how to setup a XFS volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efile -s /dev/nvme2n1\nmkfs -t xfs /dev/nvme2n1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount to /data.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir /data\nmount /dev/nvme2n1 /data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd to /etc/fstab.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim /etc/fstab\n#\n#\nUUID=xxxxxxxxxxxxxxxxxxxxxx /data  xfs  defaults 0 0\n\u003c/code\u003e\u003c/pre\u003e","title":"aws xfs volume setup"},{"content":"To see which disk is available for swap disk use.\nlsblk blkid df -Th Format the disk.\nfdisk /dev/xvda Create a swap disk.\nsudo mkswap -f /dev/xvda sudo swapon -s /dev/xvda # or sudo swapon /dev/xvda Check if swap disk is available.\nlsblk free -h cat /proc/swaps cat /proc/meminfo swapon -s top vmstat vmstat 1 5 ","permalink":"http://uly.me/posts/create-swap-disk/","summary":"\u003cp\u003eTo see which disk is available for swap disk use.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk\nblkid\ndf -Th\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFormat the disk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efdisk /dev/xvda\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a swap disk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo mkswap -f /dev/xvda\nsudo swapon -s /dev/xvda\n# or\nsudo swapon /dev/xvda\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if swap disk is available.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk\nfree -h \ncat /proc/swaps\ncat /proc/meminfo\nswapon -s\ntop\nvmstat\nvmstat 1 5\n\u003c/code\u003e\u003c/pre\u003e","title":"create swap disk"},{"content":"Here are the commands to find out the bucket size in GCP.\ngsutil du -s gs://bucket-name/ ","permalink":"http://uly.me/posts/gcp-bucket-size/","summary":"\u003cp\u003eHere are the commands to find out the bucket size in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsutil du -s gs://bucket-name/\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp bucket size"},{"content":"Here’s how to get a list of GCP projects.\ngcloud projects list Result:\nPROJECT_ID NAME PROJECT_NUMBER your-project-id-xxxx servers xxxxxxxxxxxx Use awk to display the project id only.\ngcloud projects list | awk \u0026#39;{print $1}\u0026#39; Result\nPROJECT ID your-project-id-xxxx ","permalink":"http://uly.me/posts/gcp-projects-list/","summary":"\u003cp\u003eHere’s how to get a list of GCP projects.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud projects list \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePROJECT_ID            NAME     PROJECT_NUMBER\nyour-project-id-xxxx  servers  xxxxxxxxxxxx\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUse awk to display the project id only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud projects list | awk \u0026#39;{print $1}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePROJECT ID\nyour-project-id-xxxx\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp projects list"},{"content":"Here’s how to set the DeleteOnTermination setting on EBS volumes. The DeleteOnTermination flag determines if an EBS volume will be kept or deleted when an EC2 instance is terminated. The DeleteOnTermination setting can be set during EC2 instance creation, or it can be applied to an existing or a running EC2 instance. The settings can be placed in a JSON file and loaded using –block-device-mappings option upon creation.\nDuring creation.\naws ec2 run-instances \\ --count 1 \\ --region us-east-2 \\ --key-name tfc-ohio \\ --image-id ami-xxxxxxxx \\ --instance-type t2.large \\ --subnet-id subnet-xxxxxxx \\ --private-ip-address 10.0.4.100 \\ --iam-instance-profile Name=machinerole \\ --security-group-ids sg-xxxxxxxxxxxxx \\ --block-device-mappings file://mapping.json Contents of mapping.json\n[ { \u0026#34;DeviceName\u0026#34;: \u0026#34;/dev/sda1\u0026#34;, \u0026#34;Ebs\u0026#34;: { \u0026#34;DeleteOnTermination\u0026#34;: true, \u0026#34;VolumeSize\u0026#34;: 30 \u0026#34;VolumeType\u0026#34;: \u0026#34;gp2\u0026#34; } } ] Device name is /dev/sda1. Termination is set to true. Volume size is 30GB and EBS type is gp2.\nModifying an existing EC2 instance.\naws ec2 modify-instance-attribute \\ --instance-id i-xxxxxxxxxxxxx \\ --block-device-mappings file://mapping.json Here’s the mapping.json file.\n[ { \u0026#34;DeviceName\u0026#34;: \u0026#34;/dev/sda1\u0026#34;, \u0026#34;Ebs\u0026#34;: { \u0026#34;DeleteOnTermination\u0026#34;: false, } } ] Obviously, you can’t change Volume size and type to an existing EBS volume, but you can flip the DeleteOnTermination flag and vice versa.\n","permalink":"http://uly.me/posts/ebs-deleteontermination/","summary":"\u003cp\u003eHere’s how to set the DeleteOnTermination setting on EBS volumes. The DeleteOnTermination flag determines if an EBS volume will be kept or deleted when an EC2 instance is terminated. The DeleteOnTermination setting can be set during EC2 instance creation, or it can be applied to an existing or a running EC2 instance. The settings can be placed in a JSON file and loaded using –block-device-mappings option upon creation.\u003c/p\u003e\n\u003cp\u003eDuring creation.\u003c/p\u003e","title":"ebs deleteontermination"},{"content":"Here’s how to list all the devices on your network using nmap.\nnmap -sn 192.168.0.0/24 If nmap is not installed, install it.\nyum install nmap apt install nmap ","permalink":"http://uly.me/posts/nmap/","summary":"\u003cp\u003eHere’s how to list all the devices on your network using nmap.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enmap -sn 192.168.0.0/24\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf nmap is not installed, install it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install nmap\napt install nmap\n\u003c/code\u003e\u003c/pre\u003e","title":"nmap"},{"content":"Netstat is a utility for gathering network statistics. It comes preinstalled on most systems.\nIf missing, here’s how to install.\n# Redhat, CentOS yum install net-tools # Debian, Ubuntu, Mint apt install net-tools # SLES, SUSE zypper install net-tools Here are some common and useful commands.\n# show version netstat -v # show routing table netstat -nr # show network interface statistics netstat -ai # show network connections netstat -ant # show network services netstat -tulpn ","permalink":"http://uly.me/posts/netstat/","summary":"\u003cp\u003eNetstat is a utility for gathering network statistics. It comes preinstalled on most systems.\u003c/p\u003e\n\u003cp\u003eIf missing, here’s how to install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Redhat, CentOS\nyum install net-tools\n# Debian, Ubuntu, Mint\napt install net-tools\n# SLES, SUSE\nzypper install net-tools\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere are some common and useful commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# show version\nnetstat -v\n# show routing table\nnetstat -nr\n# show network interface statistics\nnetstat -ai\n# show network connections\nnetstat -ant\n# show network services\nnetstat -tulpn\n\u003c/code\u003e\u003c/pre\u003e","title":"netstat"},{"content":"Here’s how to list the available PHP modules.\napt-cache search php- | less To get details about a module.\napt-cache show php-curl To install a module.\napt install php-curl Or install all modules.\napt install php* Restart Apache after each install.\nsystemctl restart apache2 ","permalink":"http://uly.me/posts/list-available-php-modules/","summary":"\u003cp\u003eHere’s how to list the available PHP modules.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt-cache search php- | less\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo get details about a module.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt-cache show php-curl\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo install a module.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install php-curl\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr install all modules.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install php*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart Apache after each install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e","title":"list available php modules"},{"content":"Here’s how to run docker-compose. I have an Icecast docker-compose.yml file. Icecast is an audio streaming server.\nversion: \u0026#34;2\u0026#34; services: icecast: image: moul/icecast environment: - ICECAST_SOURCE_PASSWORD=secret - ICECAST_ADMIN_PASSWORD=secret - ICECAST_PASSWORD=secret - ICECAST_RELAY_PASSWORD=secret ports: - \u0026#34;8000:8000\u0026#34; restart: always To run Icecast in a container , I run docker-compose in the background.\ndocker-compose up -d Check to see if Icecast is running on your browser.\nhttp://localhost:8000 To stop the Icecast container, I simply stop the docker-compose.\ndocker-compose stop Here are the other docker commands you can run.\ndocker images docker ps docker-compose ps ","permalink":"http://uly.me/posts/run-docker-compose/","summary":"\u003cp\u003eHere’s how to run docker-compose. I have an Icecast docker-compose.yml file. Icecast is an audio streaming server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eversion: \u0026#34;2\u0026#34;\n\nservices:\n  icecast:\n    image: moul/icecast\n    environment:\n      - ICECAST_SOURCE_PASSWORD=secret\n      - ICECAST_ADMIN_PASSWORD=secret\n      - ICECAST_PASSWORD=secret\n      - ICECAST_RELAY_PASSWORD=secret\n    ports:\n      - \u0026#34;8000:8000\u0026#34;\n    restart: always\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo run Icecast in a container , I run docker-compose in the background.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker-compose up -d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck to see if Icecast is running on your browser.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehttp://localhost:8000\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo stop the Icecast container, I simply stop the docker-compose.\u003c/p\u003e","title":"run docker compose"},{"content":"Here’s how to add a GCP firewall rule with the AH (authentication header) and ESP (Encapsulating Security Payload) protocols.\ngcloud compute firewall-rules update \u0026#34;firewall-name\u0026#34; \\ --description=\u0026#34;firewall description\u0026#34; \\ --priority \u0026#34;1000\u0026#34; \\ --target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\ --destination-ranges=\u0026#34;10.0.0.0/8\u0026#34; \\ --rules 50,51,tcp:80,udp:1000 There is no need to add protocols for AH and ESP. Just the port numbers.\n","permalink":"http://uly.me/posts/gcp-sdk-firewall-rule-ah-and-esp/","summary":"\u003cp\u003eHere’s how to add a GCP firewall rule with the AH (authentication header) and ESP (Encapsulating Security Payload) protocols.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules update \u0026#34;firewall-name\u0026#34; \\\n    --description=\u0026#34;firewall description\u0026#34; \\\n    --priority \u0026#34;1000\u0026#34; \\\n    --target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\\n    --destination-ranges=\u0026#34;10.0.0.0/8\u0026#34; \\\n    --rules 50,51,tcp:80,udp:1000\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere is no need to add protocols for AH and ESP. Just the port numbers.\u003c/p\u003e","title":"gcp sdk firewall rule ah and esp"},{"content":"Here’s an alternate way to give Linux users sudo access by adding them to the wheel group. Most Linux systems come with the wheel group already predefined. By adding users to the wheel group, they now have the ability to sudo and run root commands. The wheel group is in the sudoers file for Redhat, Centos, Debian and Ubuntu.\nusermod -aG wheel username ","permalink":"http://uly.me/posts/wheel-group/","summary":"\u003cp\u003eHere’s an alternate way to give Linux users sudo access by adding them to the wheel group. Most Linux systems come with the wheel group already predefined. By adding users to the wheel group, they now have the ability to sudo and run root commands. The wheel group is in the sudoers file for Redhat, Centos, Debian and Ubuntu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eusermod -aG wheel username\n\u003c/code\u003e\u003c/pre\u003e","title":"wheel group"},{"content":"Here’s the Splunk search for Tanium clients reporting to the Tanium server.\n\u0026#34;data.jsonPayload.rule_details.direction\u0026#34;=EGRESS \u0026#34;data.jsonPayload.connection.src_ip\u0026#34;=\u0026#34;10.0.0.1\u0026#34; \u0026#34;data.jsonPayload.connection.dest_port\u0026#34;=17472 ","permalink":"http://uly.me/posts/splunk-search-for-tanium-clients/","summary":"\u003cp\u003eHere’s the Splunk search for Tanium clients reporting to the Tanium server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026#34;data.jsonPayload.rule_details.direction\u0026#34;=EGRESS\n\u0026#34;data.jsonPayload.connection.src_ip\u0026#34;=\u0026#34;10.0.0.1\u0026#34;\n\u0026#34;data.jsonPayload.connection.dest_port\u0026#34;=17472\n\u003c/code\u003e\u003c/pre\u003e","title":"splunk search for tanium clients"},{"content":"Here’s how to update an existing GCP firewall.\nIngress\ngcloud compute firewall-rules update \u0026#34;firewall-rule-name\u0026#34; \\ --description=\u0026#34;firewall description\u0026#34; \\ --priority=\u0026#34;1000\u0026#34; --target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\ --source-ranges=\u0026#34;10.0.0.0/8\u0026#34; --rules tcp:80,tcp:443,udp:1000-1100 Egress\ngcloud compute firewall-rules update \u0026#34;firewall-rule-name\u0026#34; \\ --description=\u0026#34;firewall description\u0026#34; \\ --priority=\u0026#34;1000\u0026#34; --target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\ --destination-ranges=\u0026#34;10.0.0.0/8\u0026#34; --rules tcp:80,tcp:443,udp:1000-1100 ","permalink":"http://uly.me/posts/gcp-sdk-firewall-update/","summary":"\u003cp\u003eHere’s how to update an existing GCP firewall.\u003c/p\u003e\n\u003cp\u003eIngress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules update \u0026#34;firewall-rule-name\u0026#34; \\\n--description=\u0026#34;firewall description\u0026#34; \\\n--priority=\u0026#34;1000\u0026#34;\n--target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\\n--source-ranges=\u0026#34;10.0.0.0/8\u0026#34;\n--rules tcp:80,tcp:443,udp:1000-1100\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEgress\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules update \u0026#34;firewall-rule-name\u0026#34; \\\n--description=\u0026#34;firewall description\u0026#34; \\\n--priority=\u0026#34;1000\u0026#34;\n--target-service-accounts=\u0026#34;service-account@gserviceaccount.com\u0026#34; \\\n--destination-ranges=\u0026#34;10.0.0.0/8\u0026#34;\n--rules tcp:80,tcp:443,udp:1000-1100\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp sdk firewall update"},{"content":"Here are the start and stop scripts for the lastest Wowza version 4.8.0.\nStart scripts\nsudo service WowzaStreamingEngine start # or /etc/init.d/WowzaStreamingEngine start Stop scripts\nsudo service WowzaStreamingEngine stop # or /etc/init.d/WowzaStreamingEngine stop ","permalink":"http://uly.me/posts/wowza-4-8-0-scripts/","summary":"\u003cp\u003eHere are the start and stop scripts for the lastest Wowza version 4.8.0.\u003c/p\u003e\n\u003cp\u003eStart scripts\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo service WowzaStreamingEngine start\n# or\n/etc/init.d/WowzaStreamingEngine start\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStop scripts\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo service WowzaStreamingEngine stop\n# or\n/etc/init.d/WowzaStreamingEngine stop\n\u003c/code\u003e\u003c/pre\u003e","title":"wowza 4.8.0 scripts"},{"content":"Here’s the AWS CLI to register instances to a load balancer.\naws elb register-instances-with-load-balancer \\ --load-balancer-name my-load-balancer \\ --instances i-xxxxxxxxxxx i-xxxxxxxxxxx i-xxxxxxxxxxx ","permalink":"http://uly.me/posts/aws-register-instances-with-load-balancer/","summary":"\u003cp\u003eHere’s the AWS CLI to register instances to a load balancer.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws elb register-instances-with-load-balancer \\\n--load-balancer-name my-load-balancer \\\n--instances i-xxxxxxxxxxx i-xxxxxxxxxxx i-xxxxxxxxxxx \n\u003c/code\u003e\u003c/pre\u003e","title":"aws register instances with load balancer"},{"content":"Here’s the command to determine if a host needs rebooting after system updates in Redhat.\n$ needs-restarting ","permalink":"http://uly.me/posts/redhat-needs-restarting/","summary":"\u003cp\u003eHere’s the command to determine if a host needs rebooting after system updates in Redhat.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ needs-restarting\n\u003c/code\u003e\u003c/pre\u003e","title":"redhat needs restarting"},{"content":"Here’s a quick way to setup a chrooted environment.\nmkdir /helper for i in proc sys dev; do mount o bind /$i /helper/$i; done chroot /helper ","permalink":"http://uly.me/posts/chroot-shortcut/","summary":"\u003cp\u003eHere’s a quick way to setup a chrooted environment.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emkdir /helper\nfor i in proc sys dev; do mount o bind /$i /helper/$i; done\nchroot /helper\n\u003c/code\u003e\u003c/pre\u003e","title":"chroot shortcut"},{"content":"This are grub fixes to servers that are not booting up due to improper entries in the grub menu.\ngrub --batch The fix includes replacing (hd0) with (hd0,0) and /dev/sda with /dev/hda.\n","permalink":"http://uly.me/posts/grub-fixes/","summary":"\u003cp\u003eThis are grub fixes to servers that are not booting up due to improper entries in the grub menu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egrub --batch \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe fix includes replacing (hd0) with (hd0,0) and /dev/sda with /dev/hda.\u003c/p\u003e","title":"grub fixes"},{"content":"How to suppress typing “yes” when prompted by ssh.\n#!/bin/bash ssh-keygen -f \u0026#34;/home/user/.ssh/known_hosts\u0026#34; -R \u0026#34;yourdomain.com\u0026#34; ssh -o \u0026#34;StrictHostKeyChecking=no\u0026#34; -i \u0026#34;keys/key.pem\u0026#34; ubuntu@domain.com First remove old keys in the know_hosts file. Use “StrictHostKeyChecking” to suppress prompt. ","permalink":"http://uly.me/posts/disable-host-key-checking/","summary":"\u003cp\u003eHow to suppress typing “yes” when prompted by ssh.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nssh-keygen -f \u0026#34;/home/user/.ssh/known_hosts\u0026#34; -R \u0026#34;yourdomain.com\u0026#34; \nssh -o \u0026#34;StrictHostKeyChecking=no\u0026#34; -i \u0026#34;keys/key.pem\u0026#34; ubuntu@domain.com\n\u003c/code\u003e\u003c/pre\u003e\u003col\u003e\n\u003cli\u003eFirst remove old keys in the know_hosts file.\u003c/li\u003e\n\u003cli\u003eUse “StrictHostKeyChecking” to suppress prompt.\u003c/li\u003e\n\u003c/ol\u003e","title":"disable host key checking"},{"content":"Here’s how to install Go on Ubuntu Linux Mint 19.3.\nDownload the latest from https://golang.org/dl/.\nwget https://dl.google.com/go/go1.13.linux-amd64.tar.gz Check the checksum.\nsha256sum go1.13.linux-amd64.tar.gz Extract the Go tarball to the /usr/local directory.\nsudo tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz Edit your Bash profile to add Go’s path.\ncd ~ vim ~/.profile # Add Go\u0026#39;s path export PATH=$PATH:/usr/local/go/bin # Load the profile source ~/.profile Check if Go is installed.\ngo version Output.\ngo version go1.13 linux/amd64 ","permalink":"http://uly.me/posts/install-go-on-linux-mint-19-3/","summary":"\u003cp\u003eHere’s how to install Go on Ubuntu Linux Mint 19.3.\u003c/p\u003e\n\u003cp\u003eDownload the latest from \u003ca href=\"https://golang.org/dl/\"\u003ehttps://golang.org/dl/\u003c/a\u003e.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget https://dl.google.com/go/go1.13.linux-amd64.tar.gz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck the checksum.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esha256sum go1.13.linux-amd64.tar.gz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExtract the Go tarball to the /usr/local directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit your Bash profile to add Go’s path.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd ~\nvim ~/.profile\n# Add Go\u0026#39;s path\nexport PATH=$PATH:/usr/local/go/bin\n# Load the profile\nsource ~/.profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if Go is installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ego version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ego version go1.13 linux/amd64\n\u003c/code\u003e\u003c/pre\u003e","title":"install go on linux mint 19.3"},{"content":"Here’s a simple Python program that calculates the hypotenuse of a right angle triangle using the Pythagorean Theory.\na2 + b2 = c2\n#!/usr/local/bin/python3 import math print(\u0026#34;================================================\u0026#34;) print(\u0026#34;This program will calculate pythagorean theorem.\u0026#34;) print(\u0026#34;================================================\u0026#34;) side_A = float(input(\u0026#34;Enter side A: \u0026#34;)) side_B = float(input(\u0026#34;Enter side B: \u0026#34;)) def pythagoreamTherem(side_A, side_B): side_C = math.sqrt(side_A * side_A + side_B * side_B) return side_C side_C = pythagoreamTherem(side_A, side_B) print(\u0026#34;\u0026#34;) print(\u0026#34;Side C is: \u0026#34; + \u0026#34;%.2f\u0026#34; % round(side_C,2)) print(\u0026#34;\u0026#34;) Output\nulysses@penguin:~/home/user$ python3 pythagorean.py ================================================ This program will calculate pythagorean theorem. ================================================ Enter side A: 3 Enter side B: 4 Side C is: 5.00 ","permalink":"http://uly.me/posts/python-pythagorean-theorem/","summary":"\u003cp\u003eHere’s a simple Python program that calculates the hypotenuse of a right angle triangle using the Pythagorean Theory.\u003c/p\u003e\n\u003cp\u003ea\u003csup\u003e2\u003c/sup\u003e + b\u003csup\u003e2\u003c/sup\u003e = c\u003csup\u003e2\u003c/sup\u003e\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/usr/local/bin/python3\nimport math\nprint(\u0026#34;================================================\u0026#34;)\nprint(\u0026#34;This program will calculate pythagorean theorem.\u0026#34;)\nprint(\u0026#34;================================================\u0026#34;)\nside_A = float(input(\u0026#34;Enter side A: \u0026#34;))\nside_B = float(input(\u0026#34;Enter side B: \u0026#34;))\ndef pythagoreamTherem(side_A, side_B):\n\tside_C = math.sqrt(side_A * side_A + side_B * side_B)\n\treturn side_C\nside_C = pythagoreamTherem(side_A, side_B)\nprint(\u0026#34;\u0026#34;)\nprint(\u0026#34;Side C is: \u0026#34; + \u0026#34;%.2f\u0026#34; % round(side_C,2))\nprint(\u0026#34;\u0026#34;)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput\u003c/p\u003e","title":"python pythagorean theorem"},{"content":"Here’s a standard template for SSL Apache found in /etc/apache2/sites-available/default-ssl.conf.\n\u0026lt;ifmodule mod_ssl.c=\u0026#34;\u0026#34;\u0026gt; \u0026lt;virtualhost _default_:443=\u0026#34;\u0026#34;\u0026gt; ServerAdmin your-email@your-domain.com ServerName www.yourdomain.com ServerName yourdomain.com DocumentRoot /var/www/your-domain.com ErrorLog /var/www/your-domain.com/log/error.log CustomLog /var/www/your-domain.com/log/access.log combined \u0026lt;directory\u0026gt; Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted \u0026lt;/directory\u0026gt; SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf \u0026lt;/virtualhost\u0026gt; \u0026lt;/ifmodule\u0026gt; Enable SSL.\n# Enable SSL Module a2enmod ssl systemctl restart apache2.service # Enable SSL Apache Config a2ensite default-ssl systemctl restart apache2.service # Alternate way to restart. service apache2 restart ","permalink":"http://uly.me/posts/standard-ssl-policy/","summary":"\u003cp\u003eHere’s a standard template for SSL Apache found in /etc/apache2/sites-available/default-ssl.conf.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;ifmodule mod_ssl.c=\u0026#34;\u0026#34;\u0026gt;\n\u0026lt;virtualhost _default_:443=\u0026#34;\u0026#34;\u0026gt;\n   ServerAdmin your-email@your-domain.com\n   ServerName www.yourdomain.com\n   ServerName yourdomain.com\n   DocumentRoot /var/www/your-domain.com\n   ErrorLog /var/www/your-domain.com/log/error.log\n   CustomLog /var/www/your-domain.com/log/access.log combined\n   \u0026lt;directory\u0026gt;\n      Options Indexes FollowSymLinks MultiViews\n      AllowOverride All\n      Require all granted\n   \u0026lt;/directory\u0026gt;\n   SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem\n   SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem\n   Include /etc/letsencrypt/options-ssl-apache.conf\n\u0026lt;/virtualhost\u0026gt;\n\u0026lt;/ifmodule\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEnable SSL.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Enable SSL Module\na2enmod ssl\nsystemctl restart apache2.service\n# Enable SSL Apache Config\na2ensite default-ssl\nsystemctl restart apache2.service\n# Alternate way to restart.\nservice apache2 restart\n\u003c/code\u003e\u003c/pre\u003e","title":"standard ssl policy"},{"content":"Here’s a dd command to display sequential write throughput from the command line.\ntime dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress Output is.\n512+0 records in 512+0 records out 536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s real 0m0.669s user 0m0.000s sys 0m0.359s ","permalink":"http://uly.me/posts/display-sequential-write-throughput/","summary":"\u003cp\u003eHere’s a dd command to display sequential write throughput from the command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etime dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput is.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e512+0 records in\n512+0 records out\n536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s\n\nreal    0m0.669s\nuser    0m0.000s\nsys     0m0.359s\n\u003c/code\u003e\u003c/pre\u003e","title":"display sequential write throughput"},{"content":"Here’s a simple sed command to replace multiple spaces into a comma delimited file.\nsample.txt\none two three four The sed command.\nsed \u0026#39;s/ \\+ /,/g\u0026#39; sample.txt \u0026gt; sample2.txt sample2.txt\none,two three,four ","permalink":"http://uly.me/posts/replace-spaces-with-comma/","summary":"\u003cp\u003eHere’s a simple sed command to replace multiple spaces into a comma delimited file.\u003c/p\u003e\n\u003cp\u003esample.txt\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eone       two\nthree     four\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe sed command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esed \u0026#39;s/ \\+ /,/g\u0026#39; sample.txt \u0026gt; sample2.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003esample2.txt\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eone,two\nthree,four\n\u003c/code\u003e\u003c/pre\u003e","title":"replace spaces with comma"},{"content":"Here’s how to copy multiple files recursively using AWS CLI. The S3 cp command by default only copies a single file. To copy multiple files, you have to use the –recursive option along with –exclude and –include. In this example, we will exclude every file, but include only files with a json extension.\naws s3 cp /tmp/folder s3://bucket/folder \\ --recursive --exclude \u0026#34;*\u0026#34; --include \u0026#34;*.json\u0026#34; The result:\nupload: ./abc.json to s3://bucket/folder/abc.json upload: ./xyz.json to s3://bucket/folder/xyz.json ","permalink":"http://uly.me/posts/aws-cli-s3-recursive-copy/","summary":"\u003cp\u003eHere’s how to copy multiple files recursively using AWS CLI. The S3 cp command by default only copies a single file. To copy multiple files, you have to use the –recursive option along with –exclude and –include. In this example, we will exclude every file, but include only files with a json extension.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3 cp /tmp/folder s3://bucket/folder \\\n  --recursive\n  --exclude \u0026#34;*\u0026#34;\n  --include \u0026#34;*.json\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe result:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eupload: ./abc.json to s3://bucket/folder/abc.json    \nupload: ./xyz.json to s3://bucket/folder/xyz.json\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli s3 recursive copy"},{"content":"Here’s a standard S3 policy to grant an IAM user access to a bucket within an AWS account. User is allowed to add, update, and delete objects. These 3 actions s3:ListAllMyBuckets, s3:GetBucketLocation, and s3:ListBucket are the additional permissions required to access the console. Also, the s3:PutObjectAcl and the s3:GetObjectAcl actions are required to be able to copy, cut, and paste objects within the console.\n{ \u0026#34;Version\u0026#34;:\u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;:[ { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:ListAllMyBuckets\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::*\u0026#34; }, { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:ListBucket\u0026#34;, \u0026#34;s3:GetBucketLocation\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::examplebucket\u0026#34; }, { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:PutObject\u0026#34;, \u0026#34;s3:PutObjectAcl\u0026#34;, \u0026#34;s3:GetObject\u0026#34;, \u0026#34;s3:GetObjectAcl\u0026#34;, \u0026#34;s3:DeleteObject\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::examplebucket/*\u0026#34; } ] } ","permalink":"http://uly.me/posts/standard-s3-policy/","summary":"\u003cp\u003eHere’s a standard S3 policy to grant an IAM user access to a bucket within an AWS account. User is allowed to add, update, and delete objects. These 3 actions s3:ListAllMyBuckets, s3:GetBucketLocation, and s3:ListBucket are the additional permissions required to access the console. Also, the s3:PutObjectAcl and the s3:GetObjectAcl actions are required to be able to copy, cut, and paste objects within the console.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n   \u0026#34;Version\u0026#34;:\u0026#34;2012-10-17\u0026#34;,\n   \u0026#34;Statement\u0026#34;:[\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:ListAllMyBuckets\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::*\u0026#34;\n      },\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:ListBucket\u0026#34;,\n            \u0026#34;s3:GetBucketLocation\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::examplebucket\u0026#34;\n      },\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:PutObject\u0026#34;,\n            \u0026#34;s3:PutObjectAcl\u0026#34;,\n            \u0026#34;s3:GetObject\u0026#34;,\n            \u0026#34;s3:GetObjectAcl\u0026#34;,\n            \u0026#34;s3:DeleteObject\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::examplebucket/*\u0026#34;\n      }\n   ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"standard s3 policy"},{"content":"Here’s a couple of things you can do to check if WordPress permalinks is not working.\nMake sure .htaccess has the right permissions. Make sure a2enmod Apache module is enabled. Restart the Apache server. chmod 664 /var/www/domain.com/.htaccess a2enmod rewrite systemctl restart apache2 ","permalink":"http://uly.me/posts/wordpress-permalinks-not-working/","summary":"\u003cp\u003eHere’s a couple of things you can do to check if WordPress permalinks is not working.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eMake sure .htaccess has the right permissions.\u003c/li\u003e\n\u003cli\u003eMake sure a2enmod Apache module is enabled.\u003c/li\u003e\n\u003cli\u003eRestart the Apache server.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echmod 664 /var/www/domain.com/.htaccess\na2enmod rewrite\nsystemctl restart apache2\n\u003c/code\u003e\u003c/pre\u003e","title":"wordpress permalinks not working"},{"content":"Here’s another way of setting Linux time zone.\nCheck server time.\n# check server time date Change to local time.\n# set to local time rm /etc/localtime ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime Check server time again.\n# check server time again date ","permalink":"http://uly.me/posts/set-linux-time-zone/","summary":"\u003cp\u003eHere’s another way of setting Linux time zone.\u003c/p\u003e\n\u003cp\u003eCheck server time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check server time\ndate\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange to local time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# set to local time\nrm /etc/localtime\nln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck server time again.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check server time again\ndate\n\u003c/code\u003e\u003c/pre\u003e","title":"set linux time zone"},{"content":"Here’s a function to convert bytes into kilo, mega, giga, tera up to zeta bytes.\nfunction convert_bytes { bytes=$credits b=${bytes:-0}; d=\u0026#39;\u0026#39;; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}B) while ((b \u0026gt; 1024)); do d=\u0026#34;$(printf \u0026#34;.%02d\u0026#34; $((b % 1000 * 100 / 1000)))\u0026#34; b=$((b / 1000)) let s++ done echo \u0026#34;$b$d ${S[$s]}\u0026#34; } credits=2308974418330 echo $credits convert_bytes $credits Result is:\n2308974418330 2.30 TB ","permalink":"http://uly.me/posts/bash-convert-bytes/","summary":"\u003cp\u003eHere’s a function to convert bytes into kilo, mega, giga, tera up to zeta bytes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction convert_bytes {\n    bytes=$credits\n    b=${bytes:-0}; d=\u0026#39;\u0026#39;; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}B)\n    while ((b \u0026gt; 1024)); do\n        d=\u0026#34;$(printf \u0026#34;.%02d\u0026#34; $((b % 1000 * 100 / 1000)))\u0026#34;\n        b=$((b / 1000))\n        let s++\n    done\n    echo \u0026#34;$b$d ${S[$s]}\u0026#34;\n}\ncredits=2308974418330\necho $credits \nconvert_bytes $credits\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult is:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e2308974418330\n2.30 TB\n\u003c/code\u003e\u003c/pre\u003e","title":"bash convert bytes"},{"content":"Tasksel is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system. It’s similar to meta-packages where tasks are dericed from from Ubuntu package managers like Synaptic or KPackageKit.\nHere’s a quickway to install a lamp server.\n# install tasksel first if you don\u0026#39;t have it. apt install tasksel # install a lamp server package tasksel install lamp-server ","permalink":"http://uly.me/posts/tasksel-lampserver/","summary":"\u003cp\u003e\u003ca href=\"http://wiki.debian.org/tasksel\"\u003eTasksel\u003c/a\u003e is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system. It’s similar to meta-packages where tasks are dericed from from Ubuntu package managers like Synaptic or KPackageKit.\u003c/p\u003e\n\u003cp\u003eHere’s a quickway to install a lamp server.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# install tasksel first if you don\u0026#39;t have it.\napt install tasksel\n# install a lamp server package\ntasksel install lamp-server\n\u003c/code\u003e\u003c/pre\u003e","title":"tasksel lampserver"},{"content":"Here’s a quick way to autogenerate salt for WordPress.\ncurl -s https://api.wordpress.org/secret-key/1.1/salt/ ","permalink":"http://uly.me/posts/wordpress-salt/","summary":"\u003cp\u003eHere’s a quick way to autogenerate salt for WordPress.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl -s https://api.wordpress.org/secret-key/1.1/salt/\n\u003c/code\u003e\u003c/pre\u003e","title":"wordpress salt"},{"content":"Here’s the script.\necho \u0026#34;deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \\ https://packages.cloud.google.com/apt cloud-sdk main\u0026#34; | \\ sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list sudo apt-get install apt-transport-https ca-certificates sudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \\ sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - sudo apt-get update \u0026amp;\u0026amp; sudo apt-get install google-cloud-sdk ","permalink":"http://uly.me/posts/google-sdk-install-on-debian-or-ubuntu/","summary":"\u003cp\u003eHere’s the script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#34;deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \\\n  https://packages.cloud.google.com/apt cloud-sdk main\u0026#34; | \\\n  sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list\nsudo apt-get install apt-transport-https ca-certificates\nsudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \\\n  sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -\nsudo apt-get update \u0026amp;\u0026amp; sudo apt-get install google-cloud-sdk\n\u003c/code\u003e\u003c/pre\u003e","title":"google sdk install on debian  or ubuntu"},{"content":"SSL certificates were uploaded to IAM prior to Certificate Manager. Unfortunately, the certificates are not visible from the IAM console. There’s no way to view when a certificate is expiring. So, here’s how to display IAM certificates from the AWS CLI.\naws iam list-server-certificates ","permalink":"http://uly.me/posts/aws-display-iam-certificates/","summary":"\u003cp\u003eSSL certificates were uploaded to IAM prior to Certificate Manager. Unfortunately, the certificates are not visible from the IAM console. There’s no way to view when a certificate is expiring. So, here’s how to display IAM certificates from the AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam list-server-certificates\n\u003c/code\u003e\u003c/pre\u003e","title":"aws display iam certificates"},{"content":"Here’s how to determine what type of USB format a thumb drive is in Linux.\ndf -Th (shows the file system type) lsblk (shows the block devices) lsusb (show usb ports and devices) fdisk -l (displays the USB format type) To display, use “fdisk -l” to display either NTFS, FAT32 or exFAT32.\n","permalink":"http://uly.me/posts/determine-usb-format-type/","summary":"\u003cp\u003eHere’s how to determine what type of USB format a thumb drive is in Linux.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003edf -Th (shows the file system type)\u003c/li\u003e\n\u003cli\u003elsblk (shows the block devices)\u003c/li\u003e\n\u003cli\u003elsusb (show usb ports and devices)\u003c/li\u003e\n\u003cli\u003efdisk -l (displays the USB format type)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eTo display, use “fdisk -l” to display either NTFS, FAT32 or exFAT32.\u003c/p\u003e","title":"determine usb format type"},{"content":"Here’s my favorite Linux prompt.\nPS1=\u0026#39;\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ \u0026#39; Add to end of your .bashrc to make it permanent.\n","permalink":"http://uly.me/posts/linux-prompt/","summary":"\u003cp\u003eHere’s my favorite Linux prompt.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePS1=\u0026#39;\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ \u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd to end of your .bashrc to make it permanent.\u003c/p\u003e","title":"linux prompt"},{"content":"Here’s how to start multiple instances using Bash and Google SDK.\n#!/bin/bash while IFS=\u0026#39;, \u0026#39; read -r a b c; do instance=\u0026#34;${a//[[:blank:]]/}\u0026#34; project=\u0026#34;${b//[[:blank:]]/}\u0026#34; zone=\u0026#34;${c//[[:blank:]]/}\u0026#34; echo \u0026#34;Starting $instance ....\u0026#34; gcloud compute instances start $instance \\ --zone $zone --project $project --async done Instances are read from an external file. The file format is displayed below.\nserver1,project1,us-central1-a server2,project2,us-central1-b server3,project3,us-central1-c To stop multiple instances, replace \u0026ldquo;start\u0026rdquo; with \u0026ldquo;stop.\u0026rdquo;\n","permalink":"http://uly.me/posts/gcp-start-multiple-instances/","summary":"\u003cp\u003eHere’s how to start multiple instances using Bash and Google SDK.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nwhile IFS=\u0026#39;, \u0026#39; read -r a b c; do\n  instance=\u0026#34;${a//[[:blank:]]/}\u0026#34;\n  project=\u0026#34;${b//[[:blank:]]/}\u0026#34;\n  zone=\u0026#34;${c//[[:blank:]]/}\u0026#34;\n  echo \u0026#34;Starting $instance ....\u0026#34;\n  gcloud compute instances start $instance \\\n  --zone $zone --project $project --async\ndone \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstances are read from an external file. The file format is displayed below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserver1,project1,us-central1-a\nserver2,project2,us-central1-b\nserver3,project3,us-central1-c\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo stop multiple instances, replace \u0026ldquo;start\u0026rdquo; with \u0026ldquo;stop.\u0026rdquo;\u003c/p\u003e","title":"gcp start multiple instances"},{"content":"Here’s how to check if instances are running in GCP.\n#!/bin/bash while IFS=\u0026#39;, \u0026#39; read -r a b c; do instance=\u0026#34;${a//[[:blank:]]/}\u0026#34; project=\u0026#34;${b//[[:blank:]]/}\u0026#34; zone=\u0026#34;${c//[[:blank:]]/}\u0026#34; gcloud compute instances describe $instance \\ --zone $zone --project $project \\ --format=\u0026#39;table[no-heading](name,status,zone)\u0026#39; done Instances are read from an external file. File is comma delimited with instance name, project id and zone data.\n","permalink":"http://uly.me/posts/gcp-check-instances-running/","summary":"\u003cp\u003eHere’s how to check if instances are running in GCP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nwhile IFS=\u0026#39;, \u0026#39; read -r a b c; do\n  instance=\u0026#34;${a//[[:blank:]]/}\u0026#34;\n  project=\u0026#34;${b//[[:blank:]]/}\u0026#34;\n  zone=\u0026#34;${c//[[:blank:]]/}\u0026#34;\n  gcloud compute instances describe $instance \\\n  --zone $zone --project $project \\\n  --format=\u0026#39;table[no-heading](name,status,zone)\u0026#39;\ndone \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstances are read from an external file. File is comma delimited with instance name, project id and zone data.\u003c/p\u003e","title":"gcp check instances running"},{"content":"If you were running the older versions of Terraform, with release 0.12 and higher, there will be certain parts of your script that are no longer supported. Terraform uses expressions for dynamic configuration and dependencies. First-class expressions enable variables and operations to be performed outside of strings. In Terraform 0.11 and earlier all expressions were required to be part of interpolations in existing strings, such as “${var.foo}.\nIn Terraform 0.11.\nresource \u0026#34;aws_instance\u0026#34; \u0026#34;example\u0026#34; { ami = \u0026#34;${var.ami}\u0026#34; instance_type = \u0026#34;${var.instance_type}\u0026#34; } In Terraform 0.12.\nresource \u0026#34;aws_instance\u0026#34; \u0026#34;example\u0026#34; { ami = var.ami instance_type = var.instance_type } Gone are quotes, curly braces and the $ sign.\n","permalink":"http://uly.me/posts/terraform-first-class-expressions/","summary":"\u003cp\u003eIf you were running the older versions of Terraform, with release 0.12 and higher, there will be certain parts of your script that are no longer supported. Terraform uses expressions for dynamic configuration and dependencies. First-class expressions enable variables and operations to be performed outside of strings. In Terraform 0.11 and earlier all expressions were required to be part of interpolations in existing strings, such as “${var.foo}.\u003c/p\u003e\n\u003cp\u003eIn Terraform 0.11.\u003c/p\u003e","title":"terraform first class expressions"},{"content":"Here’s how to add tags to an existing user.\naws iam tag-user \\ --user-name ulysses \\ --tags \u0026#34;Key\u0026#34;=\u0026#34;dept\u0026#34;,\u0026#34;Value\u0026#34;=\u0026#34;it\u0026#34; \u0026#34;Key\u0026#34;=\u0026#34;role\u0026#34;,\u0026#34;Value\u0026#34;=\u0026#34;admin\u0026#34; Tags with identical keys are overwritten. New keys are added.\n","permalink":"http://uly.me/posts/aws-iam-tag-user/","summary":"\u003cp\u003eHere’s how to add tags to an existing user.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam tag-user \\\n--user-name ulysses \\\n--tags \u0026#34;Key\u0026#34;=\u0026#34;dept\u0026#34;,\u0026#34;Value\u0026#34;=\u0026#34;it\u0026#34; \u0026#34;Key\u0026#34;=\u0026#34;role\u0026#34;,\u0026#34;Value\u0026#34;=\u0026#34;admin\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTags with identical keys are overwritten. New keys are added.\u003c/p\u003e","title":"aws iam tag user"},{"content":"To get status of a file.\nlock status -f \u0026#34;/vol/folder/path/filename.doc\u0026#34; -p cifs To unlock a file.\nlock break -f \u0026#34;/vol/folder/path/filename.doc\u0026#34; -p cifs ","permalink":"http://uly.me/posts/netapp-unlock-file/","summary":"\u003cp\u003eTo get status of a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elock status -f \u0026#34;/vol/folder/path/filename.doc\u0026#34; -p cifs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo unlock a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elock break -f \u0026#34;/vol/folder/path/filename.doc\u0026#34; -p cifs\n\u003c/code\u003e\u003c/pre\u003e","title":"netapp unlock file"},{"content":"I ran into an issue with Google Compute Engine TCP internal load balancer. The targets are unhealthy although all configs were correct installed. At one time the targets were working, but somehow they became unhealthy. In the end, 3 things needed to be checked.\nMake sure GCP’s guest environment is installed. Add the internal load balancer VIP address to the network properties. Add route via cmd. “route ADD VIP MASK 255.255.255.255” You will need to change the server’s IP from DHCP to static to add ILB VIP.\n","permalink":"http://uly.me/posts/gcp-ilb-issue-targets-not-healthy/","summary":"\u003cp\u003eI ran into an issue with Google Compute Engine TCP internal load balancer. The targets are unhealthy although all configs were correct installed. At one time the targets were working, but somehow they became unhealthy. In the end, 3 things needed to be checked.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eMake sure GCP’s guest environment is installed.\u003c/li\u003e\n\u003cli\u003eAdd the internal load balancer VIP address to the network properties.\u003c/li\u003e\n\u003cli\u003eAdd route via cmd. “route ADD VIP MASK 255.255.255.255”\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eYou will need to change the server’s IP from DHCP to static to add ILB VIP.\u003c/p\u003e","title":"gcp ilb issue targets not healthy"},{"content":"Here’s how to list all the access keys in AWS via Python.\nimport logging import boto3 from botocore.exceptions import ClientError # set aws profile session = boto3.Session(profile_name=\u0026#34;default\u0026#34;) # get list of users iam = session.client(\u0026#39;iam\u0026#39;) users = iam.list_users() # display results print(\u0026#34;{0: ","permalink":"http://uly.me/posts/iam-list-access-keys/","summary":"\u003cp\u003eHere’s how to list all the access keys in AWS via Python.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport logging\nimport boto3\nfrom botocore.exceptions import ClientError\n\n# set aws profile\nsession = boto3.Session(profile_name=\u0026#34;default\u0026#34;)\n\n# get list of users\n\niam = session.client(\u0026#39;iam\u0026#39;)\nusers = iam.list_users()\n\n# display results\nprint(\u0026#34;{0:\n\u003c/code\u003e\u003c/pre\u003e","title":"iam list access keys"},{"content":"Here’s how to add a route in Windows. Open CMD as Administrator.\nroute add 10.10.10.10 mask 255.255.255.0 10.10.10.254 To make it persistent, add -p.\nroute add 10.10.10.10 mask 255.255.255.0 10.10.10.254 To display. Specifies IP 4 only.\nroute print -4 ","permalink":"http://uly.me/posts/windows-route-add/","summary":"\u003cp\u003eHere’s how to add a route in Windows. Open CMD as Administrator.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eroute add 10.10.10.10 mask 255.255.255.0 10.10.10.254\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo make it persistent, add -p.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eroute add 10.10.10.10 mask 255.255.255.0 10.10.10.254\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo display. Specifies IP 4 only.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eroute print -4\n\u003c/code\u003e\u003c/pre\u003e","title":"windows route add"},{"content":"To check VM stats, use the following commands.\nTo see used and unused memory, swap space.\nfree To see RAM details.\nsudo dmidecode -t 17 To see number of processors.\nnproc To see CPU details.\nlscpu ","permalink":"http://uly.me/posts/vm-stats/","summary":"\u003cp\u003eTo check VM stats, use the following commands.\u003c/p\u003e\n\u003cp\u003eTo see used and unused memory, swap space.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efree\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo see RAM details.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo dmidecode -t 17\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo see number of processors.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enproc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo see CPU details.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elscpu\n\u003c/code\u003e\u003c/pre\u003e","title":"vm stats"},{"content":"Here’s a couple of steps to move a Docker image to the Google Container Registry.\nCreate a container image.\ndocker build -t gcr.io/${PROJECT_ID}/my-app:v1 . Push image to GCR.\ndocker push gcr.io/[PROJECT-ID]/[IMAGE] ","permalink":"http://uly.me/posts/docker-to-gcr/","summary":"\u003cp\u003eHere’s a couple of steps to move a Docker image to the Google Container Registry.\u003c/p\u003e\n\u003cp\u003eCreate a container image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker build -t gcr.io/${PROJECT_ID}/my-app:v1 .\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePush image to GCR.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker push gcr.io/[PROJECT-ID]/[IMAGE]\n\u003c/code\u003e\u003c/pre\u003e","title":"docker to gcr"},{"content":"When Google acquired Feedburner a few years ago, we thought it would make Feedburner a better product. The opposite has happened. Google has basically shelved the Feedburner product. There hasn’t been any updates to Feedburner the last 5 years.\nIf you’ve recently updated your site from http to https, you may have noticed that https feeds are not supported. It looks like Google doesn’t plan on updating Feedburner anytime soon. If you want to replace Feedburner, take a look at couple of options. Try FeedBlitz or perhaps even Mailchimp.\nIn addition, you can import your current subscribers, and never miss a beat.\n","permalink":"http://uly.me/posts/feedburner-https-feed/","summary":"\u003cp\u003eWhen Google acquired Feedburner a few years ago, we thought it would make Feedburner a better product. The opposite has happened. Google has basically shelved the Feedburner product. There hasn’t been any updates to Feedburner the last 5 years.\u003c/p\u003e\n\u003cp\u003eIf you’ve recently updated your site from http to https, you may have noticed that https feeds are not supported. It looks like Google doesn’t plan on updating Feedburner anytime soon. If you want to replace Feedburner, take a look at couple of options. Try FeedBlitz or perhaps even Mailchimp.\u003c/p\u003e","title":"feedburner https feed"},{"content":"If you are using AWS CloudFront, you can avoid costly invalidations by using object versioning. Due to the nature of CloudFront, overwriting to the same file will not have any effect until caching is invalidated. The default timeout for CloudFront is 24 hours. If you have a website and you’ve overwritten your logo image, the updated image file will not be reflected on your site due to the caching timeout is 24 hours. To avoid invalidation, enable object versioning by adding a policy when overwriting files.\n# Logo Image \u0026lt;a href=\u0026#34;logo.png\u0026#34;\u0026gt;Website Logo\u0026lt;/a\u0026gt; # # Implement object versioning. # Increase the filename after each logo change. # \u0026lt;a href=\u0026#34;logo-001.png\u0026#34;\u0026gt;Website Logo\u0026lt;/a\u0026gt; \u0026lt;a href=\u0026#34;logo-002.png\u0026#34;\u0026gt;Website Logo\u0026lt;/a\u0026gt; \u0026lt;a href=\u0026#34;logo-003.png\u0026#34;\u0026gt;Website Logo\u0026lt;/a\u0026gt; \u0026lt;a href=\u0026#34;logo-004.png\u0026#34;\u0026gt;Website Logo\u0026lt;/a\u0026gt; Each time the logo is updated, change the filename to avoid CloudFront invalidation.\n","permalink":"http://uly.me/posts/use-object-versioning-with-cloudfront/","summary":"\u003cp\u003eIf you are using AWS CloudFront, you can avoid costly invalidations by using object versioning. Due to the nature of CloudFront, overwriting to the same file will not have any effect until caching is invalidated. The default timeout for CloudFront is 24 hours. If you have a website and you’ve overwritten your logo image, the updated image file will not be reflected on your site due to the caching timeout is 24 hours. To avoid invalidation, enable object versioning by adding a policy when overwriting files.\u003c/p\u003e","title":"use object versioning with cloudfront"},{"content":"Boto is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure, and manage AWS services, such as EC2 and S3. Boto provides an easy to use, object-oriented API, as well as low-level access to AWS services.\nHere’s a quick example how to query for AWS resources.\nimport logging import boto3 from botocore.exceptions import ClientError # set aws profile session = boto3.Session(profile_name=\u0026#34;default\u0026#34;) # get buckets s3 = session.client(\u0026#39;s3\u0026#39;) results = s3.list_buckets() # display buckets print(\u0026#39;Existing buckets:\u0026#39;) for key in results[\u0026#39;Buckets\u0026#39;]: print(f\u0026#39;{key[\u0026#34;Name\u0026#34;]}\u0026#39;) # get ec2 instances. set region. ec2 = session.client(\u0026#39;ec2\u0026#39;, region_name=\u0026#39;us-east-1\u0026#39;) results = ec2.describe_instances() # display instances for key in results[\u0026#34;Reservations\u0026#34;]: for instance in key[\u0026#34;Instances\u0026#34;]: instance_id = instance[\u0026#34;InstanceId\u0026#34;] instance_type = instance[\u0026#34;InstanceType\u0026#34;] availability_zone = instance[\u0026#34;Placement\u0026#34;][\u0026#34;AvailabilityZone\u0026#34;] print(instance_id + \u0026#34;\\t\u0026#34; + instance_type + \u0026#34;\\t\u0026#34; + availability_zone) # get list of users client = session.client(\u0026#39;iam\u0026#39;) results = client.list_users() # display list of users for key in results[\u0026#39;Users\u0026#39;]: print (key[\u0026#39;UserName\u0026#39;]) ","permalink":"http://uly.me/posts/aws-boto3-client/","summary":"\u003cp\u003eBoto is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure, and manage AWS services, such as EC2 and S3. Boto provides an easy to use, object-oriented API, as well as low-level access to AWS services.\u003c/p\u003e\n\u003cp\u003eHere’s a quick example how to query for AWS resources.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport logging\nimport boto3\nfrom botocore.exceptions import ClientError\n\n# set aws profile\nsession = boto3.Session(profile_name=\u0026#34;default\u0026#34;)\n\n# get buckets\ns3 = session.client(\u0026#39;s3\u0026#39;)\nresults = s3.list_buckets()\n\n# display buckets\nprint(\u0026#39;Existing buckets:\u0026#39;)\nfor key in results[\u0026#39;Buckets\u0026#39;]:\n    print(f\u0026#39;{key[\u0026#34;Name\u0026#34;]}\u0026#39;)\n\n# get ec2 instances. set region.\nec2 = session.client(\u0026#39;ec2\u0026#39;, region_name=\u0026#39;us-east-1\u0026#39;)\nresults = ec2.describe_instances()\n\n# display instances\nfor key in results[\u0026#34;Reservations\u0026#34;]:\n      for instance in key[\u0026#34;Instances\u0026#34;]:\n           instance_id = instance[\u0026#34;InstanceId\u0026#34;]\n           instance_type = instance[\u0026#34;InstanceType\u0026#34;]\n           availability_zone = instance[\u0026#34;Placement\u0026#34;][\u0026#34;AvailabilityZone\u0026#34;]\n           print(instance_id + \u0026#34;\\t\u0026#34; + instance_type + \u0026#34;\\t\u0026#34; + availability_zone)\n\n# get list of users\nclient = session.client(\u0026#39;iam\u0026#39;)\nresults = client.list_users()\n\n# display list of users\nfor key in results[\u0026#39;Users\u0026#39;]:\n    print (key[\u0026#39;UserName\u0026#39;])\n\u003c/code\u003e\u003c/pre\u003e","title":"aws boto3 client"},{"content":"Here’s a quick script to stand up a web server based on Centos image.\ngcloud compute instances create [VM-NAME] \\ --zone=[ZONE] \\ --image-family=debian-9 \\ --image-project=debian-cloud \\ --tags=allow-ssh,allow-health-check \\ --subnet=lb-subnet \\ --metadata=startup-script=\u0026#39;#! /bin/bash apt-get update apt-get install apache2 -y a2ensite default-ssl a2enmod ssl vm_hostname=\u0026#34;$(curl -H \u0026#34;Metadata-Flavor:Google\u0026#34; \\ http://169.254.169.254/computeMetadata/v1/instance/name)\u0026#34; echo \u0026#34;Page served from: $vm_hostname\u0026#34; | \\ tee /var/www/html/index.html systemctl restart apache2\u0026#39; ","permalink":"http://uly.me/posts/gcp-web-server/","summary":"\u003cp\u003eHere’s a quick script to stand up a web server based on Centos image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances create [VM-NAME] \\\n    --zone=[ZONE] \\\n    --image-family=debian-9 \\\n    --image-project=debian-cloud \\\n    --tags=allow-ssh,allow-health-check \\\n    --subnet=lb-subnet \\\n    --metadata=startup-script=\u0026#39;#! /bin/bash\napt-get update\napt-get install apache2 -y\na2ensite default-ssl\na2enmod ssl\nvm_hostname=\u0026#34;$(curl -H \u0026#34;Metadata-Flavor:Google\u0026#34; \\\nhttp://169.254.169.254/computeMetadata/v1/instance/name)\u0026#34;\necho \u0026#34;Page served from: $vm_hostname\u0026#34; | \\\ntee /var/www/html/index.html\nsystemctl restart apache2\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp web server"},{"content":"How to split a large file.\nsplit -b 500MB httpd.log ll -lh total 1.9G -rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log -rw-r--r-- 1 root root 477M Mar 25 12:38 xaa -rw-r--r-- 1 root root 477M Mar 25 12:38 xab Split with an output file.\nsplit -b 200M httpd.log split.log ll -lh total 1.9G -rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logaa -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logab -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logac -rw-r--r-- 1 root root 200M Mar 25 12:52 split.logad -rw-r--r-- 1 root root 154M Mar 25 12:52 split.logae ","permalink":"http://uly.me/posts/split-a-large-file/","summary":"\u003cp\u003eHow to split a large file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esplit -b 500MB httpd.log\nll -lh\ntotal 1.9G\n-rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log\n-rw-r--r-- 1 root root 477M Mar 25 12:38 xaa\n-rw-r--r-- 1 root root 477M Mar 25 12:38 xab\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSplit with an output file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esplit -b 200M httpd.log split.log\nll -lh\ntotal 1.9G\n-rw-r--r-- 1 root root 954M Mar 25 12:35 httpd.log\n-rw-r--r-- 1 root root 200M Mar 25 12:52 split.logaa\n-rw-r--r-- 1 root root 200M Mar 25 12:52 split.logab\n-rw-r--r-- 1 root root 200M Mar 25 12:52 split.logac\n-rw-r--r-- 1 root root 200M Mar 25 12:52 split.logad\n-rw-r--r-- 1 root root 154M Mar 25 12:52 split.logae\n\u003c/code\u003e\u003c/pre\u003e","title":"split a large file"},{"content":"SCP is similar to the CP or copy command, but it’s done via a secure network.\nHere’s a CP command.\ncp /dir1/filename /dir2 You can use SCP to copy file to another system. It requires login.\nscp /dir1/filename user@server:/home/user This is using SCP to copy a file from 2 remote systems.\nscp user@host1:/home/user/dir1/file.txt user@host2:/home/user/dir2 ","permalink":"http://uly.me/posts/scp/","summary":"\u003cp\u003eSCP is similar to the CP or copy command, but it’s done via a secure network.\u003c/p\u003e\n\u003cp\u003eHere’s a CP command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecp /dir1/filename /dir2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can use SCP to copy file to another system. It requires login.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escp /dir1/filename user@server:/home/user\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is using SCP to copy a file from 2 remote systems.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003escp user@host1:/home/user/dir1/file.txt user@host2:/home/user/dir2\n\u003c/code\u003e\u003c/pre\u003e","title":"scp"},{"content":"Here’s how to get the EFS Burst Credits from CloudWatch via AWS CLI.\naws cloudwatch get-metric-statistics \\ --namespace \u0026#34;AWS/EFS\u0026#34; \\ --metric-name BurstCreditBalance \\ --dimensions \u0026#34;Name=FileSystemId,Value=fs-xxxxxxx\u0026#34; \\ --start-time 2019-12-31T00:00:00Z \\ --end-time 2019-12-31T01:00:00Z \\ --statistics Average \\ --period 3600 \\ --profile default Notice the start time, end time, period and statistics. Here’s the CLI doc.\n","permalink":"http://uly.me/posts/aws-cloudwatch-efs-burst-credits/","summary":"\u003cp\u003eHere’s how to get the EFS Burst Credits from CloudWatch via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws cloudwatch get-metric-statistics \\\n--namespace \u0026#34;AWS/EFS\u0026#34; \\\n--metric-name BurstCreditBalance \\\n--dimensions \u0026#34;Name=FileSystemId,Value=fs-xxxxxxx\u0026#34; \\\n--start-time 2019-12-31T00:00:00Z \\\n--end-time 2019-12-31T01:00:00Z \\\n--statistics Average \\\n--period 3600 \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNotice the start time, end time, period and statistics. Here’s the CLI \u003ca href=\"https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html\"\u003edoc\u003c/a\u003e.\u003c/p\u003e","title":"aws cloudwatch efs burst credits"},{"content":"Here’s the IAM policy to allow RDS Backup or create a snapshot on AWS.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;VisualEditor0\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;rds:RestoreDBClusterFromSnapshot\u0026#34;, \u0026#34;rds:DescribeDBSnapshots\u0026#34;, \u0026#34;rds:CopyDBSnapshot\u0026#34;, \u0026#34;rds:CopyDBClusterSnapshot\u0026#34;, \u0026#34;rds:DeleteDBSnapshot\u0026#34;, \u0026#34;rds:DeleteDBClusterSnapshot\u0026#34;, \u0026#34;rds:CreateDBSnapshot\u0026#34;, \u0026#34;rds:RestoreDBInstanceFromDBSnapshot\u0026#34;, \u0026#34;rds:CreateDBInstance\u0026#34;, \u0026#34;rds:DescribeDBClusterSnapshots\u0026#34;, \u0026#34;rds:DescribeDBInstances\u0026#34;, \u0026#34;rds:DescribeDBClusters\u0026#34;, \u0026#34;rds:DeleteDBInstance\u0026#34;, \u0026#34;rds:CreateDBClusterSnapshot\u0026#34;, \u0026#34;rds:ModifyDBSnapshotAttribute\u0026#34;, \u0026#34;rds:ModifyDBClusterSnapshotAttribute\u0026#34;, \u0026#34;rds:ListTagsForResource\u0026#34;, \u0026#34;rds:DeleteDBCluster\u0026#34;, \u0026#34;ec2:DescribeSecurityGroups\u0026#34;, \u0026#34;ec2:DescribeRegions\u0026#34;, \u0026#34;ec2:DescribeAvailabilityZones\u0026#34;, \u0026#34;ec2:DescribeVpcs\u0026#34;, \u0026#34;ec2:DescribeAccountAttributes\u0026#34;, \u0026#34;ec2:DescribeSubnets\u0026#34;, \u0026#34;iam:GetUser\u0026#34;, \u0026#34;iam:GetAccountAuthorizationDetails\u0026#34;, \u0026#34;kms:ReEncrypt*\u0026#34;, \u0026#34;kms:GenerateDataKey*\u0026#34;, \u0026#34;kms:CreateGrant\u0026#34;, \u0026#34;kms:DescribeKey*\u0026#34;, \u0026#34;kms:ListKeys\u0026#34;, \u0026#34;kms:ListAliases\u0026#34;, \u0026#34;kms:Encrypt\u0026#34;, \u0026#34;kms:Decrypt\u0026#34;, \u0026#34;kms:GenerateDataKeyWithoutPlaintext\u0026#34;, \u0026#34;kms:ListKeys\u0026#34;, \u0026#34;kms:ListAliases\u0026#34;, \u0026#34;kms:ListResourceTags\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-rds-backup-permission/","summary":"\u003cp\u003eHere’s the IAM policy to allow RDS Backup or create a snapshot on AWS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;VisualEditor0\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;rds:RestoreDBClusterFromSnapshot\u0026#34;,\n\t\t\u0026#34;rds:DescribeDBSnapshots\u0026#34;,\n\t\t\u0026#34;rds:CopyDBSnapshot\u0026#34;,\n\t\t\u0026#34;rds:CopyDBClusterSnapshot\u0026#34;,\n\t\t\u0026#34;rds:DeleteDBSnapshot\u0026#34;,\n\t\t\u0026#34;rds:DeleteDBClusterSnapshot\u0026#34;,\n\t\t\u0026#34;rds:CreateDBSnapshot\u0026#34;,\n\t\t\u0026#34;rds:RestoreDBInstanceFromDBSnapshot\u0026#34;,\n\t\t\u0026#34;rds:CreateDBInstance\u0026#34;,\n\t\t\u0026#34;rds:DescribeDBClusterSnapshots\u0026#34;,\n\t\t\u0026#34;rds:DescribeDBInstances\u0026#34;,\n\t\t\u0026#34;rds:DescribeDBClusters\u0026#34;,\n\t\t\u0026#34;rds:DeleteDBInstance\u0026#34;,\n\t\t\u0026#34;rds:CreateDBClusterSnapshot\u0026#34;,\n\t\t\u0026#34;rds:ModifyDBSnapshotAttribute\u0026#34;,\n\t\t\u0026#34;rds:ModifyDBClusterSnapshotAttribute\u0026#34;,\n\t\t\u0026#34;rds:ListTagsForResource\u0026#34;,\n\t\t\u0026#34;rds:DeleteDBCluster\u0026#34;,\n\t\t\u0026#34;ec2:DescribeSecurityGroups\u0026#34;,\n\t\t\u0026#34;ec2:DescribeRegions\u0026#34;,\n\t\t\u0026#34;ec2:DescribeAvailabilityZones\u0026#34;,\n\t\t\u0026#34;ec2:DescribeVpcs\u0026#34;,\n\t\t\u0026#34;ec2:DescribeAccountAttributes\u0026#34;,\n\t\t\u0026#34;ec2:DescribeSubnets\u0026#34;,\n\t\t\u0026#34;iam:GetUser\u0026#34;,\n\t\t\u0026#34;iam:GetAccountAuthorizationDetails\u0026#34;,\n\t\t\u0026#34;kms:ReEncrypt*\u0026#34;,\n\t\t\u0026#34;kms:GenerateDataKey*\u0026#34;,\n\t\t\u0026#34;kms:CreateGrant\u0026#34;,\n\t\t\u0026#34;kms:DescribeKey*\u0026#34;,\n\t\t\u0026#34;kms:ListKeys\u0026#34;,\n\t\t\u0026#34;kms:ListAliases\u0026#34;,\n\t\t\u0026#34;kms:Encrypt\u0026#34;,\n\t\t\u0026#34;kms:Decrypt\u0026#34;,\n\t\t\u0026#34;kms:GenerateDataKeyWithoutPlaintext\u0026#34;,\n\t\t\u0026#34;kms:ListKeys\u0026#34;,\n\t\t\u0026#34;kms:ListAliases\u0026#34;,\n\t\t\u0026#34;kms:ListResourceTags\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws rds backup permission"},{"content":"If WordPress is asking for FTP details when you’re trying to update a theme, plugin, or WordPress itself, you will need to edit your wp-config.php file to add the following line to your configuration.\ndefine(\u0026#39;FS_METHOD\u0026#39;,\u0026#39;direct\u0026#39;); Save the file and try updating again. It shouldn’t ask you for FTP details.\n","permalink":"http://uly.me/posts/wordpress-asking-for-ftp-details/","summary":"\u003cp\u003eIf WordPress is asking for FTP details when you’re trying to update a theme, plugin, or WordPress itself, you will need to edit your wp-config.php file to add the following line to your configuration.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edefine(\u0026#39;FS_METHOD\u0026#39;,\u0026#39;direct\u0026#39;);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSave the file and try updating again. It shouldn’t ask you for FTP details.\u003c/p\u003e","title":"wordpress asking for ftp details"},{"content":"This Docker image contains Apache (httpd), a web server.\nHere’s the Dockerfile.\nFROM httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/ Build and run your Docker image.\ndocker build -t my-app . docker run -dit --name my-running-app -p 8080:80 my-app Visit http://localhost:8080 to view your app.\n","permalink":"http://uly.me/posts/apache-dockerfile/","summary":"\u003cp\u003eThis Docker image contains Apache (httpd), a web server.\u003c/p\u003e\n\u003cp\u003eHere’s the Dockerfile.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFROM httpd:2.4\nCOPY ./public-html/ /usr/local/apache2/htdocs/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBuild and run your Docker image.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker build -t my-app .\ndocker run -dit --name my-running-app -p 8080:80 my-app\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVisit http://localhost:8080 to view your app.\u003c/p\u003e","title":"apache dockerfile"},{"content":"Create a static IP.\ngcloud compute addresses create your-app-static-ip \\ --region us-central1 List static IP.\ngcloud compute addresses list your-static-ip-name --region us-central1 # or gcloud compute addresses list --filter=\u0026#34;name=(\u0026#39;live-tfc-static-ip-address\u0026#39;)\u0026#34; Release static IP.\ngcloud compute addresses delete your-app-static-ip \\ --region us-central1 ","permalink":"http://uly.me/posts/gcp-static-ip/","summary":"\u003cp\u003eCreate a static IP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses create your-app-static-ip \\\n--region us-central1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList static IP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses list your-static-ip-name --region us-central1\n# or\ngcloud compute addresses list --filter=\u0026#34;name=(\u0026#39;live-tfc-static-ip-address\u0026#39;)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRelease static IP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute addresses delete your-app-static-ip \\\n--region us-central1\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp static ip"},{"content":"Here’s how to run your web application on Google Kubernetes Engine.\nCreate a Dockerfile. Place your web pages in the public-html directory.\nFROM httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/ Build a container image for Google Container Registry (GCR).\n# set your project export PROJECT_ID=[project_id] # build a container image docker build -t gcr.io/${PROJECT_ID}/your-app:v1 . # verify docker images docker images Upload the container image to GCR.\n# authenticate gcloud auth configure-docker # upload image docker push gcr.io/${PROJECT_ID}/your-app:v1 Create a container GKE cluster.\n# create cluster gcloud container clusters create your-app-cluster \\ --num-nodes=2 # check clusters gcloud compute instances list Deploy your web application.\n# create deployment kubectl create deployment your-app \\ --image=gcr.io/${PROJECT_ID}/your-app:v1 # see the pods kubectl get pods Expose your application to the Internet.\n# expose your application kubectl expose deployment your-app \\ --type=LoadBalancer \\ --port 80 \\ --target-port 80 # get the external ip address kubectl get service Scale your application.\n# scale to 3 replicas kubectl scale deployment your-app --replicas=3 # display the replicas kubectl get deployment your-app Cleanup.\nkubectl delete service your-app gcloud container clusters delete your-app-cluster ","permalink":"http://uly.me/posts/static-website-on-gke/","summary":"\u003cp\u003eHere’s how to run your web application on Google Kubernetes Engine.\u003c/p\u003e\n\u003cp\u003eCreate a Dockerfile. Place your web pages in the public-html directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFROM httpd:2.4\nCOPY ./public-html/ /usr/local/apache2/htdocs/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBuild a container image for Google Container Registry (GCR).\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# set your project\nexport PROJECT_ID=[project_id]\n# build a container image\ndocker build -t gcr.io/${PROJECT_ID}/your-app:v1 .\n# verify docker images\ndocker images\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUpload the container image to GCR.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# authenticate\ngcloud auth configure-docker\n# upload image\ndocker push gcr.io/${PROJECT_ID}/your-app:v1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a container GKE cluster.\u003c/p\u003e","title":"static website on gke"},{"content":"I tried running git after the Mac OS Catalina upgrade and got this error.\nxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Here’s the fix. For some very odd reason, Apple does not automatically reinstall xcode after each Mac OS upgrade.\nYou will need to either reset it or install it again.\n# Try reset first xcode-select --reset # Or install it if reset doesn\u0026#39;t work xcode-select --install Close your terminal, and reopen and run git again.\n","permalink":"http://uly.me/posts/xcode-after-catalina-upgrade/","summary":"\u003cp\u003eI tried running git after the Mac OS Catalina upgrade and got this error.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003excrun: error: invalid active developer path (/Library/Developer/CommandLineTools),\nmissing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the fix. For some very odd reason, Apple does not automatically reinstall xcode after each Mac OS upgrade.\u003c/p\u003e\n\u003cp\u003eYou will need to either reset it or install it again.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Try reset first\nxcode-select --reset\n# Or install it if reset doesn\u0026#39;t work\nxcode-select --install\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eClose your terminal, and reopen and run git again.\u003c/p\u003e","title":"xcode after catalina upgrade"},{"content":"Here’s how to login to GCP from Google SDK.\ngcloud auth login Click on the URL to authenticate on your browser. Login with your Google Account. Use MFA if prompted. Click Allow when prompted. You will then be taken to a page that you have successfully logged in.\n","permalink":"http://uly.me/posts/gcp-sdk-auth-login/","summary":"\u003cp\u003eHere’s how to login to GCP from Google SDK.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth login\n\u003c/code\u003e\u003c/pre\u003e\u003cul\u003e\n\u003cli\u003eClick on the URL to authenticate on your browser.\u003c/li\u003e\n\u003cli\u003eLogin with your Google Account. Use MFA if prompted.\u003c/li\u003e\n\u003cli\u003eClick Allow when prompted.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eYou will then be taken to a page that you have successfully logged in.\u003c/p\u003e","title":"gcp sdk auth login"},{"content":"To automatically mount a EFS volume after each reboot, you’ll need to add the following format to /etc/fstab.\nYou can use the DNS name given by AWS.\nfs-12345678:/ /mnt/efs efs defaults,_netdev 0 0 Or the IP address.\n10.0.0.22:/ /mnt/efs efs defaults,_netdev 0 0 Mount all with fake and verbose.\nmount -fav ","permalink":"http://uly.me/posts/aws-efs-etc-fstab/","summary":"\u003cp\u003eTo automatically mount a EFS volume after each reboot, you’ll need to add the following format to /etc/fstab.\u003c/p\u003e\n\u003cp\u003eYou can use the DNS name given by AWS.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efs-12345678:/ /mnt/efs efs defaults,_netdev 0 0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr the IP address.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e10.0.0.22:/ /mnt/efs efs defaults,_netdev 0 0\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount all with fake and verbose.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emount -fav\n\u003c/code\u003e\u003c/pre\u003e","title":"aws efs /etc/fstab"},{"content":"Here’s how to setup a Network Load Balancer in GCP.\nSetup your instances.\n# Instance 1 gcloud compute instances create www1 \\ --image-family debian-9 \\ --image-project debian-cloud \\ --zone us-central1-b \\ --tags network-lb-tag \\ --metadata startup-script=\u0026#34;#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo \u0026#39;\u0026lt;h1\u0026gt;www1\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html EOF\u0026#34; # Instance 2 gcloud compute instances create www2 \\ --image-family debian-9 \\ --image-project debian-cloud \\ --zone us-central1-b \\ --tags network-lb-tag \\ --metadata startup-script=\u0026#34;#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo \u0026#39;\u0026lt;h1\u0026gt;www2\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html EOF\u0026#34; # Instance 3 gcloud compute instances create www3 \\ --image-family debian-9 \\ --image-project debian-cloud \\ --zone us-central1-b \\ --tags network-lb-tag \\ --metadata startup-script=\u0026#34;#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo \u0026#39;\u0026lt;h1\u0026gt;www3\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html EOF\u0026#34; Create a firewall to allow external traffic to reach port 80.\ngcloud compute firewall-rules create www-firewall-network-lb \\ --target-tags network-lb-tag --allow tcp:80 Configure your network load balancer.\n# Create an external IP address. gcloud compute addresses create network-lb-ip-1 \\ --region us-central1 # Add a legacy HTTP health check. gcloud compute http-health-checks create basic-check # Add a target pool. gcloud compute target-pools add-instances www-pool \\ --instances www1,www2,www3 \\ --instances-zone us-central1-b # Add a forwarding rule. gcloud compute forwarding-rules create www-rule \\ --region us-central1 \\ --ports 80 \\ --address network-lb-ip-1 \\ --target-pool www-pool # Lookup external IP address. gcloud compute forwarding-rules describe www-rule \\ --region us-central1 Finally, use the curl command to send traffic to the NLB external IP address.\nwhile true; do curl -m1 [IP_ADDRESS]; done ","permalink":"http://uly.me/posts/gcp-setup-nlb/","summary":"\u003cp\u003eHere’s how to setup a Network Load Balancer in GCP.\u003c/p\u003e\n\u003cp\u003eSetup your instances.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Instance 1\ngcloud compute instances create www1 \\\n  --image-family debian-9 \\\n  --image-project debian-cloud \\\n  --zone us-central1-b \\\n  --tags network-lb-tag \\\n  --metadata startup-script=\u0026#34;#! /bin/bash\n    sudo apt-get update\n    sudo apt-get install apache2 -y\n    sudo service apache2 restart\n    echo \u0026#39;\u0026lt;h1\u0026gt;www1\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html\n    EOF\u0026#34;\n# Instance 2\ngcloud compute instances create www2 \\\n  --image-family debian-9 \\\n  --image-project debian-cloud \\\n  --zone us-central1-b \\\n  --tags network-lb-tag \\\n  --metadata startup-script=\u0026#34;#! /bin/bash\n    sudo apt-get update\n    sudo apt-get install apache2 -y\n    sudo service apache2 restart\n    echo \u0026#39;\u0026lt;h1\u0026gt;www2\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html\n    EOF\u0026#34;\n# Instance 3\ngcloud compute instances create www3 \\\n  --image-family debian-9 \\\n  --image-project debian-cloud \\\n  --zone us-central1-b \\\n  --tags network-lb-tag \\\n  --metadata startup-script=\u0026#34;#! /bin/bash\n    sudo apt-get update\n    sudo apt-get install apache2 -y\n    sudo service apache2 restart\n    echo \u0026#39;\u0026lt;h1\u0026gt;www3\u0026lt;/h1\u0026gt;\u0026#39; | tee /var/www/html/index.html\n    EOF\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a firewall to allow external traffic to reach port 80.\u003c/p\u003e","title":"gcp setup nlb"},{"content":"Here’s a few commands to create, delete and disable AWS user keys.\nList user keys.\naws iam list-access-keys --user-name john.doe Create access key. Results are printed on screen in JSON format.\naws iam create-access-key --user-name john.doe Disable a key. The real key id is obfuscated.\naws iam update-access-key \\ --access-key-id ******************** \\ --status Inactive \\ --user-name john.doe Delete a key. They real key id is obfuscated.\naws iam delete-access-key \\ --access-key-id ******************** \\ --user-name john.doe ","permalink":"http://uly.me/posts/aws-cli-iam-keys/","summary":"\u003cp\u003eHere’s a few commands to create, delete and disable AWS user keys.\u003c/p\u003e\n\u003cp\u003eList user keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam list-access-keys --user-name john.doe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate access key. Results are printed on screen in JSON format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam create-access-key --user-name john.doe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable a key. The real key id is obfuscated.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam update-access-key \\\n--access-key-id ******************** \\\n--status Inactive \\\n--user-name john.doe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete a key. They real key id is obfuscated.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam delete-access-key \\\n--access-key-id ******************** \\\n--user-name john.doe\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli iam keys"},{"content":"Here’s the policy for S3 replication between regions.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Action\u0026#34;: [ \u0026#34;s3:Get*\u0026#34;, \u0026#34;s3:ListBucket\u0026#34; ], \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:s3:::source-bucket-name\u0026#34;, \u0026#34;arn:aws:s3:::source-bucket-name/*\u0026#34; ] }, { \u0026#34;Action\u0026#34;: [ \u0026#34;s3:ReplicateObject\u0026#34;, \u0026#34;s3:ReplicateDelete\u0026#34;, \u0026#34;s3:ReplicateTags\u0026#34;, \u0026#34;s3:GetObjectVersionTagging\u0026#34; ], \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::destination-bucket-name/*\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-s3-replication-policy/","summary":"\u003cp\u003eHere’s the policy for S3 replication between regions.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;s3:Get*\u0026#34;,\n                \u0026#34;s3:ListBucket\u0026#34;\n            ],\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Resource\u0026#34;: [\n                \u0026#34;arn:aws:s3:::source-bucket-name\u0026#34;,\n                \u0026#34;arn:aws:s3:::source-bucket-name/*\u0026#34;\n            ]\n        },\n        {\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;s3:ReplicateObject\u0026#34;,\n                \u0026#34;s3:ReplicateDelete\u0026#34;,\n                \u0026#34;s3:ReplicateTags\u0026#34;,\n                \u0026#34;s3:GetObjectVersionTagging\u0026#34;\n            ],\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::destination-bucket-name/*\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws s3 replication policy"},{"content":"You can use the curl command to test if your load balancer is working as expected. The curl command will alternately and randomly access several instances in your load balancer. If you have 3 instances behind your load balancer, it will be cycled across all 3. The -m1 command means max time is set to 1 second.\nwhile true; do curl -m1 [IP_ADDRESS]; done ","permalink":"http://uly.me/posts/use-curl-on-load-balancers/","summary":"\u003cp\u003eYou can use the curl command to test if your load balancer is working as expected. The curl command will alternately and randomly access several instances in your load balancer. If you have 3 instances behind your load balancer, it will be cycled across all 3. The -m1 command means max time is set to 1 second.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewhile true; do curl -m1 [IP_ADDRESS]; done\n\u003c/code\u003e\u003c/pre\u003e","title":"use curl on load balancers"},{"content":"Moving a GCP instance to another zone is actually much simpler than initially thought. It’s just a single gcloud command.\ngcloud compute instances move instance-name \\ --zone us-central1-a \\ --destination-zone us-central1-b A few details about moving to another zone.\nVM has to be running. You may get a new internal or external IP address Local SSDs are ephemeral, so you can’t move them. When moving between regions, you may have to select a subnetwork. You may have to change GPUs available in the destination if you use them. ","permalink":"http://uly.me/posts/gcp-move-instance-to-another-zone/","summary":"\u003cp\u003eMoving a GCP instance to another zone is actually much simpler than initially thought. It’s just a single gcloud command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances move instance-name \\\n--zone us-central1-a \\\n--destination-zone us-central1-b\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eA few details about moving to another zone.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eVM has to be running.\u003c/li\u003e\n\u003cli\u003eYou may get a new internal or external IP address\u003c/li\u003e\n\u003cli\u003eLocal SSDs are ephemeral, so you can’t move them.\u003c/li\u003e\n\u003cli\u003eWhen moving between regions, you may have to select a subnetwork.\u003c/li\u003e\n\u003cli\u003eYou may have to change GPUs available in the destination if you use them.\u003c/li\u003e\n\u003c/ul\u003e","title":"gcp move instance to another zone"},{"content":"Here’s a quick way how to find which Java version you are running.\nwhich java java -version ","permalink":"http://uly.me/posts/which-java-version/","summary":"\u003cp\u003eHere’s a quick way how to find which Java version you are running.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewhich java\njava -version\n\u003c/code\u003e\u003c/pre\u003e","title":"which java version"},{"content":"Here’s how to copy a disk from one project to another.\ngcloud compute disks create lamp-server \\ --source-snapshot https://www.googleapis.com/compute/v1/projects/project-id/global/snapshots/lamp-server \\ --project next-project-id \\ --zone us-central1-a Once all the disks are copied. You can create a snapshot of the boot.\ngcloud compute disks snapshot lamp-server Create an instance from snapshot.\ngcloud compute disks create \u0026#34;hostname-boot\u0026#34; \\ --project \u0026#34;project-id\u0026#34; \\ --zone \u0026#34;us-central1-a\u0026#34; \\ --source-snapshot \u0026#34;snapshot-name\u0026#34; \\ --type \u0026#34;pd-standard\u0026#34; \\ --size \u0026#34;100\u0026#34; ","permalink":"http://uly.me/posts/gcp-move-instance-to-another-project/","summary":"\u003cp\u003eHere’s how to copy a disk from one project to another.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create lamp-server \\\n--source-snapshot https://www.googleapis.com/compute/v1/projects/project-id/global/snapshots/lamp-server \\\n--project next-project-id \\\n--zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce all the disks are copied. You can create a snapshot of the boot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks snapshot lamp-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an instance from snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create \u0026#34;hostname-boot\u0026#34; \\\n--project \u0026#34;project-id\u0026#34; \\\n--zone \u0026#34;us-central1-a\u0026#34; \\\n--source-snapshot \u0026#34;snapshot-name\u0026#34; \\\n--type \u0026#34;pd-standard\u0026#34; \\\n--size \u0026#34;100\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp move instance to another project"},{"content":"How to find out if a Windows Server was last patched.\nFrom Powershell, run this command.\nget-hotfix From the command line, run this command.\nC:\\\u0026gt; systeminfo.exe Or from the menu, follow these steps.\nOpen the Windows Settings UI. Click on Update \u0026amp; security. Click on the \u0026#34;Update history\u0026#34; link located under the Windows Update tab. ","permalink":"http://uly.me/posts/get-hotfix-2/","summary":"\u003cp\u003eHow to find out if a Windows Server was last patched.\u003c/p\u003e\n\u003cp\u003eFrom Powershell, run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eget-hotfix\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFrom the command line, run this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eC:\\\u0026gt; systeminfo.exe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr from the menu, follow these steps.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eOpen the Windows Settings UI.\nClick on Update \u0026amp; security.\nClick on the \u0026#34;Update history\u0026#34; link located under the Windows Update tab.\n\u003c/code\u003e\u003c/pre\u003e","title":"get-hotfix"},{"content":"If you’ve recently upgraded your Mac to Catalina or Mac OS 10.15.1, you may have noticed that Audacity is no longer working. To get it working, you’ll need to download version Audacity 2.3.3. However, installing and running it normally the way you’ve done it in the past will not be enough. Because of Catalina, Audacity is not able to gain permissions to the microphone inputs. The only way I was able to get it working is to launch Audacity from the Terminal.\nLaunch Audacity from the Terminal.\n# cd to Application directory cd /Applications/Audacity.app/Contents/MacOS # Run it in the background bash Audacity.sh \u0026amp; Click Ok if prompted to use the microphone.\n","permalink":"http://uly.me/posts/audacity-on-catalina/","summary":"\u003cp\u003eIf you’ve recently upgraded your Mac to Catalina or Mac OS 10.15.1, you may have noticed that Audacity is no longer working. To get it working, you’ll need to download version Audacity 2.3.3. However, installing and running it normally the way you’ve done it in the past will not be enough. Because of Catalina, Audacity is not able to gain permissions to the microphone inputs. The only way I was able to get it working is to launch Audacity from the Terminal.\u003c/p\u003e","title":"audacity on catalina"},{"content":"GCP Cloud Filestore is a managed file storage service for applications that require a filesystem interface and a shared filesystem for data. Filestore gives users a simple, native experience for standing up managed Network Attached Storage (NAS) with their Google Compute Engine and Kubernetes Engine instances.\nWith that said, let’s build one.\ngcloud filestore instances create nfs-server \\ --project=[PROJECT_ID] \\ --zone=us-central1-c \\ --tier=STANDARD \\ --file-share=name=\u0026#34;vol1\u0026#34;,capacity=1TB \\ --network=name=\u0026#34;default\u0026#34; How to mount the filestore on clients.\nsudo apt-get -y update sudo apt-get -y install nfs-common sudo mkdir /mnt/test sudo mount 10.0.0.2:/vol1 /mnt/test sudo chmod go+rw /mnt/test Increase capacity to 3TB.\ngcloud filestore instances update nfs-server --project=myproject --zone=us-central1-c --file-share=name=\u0026#34;vol1\u0026#34;,capacity=3TB ","permalink":"http://uly.me/posts/gcp-create-filestore/","summary":"\u003cp\u003eGCP Cloud Filestore is a managed file storage service for applications that require a filesystem interface and a shared filesystem for data. Filestore gives users a simple, native experience for standing up managed Network Attached Storage (NAS) with their Google Compute Engine and Kubernetes Engine instances.\u003c/p\u003e\n\u003cp\u003eWith that said, let’s build one.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud filestore instances create nfs-server \\\n  --project=[PROJECT_ID] \\\n  --zone=us-central1-c \\\n  --tier=STANDARD \\\n  --file-share=name=\u0026#34;vol1\u0026#34;,capacity=1TB \\\n  --network=name=\u0026#34;default\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHow to mount the filestore on clients.\u003c/p\u003e","title":"gcp create filestore"},{"content":"Here’s how to add an AWS user using the CLI.\naws iam create-user --user-name john.doe \\ --tags Key=\u0026#39;Name\u0026#39;,Value=\u0026#39;John Doe\u0026#39; Key=\u0026#39;Role\u0026#39;,Value=\u0026#39;Admin\u0026#39; Create an access key for the user.\naws iam create-access-key --user-name john.doe ","permalink":"http://uly.me/posts/aws-cli-add-user/","summary":"\u003cp\u003eHere’s how to add an AWS user using the CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam create-user --user-name john.doe \\\n--tags Key=\u0026#39;Name\u0026#39;,Value=\u0026#39;John Doe\u0026#39; Key=\u0026#39;Role\u0026#39;,Value=\u0026#39;Admin\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an access key for the user.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam create-access-key --user-name john.doe\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli add user"},{"content":"If you have video files that are formatted in MPEG-2, video files with a .m2ts extension, you can convert them to MP4 using ffmpeg.\nffmpeg -i input.ts -c:v libx264 -c:a aac output.mp4 The video is encoded using open format H.264, while audio is encoded using AAC.\n","permalink":"http://uly.me/posts/ffmpeg-convert-ts-to-mp4/","summary":"\u003cp\u003eIf you have video files that are formatted in MPEG-2, video files with a .m2ts extension, you can convert them to MP4 using ffmpeg.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i input.ts -c:v libx264 -c:a aac output.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe video is encoded using open format H.264, while audio is encoded using AAC.\u003c/p\u003e","title":"ffmpeg convert ts to mp4"},{"content":"Here’s how to find when a Windows server was last rebooted.\nsysteminfo | find /i \u0026#34;boot time\u0026#34; ","permalink":"http://uly.me/posts/windows-boot-time/","summary":"\u003cp\u003eHere’s how to find when a Windows server was last rebooted.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esysteminfo | find /i \u0026#34;boot time\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"windows boot time"},{"content":"I’ve updated my system to the latest Mac OS 10.15.1 codenamed Catalina. Well, it broke a couple of apps that I use regularly, Audacity and OBS. There are currently no updates from Audacity. However, OBS has a workaround in terms of a test build. You have to download it, and set the system preferences to allow the Mac OS to access the cameras (webcam) and audio devices (microphones). There are no official releases yet from neither Audacity and OBS projects. Maybe in a couple of months.\n","permalink":"http://uly.me/posts/mac-os-catalina/","summary":"\u003cp\u003eI’ve updated my system to the latest Mac OS 10.15.1 codenamed Catalina. Well, it broke a couple of apps that I use regularly, Audacity and OBS. There are currently no updates from Audacity. However, OBS has a workaround in terms of a test build. You have to download it, and set the system preferences to allow the Mac OS to access the cameras (webcam) and audio devices (microphones). There are no official releases yet from neither Audacity and OBS projects. Maybe in a couple of months.\u003c/p\u003e","title":"mac os catalina"},{"content":"Create a new interface via AWS CLI with static IP.\n$ aws ec2 create-network-interface \\ --subnet-id subnet-xxxxxxx \\ --description \u0026#34;second ip\u0026#34; \\ --groups sg-xxxxxxx \\ --private-ip-address 10.0.0.16 ","permalink":"http://uly.me/posts/aws-cli-add-network-interface/","summary":"\u003cp\u003eCreate a new interface via AWS CLI with static IP.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws ec2 create-network-interface \\\n--subnet-id subnet-xxxxxxx \\\n--description \u0026#34;second ip\u0026#34; \\\n--groups sg-xxxxxxx \\\n--private-ip-address 10.0.0.16\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli add network interface"},{"content":"If you don’t want a file edited or deleted, you can set the immutable attribute to ON. If activated, not even root or the owner of the file can delete it. Users with write access can still read it, but they obviously will not be able to modify it. To unset it, just use the -i option.\n# Set immutable attribute sudo chattr +i text.txt # Unset immutable attribute sudo chattr -i text.txt ","permalink":"http://uly.me/posts/set-immutable-attribute/","summary":"\u003cp\u003eIf you don’t want a file edited or deleted, you can set the immutable attribute to ON. If activated, not even root or the owner of the file can delete it. Users with write access can still read it, but they obviously will not be able to modify it. To unset it, just use the -i option.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Set immutable attribute\nsudo chattr +i text.txt\n\n# Unset immutable attribute\nsudo chattr -i text.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"set immutable attribute"},{"content":"Tcpdump is a command line utility that allows you to capture and analyze network traffic going through your system. It is often used to help troubleshoot network issues.\n# Find out if tcpdump is installed $ which tcpdump /usr/sbin/tcpdump # Install tcpdump sudo yum install -y tcpdump # Find which interface is available to you tcpdump -D # Capture on eth0. Use Ctrl-C to end capture. tcpdump -i eth0 # Capture after 10 packets tcpdump -i eth0 -c10 # Filter by port tcpdump -i any -c10 -nn port 80 # Filter by ip address tcpdump -i any -c10 -nn host 192.168.1.23 # Filter by source or destination ip tcpdump -i any -c10 -nn src 192.168.1.23 tcpdump -i any -c10 -nn dst 192.168.1.23 # Filter by destination ip and port tcpdump -i any -c5 -nn src 192.168.1.23 and port 80 # Save output to a file (binary format) tcpdump -i any -c10 -nn -w http.pcap port 80 # Save output to a file (text format) tcpdump -nn -r http.pcap Here’s a good intro article about tcpdump.\n","permalink":"http://uly.me/posts/tcpdump/","summary":"\u003cp\u003eTcpdump is a command line utility that allows you to capture and analyze network traffic going through your system. It is often used to help troubleshoot network issues.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Find out if tcpdump is installed\n$ which tcpdump\n/usr/sbin/tcpdump\n\n# Install tcpdump\nsudo yum install -y tcpdump\n\n# Find which interface is available to you\ntcpdump -D\n\n# Capture on eth0. Use Ctrl-C to end capture.\ntcpdump -i eth0\n\n# Capture after 10 packets\ntcpdump -i eth0 -c10\n\n# Filter by port\ntcpdump -i any -c10 -nn port 80\n\n# Filter by ip address\ntcpdump -i any -c10 -nn host 192.168.1.23\n\n# Filter by source or destination ip\ntcpdump -i any -c10 -nn src 192.168.1.23\ntcpdump -i any -c10 -nn dst 192.168.1.23\n\n# Filter by destination ip and port\ntcpdump -i any -c5 -nn src 192.168.1.23 and port 80\n\n# Save output to a file (binary format)\ntcpdump -i any -c10 -nn -w http.pcap port 80\n\n# Save output to a file (text format)\ntcpdump -nn -r http.pcap\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s a good \u003ca href=\"https://opensource.com/article/18/10/introduction-tcpdump\"\u003eintro\u003c/a\u003e article about tcpdump.\u003c/p\u003e","title":"tcpdump"},{"content":"MTU means maximum transmission unit. The default value is 1500 for Ethernet, which is also the standard for the Internet. If your application or network requires a different MTU size, you can set the MTU size by running the following commands.\n# Edit ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth0 #Add MTU, settings: MTU=\u0026#34;1460\u0026#34; # Save and close the file. Restart networking: service network restart ","permalink":"http://uly.me/posts/change-mtu-size/","summary":"\u003cp\u003eMTU means maximum transmission unit. The default value is 1500 for Ethernet, which is also the standard for the Internet. If your application or network requires a different MTU size, you can set the MTU size by running the following commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Edit ifcfg-eth0\nvi /etc/sysconfig/network-scripts/ifcfg-eth0\n\n#Add MTU, settings:\nMTU=\u0026#34;1460\u0026#34;\n\n# Save and close the file. Restart networking:\nservice network restart\n\u003c/code\u003e\u003c/pre\u003e","title":"change mtu size"},{"content":"Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.\nHere’s the AWS IAM policy to push and pull images from Docker within ECR.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2008-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;AllowPushPull\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:iam::*:role/your-custom-role\u0026#34; ], \u0026#34;Action\u0026#34;: [ \u0026#34;ecr:GetDownloadUrlForLayer\u0026#34;, \u0026#34;ecr:BatchGetImage\u0026#34;, \u0026#34;ecr:BatchCheckLayerAvailability\u0026#34;, \u0026#34;ecr:PutImage\u0026#34;, \u0026#34;ecr:InitiateLayerUpload\u0026#34;, \u0026#34;ecr:UploadLayerPart\u0026#34;, \u0026#34;ecr:CompleteLayerUpload\u0026#34; ] } ] } ","permalink":"http://uly.me/posts/aws-ecr-pushpull-policy/","summary":"\u003cp\u003eAmazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.\u003c/p\u003e\n\u003cp\u003eHere’s the AWS IAM policy to push and pull images from Docker within ECR.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n  \u0026#34;Version\u0026#34;: \u0026#34;2008-10-17\u0026#34;,\n  \u0026#34;Statement\u0026#34;: [\n    {\n      \u0026#34;Sid\u0026#34;: \u0026#34;AllowPushPull\u0026#34;,\n      \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n      \u0026#34;Resource\u0026#34;: [\n            \u0026#34;arn:aws:iam::*:role/your-custom-role\u0026#34;\n      ],\n      \u0026#34;Action\u0026#34;: [\n        \u0026#34;ecr:GetDownloadUrlForLayer\u0026#34;,\n        \u0026#34;ecr:BatchGetImage\u0026#34;,\n        \u0026#34;ecr:BatchCheckLayerAvailability\u0026#34;,\n        \u0026#34;ecr:PutImage\u0026#34;,\n        \u0026#34;ecr:InitiateLayerUpload\u0026#34;,\n        \u0026#34;ecr:UploadLayerPart\u0026#34;,\n        \u0026#34;ecr:CompleteLayerUpload\u0026#34;\n      ]\n    }\n  ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws ecr pushpull policy"},{"content":"Linux has tail command. What about Windows? You can use Powershell to tail a file.\nGet-Content myLog.log –Wait ","permalink":"http://uly.me/posts/tail-a-file-in-windows-server/","summary":"\u003cp\u003eLinux has tail command. What about Windows? You can use Powershell to tail a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eGet-Content myLog.log –Wait\n\u003c/code\u003e\u003c/pre\u003e","title":"tail a file in windows server"},{"content":"Here’s how to change instance types via the command line\n# Set Project gcloud config set project your-project-id # Change instance type to 2 CPU 20GB memory. gcloud compute instances set-machine-type your-server-name \\ --zone us-east1-a \\ --machine-type n2-custom-2-20480 # Change instance type to original settings. gcloud compute instances set-machine-type your-server-name \\ --zone us-east1-a \\ --machine-type n2-custom-2-15360 ","permalink":"http://uly.me/posts/gcp-change-instance-type/","summary":"\u003cp\u003eHere’s how to change instance types via the command line\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Set Project\ngcloud config set project your-project-id\n\n# Change instance type to 2 CPU 20GB memory.\ngcloud compute instances set-machine-type your-server-name \\\n--zone us-east1-a \\\n--machine-type n2-custom-2-20480\n\n# Change instance type to original settings.\ngcloud compute instances set-machine-type your-server-name \\\n--zone us-east1-a \\\n--machine-type n2-custom-2-15360\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp change instance type"},{"content":"Passive FTP is a FTP mode that alleviates the issues with client firewalls. The client initiates a call to the server. The return traffic is allowed as long as the client has initiated it. In addition, the server sends a port command along with an ephemeral port that the client can connect to. The client initiates a call on that ephemeral port, and the connection is then established.\nEgress port 21 and ephemeral ports 1024-65535 needs to be opened from the client side.\n# From the client side, egress port 21 must be open. tcp:21 # From the client side, ephemeral ports from port 1024 to 165535 must be open. tcp:1024-165535 ","permalink":"http://uly.me/posts/passive-ftp-firewall/","summary":"\u003cp\u003ePassive FTP is a FTP mode that alleviates the issues with client firewalls. The client initiates a call to the server. The return traffic is allowed as long as the client has initiated it. In addition, the server sends a port command along with an ephemeral port that the client can connect to. The client initiates a call on that ephemeral port, and the connection is then established.\u003c/p\u003e\n\u003cp\u003eEgress port 21 and ephemeral ports 1024-65535 needs to be opened from the client side.\u003c/p\u003e","title":"passive ftp firewall"},{"content":"Here’s how to display mount targets of an EFS system via AWS CLI.\naws efs describe-mount-targets \\ --file-system-id fs-xxxxxxxx \\ --profile default \\ --region us-east-1 ","permalink":"http://uly.me/posts/aws-efs-describe-mount-targets/","summary":"\u003cp\u003eHere’s how to display mount targets of an EFS system via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws efs describe-mount-targets \\\n--file-system-id fs-xxxxxxxx \\\n--profile default \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws efs describe mount targets"},{"content":"If you need to see Bash history with timestamps, use this command.\nHISTTIMEFORMAT=\u0026#34;%d/%m/%y %T \u0026#34; To make it permanent, add it to your .bashrc.\necho \u0026#39;HISTTIMEFORMAT=\u0026#34;%d/%m/%y %T \u0026#34;\u0026#39; \u0026gt;\u0026gt; ~/.bashrc source ~/.bashrc Timestamps accuracy is retroactively, meaning it will not be accurate for commands performed prior to the history time format being set.\n","permalink":"http://uly.me/posts/bash-history-with-timestamps/","summary":"\u003cp\u003eIf you need to see Bash history with timestamps, use this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eHISTTIMEFORMAT=\u0026#34;%d/%m/%y %T \u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo make it permanent, add it to your .bashrc.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#39;HISTTIMEFORMAT=\u0026#34;%d/%m/%y %T \u0026#34;\u0026#39; \u0026gt;\u0026gt; ~/.bashrc\nsource ~/.bashrc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTimestamps accuracy is retroactively, meaning it will not be accurate for commands performed prior to the history time format being set.\u003c/p\u003e","title":"bash history with timestamps"},{"content":"Here’s how to delete blank rows in Excel.\n","permalink":"http://uly.me/posts/excel-delete-blank-rows/","summary":"\u003cp\u003eHere’s how to \u003ca href=\"https://www.excel-easy.com/examples/delete-blank-rows.html\"\u003edelete blank rows\u003c/a\u003e in Excel.\u003c/p\u003e","title":"excel delete blank rows"},{"content":"Here are two important tar commands on how to create and extract a tar.gz file.\nCreate a tar gzip file called “project.tar.gz” of a directory called “foo.”\ntar -cvzf project.tar.gz foo Untar the “project.tar.gz” file to a directory called bar.\ntar -xvzf project.tar.gz bar ","permalink":"http://uly.me/posts/tar-commands/","summary":"\u003cp\u003eHere are two important tar commands on how to create and extract a tar.gz file.\u003c/p\u003e\n\u003cp\u003eCreate a tar gzip file called “project.tar.gz” of a directory called “foo.”\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -cvzf project.tar.gz foo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUntar the “project.tar.gz” file to a directory called bar.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -xvzf project.tar.gz bar\n\u003c/code\u003e\u003c/pre\u003e","title":"tar commands"},{"content":"This is a follow up to a previous post about FFMPEG. In addition to sending a RTMP stream, you can also set a start time and duration.\nHere’s how to set the start time using -ss option and -to for the duration. Video will start at 1 min 23 secs and play until 2 mins.\nffmpeg -ss 00:01:23 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4 Here’s how to start time to start the video at 1 min 23 sec for RTMP streaming. Please note, the start time option needs to be before the input file.\nffmpeg -ss 00:01:23 \\ -re -i $1 -acodec libmp3lame -ar 44100 -b:a 128k \\ -pix_fmt yuv420p -profile:v baseline -s 1280x720 -bufsize 6000k \\ -vb 1200k -maxrate 1500k -deinterlace -vcodec libx264 \\ -preset veryfast -g 30 -r 30 -f flv \\ -flvflags no_duration_filesize \\ \u0026#34;rtmp://username:password@yourserver:1935/live/backup\u0026#34; ","permalink":"http://uly.me/posts/ffmpeg-with-start-time/","summary":"\u003cp\u003eThis is a follow up to a previous post about FFMPEG. In addition to sending a RTMP stream, you can also set a start time and duration.\u003c/p\u003e\n\u003cp\u003eHere’s how to set the start time using -ss option and -to for the duration. Video will start at 1 min 23 secs and play until 2 mins.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -ss 00:01:23 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to start time to start the video at 1 min 23 sec for RTMP streaming. Please note, the start time option needs to be before the input file.\u003c/p\u003e","title":"ffmpeg with start time"},{"content":"FFMPEG is the jack of all trades utility for both audio and video files. You can record, convert, and even live stream an audio or video file in just about any file format. In this example, I will be sending a RTMP stream of a MP4 file to a Wowza streaming server. I can easily send the same stream to YouTube, Facebook or any streaming server that accepts a RTMP source. In this example, I created simple Bash script called play.sh, with all the options needed to live stream to Wowza Streaming server.\nHere are the options in play.sh.\nffmpeg -re -i $1 -acodec libmp3lame -ar 44100 -b:a 128k \\ -pix_fmt yuv420p -profile:v baseline -s 1280x720 -bufsize 6000k \\ -vb 1200k -maxrate 1500k -deinterlace -vcodec libx264 \\ -preset veryfast -g 30 -r 30 -f flv \\ -flvflags no_duration_filesize \\ \u0026#34;rtmp://username:password@yourserver:1935/live/backup\u0026#34; To launch, run the script.\nbash play.sh filename.mp4 ","permalink":"http://uly.me/posts/rtmp-of-mp4-via-ffmpeg/","summary":"\u003cp\u003eFFMPEG is the jack of all trades utility for both audio and video files. You can record, convert, and even live stream an audio or video file in just about any file format. In this example, I will be sending a RTMP stream of a MP4 file to a Wowza streaming server. I can easily send the same stream to YouTube, Facebook or any streaming server that accepts a RTMP source. In this example, I created simple Bash script called play.sh, with all the options needed to live stream to Wowza Streaming server.\u003c/p\u003e","title":"rtmp of mp4 via ffmpeg"},{"content":"Here’s the original document published back in February 1996 detailing the allocation for private internet addresses. The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets. RFC 1918.\n10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) ","permalink":"http://uly.me/posts/rfc-1918/","summary":"\u003cp\u003eHere’s the original document published back in February 1996 detailing the allocation for private internet addresses. The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets. \u003ca href=\"https://tools.ietf.org/html/rfc1918\"\u003eRFC 1918\u003c/a\u003e.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e10.0.0.0        -   10.255.255.255  (10/8 prefix)\n172.16.0.0      -   172.31.255.255  (172.16/12 prefix)\n192.168.0.0     -   192.168.255.255 (192.168/16 prefix)\n\u003c/code\u003e\u003c/pre\u003e","title":"rfc 1918"},{"content":"Here’s how to fix a duplicate UUID on a XFS file system.\nmount -o rw,nouuid /dev/sda1 /data Mounting with nouuid will work, but not after a reboot.\nTo avoid a duplicate ID, run this command to generate a new UUID.\nxfs_admin -U generate /dev/sda3 Clearing log and setting UUID writing all SBs new UUID = xxxxx-xxxx-xxxx-xxxxxxxxx ","permalink":"http://uly.me/posts/xfs-filesystem-has-duplicate-uuid/","summary":"\u003cp\u003eHere’s how to fix a duplicate UUID on a XFS file system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emount -o rw,nouuid /dev/sda1  /data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMounting with nouuid will work, but not after a reboot.\u003c/p\u003e\n\u003cp\u003eTo avoid a duplicate ID, run this command to generate a new UUID.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003exfs_admin -U generate /dev/sda3\nClearing log and setting UUID\nwriting all SBs\nnew UUID = xxxxx-xxxx-xxxx-xxxxxxxxx\n\u003c/code\u003e\u003c/pre\u003e","title":"xfs filesystem has duplicate uuid"},{"content":"Here’s one way how to look at traffic hitting a GCP firewall. To view the traffic activity, go to Stackdriver Logging \u0026gt; Viewer. Enter the following search string. Just replace the network name and firewall name.\nlogName:(projects/project-name/logs/compute.googleapis.com%2Ffirewall) AND jsonPayload.rule_details.reference:(\u0026#34;network:network-name/firewall:firewall-name\u0026#34;) ","permalink":"http://uly.me/posts/gcp-stackdriver-firewall-log/","summary":"\u003cp\u003eHere’s one way how to look at traffic hitting a GCP firewall. To view the traffic activity, go to Stackdriver Logging \u0026gt; Viewer. Enter the following search string. Just replace the network name and firewall name.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elogName:(projects/project-name/logs/compute.googleapis.com%2Ffirewall) \nAND jsonPayload.rule_details.reference:(\u0026#34;network:network-name/firewall:firewall-name\u0026#34;)\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp stackdriver firewall log"},{"content":"If you are getting an error similar to the yum error below, yum may be broken in your system.\nerror: rpmdb: BDB0113 Thread/process 2196/139984719730496 failed: BDB1507 Thread died in Berkeley DB library error: db5 error(-30973) from dbenv-\u0026gt;failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery error: cannot open Packages index using db5 - (-30973) error: cannot open Packages database in /var/lib/rpm CRITICAL:yum.main: Error: rpmdb open failed Here’s the fix.\nmv /var/lib/rpm/__db* /tmp yum clean all Run your yum commands. The errors should be gone.\n","permalink":"http://uly.me/posts/yum-rpmdb-failed/","summary":"\u003cp\u003eIf you are getting an error similar to the yum error below, yum may be broken in your system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eerror: rpmdb: BDB0113 Thread/process 2196/139984719730496 failed: BDB1507 Thread died in Berkeley DB library\nerror: db5 error(-30973) from dbenv-\u0026gt;failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery\nerror: cannot open Packages index using db5 - (-30973)\nerror: cannot open Packages database in /var/lib/rpm\nCRITICAL:yum.main:\n\nError: rpmdb open failed\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the fix.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv /var/lib/rpm/__db* /tmp\nyum clean all\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRun your yum commands. The errors should be gone.\u003c/p\u003e","title":"yum rpmdb failed"},{"content":"If you’re downloading large files, you can speed up download speeds by modifying gsutil. Decrease the number of threads and increase the number of components.\ngsutil \\ -o \u0026#34;GSUtil:parallel_thread_count=1\u0026#34; \\ -o \u0026#34;GSUtil:parallel_process_count=8\u0026#34; \\ cp gs://bucket/source.dat /download/dest/file.dat ","permalink":"http://uly.me/posts/gcp-increase-download-speed-for-gsutil/","summary":"\u003cp\u003eIf you’re downloading large files, you can speed up download speeds by modifying gsutil. Decrease the number of threads and increase the number of components.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egsutil \\\n-o \u0026#34;GSUtil:parallel_thread_count=1\u0026#34; \\\n-o \u0026#34;GSUtil:parallel_process_count=8\u0026#34; \\\ncp gs://bucket/source.dat /download/dest/file.dat\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp increase download speed for gsutil"},{"content":"Here’s how display the Service Account of a particular instance in Google Cloud.\ngcloud compute instances describe server-name \\ --zone us-central1-c \\ --project project-id \\ --format=\u0026#34;flattened(serviceAccounts[].email)\u0026#34; Result is:\nserviceAccounts[0].email: service-account-name@project-id.iam.gserviceaccount.com ","permalink":"http://uly.me/posts/gcp-service-accounts/","summary":"\u003cp\u003eHere’s how display the Service Account of a particular instance in Google Cloud.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances describe server-name \\\n--zone us-central1-c \\\n--project project-id \\\n--format=\u0026#34;flattened(serviceAccounts[].email)\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult is:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserviceAccounts[0].email: service-account-name@project-id.iam.gserviceaccount.com\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp service accounts"},{"content":"Here’s a nice little Bash function in a script to display the elapse time. It’s a nice function for showing how long a process ran.\n#!/bin/bash # pass number of seconds as argument. # Example below calculates 1000s. # elapse.sh 1000 function show_time () { num=$1 min=0 hour=0 day=0 if((num\u0026gt;59));then ((sec=num%60)) ((num=num/60)) if((num\u0026gt;59));then ((min=num%60)) ((num=num/60)) if((num\u0026gt;23));then ((hour=num%24)) ((day=num/24)) else ((hour=num)) fi else ((min=num)) fi else ((sec=num)) fi echo \u0026#34;$day\u0026#34;d \u0026#34;$hour\u0026#34;h \u0026#34;$min\u0026#34;m \u0026#34;$sec\u0026#34;s } show_time $1 ","permalink":"http://uly.me/posts/elapse-time-on-bash-script/","summary":"\u003cp\u003eHere’s a nice little Bash function in a script to display the elapse time. It’s a nice function for showing how long a process ran.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n# pass number of seconds as argument. \n# Example below calculates 1000s.\n# elapse.sh 1000\nfunction show_time () {\n    num=$1\n    min=0\n    hour=0\n    day=0\n    if((num\u0026gt;59));then\n        ((sec=num%60))\n        ((num=num/60))\n        if((num\u0026gt;59));then\n            ((min=num%60))\n            ((num=num/60))\n            if((num\u0026gt;23));then\n                ((hour=num%24))\n                ((day=num/24))\n            else\n                ((hour=num))\n            fi\n        else\n            ((min=num))\n        fi\n    else\n        ((sec=num))\n    fi\n    echo \u0026#34;$day\u0026#34;d \u0026#34;$hour\u0026#34;h \u0026#34;$min\u0026#34;m \u0026#34;$sec\u0026#34;s\n}\nshow_time $1\n\u003c/code\u003e\u003c/pre\u003e","title":"elapse time on bash script"},{"content":"Fpsync is command line tool for synchronizing directories in parallel using fpart and rsync tools. You can specify a number of concurrent sync jobs, number of files per sync job, and the maximum byte size per sync among other things. Fpsync is believed to be 4 to 5 times faster than rsync. Fpsync makes sense when syncing massive drives with thousands of directories and small files.\nTo install fpsync.\napt install fpart Fpsync with 8 parallel jobs.\nlog=\u0026#39;/root/fpsync.log\u0026#39; fpsync -n 8 -v /root/tmp1/ /root/tmp2/ \u0026gt;\u0026gt; $log A sample Script with timestamps to display elapse time.\n#!/bin/bash log=\u0026#39;/root/fpsync.log\u0026#39; start=$(date) begin=$(date +%s) echo \u0026#39;Start: \u0026#39;$start \u0026gt; $log fpsync -n 8 -v /root/tmp1/ /root/tmp2/ \u0026gt;\u0026gt; $log stop=$(date) end=$(date +%s) echo \u0026#39;Stop: \u0026#39;$stop \u0026gt;\u0026gt; $log elapse=$((end-begin)) function show_time () { num=$elapse min=0 hour=0 day=0 if((num\u0026gt;59));then ((sec=num%60)) ((num=num/60)) if((num\u0026gt;59));then ((min=num%60)) ((num=num/60)) if((num\u0026gt;23));then ((hour=num%24)) ((day=num/24)) else ((hour=num)) fi else ((min=num)) fi else ((sec=num)) fi echo \u0026#34;$day\u0026#34;d \u0026#34;$hour\u0026#34;h \u0026#34;$min\u0026#34;m \u0026#34;$sec\u0026#34;s } show_time $elapse \u0026gt;\u0026gt; $log For comparison, you can substitute fpsync with rysnc and see the performance difference.\nfpsync -n 8 -v /root/tmp1/ /root/tmp2/ \u0026gt;\u0026gt; $log # or rsync -av /root/tmp1 /root/tmp2/ \u0026gt; /var/null ","permalink":"http://uly.me/posts/fpsync/","summary":"\u003cp\u003e\u003ca href=\"http://manpages.ubuntu.com/manpages/bionic/man1/fpsync.1.html\"\u003eFpsync\u003c/a\u003e is command line tool for synchronizing directories in parallel using fpart and \u003ca href=\"https://linux.die.net/man/1/rsync\"\u003ersync\u003c/a\u003e tools. You can specify a number of concurrent sync jobs, number of files per sync job, and the maximum byte size per sync among other things. Fpsync is believed to be 4 to 5 times faster than rsync. Fpsync makes sense when syncing massive drives with thousands of directories and small files.\u003c/p\u003e\n\u003cp\u003eTo install fpsync.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install fpart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFpsync with 8 parallel jobs.\u003c/p\u003e","title":"fpsync"},{"content":"Here’s how to add an IAM role to a GCP Service Account.\ngcloud projects add-iam-policy-binding your-project-id \\ --member serviceAccount:service-account-name@your-project-id.iam.gserviceaccount.com \\ --role roles/storage.objectAdmin ","permalink":"http://uly.me/posts/gcp-add-iam-role-to-service-account/","summary":"\u003cp\u003eHere’s how to add an IAM role to a GCP Service Account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud projects add-iam-policy-binding your-project-id \\\n--member serviceAccount:service-account-name@your-project-id.iam.gserviceaccount.com \\\n--role roles/storage.objectAdmin\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp add iam role to service account"},{"content":"Here’s how to create a GCP Service Account.\ngcloud beta iam service-accounts create service-account-name \\ --description \u0026#34;service account description\u0026#34; \\ --display-name \u0026#34;service account display name\u0026#34; ","permalink":"http://uly.me/posts/gcp-create-service-account/","summary":"\u003cp\u003eHere’s how to create a GCP Service Account.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta iam service-accounts create service-account-name \\\n    --description \u0026#34;service account description\u0026#34; \\\n    --display-name \u0026#34;service account display name\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create service account"},{"content":"Here’s how to create a key for the GCP Service Account.\nCreate Key.\ngcloud iam service-accounts keys create ~/key.json \\ --iam-account service-name@project-id.iam.gserviceaccount.com Activate Key\ngcloud auth activate-service-account service-name@project-id.iam.gserviceaccount.com \\ --key-file=key.json Revoke Key.\ngcloud auth revoke service-account@project-id.iam.gserviceaccount.com Delete Key\ngcloud iam service-accounts keys delete key-id \\ --iam-account service-name@project-id.iam.gserviceaccount.com ","permalink":"http://uly.me/posts/gcp-create-service-account-key/","summary":"\u003cp\u003eHere’s how to create a key for the GCP Service Account.\u003c/p\u003e\n\u003cp\u003eCreate Key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud iam service-accounts keys create ~/key.json \\\n  --iam-account service-name@project-id.iam.gserviceaccount.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eActivate Key\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth activate-service-account service-name@project-id.iam.gserviceaccount.com \\\n--key-file=key.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRevoke Key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud auth revoke service-account@project-id.iam.gserviceaccount.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete Key\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud iam service-accounts keys delete key-id \\\n    --iam-account service-name@project-id.iam.gserviceaccount.com\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create service account key"},{"content":"Here’s how to update your Google Cloud Platform SDK (Software Development Kit) which is aka the CLI for interacting with Google’s API.\nGet Current Version\ngcloud version Get the Components List\ngcloud components list Update\ngcloud components update ","permalink":"http://uly.me/posts/gcp-sdk-update/","summary":"\u003cp\u003eHere’s how to update your Google Cloud Platform SDK (Software Development Kit) which is aka the CLI for interacting with Google’s API.\u003c/p\u003e\n\u003cp\u003eGet Current Version\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGet the Components List\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud components list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUpdate\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud components update\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp sdk update"},{"content":"If you already have Google SDK installed, you can activate GCloud Interactive Shell, which is still in beta by the way, by typing the following command from the Google SDK terminal.\ngcloud beta interactive The interactive shell environment has auto-completion. It shows you who’s logged in and which project you are currently set in. To exit the interactive shell, just Press F9 to quit.\n","permalink":"http://uly.me/posts/gcloud-interactive-shell/","summary":"\u003cp\u003eIf you already have Google SDK installed, you can activate GCloud Interactive Shell, which is still in beta by the way, by typing the following command from the Google SDK terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta interactive\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/09/interactive-shell.png\"\u003e\u003c/p\u003e\n\u003cp\u003eThe interactive shell environment has auto-completion. It shows you who’s logged in and which project you are currently set in. To exit the interactive shell, just Press F9 to quit.\u003c/p\u003e","title":"gcloud interactive shell"},{"content":"Here’s how to move a GCP disk between zones.\nMake sure disk is detached from instance. Use the GCloud Disk Move command. # Detach disk from instance gcloud compute instances detach-disk server --disk=server-boot # Move disk from us-central1-b to us-central1-f gcloud compute disks move example-disk-1 --zone us-central1-b --destination-zone us-central1-f ","permalink":"http://uly.me/posts/gcp-compute-disks-move/","summary":"\u003cp\u003eHere’s how to move a GCP disk between zones.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eMake sure disk is detached from instance.\u003c/li\u003e\n\u003cli\u003eUse the GCloud Disk Move command.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Detach disk from instance\ngcloud compute instances detach-disk server --disk=server-boot\n# Move disk from us-central1-b to us-central1-f\ngcloud compute disks move example-disk-1 --zone us-central1-b --destination-zone us-central1-f\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp compute disks move"},{"content":"I have a CodeIgniter dev site in Google Cloud. The instance obtains a new IP address at every start. You can set the base URL to a domain or IP address in the “/application/config/config.php” file. Since it’s only a dev box, I don’t have a domain assigned. It’s accessible via IP address only which changes every time the instance is started. So here’s the workaround. I added some extra code in the config file to obtain the external IP address.\n$realIP = file_get_contents(\u0026#34;http://ipecho.net/plain\u0026#34;); $config[\u0026#39;base_url\u0026#39;] = \u0026#39;http://\u0026#39;.$realIP; The code is using a service from ipecho.net which returns your external IP address. Works like a charm!\n","permalink":"http://uly.me/posts/codeigniter-base-url/","summary":"\u003cp\u003eI have a CodeIgniter dev site in Google Cloud. The instance obtains a new IP address at every start. You can set the base URL to a domain or IP address in the “/application/config/config.php” file. Since it’s only a dev box, I don’t have a domain assigned. It’s accessible via IP address only which changes every time the instance is started. So here’s the workaround. I added some extra code in the config file to obtain the external IP address.\u003c/p\u003e","title":"codeigniter base url"},{"content":"Found another gem to display all Windows by using …\nWindows + Tab ","permalink":"http://uly.me/posts/windows-tab-2/","summary":"\u003cp\u003eFound another gem to display all Windows by using …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eWindows + Tab\n\u003c/code\u003e\u003c/pre\u003e","title":"windows + tab"},{"content":"There are two steps in creating an instance from a snapshot.\nCreate a disk from snapshot Create an instance from the disk Create a disk from snapshot.\ngcloud compute disks create \u0026#34;hostname-boot\u0026#34; \\ --project \u0026#34;project-id\u0026#34; \\ --zone \u0026#34;us-central1-a\u0026#34; \\ --source-snapshot \u0026#34;snapshot-name\u0026#34; \\ --type \u0026#34;pd-standard\u0026#34; \\ --size \u0026#34;100\u0026#34; Create an instance from disk.\ngcloud beta compute instances create hostname \\ --project=project-id \\ --zone=us-central1-a \\ --subnet=your-subnetwork \\ --machine-type=n1-standard-1 \\ --no-address \\ --maintenance-policy=MIGRATE \\ --service-account=service.account@developer.gserviceaccount.com \\ --disk=name=instance-1,device-name=instance-1,mode=rw,boot=yes,auto-delete=yes \\ --reservation-affinity=any \\ --labels=builtby=john.doe \\ --tags=web \\ --scopes= \\ --metadata= ","permalink":"http://uly.me/posts/gcp-create-instance-from-snapshot/","summary":"\u003cp\u003eThere are two steps in creating an instance from a snapshot.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eCreate a disk from snapshot\u003c/li\u003e\n\u003cli\u003eCreate an instance from the disk\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eCreate a disk from snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create \u0026#34;hostname-boot\u0026#34; \\\n--project \u0026#34;project-id\u0026#34; \\\n--zone \u0026#34;us-central1-a\u0026#34; \\\n--source-snapshot \u0026#34;snapshot-name\u0026#34; \\\n--type \u0026#34;pd-standard\u0026#34; \\\n--size \u0026#34;100\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate an instance from disk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud beta compute instances create hostname \\\n--project=project-id \\\n--zone=us-central1-a \\\n--subnet=your-subnetwork \\\n--machine-type=n1-standard-1 \\\n--no-address \\\n--maintenance-policy=MIGRATE \\\n--service-account=service.account@developer.gserviceaccount.com \\\n--disk=name=instance-1,device-name=instance-1,mode=rw,boot=yes,auto-delete=yes \\\n--reservation-affinity=any \\\n--labels=builtby=john.doe \\\n--tags=web \\\n--scopes= \\\n--metadata= \n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create instance from snapshot"},{"content":"AWS introduced Nitro-based instances which are modular. They are meant for high performance, high availability, and high security systems. Nitro building blocks provide direct access to high-speed local storage over a PCI interface and transparently encrypts all data using dedicated hardware. It also provides hardware-level isolation between storage devices and EC2 instances so that bare metal instances can benefit from local NVMe storage. The following are Nitro-based instances: A1, C5, C5d, C5n, I3en, M5, M5a, M5ad, M5d, p3dn.24xlarge, R5, R5a, R5ad, R5d, T3, T3a, and z1d. Bare metal: c5.metal, c5n.metal, i3.metal, i3en.metal, m5.metal, m5d.metal, r5.metal, r5d.metal, u-6tb1.metal, u-9tb1.metal, u-12tb1.metal, and z1d.metal.\nAlthough Nitro-based instances looks like regular volumes (/dev/xvda) from the AWS Console, inside the operating system, they look (/dev/nvme6n1) completely different.\nIn AWS Console, the storage devices will look like this.\n/dev/sda1 /dev/xvdb /dev/xvdc /dev/xvdd /dev/xvde /dev/xvdh /dev/xvdf /dev/xvdi /dev/xvdg /dev/xvdj In the operating system, invoking df -h, results in this.\n/dev/nvme0n1p2 30G 7.0G 24G 24% / /dev/nvme4n1 50G 20G 31G 40% /vol1 /dev/nvme1n1 10G 753M 9.3G 8% /vol2 /dev/nvme8n1 500G 67G 433G 14% /backups /dev/nvme2n1 400G 12G 388G 3% /vol3 /dev/nvme6n1 150G 150G 755M 100% /vol4 /dev/nvme7n1 10G 33M 10G 1% /vol5 /dev/nvme5n1 10G 553M 9.5G 6% /vol6 /dev/nvme9n1 100G 91G 10G 91% /vol7 The big question is, how can you tell which volume is associated with which. You’ll need nvme program to map out the volumes. Install nvme-cli first.\nyum install nvme-cli Then run the command below.\n# run nvme sudo nvme id-ctrl -v /dev/nvme6n1 | grep xv # the result 0000: 2f 64 65 76 2f 73 64 6a 20 20 20 20 20 20 20 20 \u0026#34;/dev/xvdf...\u0026#34; ","permalink":"http://uly.me/posts/nitro-based-instance-volumes/","summary":"\u003cp\u003eAWS introduced Nitro-based instances which are modular. They are meant for high performance, high availability, and high security systems. Nitro building blocks provide direct access to high-speed local storage over a PCI interface and transparently encrypts all data using dedicated hardware. It also provides hardware-level isolation between storage devices and EC2 instances so that bare metal instances can benefit from local NVMe storage. The following are Nitro-based instances: A1, C5, C5d, C5n, I3en, M5, M5a, M5ad, M5d, p3dn.24xlarge, R5, R5a, R5ad, R5d, T3, T3a, and z1d. Bare metal: c5.metal, c5n.metal, i3.metal, i3en.metal, m5.metal, m5d.metal, r5.metal, r5d.metal, u-6tb1.metal, u-9tb1.metal, u-12tb1.metal, and z1d.metal.\u003c/p\u003e","title":"nitro-based instance volumes"},{"content":"If device is busy and you can’t umount it, try it with -l option (lazy unmount). Or you can force it.\n# standard umount /mnt/data # lazy umount umount -l /mnt/data # force umount -f /mnt/data Lazy unmount is safer since it will detach immediately and clean up all references to the file system. Force is a bit more drastic.\n","permalink":"http://uly.me/posts/force-umount-if-busy/","summary":"\u003cp\u003eIf device is busy and you can’t umount it, try it with -l option (lazy unmount). Or you can force it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# standard\numount /mnt/data\n# lazy umount\numount -l /mnt/data\n# force\numount -f /mnt/data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eLazy unmount is safer since it will detach immediately and clean up all references to the file system. Force is a bit more drastic.\u003c/p\u003e","title":"force umount if busy"},{"content":"If unable to login via SSH, check the /etc/ssh/sshd_config for AllowGroups.\nAllowGroups root groupname It’s case sensitive.\n","permalink":"http://uly.me/posts/ssh-access-allowgroups/","summary":"\u003cp\u003eIf unable to login via SSH, check the /etc/ssh/sshd_config for AllowGroups.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eAllowGroups root groupname\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s case sensitive.\u003c/p\u003e","title":"ssh access allowgroups"},{"content":"Here’s how to search for AWS Security Groups containing this IP Cidr.\naws ec2 describe-security-groups \\ --filter Name=egress.ip-permission.cidr,Values=\u0026#39;10.8.8.8/32\u0026#39; \\ --query \u0026#34;SecurityGroups[*].{Name:GroupName}\u0026#34; \\ --output text \\ --profile default \\ --region us-east-1 Search with ports.\naws ec2 describe-security-groups \\ --filter Name=egress.ip-permission.cidr,Values=\u0026#39;10.8.8.8/32\u0026#39; \\ Name=egress.ip-permission.from-port,Values=\u0026#39;22\u0026#39; \\ Name=egress.ip-permission.to-port,Values=\u0026#39;22\u0026#39; \\ --query \u0026#34;SecurityGroups[*].{Name:GroupName}\u0026#34; \\ --output text \\ --profile default \\ --region us-east-1 Query will only display the Security Group name.\n","permalink":"http://uly.me/posts/aws-security-groups-ip-cidr/","summary":"\u003cp\u003eHere’s how to search for AWS Security Groups containing this IP Cidr.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-security-groups \\\n--filter Name=egress.ip-permission.cidr,Values=\u0026#39;10.8.8.8/32\u0026#39; \\\n--query \u0026#34;SecurityGroups[*].{Name:GroupName}\u0026#34; \\\n--output text \\\n--profile default \\\n--region us-east-1 \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSearch with ports.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-security-groups \\\n--filter Name=egress.ip-permission.cidr,Values=\u0026#39;10.8.8.8/32\u0026#39; \\\n         Name=egress.ip-permission.from-port,Values=\u0026#39;22\u0026#39; \\\n         Name=egress.ip-permission.to-port,Values=\u0026#39;22\u0026#39; \\\n--query \u0026#34;SecurityGroups[*].{Name:GroupName}\u0026#34; \\\n--output text \\\n--profile default \\\n--region us-east-1 \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eQuery will only display the Security Group name.\u003c/p\u003e","title":"aws security groups ip cidr"},{"content":"Here are the steps how to migrate a GCP VM from one network to another. It involves recreating the instance in that network.\nFind the VM. Click the ‘Create Similar’ button. Select the new network. Save Network. Everything else should stay the same. Don’t click Create, but get the ‘Create Similar’ command line script only. Click Cancel after. Make sure to edit the hostname. GCP appends a ‘-1’ at the end of hostname. Edit VM to keep all disks. Delete VM. Make sure to preserve boot drive. Run the ‘Create Similar’ command line script you capture to create new VM in the new network. The new VM will be based on golden image. Stop VM. Swap new disks with old disks. Start VM. Done. ","permalink":"http://uly.me/posts/migrate-gcp-vm-to-another-network/","summary":"\u003cp\u003eHere are the steps how to migrate a GCP VM from one network to another. It involves recreating the instance in that network.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eFind the VM. Click the ‘Create Similar’ button.\u003c/li\u003e\n\u003cli\u003eSelect the new network. Save Network. Everything else should stay the same.\u003c/li\u003e\n\u003cli\u003eDon’t click Create, but get the ‘Create Similar’ command line script only. Click Cancel after.\u003c/li\u003e\n\u003cli\u003eMake sure to edit the hostname. GCP appends a ‘-1’ at the end of hostname.\u003c/li\u003e\n\u003cli\u003eEdit VM to keep all disks. Delete VM. Make sure to preserve boot drive.\u003c/li\u003e\n\u003cli\u003eRun the ‘Create Similar’ command line script you capture to create new VM in the new network.\u003c/li\u003e\n\u003cli\u003eThe new VM will be based on golden image.\u003c/li\u003e\n\u003cli\u003eStop VM. Swap new disks with old disks.\u003c/li\u003e\n\u003cli\u003eStart VM.\u003c/li\u003e\n\u003cli\u003eDone.\u003c/li\u003e\n\u003c/ol\u003e","title":"migrate gcp vm to another network"},{"content":"Here’s how to fix when phpinfo is displaying a blank page. The install is missing this php module.\napt install php libapache2-mod-php Restart after install.\nservice apache2 restart ","permalink":"http://uly.me/posts/phpinfo-blank-page/","summary":"\u003cp\u003eHere’s how to fix when phpinfo is displaying a blank page. The install is missing this php module.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install php libapache2-mod-php\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestart after install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice apache2 restart\n\u003c/code\u003e\u003c/pre\u003e","title":"phpinfo blank page"},{"content":"Here’s how to run a shell script from your website. You’ll need 2 files.\nHere’s the contents of foo.php. Wrap your output with ‘pre’ for better formatting.\n\u0026lt;?php $output = shell_exec(\u0026#39;/var/www/html/bar.sh 2?\u0026gt;\u0026amp;1\u0026#39;); echo \u0026#34;$output\u0026#34;; Here’s the content of bar.sh. Output will be displayed on web page.\n#!/bin/bash now=\u0026#34;$(date +\u0026#39;%y%m%d\u0026#39;)\u0026#34; echo $now aws s3 ls ","permalink":"http://uly.me/posts/run-shell-script-from-your-website/","summary":"\u003cp\u003eHere’s how to run a shell script from your website. You’ll need 2 files.\u003c/p\u003e\n\u003cp\u003eHere’s the contents of foo.php. Wrap your output with ‘pre’ for better formatting.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;?php $output = shell_exec(\u0026#39;/var/www/html/bar.sh 2?\u0026gt;\u0026amp;1\u0026#39;);\necho \u0026#34;$output\u0026#34;;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the content of bar.sh. Output will be displayed on web page.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nnow=\u0026#34;$(date +\u0026#39;%y%m%d\u0026#39;)\u0026#34;\necho $now\naws s3 ls\n\u003c/code\u003e\u003c/pre\u003e","title":"run shell script from your website"},{"content":"Here’s how to sync files between two directories, while copying only new files and ignoring existing files.\nrsync --ignore-existing -rapzvh /dir1 /dir2 \u0026gt;\u0026gt; /root/rsync.log \u0026amp; ","permalink":"http://uly.me/posts/rsync-only-new-files/","summary":"\u003cp\u003eHere’s how to sync files between two directories, while copying only new files and ignoring existing files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ersync --ignore-existing -rapzvh /dir1 /dir2 \u0026gt;\u0026gt; /root/rsync.log \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e","title":"rsync only new files"},{"content":"Here’s the code to add to your archive template, e.g. archives.php.\nLast 50 Posts:\nwp_get_archives( array( \u0026#39;type\u0026#39; =?\u0026gt; \u0026#39;postbypost\u0026#39;, \u0026#39;limit\u0026#39; =\u0026amp;gt; 50, \u0026#39;format\u0026#39; =\u0026amp;gt; \u0026#39;\u0026#39;, \u0026#39;before\u0026#39; =\u0026amp;gt; \u0026#39;- \u0026#39;, \u0026#39;after\u0026#39; =\u0026amp;gt; \u0026#39; \u0026#39; )); ?\u0026gt; ","permalink":"http://uly.me/posts/display-last-50-posts-in-archive-page/","summary":"\u003cp\u003eHere’s the code to add to your archive template, e.g. archives.php.\u003c/p\u003e\n\u003cp\u003eLast 50 Posts:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewp_get_archives( array( \n\t\u0026#39;type\u0026#39; =?\u0026gt;\n \u0026#39;postbypost\u0026#39;, \u0026#39;limit\u0026#39; =\u0026amp;gt; 50, \u0026#39;format\u0026#39; =\u0026amp;gt; \u0026#39;\u0026#39;, \u0026#39;before\u0026#39; =\u0026amp;gt; \u0026#39;- \u0026#39;, \u0026#39;after\u0026#39; =\u0026amp;gt; \u0026#39;\n\u0026#39; )); ?\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e","title":"display last 50 posts in archive page"},{"content":"Here’s how to view the contents of a tar file without extracting the files.\ntar -tvf file.tar ","permalink":"http://uly.me/posts/view-contents-of-tar-file/","summary":"\u003cp\u003eHere’s how to view the contents of a tar file without extracting the files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar -tvf file.tar\n\u003c/code\u003e\u003c/pre\u003e","title":"view contents of tar file"},{"content":"Here’s how to add numeric pagination on your WordPress pages.\nAdd this code to functions.php.\nfunction pagination($pages = \u0026#39;\u0026#39;, $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == \u0026#39;\u0026#39;) { global $wp_query; $pages = $wp_query-\u0026gt;max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo \u0026#39;\u0026lt;p\u0026gt;\u0026lt;/p\u0026gt;\u0026lt;div class=\u0026#34;pagination\u0026#34;\u0026gt;\u0026lt;span\u0026gt;Page\u0026#39; . $paged . \u0026#39; of \u0026#39; . $pages . \u0026#39;\u0026lt;/span\u0026gt; \u0026#39;; if($paged \u0026gt; 2 \u0026amp;\u0026amp; $paged \u0026gt; $range+1 \u0026amp;\u0026amp; $showitems \u0026#39;; if($paged \u0026gt; 1 \u0026amp;\u0026amp; $showitems \u0026#39;; for ($i=1; $i = $paged+$range+1 || $i \u0026#39; . $i . \u0026#39;\u0026#39; : \u0026#39;\u0026lt;a class=\u0026#34;inactive\u0026#34; href=\u0026#34;\u0026#39; . get_pagenum_link($i) . \u0026#39;\u0026#34;\u0026gt;\u0026#39; . $i . \u0026#39;\u0026lt;/a\u0026gt;\u0026#39;; } } if ($paged Next \u0026gt;\u0026#39;; if ($paged Last \u0026gt;\u0026gt;\u0026#39;; echo \u0026#39;\u0026lt;/div\u0026gt;\u0026#39;; } } To display, comment out ‘the_post_navigation’ function and add the ‘pagination’ function instead in your template files.\n//the_posts_navigation(); pagination(); Code courtesy of webdesignsun.\n","permalink":"http://uly.me/posts/wordpress-numeric-pagination/","summary":"\u003cp\u003eHere’s how to add numeric pagination on your WordPress pages.\u003c/p\u003e\n\u003cp\u003eAdd this code to functions.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction pagination($pages = \u0026#39;\u0026#39;, $range = 4) {\n $showitems = ($range * 2)+1;\n global $paged;\n if(empty($paged)) $paged = 1;\n if($pages == \u0026#39;\u0026#39;) {\n   global $wp_query;\n   $pages = $wp_query-\u0026gt;max_num_pages;\n   if(!$pages) {\n     $pages = 1;\n   }\n }\n if(1 != $pages) {\n   echo \u0026#39;\u0026lt;p\u0026gt;\u0026lt;/p\u0026gt;\u0026lt;div class=\u0026#34;pagination\u0026#34;\u0026gt;\u0026lt;span\u0026gt;Page\u0026#39; . $paged . \u0026#39; of  \u0026#39; . $pages . \u0026#39;\u0026lt;/span\u0026gt;   \u0026#39;;\n   if($paged \u0026gt; 2 \u0026amp;\u0026amp; $paged \u0026gt; $range+1 \u0026amp;\u0026amp; $showitems \u0026#39;;\n   if($paged \u0026gt; 1 \u0026amp;\u0026amp; $showitems \u0026#39;;\n   for ($i=1; $i = $paged+$range+1 || $i \u0026#39; . $i . \u0026#39;\u0026#39; : \u0026#39;\u0026lt;a class=\u0026#34;inactive\u0026#34; href=\u0026#34;\u0026#39; . get_pagenum_link($i) . \u0026#39;\u0026#34;\u0026gt;\u0026#39; . $i . \u0026#39;\u0026lt;/a\u0026gt;\u0026#39;;\n     }\n   }\n   if ($paged Next \u0026gt;\u0026#39;;\n   if ($paged Last \u0026gt;\u0026gt;\u0026#39;;\n   echo \u0026#39;\u0026lt;/div\u0026gt;\u0026#39;;\n }\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo display, comment out ‘the_post_navigation’ function and add the ‘pagination’ function instead in your template files.\u003c/p\u003e","title":"wordpress numeric pagination"},{"content":"Here’s how to get the size of a directory.\ndu -sh /var/www Output:\n2.1GB /var/www Size of the directories and files one level down.\ndu -sh /var/www/* Sort with biggest files from top to bottom.\ndu -sh /var/www/* | sort -rh Top 5 biggest files from top to bottom.\ndu -sh /var/www/* | sort -rh | head -5 ","permalink":"http://uly.me/posts/get-directory-size/","summary":"\u003cp\u003eHere’s how to get the size of a directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edu -sh /var/www\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e2.1GB    /var/www\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSize of the directories and files one level down.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edu -sh /var/www/*\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSort with biggest files from top to bottom.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edu -sh /var/www/* | sort -rh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTop 5 biggest files from top to bottom.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edu -sh /var/www/* | sort -rh | head -5\n\u003c/code\u003e\u003c/pre\u003e","title":"get directory size"},{"content":"Here’s my MySQL backup script to the S3 Bucket.\nJust a couple of things about the script. It’s using …\nAWS CLI Mysqldump They must be setup and configured to work properly.\n#!/bin/bash cd /root/database TIMESTAMP=$(date +%Y-%m-%d) S3FILE=\u0026#34;s3://bucketname/sqlbackup/backup-$TIMESTAMP.sql\u0026#34; /usr/bin/mysqldump dbname \u0026gt; dbname.sql /usr/local/bin/aws s3 cp dbname.sql $S3FILE sleep 3s rm dbname.sql Finally, set the S3 bucket with a 7 day retention. Backups older than 7 days are automatically deleted.\n","permalink":"http://uly.me/posts/mysql-backup-to-s3-bucket/","summary":"\u003cp\u003eHere’s my MySQL backup script to the S3 Bucket.\u003c/p\u003e\n\u003cp\u003eJust a couple of things about the script. It’s using …\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eAWS CLI\u003c/li\u003e\n\u003cli\u003eMysqldump\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eThey must be setup and configured to work properly.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\ncd /root/database\nTIMESTAMP=$(date +%Y-%m-%d)\nS3FILE=\u0026#34;s3://bucketname/sqlbackup/backup-$TIMESTAMP.sql\u0026#34;\n/usr/bin/mysqldump dbname \u0026gt; dbname.sql\n/usr/local/bin/aws s3 cp dbname.sql $S3FILE\nsleep 3s\nrm dbname.sql\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally, set the S3 bucket with a 7 day retention. Backups older than 7 days are automatically deleted.\u003c/p\u003e","title":"mysql backup to s3 bucket"},{"content":"Here’s how to check what’s changed in your local Git repo vs the master repo.\nGit Status tells you what file has changed, but not to the level of detail such as what lines or what code was changed.\ngit diff HEAD ","permalink":"http://uly.me/posts/git-diff-head/","summary":"\u003cp\u003eHere’s how to check what’s changed in your local Git repo vs the master repo.\u003c/p\u003e\n\u003cp\u003eGit Status tells you what file has changed, but not to the level of detail such as what lines or what code was changed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit diff HEAD\n\u003c/code\u003e\u003c/pre\u003e","title":"git diff head"},{"content":"Here’s how to get the differences between two directories using diff.\n-q display only files when they differ -r recursive to all sub-directories diff -qr /directory-1 /directory-2 ","permalink":"http://uly.me/posts/diff-between-two-directories/","summary":"\u003cp\u003eHere’s how to get the differences between two directories using diff.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e-q display only files when they differ\u003c/li\u003e\n\u003cli\u003e-r recursive to all sub-directories\u003c/li\u003e\n\u003c/ul\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ediff -qr /directory-1 /directory-2\n\u003c/code\u003e\u003c/pre\u003e","title":"diff between two directories"},{"content":"How to recover a MySQL root password without a password.\nStop MySQL. Start MySQL Safe Mode. Login to MySQL as root without password. Change root password. # Stop MySQL. service mysql stop # MySQL Safe Mode. mysqld_safe --skip-grant-tables \u0026amp; # Login to MySQL without password. Set new password. mysql -u root -p use mysql; # For MySQL 5.6 or lower UPDATE mysql.user SET Password=PASSWORD(\u0026#39;newpassword\u0026#39;) WHERE User=\u0026#39;root\u0026#39;; # For MySQL 5.7 or higher SET PASSWORD FOR \u0026#39;root\u0026#39;@\u0026#39;localhost\u0026#39; = PASSWORD(\u0026#34;newpassword\u0026#34;); FLUSH PRIVILEGES; exit; # Kill mysqld killall mysqld # Restart MySQL service mysql start I ran into issues running MySQL Safe mode. I got a “UNIX socket file don’t exists” error. Here’s the fix.\nmkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld ","permalink":"http://uly.me/posts/recover-mysql-root-password/","summary":"\u003cp\u003eHow to recover a MySQL root password without a password.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eStop MySQL.\u003c/li\u003e\n\u003cli\u003eStart MySQL Safe Mode.\u003c/li\u003e\n\u003cli\u003eLogin to MySQL as root without password.\u003c/li\u003e\n\u003cli\u003eChange root password.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Stop MySQL.\nservice mysql stop\n# MySQL Safe Mode.\nmysqld_safe --skip-grant-tables \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Login to MySQL without password. Set new password.\nmysql -u root -p\nuse mysql;\n# For MySQL 5.6 or lower\nUPDATE mysql.user SET Password=PASSWORD(\u0026#39;newpassword\u0026#39;) WHERE User=\u0026#39;root\u0026#39;;\n# For MySQL 5.7 or higher\nSET PASSWORD FOR \u0026#39;root\u0026#39;@\u0026#39;localhost\u0026#39; = PASSWORD(\u0026#34;newpassword\u0026#34;);\nFLUSH PRIVILEGES;\nexit;\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Kill mysqld\nkillall mysqld\n# Restart MySQL\nservice mysql start\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI ran into issues running MySQL Safe mode. I got a “UNIX socket file don’t exists” error. Here’s the fix.\u003c/p\u003e","title":"recover mysql root password"},{"content":"If you’ve changed keys, you will need to delete a ssh key from /etc/known_hosts file.\nYou can edit it manually using an editor such as vi or vim.\nvim ~/.ssh/known_hosts Or you can use ssh-keygen command with -R option to delete the hostname or IP address.\nssh-keygen -f \u0026#34;~/.ssh/known_hosts\u0026#34; -R \u0026#34;xxx.xxx.xxx.xxx\u0026#34; ","permalink":"http://uly.me/posts/remove-key-from-known_hosts/","summary":"\u003cp\u003eIf you’ve changed keys, you will need to delete a ssh key from /etc/known_hosts file.\u003c/p\u003e\n\u003cp\u003eYou can edit it manually using an editor such as vi or vim.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim ~/.ssh/known_hosts\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr you can use ssh-keygen command with -R option to delete the hostname or IP address.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003essh-keygen -f \u0026#34;~/.ssh/known_hosts\u0026#34; -R \u0026#34;xxx.xxx.xxx.xxx\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"remove key from known_hosts"},{"content":"Here’s how to copy files from one directory to another.\nrsync -arvz /dir1 /dir2 \u0026gt;\u0026gt; /tmp/rsync.log \u0026amp; Format: rsynch –options source destination\nOptions\n-a archive mode -v verbose -p keep permissions -z zipped during transfer -r recursive ","permalink":"http://uly.me/posts/copy-files-using-rsync/","summary":"\u003cp\u003eHere’s how to copy files from one directory to another.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ersync -arvz /dir1 /dir2 \u0026gt;\u0026gt; /tmp/rsync.log \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFormat: rsynch –options source destination\u003c/p\u003e\n\u003cp\u003eOptions\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e-a archive mode\u003c/li\u003e\n\u003cli\u003e-v verbose\u003c/li\u003e\n\u003cli\u003e-p keep permissions\u003c/li\u003e\n\u003cli\u003e-z zipped during transfer\u003c/li\u003e\n\u003cli\u003e-r recursive\u003c/li\u003e\n\u003c/ul\u003e","title":"copy files using rsync"},{"content":"Here’s a IAM policy that you can add to an IAM user or an IAM role so they are able to start and stop a specific RDS instance.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Condition\u0026#34;: { \u0026#34;StringEqualsIgnoreCase\u0026#34;: { \u0026#34;rds:db-tag/Application\u0026#34;: \u0026#34;application-name\u0026#34; } }, \u0026#34;Action\u0026#34;: [ \u0026#34;rds:DescribeDBInstances\u0026#34;, \u0026#34;rds:StartDBInstance\u0026#34;, \u0026#34;rds:StopDBInstance\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:rds:us-east-1:xxxxxxxxxxxx:db:db-instance-name\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-rds-start-and-stop-policy/","summary":"\u003cp\u003eHere’s a IAM policy that you can add to an IAM user or an IAM role so they are able to start and stop a specific RDS instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Condition\u0026#34;: {\n                \u0026#34;StringEqualsIgnoreCase\u0026#34;: {\n                    \u0026#34;rds:db-tag/Application\u0026#34;: \u0026#34;application-name\u0026#34;\n                }\n            },\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;rds:DescribeDBInstances\u0026#34;,\n                \u0026#34;rds:StartDBInstance\u0026#34;,\n                \u0026#34;rds:StopDBInstance\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:rds:us-east-1:xxxxxxxxxxxx:db:db-instance-name\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws rds start and stop policy"},{"content":"If you have changed instance type to either C5 or M5 and it no longer boots, it’s due to the following reasons.\nThe Elastic Network Adapter (ENA) enaSupport attribute is disabled for the instance. The ENA module isn’t installed on the instance The NVMe module isn’t installed on the instance, or, if installed, the NVMe module isn’t loaded in the initramfs image of the instance. You are trying to mount the file systems at boot time in the “/etc/fstab” file using a device name. Amazon Elastic Block Store (Amazon EBS) volumes are exposed as NVMe devices to these instance types, and the device names are changed. To avoid this, mount the file systems using UUID/Label. For more information, see Amazon EBS and NVMe. You will need to run a Bash script to update the current instance to be able to support a C5 or M5 instance.\n","permalink":"http://uly.me/posts/aws-instance-type-to-m5-or-c5/","summary":"\u003cp\u003eIf you have changed instance type to either C5 or M5 and it no longer boots, it’s due to the following reasons.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eThe Elastic Network Adapter (ENA) enaSupport attribute is disabled for the instance.\u003c/li\u003e\n\u003cli\u003eThe ENA module isn’t installed on the instance\u003c/li\u003e\n\u003cli\u003eThe NVMe module isn’t installed on the instance, or, if installed, the NVMe module isn’t loaded in the initramfs image of the instance.\u003c/li\u003e\n\u003cli\u003eYou are trying to mount the file systems at boot time in the “/etc/fstab” file using a device name. Amazon Elastic Block Store (Amazon EBS) volumes are exposed as NVMe devices to these instance types, and the device names are changed. To avoid this, mount the file systems using UUID/Label. For more information, see \u003ca href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html\"\u003eAmazon EBS and NVMe\u003c/a\u003e.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eYou will need to run a Bash script to update the current instance to be able to support a \u003ca href=\"https://aws.amazon.com/premiumsupport/knowledge-center/boot-error-linux-m5-c5/\"\u003eC5 or M5\u003c/a\u003e instance.\u003c/p\u003e","title":"aws instance type to m5 or c5"},{"content":"Here’s how to get a user info from AWS CLI.\naws iam get-user --user-name John.Doe --profile default ","permalink":"http://uly.me/posts/aws-iam-get-user/","summary":"\u003cp\u003eHere’s how to get a user info from AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam get-user --user-name John.Doe --profile default\n\u003c/code\u003e\u003c/pre\u003e","title":"aws iam get user"},{"content":"Here’s how to get a list of EC2 tags.\naws ec2 describe-tags \\ --filters \u0026#34;Name=resource-id,Values=i-xxxxxxxxxxxxx\u0026#34; \\ --query \u0026#39;Tags[][Key,Value]\u0026#39; \\ --profile default \\ --region us-east-1 \\ --output text ","permalink":"http://uly.me/posts/aws-cli-ec2-describe-tags/","summary":"\u003cp\u003eHere’s how to get a list of EC2 tags.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-tags \\\n--filters \u0026#34;Name=resource-id,Values=i-xxxxxxxxxxxxx\u0026#34; \\\n--query \u0026#39;Tags[][Key,Value]\u0026#39;  \\\n--profile default \\\n--region us-east-1 \\\n--output text\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli ec2 describe tags"},{"content":"Here’s a typical setup for an Outbound DNS server.\nWhat are unbound servers? Unbound servers are a validating, recursive and caching DNS server\nInstall Unbound DNS\nyum install unbound Configuration: /etc/outbound/outbound.conf\nserver: interface: 0.0.0.0 access-control: 0.0.0.0/0 allow local-zone: \u0026#34;10.in-addr.arpa.\u0026#34; nodefault forward-zone: name: \u0026#34;10.in-addr.arpa.\u0026#34; forward-addr: 169.254.169.253 forward-zone: name: \u0026#34;ec2.internal\u0026#34; forward-addr: 169.254.169.253 forward-zone: name: \u0026#39;.\u0026#39; forward-addr: 10.10.10.1 forward-addr: 10.10.11.2 Unbound Start, Stop, Restart and Status\nservice outbound start | stop | restart | status ","permalink":"http://uly.me/posts/outbound-dns/","summary":"\u003cp\u003eHere’s a typical setup for an Outbound DNS server.\u003c/p\u003e\n\u003cp\u003eWhat are unbound servers? Unbound servers are a validating, recursive and caching DNS server\u003c/p\u003e\n\u003cp\u003eInstall Unbound DNS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install unbound\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eConfiguration: /etc/outbound/outbound.conf\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eserver:\n        interface: 0.0.0.0\n        access-control: 0.0.0.0/0 allow\n        local-zone: \u0026#34;10.in-addr.arpa.\u0026#34; nodefault\nforward-zone:\n        name: \u0026#34;10.in-addr.arpa.\u0026#34;\n        forward-addr: 169.254.169.253\nforward-zone:\n        name: \u0026#34;ec2.internal\u0026#34;\n        forward-addr: 169.254.169.253\nforward-zone:\n        name: \u0026#39;.\u0026#39;\n        forward-addr: 10.10.10.1\n        forward-addr: 10.10.11.2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUnbound Start, Stop, Restart and Status\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice outbound start | stop | restart | status\n\u003c/code\u003e\u003c/pre\u003e","title":"outbound dns"},{"content":".bash_profile is executed for login shells. .bashrc is executed for interactive non-login shells. When you login, .bash_profile is executed. If you are already logged in, .bashrc is executed. .bashrc is also executed when you start a new bash using /bin/bash.\n","permalink":"http://uly.me/posts/bash_profile-vs-bashrc/","summary":"\u003cp\u003e.bash_profile is executed for login shells. .bashrc is executed for interactive non-login shells. When you login, .bash_profile is executed. If you are already logged in, .bashrc is executed. .bashrc is also executed when you start a new bash using /bin/bash.\u003c/p\u003e","title":".bash_profile vs .bashrc"},{"content":"Here’s how to install Google Cloud Platform SDK on the following.\nCentos, Fedora and Redhat\n# Setup Repo sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo For Debian, Ubuntu, Mint.\n# Create an environment variable for the correct distribution export CLOUD_SDK_REPO=\u0026#34;cloud-sdk-$(lsb_release -c -s)\u0026#34; # Add the Cloud SDK distribution URI as a package source echo \u0026#34;deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main\u0026#34; | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list # Import the Google Cloud Platform public key curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - # Update the package list and install the Cloud SDK sudo apt-get update \u0026amp;\u0026amp; sudo apt-get install google-cloud-sdk ","permalink":"http://uly.me/posts/install-gcp-sdk/","summary":"\u003cp\u003eHere’s how to install Google Cloud Platform SDK on the following.\u003c/p\u003e\n\u003cp\u003eCentos, Fedora and Redhat\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Setup Repo\nsudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor Debian, Ubuntu, Mint.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Create an environment variable for the correct distribution\nexport CLOUD_SDK_REPO=\u0026#34;cloud-sdk-$(lsb_release -c -s)\u0026#34;\n# Add the Cloud SDK distribution URI as a package source\necho \u0026#34;deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main\u0026#34; | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list\n# Import the Google Cloud Platform public key\ncurl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -\n# Update the package list and install the Cloud SDK\nsudo apt-get update \u0026amp;\u0026amp; sudo apt-get install google-cloud-sdk\n\u003c/code\u003e\u003c/pre\u003e","title":"install gcp sdk"},{"content":"What’s a stale file handle? A file handle becomes stale when the file or directory referenced by the handle is removed by another host/server, while our client still holds an active reference to the object file/directory. A typical example occurs when the current directory of a process, running on our client, is removed on the server (either by a process running on the server or on another client).\nIf your NFS file handles are stale, run this command.\n/usr/bin/exportfs -a ","permalink":"http://uly.me/posts/exportfs/","summary":"\u003cp\u003eWhat’s a stale file handle? A file handle becomes stale when the file or directory referenced by the handle is removed by another host/server, while our client still holds an active reference to the object file/directory. A typical example occurs when the current directory of a process, running on our client, is removed on the server (either by a process running on the server or on another client).\u003c/p\u003e\n\u003cp\u003eIf your NFS file handles are stale, run this command.\u003c/p\u003e","title":"exportfs"},{"content":"How to convert Persistent Standard disk to SSD.\nFirst create a snapshot of the disk.\ngcloud compute disks snapshot your-server \\ --snapshot-names manual-snapshot-disk-1 \\ --project your-project \\ --zone us-central1-c Restore snapshot to SSD format.\ngcloud compute disks create disk-1-ssd \\ --source-snapshot manual-snapshot-disk-1 \\ --project your-project \\ --zone us-central1-a \\ --type pd-ssd \\ --size 10GB Swap disks using GCP attach and detach.\n","permalink":"http://uly.me/posts/gcp-convert-standard-to-ssd/","summary":"\u003cp\u003eHow to convert Persistent Standard disk to SSD.\u003c/p\u003e\n\u003cp\u003eFirst create a snapshot of the disk.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks snapshot your-server \\\n--snapshot-names manual-snapshot-disk-1 \\\n--project your-project \\\n--zone us-central1-c\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRestore snapshot to SSD format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create disk-1-ssd \\\n--source-snapshot manual-snapshot-disk-1 \\\n--project your-project \\\n--zone us-central1-a \\\n--type pd-ssd \\\n--size 10GB\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSwap disks using GCP attach and detach.\u003c/p\u003e","title":"gcp convert standard to ssd"},{"content":"How to set up umask for a Linux user.\n# sets umask for all users vi /etc/profile # sets umask for a user vi ~/.bashrc Add the following umask line to the file.\numask 0022 ","permalink":"http://uly.me/posts/set-user-umask/","summary":"\u003cp\u003eHow to set up umask for a Linux user.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# sets umask for all users\nvi /etc/profile\n# sets umask for a user\nvi ~/.bashrc\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd the following umask line to the file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eumask 0022\n\u003c/code\u003e\u003c/pre\u003e","title":"set user umask"},{"content":"Here’s a quick way to chroot another boot disk. Attach the rescued boot disk first. Run lsblk and mount.\nlsblk mount -t xfs -o nouuid /dev/xvdf2 /mnt mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys mount --bind /dev /mnt/dev chroot /mnt cd /mnt exit Unmount when done.\numount /mnt/proc umount /mnt/dev umount /mnt/sys umount /mnt ","permalink":"http://uly.me/posts/chroot-a-boot-disk/","summary":"\u003cp\u003eHere’s a quick way to chroot another boot disk. Attach the rescued boot disk first. Run lsblk and mount.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk\nmount -t xfs -o nouuid /dev/xvdf2 /mnt\nmount --bind /proc /mnt/proc\nmount --bind /sys /mnt/sys\nmount --bind /dev /mnt/dev\nchroot /mnt\ncd /mnt\nexit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUnmount when done.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eumount /mnt/proc\numount /mnt/dev\numount /mnt/sys\numount /mnt\n\u003c/code\u003e\u003c/pre\u003e","title":"chroot a boot disk"},{"content":"Here’s how to convert multiple files to UTF-8 format.\nfor file in *.csv; do iconv -f ascii -t utf-8 \u0026#34;$file\u0026#34; -o \u0026#34;${file%.txt}.utf8.csv\u0026#34; done ","permalink":"http://uly.me/posts/convert-file-to-utf-8/","summary":"\u003cp\u003eHere’s how to convert multiple files to UTF-8 format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efor file in *.csv; do\n    iconv -f ascii -t utf-8 \u0026#34;$file\u0026#34; -o \u0026#34;${file%.txt}.utf8.csv\u0026#34;\ndone\n\u003c/code\u003e\u003c/pre\u003e","title":"convert file to utf-8"},{"content":"Here’s how to import a SSL certificate into AWS Certificate Manager.\naws acm import-certificate \\ --certificate fileb://example.crt \\ --private-key fileb://example.key \\ --certificate-chain fileb://example-bundle.crt \\ --tags Key=Name,Value=mydomain.com_20220107 ","permalink":"http://uly.me/posts/aws-acm-certificate-import/","summary":"\u003cp\u003eHere’s how to import a SSL certificate into AWS Certificate Manager.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm import-certificate \\\n--certificate fileb://example.crt \\\n--private-key fileb://example.key \\\n--certificate-chain fileb://example-bundle.crt \\\n--tags Key=Name,Value=mydomain.com_20220107\n\u003c/code\u003e\u003c/pre\u003e","title":"aws acm certificate import"},{"content":"I ran into an issue with AWS CLI on Ubuntu 16.04. I was getting this error, “AWSHTTPSConnection’ object has no attribute ‘ssl_context” every time I try to do a simple “aws s3 ls” command. So, here’s the fix.\nAssuming you installed “awscli” using apt. Go ahead and uninstall it.\napt remove awscli Install awscli using pip instead.\napt install python-pip pip install awscli aws --version If this is a fresh install, you may have to run “aws configure.”\n","permalink":"http://uly.me/posts/install-aws-cli-on-ubuntu-16-04/","summary":"\u003cp\u003eI ran into an issue with AWS CLI on Ubuntu 16.04. I was getting this error, “AWSHTTPSConnection’ object has no attribute ‘ssl_context” every time I try to do a simple “aws s3 ls” command. So, here’s the fix.\u003c/p\u003e\n\u003cp\u003eAssuming you installed “awscli” using apt. Go ahead and uninstall it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt remove awscli\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall awscli using pip instead.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapt install python-pip\npip install awscli\naws --version\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf this is a fresh install, you may have to run “aws configure.”\u003c/p\u003e","title":"install aws cli on ubuntu 16.04"},{"content":"Here’s the Google Cloud Platform (GCP) GCloud command to list all disks in a specific project.\ngcloud compute disks list --project yourprojectname ","permalink":"http://uly.me/posts/gcp-lists-disk-per-project/","summary":"\u003cp\u003eHere’s the Google Cloud Platform (GCP) GCloud command to list all disks in a specific project.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks list --project yourprojectname\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp lists disk per project"},{"content":"If you’ve imported or created a SSL certificate via AWS Certificate Manager, here’s the CLI to display a list of certificates.\naws acm list-certificates Once you have the arn, you can describe certificate. Get the arn from the output above.\naws acm describe-certificate --certificate-arn arn-xxxxxxxxxxxxxxxxxx ","permalink":"http://uly.me/posts/aws-cli-list-acm-certificates/","summary":"\u003cp\u003eIf you’ve imported or created a SSL certificate via AWS Certificate Manager, here’s the CLI to display a list of certificates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm list-certificates\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce you have the arn, you can describe certificate. Get the arn from the output above.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm describe-certificate --certificate-arn arn-xxxxxxxxxxxxxxxxxx\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli list acm certificates"},{"content":"Here’s my script to create snapshots of a LightSail instance. Create daily or weekly snapshots.\n#!/bin/bash if [ $1 != \u0026#39;\u0026#39; ]; then prefix=$1 timestamp=$(date +%s) snapshotname=$prefix\u0026#39;_web-server_\u0026#39;$timestamp /usr/local/bin/aws lightsail create-instance-snapshot \\ --instance-snapshot-name $snapshotname \\ --instance-name web-server else echo \u0026#39;Need one argument. e.g. daily or weekly\u0026#39; fi Crontab. Job can be scheduled daily or weekly.\n# run daily at 4am 0 4 * * * /bin/bash /root/snapshots/create-snapshot.sh daily 2\u0026gt;\u0026amp;1 # run weekly every sunday at 5am 0 5 * * 0 /bin/bash /root/snapshots/create-snapshot.sh weekly 2\u0026gt;\u0026amp;1 ","permalink":"http://uly.me/posts/aws-lightsail-create-snapshots/","summary":"\u003cp\u003eHere’s my script to create snapshots of a LightSail instance. Create daily or weekly snapshots.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\nif [ $1 != \u0026#39;\u0026#39; ]; then \n  prefix=$1\n  timestamp=$(date +%s)\n  snapshotname=$prefix\u0026#39;_web-server_\u0026#39;$timestamp\n  /usr/local/bin/aws lightsail create-instance-snapshot \\\n  --instance-snapshot-name $snapshotname \\\n  --instance-name web-server\nelse\n  echo \u0026#39;Need one argument. e.g. daily or weekly\u0026#39;\nfi\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCrontab. Job can be scheduled daily or weekly.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# run daily at 4am\n0 4 * * * /bin/bash /root/snapshots/create-snapshot.sh daily 2\u0026gt;\u0026amp;1\n# run weekly every sunday at 5am\n0 5 * * 0 /bin/bash /root/snapshots/create-snapshot.sh weekly 2\u0026gt;\u0026amp;1\n\u003c/code\u003e\u003c/pre\u003e","title":"aws lightsail create snapshots"},{"content":"Here’s my script to delete AWS LightSail snapshots. It can delete daily or weekly backups and scheduled via crontab. If you want longer or shorter retention, adjust the expired value. It’s in seconds. 604800 is 1 week. 2592000 is 1 month.\n#!/bin/bash current=$(date +%s) if [ $# -eq 0 ]; then exit 1 fi if [[ $1 = \u0026#39;daily\u0026#39; ]]; then prefix=\u0026#39;daily\u0026#39; expired=$(($current-604800)) elif [[ $1 = \u0026#39;weekly\u0026#39; ]]; then prefix=\u0026#39;weekly\u0026#39; expired=$(($current-2592000)) else exit 1 fi snaps=\u0026#39;/root/snapshots/snapshots.json\u0026#39; names=\u0026#39;/root/snapshots/names.txt\u0026#39; parse=\u0026#39;/root/snapshots/parse.txt\u0026#39; logfile=\u0026#39;/root/snapshots/snapshots.log\u0026#39; /usr/local/bin/aws lightsail get-instance-snapshots \u0026gt; $snaps cat $snaps | jq -r \u0026#39;.instanceSnapshots[] | .name\u0026#39; \u0026gt; $names cat $names | grep $prefix \u0026gt; $parse while read -r line; do snapshot=$(echo $line | cut -d_ -f3) snapshotname=$line if [ `expr $snapshot + 1 2\u0026gt; /dev/null` ] ; then if [ $snapshot -le $expired ]; then echo \u0026#39;Deleted: \u0026#39;$snapshotname \u0026gt;\u0026gt; $logfile /usr/local/bin/aws lightsail delete-instance-snapshot \\ --instance-snapshot-name $snapshotname else echo \u0026#39;Nothing: \u0026#39;$snapshotname \u0026gt;\u0026gt; $logfile fi else echo $snapshot is not numeric \u0026gt; /dev/null fi done \u0026gt; $logfile echo \u0026#39;Expired time: \u0026#39;$expired \u0026gt;\u0026gt; $logfile echo \u0026#39;-----------------------------------\u0026#39; \u0026gt;\u0026gt; $logfile Schedule deletes via crontab.\n# run daily at 5am 0 5 * * * /bin/bash /root/snapshots/delete-snapshot.sh daily 2\u0026gt;\u0026amp;1 # run weekly every sunday at 6am 0 6 * * 0 /bin/bash /root/snapshots/delete-snapshot.sh weekly 2\u0026gt;\u0026amp;1 ","permalink":"http://uly.me/posts/aws-lightsail-delete-snapshots/","summary":"\u003cp\u003eHere’s my script to delete AWS LightSail snapshots. It can delete daily or weekly backups and scheduled via crontab. If you want longer or shorter retention, adjust the expired value. It’s in seconds. 604800 is 1 week. 2592000 is 1 month.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#!/bin/bash\n\ncurrent=$(date +%s)\n\nif [ $# -eq 0 ]; then\n  exit 1\nfi\n\nif [[ $1 = \u0026#39;daily\u0026#39; ]]; then\n  prefix=\u0026#39;daily\u0026#39;\n  expired=$(($current-604800))\nelif [[ $1 = \u0026#39;weekly\u0026#39; ]]; then\n  prefix=\u0026#39;weekly\u0026#39;\n  expired=$(($current-2592000))\nelse\n  exit 1\nfi\n\nsnaps=\u0026#39;/root/snapshots/snapshots.json\u0026#39;\nnames=\u0026#39;/root/snapshots/names.txt\u0026#39;\nparse=\u0026#39;/root/snapshots/parse.txt\u0026#39;\nlogfile=\u0026#39;/root/snapshots/snapshots.log\u0026#39;\n\n/usr/local/bin/aws lightsail get-instance-snapshots \u0026gt; $snaps\ncat $snaps | jq -r \u0026#39;.instanceSnapshots[] | .name\u0026#39; \u0026gt; $names\ncat $names | grep $prefix \u0026gt; $parse\n\nwhile read -r line; do\n\n  snapshot=$(echo $line | cut -d_ -f3)\n  snapshotname=$line\n\n  if [ `expr $snapshot + 1 2\u0026gt; /dev/null` ] ; then\n\n    if [ $snapshot -le $expired ]; then\n      echo \u0026#39;Deleted: \u0026#39;$snapshotname \u0026gt;\u0026gt; $logfile\n      /usr/local/bin/aws lightsail delete-instance-snapshot \\\n      --instance-snapshot-name $snapshotname\n    else\n      echo \u0026#39;Nothing: \u0026#39;$snapshotname \u0026gt;\u0026gt; $logfile\n    fi\n\n  else\n    echo $snapshot is not numeric \u0026gt; /dev/null\n  fi\n\ndone \u0026gt; $logfile\necho \u0026#39;Expired time: \u0026#39;$expired \u0026gt;\u0026gt; $logfile\necho \u0026#39;-----------------------------------\u0026#39; \u0026gt;\u0026gt; $logfile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSchedule deletes via crontab.\u003c/p\u003e","title":"aws lightsail delete snapshots"},{"content":"Jekyll is a static website generator you can use for developing simple websites. If you are running Jekyll on your desktop, you can view your static website by running a local server. If you want the leave the web server up and running in the background all the time, you can run this command instead.\n# normally you run this command jekyll serve # running it in the background jekyll serve \u0026gt; /dev/null 2\u0026gt;\u0026amp;1 \u0026amp; # add incremental which builds only deltas jekyll serve --incremental \u0026gt; /dev/null 2\u0026gt;\u0026amp;1 \u0026amp; To kill the server, run the following.\n# find jekyll server process ps -ef | grep jekyll # substitute pid# with process id kill -9 pid# ","permalink":"http://uly.me/posts/run-jekyll-in-background/","summary":"\u003cp\u003eJekyll is a static website generator you can use for developing simple websites. If you are running Jekyll on your desktop, you can view your static website by running a local server. If you want the leave the web server up and running in the background all the time, you can run this command instead.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# normally you run this command\njekyll serve\n# running it in the background\njekyll serve \u0026gt; /dev/null 2\u0026gt;\u0026amp;1 \u0026amp;\n# add incremental which builds only deltas\njekyll serve --incremental \u0026gt; /dev/null 2\u0026gt;\u0026amp;1 \u0026amp;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo kill the server, run the following.\u003c/p\u003e","title":"run jekyll in background"},{"content":"Add a yum repo manually by adding a configuration file in /etc/yum.repo.d/ directory.\ncd /etc/yum.repos.d/ vi newrepo Add the following.\n[newrepo] name=New Repo for RHEL/ CentOS $releasever - $basearch baseurl=http://newrepo.domain.com/centos/$releasever/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://newrepo.domain.com/RPM-GPG-KEY.txt You may need to import the key.\nrpm --import http://newrepo.domain.com/RPM-GPG-KEY.txt Finally, test the new repo by running the following.\nyum update -y yum install new-package ","permalink":"http://uly.me/posts/yum-add-repo-manually/","summary":"\u003cp\u003eAdd a yum repo manually by adding a configuration file in /etc/yum.repo.d/ directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /etc/yum.repos.d/\nvi newrepo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e[newrepo]\nname=New Repo for RHEL/ CentOS $releasever - $basearch\nbaseurl=http://newrepo.domain.com/centos/$releasever/$basearch/\nenabled=1\ngpgcheck=1\ngpgkey=http://newrepo.domain.com/RPM-GPG-KEY.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may need to import the key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm --import http://newrepo.domain.com/RPM-GPG-KEY.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFinally, test the new repo by running the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum update -y\nyum install new-package\n\u003c/code\u003e\u003c/pre\u003e","title":"yum add repo manually"},{"content":"Here’s how to get a list of EFS on AWS Backup. Displays a list and looks for a specific tag.\n#! /bin/bash tmpfil=\u0026#34;temp.txt\u0026#34; output=\u0026#34;efs-list.txt\u0026#34; \u0026gt; $output \u0026gt; $tmpfil declare -a account=(\u0026#34;default\u0026#34; \u0026#34;account1\u0026#34; \u0026#34;account2\u0026#34; \u0026#34;account3\u0026#34;) declare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;) for i in \u0026#34;${account[@]}\u0026#34;; do echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output echo $i \u0026gt;\u0026gt; $output echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output for j in \u0026#34;${region[@]}\u0026#34;; do echo $j \u0026gt;\u0026gt; $output echo \u0026#34;-------------------\u0026#34; \u0026gt;\u0026gt; $output aws efs describe-file-systems \\ --query \u0026#39;FileSystems[*].[FileSystemId]\u0026#39; \\ --profile $i --region $j --output text \u0026gt;\u0026gt; $tmpfil while read -r efs; do echo $efs \u0026gt;\u0026gt; $output sleep 1s aws efs describe-tags --file-system-id $efs \\ --query \u0026#39;Tags[?Key==`aws-backup`].{Name:Key,Value:Value}\u0026#39; \\ --profile $i --region $j --output text \u0026gt;\u0026gt; $output echo \u0026#34;...................\u0026#34; \u0026gt;\u0026gt; $output done $tmpfil done done rm $tmpfil Output file is efs-list.txt\n","permalink":"http://uly.me/posts/aws-efs-list-on-aws-backup/","summary":"\u003cp\u003eHere’s how to get a list of EFS on AWS Backup. Displays a list and looks for a specific tag.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#! /bin/bash\n\ntmpfil=\u0026#34;temp.txt\u0026#34;\noutput=\u0026#34;efs-list.txt\u0026#34;\n\n\u0026gt; $output\n\u0026gt; $tmpfil\n\ndeclare -a account=(\u0026#34;default\u0026#34; \u0026#34;account1\u0026#34; \u0026#34;account2\u0026#34; \u0026#34;account3\u0026#34;)\ndeclare -a region=(\u0026#34;us-east-1\u0026#34; \u0026#34;us-east-2\u0026#34; \u0026#34;us-west-1\u0026#34; \u0026#34;us-west-2\u0026#34;)\n\nfor i in \u0026#34;${account[@]}\u0026#34;; do\n  echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output\n  echo $i \u0026gt;\u0026gt; $output\n  echo \u0026#34;===================\u0026#34; \u0026gt;\u0026gt; $output\n  for j in \u0026#34;${region[@]}\u0026#34;; do\n    echo $j \u0026gt;\u0026gt; $output\n    echo \u0026#34;-------------------\u0026#34; \u0026gt;\u0026gt; $output\n    aws efs describe-file-systems \\\n    --query \u0026#39;FileSystems[*].[FileSystemId]\u0026#39; \\\n    --profile $i --region $j --output text \u0026gt;\u0026gt; $tmpfil\n    while read -r efs; do\n      echo $efs \u0026gt;\u0026gt; $output\n      sleep 1s\n      aws efs describe-tags --file-system-id $efs \\\n      --query \u0026#39;Tags[?Key==`aws-backup`].{Name:Key,Value:Value}\u0026#39; \\\n      --profile $i --region $j --output text \u0026gt;\u0026gt; $output\n      echo \u0026#34;...................\u0026#34; \u0026gt;\u0026gt; $output\n    done  $tmpfil\n  done\ndone\nrm $tmpfil\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput file is efs-list.txt\u003c/p\u003e","title":"aws efs list on aws backup"},{"content":"Here’s the template for launching an EC2 instance via Terraform.\nprovider \u0026#34;aws\u0026#34; { region = \u0026#34;us-east-1\u0026#34; shared_credentials_file = \u0026#34;/home/username/.aws/credentials\u0026#34; profile = \u0026#34;default\u0026#34; } resource \u0026#34;aws_security_group\u0026#34; \u0026#34;hostname-sg\u0026#34; { name = \u0026#34;allow ssh\u0026#34; vpc_id = \u0026#34;\u0026#34; ingress { cidr_blocks = [ \u0026#34;10.0.0.0/8\u0026#34; ] from_port = 22 to_port = 22 protocol = \u0026#34;tcp\u0026#34; } egress { from_port = 0 to_port = 0 protocol = \u0026#34;-1\u0026#34; cidr_blocks = [ \u0026#34;0.0.0.0/0\u0026#34; ] } } resource \u0026#34;aws_instance\u0026#34; \u0026#34;hostname\u0026#34; { ami = \u0026#34;ami-xxxxxxxxxx\u0026#34; key_name = \u0026#34;your-key\u0026#34; instance_type = \u0026#34;t2.large\u0026#34; subnet_id = \u0026#34;subnet-xxxxxxxx\u0026#34; security_groups\t= [\u0026#34;${aws_security_group.hostname-sg.id}\u0026#34;] tags { Name = \u0026#34;hostname\u0026#34; Environment = \u0026#34;development\u0026#34; } } ","permalink":"http://uly.me/posts/terraform-launch-ec2-instance/","summary":"\u003cp\u003eHere’s the template for launching an EC2 instance via Terraform.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eprovider \u0026#34;aws\u0026#34; {\n  region                  = \u0026#34;us-east-1\u0026#34;\n  shared_credentials_file = \u0026#34;/home/username/.aws/credentials\u0026#34;\n  profile                 = \u0026#34;default\u0026#34;\n}\nresource \u0026#34;aws_security_group\u0026#34; \u0026#34;hostname-sg\u0026#34; {\n\tname = \u0026#34;allow ssh\u0026#34;\n\tvpc_id = \u0026#34;\u0026#34;\n\tingress {\n\t\tcidr_blocks = [ \u0026#34;10.0.0.0/8\u0026#34; ]\n\t\tfrom_port = 22\n\t\tto_port = 22\n\t\tprotocol = \u0026#34;tcp\u0026#34;\n\t}\n\tegress {\n\t\tfrom_port = 0\n\t\tto_port = 0\n\t\tprotocol = \u0026#34;-1\u0026#34;\n\t\tcidr_blocks = [ \u0026#34;0.0.0.0/0\u0026#34; ]\n\t}\n}\nresource \u0026#34;aws_instance\u0026#34; \u0026#34;hostname\u0026#34; {\n\tami = \u0026#34;ami-xxxxxxxxxx\u0026#34;\n\tkey_name = \u0026#34;your-key\u0026#34;\n\tinstance_type = \u0026#34;t2.large\u0026#34;\n\tsubnet_id = \u0026#34;subnet-xxxxxxxx\u0026#34;\n\tsecurity_groups\t= [\u0026#34;${aws_security_group.hostname-sg.id}\u0026#34;]\n\ttags {\n\t\tName = \u0026#34;hostname\u0026#34;\n\t\tEnvironment = \u0026#34;development\u0026#34;\n\t}\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform launch ec2 instance"},{"content":"Test if the GCP Load Balancer is working by sending a curl command from the backend VM.\nAssume the load balancer IP address is 10.1.2.99, and the VM is called vm-a1.\ncurl http://10.1.2.99 The end result is …\nPage served from: vm-a1 Make sure there’s an entry in the local table that matches the IP of the load balancer.\nip route show table local | grep 10.1.2.99 If not, add it.\nip route add to local 10.1.2.99/32 dev eth0 proto 66 Documentation\n","permalink":"http://uly.me/posts/gcp-load-balancer-local-routing-table/","summary":"\u003cp\u003eTest if the GCP Load Balancer is working by sending a curl command from the backend VM.\u003c/p\u003e\n\u003cp\u003eAssume the load balancer IP address is 10.1.2.99, and the VM is called vm-a1.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl http://10.1.2.99\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe end result is …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePage served from: vm-a1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake sure there’s an entry in the local table that matches the IP of the load balancer.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eip route show table local | grep 10.1.2.99\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf not, add it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eip route add to local 10.1.2.99/32 dev eth0 proto 66\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e\u003ca href=\"https://cloud.google.com/load-balancing/docs/internal/setting-up-internal\"\u003eDocumentation\u003c/a\u003e\u003c/p\u003e","title":"gcp load balancer local routing table"},{"content":"The chrony service actually does not change the time. The misconception is that the chrony service is setting the time given by the NTP server. This is not what’s happening. The chrony service is just telling the system clock to go faster or slower. This is the reason why sometimes even though the time is wrong and the NTP server is working, the time does not get corrected immediately. It takes a little while.\n","permalink":"http://uly.me/posts/chrony-service/","summary":"\u003cp\u003eThe chrony service actually does not change the time. The misconception is that the chrony service is setting the time given by the NTP server. This is not what’s happening. The chrony service is just telling the system clock to go faster or slower. This is the reason why sometimes even though the time is wrong and the NTP server is working, the time does not get corrected immediately. It takes a little while.\u003c/p\u003e","title":"chrony service"},{"content":"Check if rpcbind is running.\nservice rpcbind status|start|stop|restart Or you can also clean the NFS cache.\nservice rpcbind stop service nfslock stop rm -rf /var/lib/nfs/statd/sm/* rm -rf /var/lib/nfs/statd/sm.bak/* service rpcbind start service nfslock start ","permalink":"http://uly.me/posts/nfs-fails-to-mount-on-bootup/","summary":"\u003cp\u003eCheck if rpcbind is running.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice rpcbind status|start|stop|restart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOr you can also clean the NFS cache.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice rpcbind stop\nservice nfslock stop\nrm -rf /var/lib/nfs/statd/sm/*\nrm -rf /var/lib/nfs/statd/sm.bak/*\nservice rpcbind start\nservice nfslock start\n\u003c/code\u003e\u003c/pre\u003e","title":"nfs fails to mount on bootup"},{"content":"Give someone upload access to a S3 bucket. Here’s the policy.\n{ \u0026#34;Version\u0026#34;:\u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;:[ { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:ListAllMyBuckets\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::*\u0026#34; }, { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:ListBucket\u0026#34;, \u0026#34;s3:GetBucketLocation\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::your-bucket-name\u0026#34; }, { \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[ \u0026#34;s3:PutObject\u0026#34;, \u0026#34;s3:PutObjectAcl\u0026#34;, \u0026#34;s3:GetObject\u0026#34;, \u0026#34;s3:GetObjectAcl\u0026#34;, \u0026#34;s3:DeleteObject\u0026#34; ], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::your-bucket-name/*\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-s3-upload-policy/","summary":"\u003cp\u003eGive someone upload access to a S3 bucket. Here’s the policy.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n   \u0026#34;Version\u0026#34;:\u0026#34;2012-10-17\u0026#34;,\n   \u0026#34;Statement\u0026#34;:[\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:ListAllMyBuckets\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::*\u0026#34;\n      },\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:ListBucket\u0026#34;,\n            \u0026#34;s3:GetBucketLocation\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::your-bucket-name\u0026#34;\n      },\n      {\n         \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n         \u0026#34;Action\u0026#34;:[\n            \u0026#34;s3:PutObject\u0026#34;,\n            \u0026#34;s3:PutObjectAcl\u0026#34;,\n            \u0026#34;s3:GetObject\u0026#34;,\n            \u0026#34;s3:GetObjectAcl\u0026#34;,\n            \u0026#34;s3:DeleteObject\u0026#34;\n         ],\n         \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:s3:::your-bucket-name/*\u0026#34;\n      }\n   ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws s3 upload policy"},{"content":"Here’s how to enable secondary private IPs for AWS EC2 instances.\nAdd secondary private IPs to the instance. Editing the instance Networking \u0026gt; Manage IP Addresses. Add new private IP addresses. Save. Set the route configuration for each secondary IP address. Config files are ifcfg-eth0:0, ifcfg-eth:0.1 and so on. Test each interface or IP to see if they respond to ping. /etc/sysconfig/network-scripts/ ifcfg-eth0:0\nNM_CONTROLLED=\u0026#34;no\u0026#34; DEVICE=\u0026#34;eth0:0\u0026#34; ONBOOT=\u0026#34;yes\u0026#34; BOOTPROTO=\u0026#34;static\u0026#34; IPADDR=\u0026#34;10.0.0.14\u0026#34; NETMASK=\u0026#34;255.255.255.255\u0026#34; ifcfg-eth0:1\nNM_CONTROLLED=\u0026#34;no\u0026#34; DEVICE=\u0026#34;eth0:1\u0026#34; ONBOOT=\u0026#34;yes\u0026#34; BOOTPROTO=\u0026#34;static\u0026#34; IPADDR=\u0026#34;10.0.0.15\u0026#34; NETMASK=\u0026#34;255.255.255.255\u0026#34; ","permalink":"http://uly.me/posts/aws-ec2-enable-secondary-ips/","summary":"\u003cp\u003eHere’s how to enable secondary private IPs for AWS EC2 instances.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eAdd secondary private IPs to the instance.\n\u003cul\u003e\n\u003cli\u003eEditing the instance Networking \u0026gt; Manage IP Addresses.\u003c/li\u003e\n\u003cli\u003eAdd new private IP addresses.\u003c/li\u003e\n\u003cli\u003eSave.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eSet the route configuration for each secondary IP address.\n\u003cul\u003e\n\u003cli\u003eConfig files are ifcfg-eth0:0, ifcfg-eth:0.1 and so on.\u003c/li\u003e\n\u003cli\u003eTest each interface or IP to see if they respond to ping.\u003c/li\u003e\n\u003cli\u003e/etc/sysconfig/network-scripts/\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eifcfg-eth0:0\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eNM_CONTROLLED=\u0026#34;no\u0026#34;\nDEVICE=\u0026#34;eth0:0\u0026#34;\nONBOOT=\u0026#34;yes\u0026#34;\nBOOTPROTO=\u0026#34;static\u0026#34;\nIPADDR=\u0026#34;10.0.0.14\u0026#34;\nNETMASK=\u0026#34;255.255.255.255\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eifcfg-eth0:1\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eNM_CONTROLLED=\u0026#34;no\u0026#34;\nDEVICE=\u0026#34;eth0:1\u0026#34;\nONBOOT=\u0026#34;yes\u0026#34;\nBOOTPROTO=\u0026#34;static\u0026#34;\nIPADDR=\u0026#34;10.0.0.15\u0026#34;\nNETMASK=\u0026#34;255.255.255.255\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws ec2 enable secondary ips"},{"content":"Some cache to clear.\nservice sssd stop rm -r /var/lib/sss/db/* rm -r /var/lib/sss/mc/* service sssd start Rejoin domain. Run sssd script. Restart sssd.\n","permalink":"http://uly.me/posts/sssd-issues-redhat-7/","summary":"\u003cp\u003eSome cache to clear.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice sssd stop\nrm -r /var/lib/sss/db/*\nrm -r /var/lib/sss/mc/*\nservice sssd start\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRejoin domain. Run sssd script. Restart sssd.\u003c/p\u003e","title":"sssd issues redhat 7"},{"content":"How to start/stop/restart/status TrendMicro Security agent.\n/etc/init.d/ds_agent start /etc/init.d/ds_agent stop /etc/init.d/ds_agent restart /etc/init.d/ds_agent status /etc/init.d/ds_agent reset Check if installed.\nrpm -qa | grep \u0026#39;ds_agent\u0026#39; Install with verbose and hash.\nrpm -ivh package-name Uninstall with verbose.\nrpm -ev package-name ","permalink":"http://uly.me/posts/trendmicro-security-agent/","summary":"\u003cp\u003eHow to start/stop/restart/status TrendMicro Security agent.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/etc/init.d/ds_agent start\n/etc/init.d/ds_agent stop\n/etc/init.d/ds_agent restart\n/etc/init.d/ds_agent status\n/etc/init.d/ds_agent reset\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa | grep \u0026#39;ds_agent\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall with verbose and hash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -ivh package-name\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUninstall with verbose.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -ev package-name\n\u003c/code\u003e\u003c/pre\u003e","title":"trendmicro security agent"},{"content":"How to use SFTP with AWS Keys.\nsftp -i \u0026#34;yourkey\u0026#34; ec2-user@your-server To copy files to server. File will copied to user’s home directory.\nsftp\u0026gt; put file.txt . ","permalink":"http://uly.me/posts/sftp-with-aws-keys/","summary":"\u003cp\u003eHow to use SFTP with AWS Keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esftp -i \u0026#34;yourkey\u0026#34; ec2-user@your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo copy files to server. File will copied to user’s home directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esftp\u0026gt; put file.txt .\n\u003c/code\u003e\u003c/pre\u003e","title":"sftp with aws keys"},{"content":"How to add tags to an existing IAM user via AWS CLI.\naws iam tag-user \\ --user-name john.doe \\ --tags \u0026#39;{\u0026#34;Key\u0026#34;: \u0026#34;Department\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;Accounting\u0026#34;}\u0026#39; Multiple tags.\naws iam tag-user \\ --user-name john.doe \\ --tags \u0026#39;[{\u0026#34;Key\u0026#34;: \u0026#34;Department\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;Accounting\u0026#34;},{\u0026#34;Key\u0026#34;: \u0026#34;Manager\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;jane.doe\u0026#34;}]\u0026#39; ","permalink":"http://uly.me/posts/aws-cli-add-tags-to-iam-user/","summary":"\u003cp\u003eHow to add tags to an existing IAM user via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam tag-user \\\n--user-name john.doe \\\n--tags \u0026#39;{\u0026#34;Key\u0026#34;: \u0026#34;Department\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;Accounting\u0026#34;}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMultiple tags.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam tag-user \\\n--user-name john.doe \\\n--tags \u0026#39;[{\u0026#34;Key\u0026#34;: \u0026#34;Department\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;Accounting\u0026#34;},{\u0026#34;Key\u0026#34;: \u0026#34;Manager\u0026#34;, \u0026#34;Value\u0026#34;: \u0026#34;jane.doe\u0026#34;}]\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli add tags to iam user"},{"content":"Here’s how to get a list of EC2 instances with a status of impaired.\naws ec2 describe-instance-status \\ --filters Name=instance-status.status,Values=impaired ","permalink":"http://uly.me/posts/aws-cli-ec2-impaired-instances/","summary":"\u003cp\u003eHere’s how to get a list of EC2 instances with a status of impaired.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instance-status \\\n--filters Name=instance-status.status,Values=impaired\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli ec2 impaired instances"},{"content":"How to create an IAM user via AWS CLI.\naws iam create-user --user-name john.doe \\ --tags Key=\u0026#39;key1\u0026#39;,Value=\u0026#39;value1\u0026#39;, Key=\u0026#39;key2\u0026#39;,Value=\u0026#39;value2\u0026#39; \\ --profile your-profile To add keys.\naws iam create-access-key \\ --user-name username \\ --profile your-profile ","permalink":"http://uly.me/posts/aws-cli-iam-create-user/","summary":"\u003cp\u003eHow to create an IAM user via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam create-user --user-name john.doe \\\n--tags Key=\u0026#39;key1\u0026#39;,Value=\u0026#39;value1\u0026#39;, Key=\u0026#39;key2\u0026#39;,Value=\u0026#39;value2\u0026#39; \\\n--profile your-profile\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo add keys.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws iam create-access-key \\\n--user-name username \\\n--profile your-profile\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli iam create user"},{"content":"Migrating a EFS from one VPC to another is quite simple. There’s no need to delete it. Just click on “manage file systems access” and remove all mount targets and Save. Once the targets are removed, you can choose another VPC from the dropdown. Once a VPC is selected. Add the subnets and security groups. Save and you are done!\n","permalink":"http://uly.me/posts/migrate-efs-to-another-vpc/","summary":"\u003cp\u003eMigrating a EFS from one VPC to another is quite simple. There’s no need to delete it. Just click on “manage file systems access” and remove all mount targets and Save. Once the targets are removed, you can choose another VPC from the dropdown. Once a VPC is selected. Add the subnets and security groups. Save and you are done!\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/07/efs-vpc.png\"\u003e\u003c/p\u003e","title":"migrate efs to another vpc"},{"content":"How to display AWS EC2 instance statuses.\naws ec2 describe-instance-status \\ --query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\ --include-all-instances \\ --region us-east-2 --profile abcdef \\ Query and Filter.\naws ec2 describe-instance-status \\ --query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\ --filter \u0026#39;Name=instance-state-name,Values=stopped\u0026#39; \\ --region us-east-2 --profile abcdef \\ Filter event.code equal to instance-reboot.\naws ec2 describe-instance-status \\ --query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\ --filter \u0026#39;Name=eventcode,Values=instance-reboot\u0026#39; \\ --region us-east-2 --profile abcdef \\ ","permalink":"http://uly.me/posts/aws-cli-ec2-instance-status/","summary":"\u003cp\u003eHow to display AWS EC2 instance statuses.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instance-status \\\n--query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\\n--include-all-instances \\\n--region us-east-2\n--profile abcdef \\\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eQuery and Filter.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instance-status \\\n--query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\\n--filter \u0026#39;Name=instance-state-name,Values=stopped\u0026#39; \\\n--region us-east-2\n--profile abcdef \\\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFilter event.code equal to instance-reboot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instance-status \\\n--query \u0026#39;InstanceStatuses[].[InstanceId,SystemStatus.Status]\u0026#39; \\\n--filter \u0026#39;Name=eventcode,Values=instance-reboot\u0026#39; \\\n--region us-east-2\n--profile abcdef \\\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli ec2 instance status"},{"content":"If you switched to HTTPS in Apache, make sure to update CodeIgniter’s config file.\nvim /var/www/applications/config/config.php Change the base URL to https.\n$config[\u0026#39;base_url\u0026#39;]\t= \u0026#39;https://yourdomain.com/ci/\u0026#39;; ","permalink":"http://uly.me/posts/https-in-codeigniter/","summary":"\u003cp\u003eIf you switched to HTTPS in Apache, make sure to update CodeIgniter’s config file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim /var/www/applications/config/config.php\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange the base URL to https.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$config[\u0026#39;base_url\u0026#39;]\t= \u0026#39;https://yourdomain.com/ci/\u0026#39;;\n\u003c/code\u003e\u003c/pre\u003e","title":"https in codeigniter"},{"content":"Here’s how to find uptime in Windows servers.\nGo to “Start” -\u0026gt; “Run”. Write “CMD” and press “Enter” key.\nnet statistics server # or net stats srv ","permalink":"http://uly.me/posts/uptime-in-windows/","summary":"\u003cp\u003eHere’s how to find uptime in Windows servers.\u003c/p\u003e\n\u003cp\u003eGo to “Start” -\u0026gt; “Run”. Write “CMD” and press “Enter” key.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enet statistics server\n# or\nnet stats srv\n\u003c/code\u003e\u003c/pre\u003e","title":"uptime in windows"},{"content":"If the EFS mount is unresponsive, try using this …\n/bin/ls -1f This is an issue with having too many small files in a directory. This can be fixed by sharding files to multiple sub-directories.\n","permalink":"http://uly.me/posts/efs-io-issue/","summary":"\u003cp\u003eIf the EFS mount is unresponsive, try using this …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/bin/ls -1f\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is an issue with having too many small files in a directory. This can be fixed by sharding files to multiple sub-directories.\u003c/p\u003e","title":"efs io issue"},{"content":"On October 2018, Lion Air Flight 610 from Jakarta to Pangkal Pinang, crashed into the sea 13 minutes after takeoff, killing all 189 people aboard. Six months later, Ethiopian Airlines Flight 302, went down under similar circumstances, killing all 157 people aboard. All Boeing 737 Max planes were grounded world-wide. Over $6 billion dollars evaporated from the company’s market cap overnight. If the crisis is not fixed soon, it will impact the long term stability of the company. Boeing 737 sales are 33% of the projected sales in the next 5 years.\nThe flaw turned out to be the MCAS system which is a life-critical system in which software quality is of the utmost importance. Software budgets should be heavily invested, which can greatly reduce defects, and make a difference between life and death. To cut costs, executives often rush decisions, imposing unrealistic deadlines, and outsourcing to cheap contractors to save money. When products and services are rushed, morale suffers, quality suffers, productivity suffers, bugs pile up, tests are skipped, and there is team burnout.\nThe valuable lesson to all of this is, don’t repeat Boeing mistakes. Don’t be obsessed with cost cutting to save a few dollars, if it’s going to cost the company a lot more in the long run. Don’t sacrifice quality. It could have been a huge win for Boeing had it not been obsessed with cost cutting. It turned out to be a big disaster in the end. All that management did was take a hatchet into the Boeing brand. In the end, cheap is sometimes expensive.\n","permalink":"http://uly.me/posts/lessons-from-boeing-737/","summary":"\u003cp\u003eOn October 2018, Lion Air Flight 610 from Jakarta to Pangkal Pinang, crashed into the sea 13 minutes after takeoff, killing all 189 people aboard. Six months later, Ethiopian Airlines Flight 302, went down under similar circumstances, killing all 157 people aboard. All Boeing 737 Max planes were grounded world-wide. Over $6 billion dollars evaporated from the company’s market cap overnight. If the crisis is not fixed soon, it will impact the long term stability of the company. Boeing 737 sales are 33% of the projected sales in the next 5 years.\u003c/p\u003e","title":"lessons from boeing 737"},{"content":"Here’s the installation of Docker for the original Amazon Linux.\n# To install docker sudo yum install docker sudo service docker start # Validate it\u0026#39;s working docker --version docker run hello-world docker ps -a docker image ls ","permalink":"http://uly.me/posts/amazon-linux-docker-install/","summary":"\u003cp\u003eHere’s the installation of Docker for the original Amazon Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# To install docker\nsudo yum install docker\nsudo service docker start\n# Validate it\u0026#39;s working\ndocker --version\ndocker run hello-world\ndocker ps -a\ndocker image ls\n\u003c/code\u003e\u003c/pre\u003e","title":"amazon linux docker install"},{"content":"How to login using SFTP on a non-standard port.\nsftp -oPort=2233 username@servername Get list of commands.\nsftp help ","permalink":"http://uly.me/posts/sftp-login/","summary":"\u003cp\u003eHow to login using SFTP on a non-standard port.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esftp -oPort=2233 username@servername\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGet list of commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esftp help\n\u003c/code\u003e\u003c/pre\u003e","title":"sftp login"},{"content":"How to display IP address and Instance ID on web page behind a AWS load balancer.\nAdd these 2 commands in crontab. The job runs every 5 mins.\n*/5 * * * * /usr/bin/curl http://169.254.169.254/latest/meta-data/instance-id \u0026gt; /var/www/html/id.txt */5 * * * * /usr/bin/curl http://169.254.169.254/latest/meta-data/public-ipv4 \u0026gt; /var/www/html/ip.txt You can view on the site.\n# your domain http://yourdomain.com/ip.txt http://yourdomain.com/id.txt # your server ip address http://1.1.1.1/ip.txt http://1.1.1.1/id.txt ","permalink":"http://uly.me/posts/display-instance-id-ip-address/","summary":"\u003cp\u003eHow to display IP address and Instance ID on web page behind a AWS load balancer.\u003c/p\u003e\n\u003cp\u003eAdd these 2 commands in crontab. The job runs every 5 mins.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e*/5 * * * * /usr/bin/curl http://169.254.169.254/latest/meta-data/instance-id \u0026gt; /var/www/html/id.txt\n*/5 * * * * /usr/bin/curl http://169.254.169.254/latest/meta-data/public-ipv4 \u0026gt; /var/www/html/ip.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can view on the site.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# your domain\nhttp://yourdomain.com/ip.txt\nhttp://yourdomain.com/id.txt\n# your server ip address\nhttp://1.1.1.1/ip.txt\nhttp://1.1.1.1/id.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"display instance id and ip address"},{"content":"If you’re the only user on your system, you don’t need to be prompted every time you run the sudo command.\nAdd yourself to the sudoers file.\n# create a new file sudo visudo -f /etc/sudoers.d/users Add this line.\n# add your username username ALL=(ALL) NOPASSWD:ALL Exit and try again.\n# exit out and login again exit # try to sudo again sudo -i # there\u0026#39;s no password prompt for sudo this time ","permalink":"http://uly.me/posts/sudo-with-no-password/","summary":"\u003cp\u003eIf you’re the only user on your system, you don’t need to be prompted every time you run the sudo command.\u003c/p\u003e\n\u003cp\u003eAdd yourself to the sudoers file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# create a new file\nsudo visudo -f /etc/sudoers.d/users\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd this line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# add your username\nusername ALL=(ALL) NOPASSWD:ALL\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExit and try again.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# exit out and login again\nexit\n# try to sudo again\nsudo -i\n# there\u0026#39;s no password prompt for sudo this time\n\u003c/code\u003e\u003c/pre\u003e","title":"sudo with no password"},{"content":"Where’s Apache and webroot for the different distros?\nWebroot:\n# Redhat, Fedora, Centos, Amazon Linux /var/www/html # Debian, Ubuntu, Mint /var/www/html Apache Configuration:\n# Redhat, Fedora, Centos, Amazon Linux /etc/httpd/conf/httpd.conf # Debian, Ubuntu, Mint /etc/apache2/sites-available/default ","permalink":"http://uly.me/posts/apache-webroot/","summary":"\u003cp\u003eWhere’s Apache and webroot for the different distros?\u003c/p\u003e\n\u003cp\u003eWebroot:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Redhat, Fedora, Centos, Amazon Linux\n/var/www/html\n# Debian, Ubuntu, Mint\n/var/www/html\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eApache Configuration:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Redhat, Fedora, Centos, Amazon Linux\n/etc/httpd/conf/httpd.conf\n# Debian, Ubuntu, Mint\n/etc/apache2/sites-available/default\n\u003c/code\u003e\u003c/pre\u003e","title":"apache webroot"},{"content":"Run Icecast2 on a Docker container.\ndocker run -d \\ -p 8000:8000 \\ -e ICECAST_SOURCE_PASSWORD=aaaa \\ -e ICECAST_ADMIN_PASSWORD=bbbb \\ -e ICECAST_PASSWORD=cccc \\ -e ICECAST_RELAY_PASSWORD=dddd \\ moul/icecast Access localhost:8000 on browser. Github.\n","permalink":"http://uly.me/posts/icecast-on-docker/","summary":"\u003cp\u003eRun Icecast2 on a Docker container.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker run -d \\\n-p 8000:8000 \\\n-e ICECAST_SOURCE_PASSWORD=aaaa \\\n-e ICECAST_ADMIN_PASSWORD=bbbb \\\n-e ICECAST_PASSWORD=cccc \\\n-e ICECAST_RELAY_PASSWORD=dddd \\\nmoul/icecast\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAccess localhost:8000 on browser. \u003ca href=\"https://github.com/moul/docker-icecast\"\u003eGithub\u003c/a\u003e.\u003c/p\u003e","title":"icecast on docker"},{"content":"Convert MP3 to Vorbis OGG format using ffmpeg.\nffmpeg -i input.mp3 -c:a libvorbis -q:a 4 output.ogg If you want multiple files, use a loop.\nfor f in ./*.mp3; do ffmpeg -i \u0026#34;$f\u0026#34; -c:a libvorbis -q:a 4 \u0026#34;${f/%mp3/ogg}\u0026#34;; done ","permalink":"http://uly.me/posts/convert-mp3-to-ogg/","summary":"\u003cp\u003eConvert MP3 to Vorbis OGG format using ffmpeg.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003effmpeg -i input.mp3 -c:a libvorbis -q:a 4 output.ogg\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want multiple files, use a loop.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efor f in ./*.mp3; do ffmpeg -i \u0026#34;$f\u0026#34; -c:a libvorbis -q:a 4 \u0026#34;${f/%mp3/ogg}\u0026#34;; done\n\u003c/code\u003e\u003c/pre\u003e","title":"convert mp3 to ogg"},{"content":"Here’s the command to stop and remove all Docker containers.\ndocker stop $(docker ps -a -q) docker rm $(docker ps -a -q) ","permalink":"http://uly.me/posts/docker-stop-and-remove-all/","summary":"\u003cp\u003eHere’s the command to stop and remove all Docker containers.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker stop $(docker ps -a -q)\ndocker rm $(docker ps -a -q)\n\u003c/code\u003e\u003c/pre\u003e","title":"docker stop and remove all"},{"content":"How to install Docker on Linux Mint or Ubuntu.\nsudo apt-get install docker-ce docker-ce-cli containerd.io docker --version ","permalink":"http://uly.me/posts/install-docker-on-linux/","summary":"\u003cp\u003eHow to install Docker on Linux Mint or Ubuntu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install docker-ce docker-ce-cli containerd.io\ndocker --version\n\u003c/code\u003e\u003c/pre\u003e","title":"install docker on linux"},{"content":"You can import the Matrox Monarch HD configuration on boot up from a web page. Go to:\nCommand Center \u0026gt; Automatic Configuration. Type in URL Address starting with https. Check \u0026#34;Load settings on device reboot.\u0026#34; You can either power off the device or hit reset. Holding reset for more than 5 seconds does a factory reset. On next bootup, device will have configuration contained from the remote file. ","permalink":"http://uly.me/posts/matrox-monarch-configuration/","summary":"\u003cp\u003eYou can import the Matrox Monarch HD configuration on boot up from a web page. Go to:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eCommand Center \u0026gt; Automatic Configuration.\nType in URL Address starting with https.\nCheck \u0026#34;Load settings on device reboot.\u0026#34;\nYou can either power off the device or hit reset.\nHolding reset for more than 5 seconds does a factory reset.\nOn next bootup, device will have configuration contained from the remote file.\n\u003c/code\u003e\u003c/pre\u003e","title":"matrox monarch configuration"},{"content":"Format USB drives to NTFS. Use USB 0 for recording.\n","permalink":"http://uly.me/posts/matrox-monarch-usb-format/","summary":"\u003cp\u003eFormat USB drives to NTFS. Use USB 0 for recording.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/07/matrox.jpg\"\u003e\u003c/p\u003e","title":"matrox monarch usb format"},{"content":"If you’re seeing an XML error, check the default root object in your CloudFront distribution.\nCloudFront distribution setting\nIt should be set to your index page.\n","permalink":"http://uly.me/posts/cloudfront-xml-error/","summary":"\u003cp\u003eIf you’re seeing an XML error, check the default root object in your CloudFront distribution.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/06/default-root.png\"\u003e\u003c/p\u003e\n\u003cp\u003eCloudFront distribution setting\u003c/p\u003e\n\u003cp\u003eIt should be set to your index page.\u003c/p\u003e","title":"cloudfront xml error"},{"content":"If you’re adding a media source (RTMP, RTSP or HLS) in OBS and all you’re getting is a red dot, here’s a quick fix.\nFor Windows, hit Control-F. For Mac OS, hit Command-F. ","permalink":"http://uly.me/posts/obs-source-is-a-red-dot/","summary":"\u003cp\u003eIf you’re adding a media source (RTMP, RTSP or HLS) in OBS and all you’re getting is a red dot, here’s a quick fix.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eFor Windows, hit Control-F.\nFor Mac OS, hit Command-F.\n\u003c/code\u003e\u003c/pre\u003e","title":"obs source is a red dot"},{"content":"Here’s how to disable falcon-sensor or CrowdStrike.\nsystemctl stop falcon-sensor systemctl disable falcon-sensor ","permalink":"http://uly.me/posts/disable-falcon-sensor/","summary":"\u003cp\u003eHere’s how to disable falcon-sensor or CrowdStrike.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl stop falcon-sensor\nsystemctl disable falcon-sensor\n\u003c/code\u003e\u003c/pre\u003e","title":"disable falcon-sensor"},{"content":"How to upgrade Google SDK on Redhat, Fedora and Centos Linux.\ngcloud components update If you are having trouble running that command because the GCloud component manager is disabled, you can try the following commands which will achieve the same result as above.\nsudo yum makecache \u0026amp;\u0026amp; sudo yum update \\ kubectl \\ google-cloud-sdk \\ google-cloud-sdk-app-engine-grpc \\ google-cloud-sdk-pubsub-emulator \\ google-cloud-sdk-app-engine-go \\ google-cloud-sdk-cloud-build-local \\ google-cloud-sdk-datastore-emulator \\ google-cloud-sdk-app-engine-python \\ google-cloud-sdk-cbt \\ google-cloud-sdk-bigtable-emulator \\ google-cloud-sdk-datalab \\ google-cloud-sdk-app-engine-java ","permalink":"http://uly.me/posts/google-sdk-update/","summary":"\u003cp\u003eHow to upgrade Google SDK on Redhat, Fedora and Centos Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud components update\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you are having trouble running that command because the GCloud component manager is disabled, you can try the following commands which will achieve the same result as above.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo yum makecache \u0026amp;\u0026amp; sudo yum update \\\nkubectl \\\ngoogle-cloud-sdk \\\ngoogle-cloud-sdk-app-engine-grpc \\\ngoogle-cloud-sdk-pubsub-emulator \\\ngoogle-cloud-sdk-app-engine-go \\\ngoogle-cloud-sdk-cloud-build-local \\\ngoogle-cloud-sdk-datastore-emulator \\\ngoogle-cloud-sdk-app-engine-python \\\ngoogle-cloud-sdk-cbt \\\ngoogle-cloud-sdk-bigtable-emulator \\\ngoogle-cloud-sdk-datalab \\\ngoogle-cloud-sdk-app-engine-java\n\u003c/code\u003e\u003c/pre\u003e","title":"google sdk update"},{"content":"Here’s how to calculate epoch time using the Linux date command.\n# Linux date --date @1561266781 date -d @1561266781 # MacOS date -r 1561266781 Output is : Sun Jun 23 05:13:01 UTC 2019\nShow current epoch time.\ndate +%s Output: 1561642643\n","permalink":"http://uly.me/posts/calculate-epoch-time-to-date/","summary":"\u003cp\u003eHere’s how to calculate epoch time using the Linux date command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Linux\ndate --date @1561266781\ndate -d @1561266781\n# MacOS\ndate -r 1561266781\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput is : Sun Jun 23 05:13:01 UTC 2019\u003c/p\u003e\n\u003cp\u003eShow current epoch time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edate +%s\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOutput: 1561642643\u003c/p\u003e","title":"calculate epoch time to date"},{"content":"How to restore an object from Amazon S3 Glacier via the AWS CLI.\naws s3api restore-object \\ --bucket awsexamplebucket \\ --key dir1/example.obj \\ --restore-request \u0026#39;{\u0026#34;Days\u0026#34;:25,\u0026#34;GlacierJobParameters\u0026#34;:{\u0026#34;Tier\u0026#34;:\u0026#34;Standard\u0026#34;}}\u0026#39; ","permalink":"http://uly.me/posts/aws-cli-restore-object-from-s3-glacier/","summary":"\u003cp\u003eHow to restore an object from Amazon S3 Glacier via the AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws s3api restore-object \\\n--bucket awsexamplebucket \\\n--key dir1/example.obj \\\n--restore-request \u0026#39;{\u0026#34;Days\u0026#34;:25,\u0026#34;GlacierJobParameters\u0026#34;:{\u0026#34;Tier\u0026#34;:\u0026#34;Standard\u0026#34;}}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli restore object from s3 glacier"},{"content":"How to create a LightSail instance from a snapshot via AWS CLI.\naws lightsail create-instances-from-snapshot \\ --instance-names your-server-name \\ --availability-zone us-east-1a \\ --instance-snapshot-name your-snapshot \\ --bundle-id nano_1_0 \\ --key-pair-name your-key-pair ","permalink":"http://uly.me/posts/aws-lightsail-create-instance/","summary":"\u003cp\u003eHow to create a LightSail instance from a snapshot via AWS CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail create-instances-from-snapshot \\\n--instance-names your-server-name \\\n--availability-zone us-east-1a \\\n--instance-snapshot-name your-snapshot \\\n--bundle-id nano_1_0 \\\n--key-pair-name your-key-pair\n\u003c/code\u003e\u003c/pre\u003e","title":"aws lightsail create instance"},{"content":"How to delete AWS LightSail instance via CLI.\naws lightsail delete-instance --instance-name your-server-name ","permalink":"http://uly.me/posts/aws-lightsail-delete-instance/","summary":"\u003cp\u003eHow to delete AWS LightSail instance via CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail delete-instance --instance-name your-server-name\n\u003c/code\u003e\u003c/pre\u003e","title":"aws lightsail delete instance"},{"content":"Get AWS LightSail instance info from the CLI.\naws lightsail get-instance --instance-name your-server ","permalink":"http://uly.me/posts/aws-lightsail-get-instance-info/","summary":"\u003cp\u003eGet AWS LightSail instance info from the CLI.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail get-instance --instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e","title":"aws lightsail get instance info"},{"content":"Here’s how to add date stamps to filenames. Uses epoch time.\ntar cpzf mybackup-`date +%s`.gz /home/user ","permalink":"http://uly.me/posts/add-date-to-filenames/","summary":"\u003cp\u003eHere’s how to add date stamps to filenames. Uses epoch time.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etar cpzf mybackup-`date +%s`.gz /home/user\n\u003c/code\u003e\u003c/pre\u003e","title":"add date to filenames"},{"content":"Here’s how to add chroma key (green screen) to your OBS shoot.\nStart OBS. Add a video source. Right click on video source and select ‘Filter’. Click + in the ‘Effects Filters’ section, and choose ‘Chroma Key’. Enter a name for the effects layer. Fine tune the settings. Add background layers. Make sure to send to the back. ","permalink":"http://uly.me/posts/obs-chroma-key/","summary":"\u003cp\u003eHere’s how to add chroma key (green screen) to your OBS shoot.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eStart OBS.\u003c/li\u003e\n\u003cli\u003eAdd a video source.\u003c/li\u003e\n\u003cli\u003eRight click on video source and select ‘Filter’.\u003c/li\u003e\n\u003cli\u003eClick + in the ‘Effects Filters’ section, and choose ‘Chroma Key’.\u003c/li\u003e\n\u003cli\u003eEnter a name for the effects layer.\u003c/li\u003e\n\u003cli\u003eFine tune the settings.\u003c/li\u003e\n\u003cli\u003eAdd background layers.\u003c/li\u003e\n\u003cli\u003eMake sure to send to the back.\u003c/li\u003e\n\u003c/ul\u003e","title":"obs chroma key"},{"content":"Here’s how to find out which shell you are running. Run any of the 3 commands below.\necho $0 echo $SHELL ps -p \u0026#34;$$\u0026#34; ","permalink":"http://uly.me/posts/which-shell-is-running/","summary":"\u003cp\u003eHere’s how to find out which shell you are running. Run any of the 3 commands below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $0\necho $SHELL\nps -p \u0026#34;$$\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"which shell is running"},{"content":"Here’s the AWS CLI for creating a LightSail snapshot.\naws lightsail create-instance-snapshot \\ --instance-snapshot-name test-snapshot \\ --instance-name your-server Here’s how to delete a snapshot.\naws lightsail delete-instance-snapshot \\ --instance-snapshot-name test-snapshot ","permalink":"http://uly.me/posts/aws-cli-create-lightsail-snapshot/","summary":"\u003cp\u003eHere’s the AWS CLI for creating a LightSail snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail create-instance-snapshot \\\n--instance-snapshot-name test-snapshot \\\n--instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s how to delete a snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail delete-instance-snapshot \\\n--instance-snapshot-name test-snapshot\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli create lightsail snapshot"},{"content":"Moving a Linux directory the safe way.\ncd /mydir ; tar cf - . | (cd /data/mydir ; tar xf -) ; mv /mydir /mydir.0 ; ln -s /data/mydir /mydir ","permalink":"http://uly.me/posts/moving-linux-directory/","summary":"\u003cp\u003eMoving a Linux directory the safe way.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /mydir ; tar cf - . | (cd /data/mydir ; tar xf -) ; mv /mydir /mydir.0 ; ln -s /data/mydir /mydir\n\u003c/code\u003e\u003c/pre\u003e","title":"moving linux directory"},{"content":"If you want to change the crontab editor, run the following:\n$ select-editor Choose one.\n","permalink":"http://uly.me/posts/crontab-editor/","summary":"\u003cp\u003eIf you want to change the crontab editor, run the following:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ select-editor\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChoose one.\u003c/p\u003e","title":"crontab editor"},{"content":"How to restore from GCP Snapshots. Let’s say you have an instance called webserver with 2 disks.\nRestore from snapshots:\ngcloud compute disks create webserver-boot-r \\ --project=your-project \\ --source-snapshot=webserver-boot-190616 \\ --zone=us-central1-a gcloud compute disks create webserver-data-r \\ --project=your-project \\ --source-snapshot=webserver-data-190616 \\ --zone=us-central1-a Stop instance. Detach and attach disks:\ngcloud compute instances detach-disk webserver --disk=webserver-boot --zone us-central1-a gcloud compute instances attach-disk webserver --disk=webserver-boot-r --zone us-central1-a --boot gcloud compute instances detach-disk webserver --disk=webserver-data --zone us-central1-a gcloud compute instances attach-disk webserver --disk=webserver-data-r --zone us-central1-a Boot instance.\n","permalink":"http://uly.me/posts/gcp-restore/","summary":"\u003cp\u003eHow to restore from GCP Snapshots. Let’s say you have an instance called webserver with 2 disks.\u003c/p\u003e\n\u003cp\u003eRestore from snapshots:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create webserver-boot-r \\\n--project=your-project \\\n--source-snapshot=webserver-boot-190616 \\\n--zone=us-central1-a\ngcloud compute disks create webserver-data-r \\\n--project=your-project \\\n--source-snapshot=webserver-data-190616 \\\n--zone=us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStop instance. Detach and attach disks:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances detach-disk webserver --disk=webserver-boot --zone us-central1-a\ngcloud compute instances attach-disk webserver --disk=webserver-boot-r --zone us-central1-a --boot\ngcloud compute instances detach-disk webserver --disk=webserver-data --zone us-central1-a\ngcloud compute instances attach-disk webserver --disk=webserver-data-r --zone us-central1-a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBoot instance.\u003c/p\u003e","title":"gcp restore"},{"content":"How to Page Up and \u0026amp; Down in VIM.\n# Page Down Ctrl-B # Page Up Ctrl-F ","permalink":"http://uly.me/posts/vim-page-up-down/","summary":"\u003cp\u003eHow to Page Up and \u0026amp; Down in VIM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Page Down\nCtrl-B\n# Page Up\nCtrl-F\n\u003c/code\u003e\u003c/pre\u003e","title":"vim page up and down"},{"content":"How to change DNS records in Route 53 via AWS CLI.\nAssuming AWS CLI is already configured Uses Route53 change-resource-record-sets to update DNS records Substitute with your own hosted-zone-id Uses JSON files containing record sets See JSON file examples below cd /path/to/scripts/ # the command to switch to the elb aws route53 change-resource-record-sets --hosted-zone-id xxxxxxxxxxxxxx --change-batch file://elb.json # the command to switch to standard site aws route53 change-resource-record-sets --hosted-zone-id xxxxxxxxxxxxxx --change-batch file://live.json elb.json = points to AWS ELB (elastic load balancer)\n{ \u0026#34;Comment\u0026#34;: \u0026#34;back to elb\u0026#34;, \u0026#34;Changes\u0026#34;: [ { \u0026#34;Action\u0026#34;: \u0026#34;UPSERT\u0026#34;, \u0026#34;ResourceRecordSet\u0026#34;: { \u0026#34;Name\u0026#34;: \u0026#34;yourdomain.com\u0026#34;, \u0026#34;Type\u0026#34;: \u0026#34;A\u0026#34;, \u0026#34;AliasTarget\u0026#34;: { \u0026#34;HostedZoneId\u0026#34;: \u0026#34;xxxxxxxxxxxxxx\u0026#34;, \u0026#34;EvaluateTargetHealth\u0026#34;: false, \u0026#34;DNSName\u0026#34;: \u0026#34;xxxxxxxxxxxxx.us-east-1.elb.amazonaws.com.\u0026#34; } } } ] } live.json = points to your standard site. Value is your IP Address.\n{ \u0026#34;Comment\u0026#34;: \u0026#34;back to live\u0026#34;, \u0026#34;Changes\u0026#34;: [ { \u0026#34;Action\u0026#34;: \u0026#34;UPSERT\u0026#34;, \u0026#34;ResourceRecordSet\u0026#34;: { \u0026#34;Name\u0026#34;: \u0026#34;yourdomain.com\u0026#34;, \u0026#34;Type\u0026#34;: \u0026#34;A\u0026#34;, \u0026#34;TTL\u0026#34;: 60, \u0026#34;ResourceRecords\u0026#34;: [ { \u0026#34;Value\u0026#34;: \u0026#34;xxx.xxx.xxx.xxx\u0026#34; } ] } } ] } ","permalink":"http://uly.me/posts/change-dns-records-in-route-53-via-cli/","summary":"\u003cp\u003eHow to change DNS records in Route 53 via AWS CLI.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eAssuming AWS CLI is already configured\u003c/li\u003e\n\u003cli\u003eUses Route53 change-resource-record-sets to update DNS records\u003c/li\u003e\n\u003cli\u003eSubstitute with your own hosted-zone-id\u003c/li\u003e\n\u003cli\u003eUses JSON files containing record sets\u003c/li\u003e\n\u003cli\u003eSee JSON file examples below\u003c/li\u003e\n\u003c/ul\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /path/to/scripts/\n# the command to switch to the elb\naws route53 change-resource-record-sets --hosted-zone-id xxxxxxxxxxxxxx --change-batch file://elb.json\n# the command to switch to standard site\naws route53 change-resource-record-sets --hosted-zone-id xxxxxxxxxxxxxx --change-batch file://live.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eelb.json = points to AWS ELB (elastic load balancer)\u003c/p\u003e","title":"change dns records in route 53 via cli"},{"content":"Here’s the IAM policy you’ll need to change Route 53 DNS records. Substitute with your own hosted zone id.\n{ \u0026#34;Statement\u0026#34;:[{ \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[\u0026#34;route53:ChangeResourceRecordSets\u0026#34;], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:route53:::hostedzone/*HOSTEDZONEID*\u0026#34; } ], \u0026#34;Statement\u0026#34;:[{ \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;:[\u0026#34;route53:GetChange\u0026#34;], \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:route53:::change/*\u0026#34; } ] } Add to policy to a user.\n","permalink":"http://uly.me/posts/route-53-policy-to-change-records/","summary":"\u003cp\u003eHere’s the IAM policy you’ll need to change Route 53 DNS records. Substitute with your own hosted zone id.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n   \u0026#34;Statement\u0026#34;:[{\n      \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n      \u0026#34;Action\u0026#34;:[\u0026#34;route53:ChangeResourceRecordSets\u0026#34;],\n      \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:route53:::hostedzone/*HOSTEDZONEID*\u0026#34;\n      }\n   ],\n   \u0026#34;Statement\u0026#34;:[{\n      \u0026#34;Effect\u0026#34;:\u0026#34;Allow\u0026#34;,\n      \u0026#34;Action\u0026#34;:[\u0026#34;route53:GetChange\u0026#34;],\n      \u0026#34;Resource\u0026#34;:\u0026#34;arn:aws:route53:::change/*\u0026#34;\n      }\n   ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd to policy to a user.\u003c/p\u003e","title":"route 53 policy to change records"},{"content":"Here are several examples how to display GCP snapshots using Google SDK (CLI – command line interface).\n# list snapshots gcloud compute snapshots list \\ --project my-project \\ --filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; # limit 10 gcloud compute snapshots list \\ --project my-project \\ --filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\ --limit 10 # reverse order gcloud compute snapshots list \\ --project my-project \\ --filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\ --limit 10 \\ --sort-by=\u0026#34;~name\u0026#34; # display uri gcloud compute snapshots list \\ --project my-project \\ --filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\ --limit 10 \\ --sort-by=\u0026#34;~name\u0026#34; \\ --uri ","permalink":"http://uly.me/posts/gcp-list-snapshots/","summary":"\u003cp\u003eHere are several examples how to display GCP snapshots using Google SDK (CLI – command line interface).\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# list snapshots\ngcloud compute snapshots list \\\n--project my-project \\\n--filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34;\n# limit 10\ngcloud compute snapshots list \\\n--project my-project \\\n--filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\\n--limit 10\n# reverse order\ngcloud compute snapshots list \\\n--project my-project \\\n--filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\\n--limit 10 \\\n--sort-by=\u0026#34;~name\u0026#34;\n# display uri\ngcloud compute snapshots list \\\n--project my-project \\\n--filter=\u0026#34;name~\u0026#39;my-server-boot\u0026#39;\u0026#34; \\\n--limit 10 \\\n--sort-by=\u0026#34;~name\u0026#34; \\\n--uri\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp list snapshots"},{"content":"How to load crontab from file.\ncrontab /path/to/file.txt Save crontab to a file.\ncrontab -l \u0026gt; /path/to/file.txt ","permalink":"http://uly.me/posts/crontab-file/","summary":"\u003cp\u003eHow to load crontab from file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab /path/to/file.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSave crontab to a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab -l \u0026gt; /path/to/file.txt\n\u003c/code\u003e\u003c/pre\u003e","title":"crontab file"},{"content":"What patches were installed on Windows Server. Run the command below in Powershell as Administrator.\nget-hotfix You can also see it from the Control Panel \u0026gt; Program \u0026gt; Programs and Features \u0026gt; Installed Updates.\n","permalink":"http://uly.me/posts/get-hotfix/","summary":"\u003cp\u003eWhat patches were installed on Windows Server. Run the command below in Powershell as Administrator.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eget-hotfix\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also see it from the Control Panel \u0026gt; Program \u0026gt; Programs and Features \u0026gt; Installed Updates.\u003c/p\u003e","title":"get-hotfix"},{"content":"Services to check.\nchkconfig nfs on service rpcbind start service nfs start mount -a If missing, install it.\nyum install nfs-utils nfs-utils-lib Mount it.\nmount -a mount 192.168.1.200:/home /mnt/nfs/home Add to /etc/fstab.\n10.10.10.10:/home on /mnt/nfs/home type nfs (rw,noatime,nolock,bg,nfsvers=2,intr,tcp,actimeo=1800,addr=10.10.10.10) ","permalink":"http://uly.me/posts/nfs-client/","summary":"\u003cp\u003eServices to check.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echkconfig nfs on\nservice rpcbind start\nservice nfs start\nmount -a\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf missing, install it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install nfs-utils nfs-utils-lib\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMount it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emount -a\nmount 192.168.1.200:/home /mnt/nfs/home\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd to /etc/fstab.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e10.10.10.10:/home on /mnt/nfs/home type nfs (rw,noatime,nolock,bg,nfsvers=2,intr,tcp,actimeo=1800,addr=10.10.10.10)\n\u003c/code\u003e\u003c/pre\u003e","title":"nfs client"},{"content":"How to check which kernel is running on your system\nuname -sr List all kernels installed on the system.\nrpm -q kernel Removing old kernels using package-cleanup. This keeps 2 kernels on the system.\nyum install yum-utils package-cleanup --oldkernels --count=2 ","permalink":"http://uly.me/posts/removing-old-kernels/","summary":"\u003cp\u003eHow to check which kernel is running on your system\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003euname -sr\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eList all kernels installed on the system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -q kernel\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRemoving old kernels using package-cleanup. This keeps 2 kernels on the system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eyum install yum-utils\npackage-cleanup --oldkernels --count=2\n\u003c/code\u003e\u003c/pre\u003e","title":"removing old kernels"},{"content":"Here’s a simple EFS CloudFormation template with a one mount target.\n{ \u0026#34;AWSTemplateFormatVersion\u0026#34;: \u0026#34;2010-09-09\u0026#34;, \u0026#34;Description\u0026#34;: \u0026#34;EFS example setup\u0026#34;, \u0026#34;Parameters\u0026#34;: { \u0026#34;VPC\u0026#34;: { \u0026#34;Description\u0026#34;: \u0026#34;VPC ID\u0026#34;, \u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::VPC::Id\u0026#34; }, \u0026#34;Subnet\u0026#34;: {\t\u0026#34;Description\u0026#34;: \u0026#34;Subnet ID\u0026#34;, \u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::Subnet::Id\u0026#34; }, \u0026#34;EC2SecurityGroup\u0026#34;: { \u0026#34;Description\u0026#34;: \u0026#34;Security Group for EC2 instance\u0026#34;, \u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::SecurityGroup::Id\u0026#34; }\t}, \u0026#34;Resources\u0026#34;: { \u0026#34;EFSFileSystem\u0026#34;: { \u0026#34;Type\u0026#34; : \u0026#34;AWS::EFS::FileSystem\u0026#34;, \u0026#34;Properties\u0026#34; : { \u0026#34;FileSystemTags\u0026#34; : [ {\u0026#34;Key\u0026#34; : \u0026#34;Name\u0026#34;, \u0026#34;Value\u0026#34; : {\u0026#34;Ref\u0026#34;: \u0026#34;AWS::StackName\u0026#34;}} ] } }, \u0026#34;EFSMountTarget\u0026#34;: { \u0026#34;Type\u0026#34;: \u0026#34;AWS::EFS::MountTarget\u0026#34;, \u0026#34;Properties\u0026#34;: { \u0026#34;FileSystemId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;EFSFileSystem\u0026#34;}, \u0026#34;SubnetId\u0026#34;: { \u0026#34;Ref\u0026#34;: \u0026#34;Subnet\u0026#34; }, \u0026#34;SecurityGroups\u0026#34;: [{\u0026#34;Ref\u0026#34;: \u0026#34;EFSSecurityGroup\u0026#34;}] } }, \u0026#34;EFSSecurityGroup\u0026#34;: { \u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::SecurityGroup\u0026#34;, \u0026#34;Properties\u0026#34;: { \u0026#34;GroupDescription\u0026#34;: \u0026#34;Allowing access to EFS\u0026#34;, \u0026#34;VpcId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;VPC\u0026#34;}, \u0026#34;SecurityGroupIngress\u0026#34;: [{ \u0026#34;IpProtocol\u0026#34;: \u0026#34;tcp\u0026#34;, \u0026#34;FromPort\u0026#34;: 2049, \u0026#34;ToPort\u0026#34;: 2049, \u0026#34;SourceSecurityGroupId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;EC2SecurityGroup\u0026#34;} }] } }\t} } ","permalink":"http://uly.me/posts/efs-cloudformation/","summary":"\u003cp\u003eHere’s a simple EFS CloudFormation template with a one mount target.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n\t\u0026#34;AWSTemplateFormatVersion\u0026#34;: \u0026#34;2010-09-09\u0026#34;,\n\t\u0026#34;Description\u0026#34;: \u0026#34;EFS example setup\u0026#34;,\n\t\u0026#34;Parameters\u0026#34;: {\n\t\t\u0026#34;VPC\u0026#34;: {\n\t\t\t\u0026#34;Description\u0026#34;: \u0026#34;VPC ID\u0026#34;,\n\t\t\t\u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::VPC::Id\u0026#34;\n\t\t},\n\t\t\u0026#34;Subnet\u0026#34;: {\t\t\t\n\t\t\t\u0026#34;Description\u0026#34;: \u0026#34;Subnet ID\u0026#34;,\n\t\t\t\u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::Subnet::Id\u0026#34;\n\t\t},\n\t\t\u0026#34;EC2SecurityGroup\u0026#34;: {\n\t\t\t\u0026#34;Description\u0026#34;: \u0026#34;Security Group for EC2 instance\u0026#34;,\n\t\t\t\u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::SecurityGroup::Id\u0026#34;\n\t\t}\t\n\t},\n\t\u0026#34;Resources\u0026#34;: {\n\t\t\u0026#34;EFSFileSystem\u0026#34;: {\n\t\t\t\u0026#34;Type\u0026#34; : \u0026#34;AWS::EFS::FileSystem\u0026#34;,\n\t\t\t\u0026#34;Properties\u0026#34; : {\n\t\t\t\t\u0026#34;FileSystemTags\u0026#34; : [\n\t\t\t\t\t{\u0026#34;Key\u0026#34; : \u0026#34;Name\u0026#34;, \u0026#34;Value\u0026#34; : {\u0026#34;Ref\u0026#34;: \u0026#34;AWS::StackName\u0026#34;}}\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\t\u0026#34;EFSMountTarget\u0026#34;: {\n\t\t\t\u0026#34;Type\u0026#34;: \u0026#34;AWS::EFS::MountTarget\u0026#34;,\n\t\t\t\u0026#34;Properties\u0026#34;: {\n\t\t\t\t\u0026#34;FileSystemId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;EFSFileSystem\u0026#34;},\n\t\t\t\t\u0026#34;SubnetId\u0026#34;: { \u0026#34;Ref\u0026#34;: \u0026#34;Subnet\u0026#34; },\n\t\t\t\t\u0026#34;SecurityGroups\u0026#34;: [{\u0026#34;Ref\u0026#34;: \u0026#34;EFSSecurityGroup\u0026#34;}]        \n\t\t\t}\n\t\t},\n\t\t\u0026#34;EFSSecurityGroup\u0026#34;: {\n\t\t\t\u0026#34;Type\u0026#34;: \u0026#34;AWS::EC2::SecurityGroup\u0026#34;,\n\t\t\t\u0026#34;Properties\u0026#34;: {\n\t\t\t\t\u0026#34;GroupDescription\u0026#34;: \u0026#34;Allowing access to EFS\u0026#34;,\n\t\t\t\t\u0026#34;VpcId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;VPC\u0026#34;},\n\t\t\t\t\u0026#34;SecurityGroupIngress\u0026#34;: [{\n\t\t\t\t\t\u0026#34;IpProtocol\u0026#34;: \u0026#34;tcp\u0026#34;,\n\t\t\t\t\t\u0026#34;FromPort\u0026#34;: 2049,\n\t\t\t\t\t\u0026#34;ToPort\u0026#34;: 2049,\n\t\t\t\t\t\u0026#34;SourceSecurityGroupId\u0026#34;: {\u0026#34;Ref\u0026#34;: \u0026#34;EC2SecurityGroup\u0026#34;}\n\t\t\t\t}]\n\t\t\t}\n\t\t}\t\t\t\t\n\t}\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"efs cloudformation"},{"content":"This policy gives a user access to the API gateway.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;apigateway-policy\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;apigateway:DELETE\u0026#34;, \u0026#34;apigateway:PUT\u0026#34;, \u0026#34;apigateway:PATCH\u0026#34;, \u0026#34;apigateway:POST\u0026#34;, \u0026#34;apigateway:GET\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } ","permalink":"http://uly.me/posts/api-gateway-policy/","summary":"\u003cp\u003eThis policy gives a user access to the API gateway.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;apigateway-policy\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Action\u0026#34;: [\n                \u0026#34;apigateway:DELETE\u0026#34;,\n                \u0026#34;apigateway:PUT\u0026#34;,\n                \u0026#34;apigateway:PATCH\u0026#34;,\n                \u0026#34;apigateway:POST\u0026#34;,\n                \u0026#34;apigateway:GET\u0026#34;\n            ],\n            \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"api gateway policy"},{"content":"Here’s the policy to restrict access to S3 bucket to certain IP addresses.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Id\u0026#34;: \u0026#34;S3PolicyIPRestrict\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;IPAllow\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Principal\u0026#34;: { \u0026#34;AWS\u0026#34;: \u0026#34;*\u0026#34; }, \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::bucket/*\u0026#34;, \u0026#34;Condition\u0026#34; : { \u0026#34;IpAddress\u0026#34; : { \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.10.10.0/24\u0026#34; }, \u0026#34;NotIpAddress\u0026#34; : { \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.10.10.100/32\u0026#34; } } } ] } Allow anyone in the 10.10.10.0/24 network except for 10.10.10.100/32.\n","permalink":"http://uly.me/posts/s3-restrict-ip-addresses/","summary":"\u003cp\u003eHere’s the policy to restrict access to S3 bucket to certain IP addresses.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Id\u0026#34;: \u0026#34;S3PolicyIPRestrict\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;IPAllow\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Principal\u0026#34;: {\n                \u0026#34;AWS\u0026#34;: \u0026#34;*\u0026#34; \n            },\n            \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::bucket/*\u0026#34;,\n            \u0026#34;Condition\u0026#34; : {\n                \u0026#34;IpAddress\u0026#34; : {\n                    \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.10.10.0/24\u0026#34; \n                },\n                \u0026#34;NotIpAddress\u0026#34; : {\n                    \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.10.10.100/32\u0026#34; \n                } \n            } \n        } \n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAllow anyone in the 10.10.10.0/24 network except for 10.10.10.100/32.\u003c/p\u003e","title":"s3 restrict ip addresses"},{"content":"Here are the instructions for renewing Certbot SSL certificates in AWS Certificate Manager. Certbot provides SSL certificates for free for 60 days and are auto-renewed before they expire. If you are using Certbot SSL certificates with CloudFront, you will need to reimport them to AWS Certificate Manager before expiration.\nGet the latest SSL certificate by running “certbot certificates.” Reimport the certificate in 3 parts. Certificate Body – the root or top portion of the full chain Certificate Private key – the private key Certificate chain – the entire full chain containing multiple certificates Click Save. Check expiration. You’ll need to update the certificate before the next expiration date.\n","permalink":"http://uly.me/posts/certbot-aws-renewals/","summary":"\u003cp\u003eHere are the instructions for renewing \u003ca href=\"https://certbot.eff.org/\"\u003eCertbot\u003c/a\u003e SSL certificates in \u003ca href=\"https://aws.amazon.com/certificate-manager/\"\u003eAWS Certificate Manager\u003c/a\u003e. Certbot provides SSL certificates for free for 60 days and are auto-renewed before they expire. If you are using Certbot SSL certificates with CloudFront, you will need to reimport them to AWS Certificate Manager before expiration.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eGet the latest SSL certificate by running “\u003cstrong\u003ecertbot certificates\u003c/strong\u003e.”\u003c/li\u003e\n\u003cli\u003eReimport the certificate in 3 parts.\n\u003cul\u003e\n\u003cli\u003eCertificate Body – the root or top portion of the full chain\u003c/li\u003e\n\u003cli\u003eCertificate Private key – the private key\u003c/li\u003e\n\u003cli\u003eCertificate chain – the entire full chain containing multiple certificates\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eClick Save. Check expiration.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eYou’ll need to update the certificate before the next expiration date.\u003c/p\u003e","title":"certbot aws renewals"},{"content":"Here’s a side by side comparison of AWS vs. GCP, and AWS vs. Azure.\n","permalink":"http://uly.me/posts/differences-between-aws-azure-and-gcp/","summary":"\u003cp\u003eHere’s a side by side comparison of \u003ca href=\"https://cloud.google.com/docs/compare/aws/\"\u003eAWS vs. GCP\u003c/a\u003e, and \u003ca href=\"https://docs.microsoft.com/en-us/azure/architecture/aws-professional/services\"\u003eAWS vs. Azure\u003c/a\u003e.\u003c/p\u003e","title":"differences between aws, azure and gcp"},{"content":"If you have multiple AWS accounts, you can gain additional permission by authorizing it to a different AWS account via IAM. Here’s the assume role documentation from AWS. And here are some documentation if you need to grant someone to switch accounts. If you are going to be using the AWS CLI, you will need to run “aws configure” to setup multiple profiles.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Action\u0026#34;: \u0026#34;sts:AssumeRole\u0026#34;, \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:iam::*:role/your-custom-role\u0026#34; ], \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-assume-role/","summary":"\u003cp\u003eIf you have multiple AWS accounts, you can gain additional permission by authorizing it to a different AWS account via IAM. Here’s the \u003ca href=\"https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html\"\u003eassume role\u003c/a\u003e documentation from AWS. And here are some documentation if you need to grant someone to \u003ca href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_permissions-to-switch.html\"\u003eswitch\u003c/a\u003e accounts. If you are going to be using the AWS CLI, you will need to run “aws configure” to setup multiple profiles.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Action\u0026#34;: \u0026#34;sts:AssumeRole\u0026#34;,\n            \u0026#34;Resource\u0026#34;: [\n                \u0026#34;arn:aws:iam::*:role/your-custom-role\u0026#34;\n            ],\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws assume role"},{"content":"I keep forgetting this command. This is to remove tabs from multiple lines in Sublime Text.\nShift+Tab ","permalink":"http://uly.me/posts/sublime-text-remove-tabs/","summary":"\u003cp\u003eI keep forgetting this command. This is to remove tabs from multiple lines in Sublime Text.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eShift+Tab\n\u003c/code\u003e\u003c/pre\u003e","title":"sublime text remove tabs"},{"content":"Get instance details\naws lightsail get-instance --instance-name your-server Get instance state\naws lightsail get-instance-state --instance-name your-server Create a snapshot\naws lightsail create-instance-snapshot \\ --instance-snapshot-name your-server-new-snapshot-201905192200 \\ --instance-name your-server Create disk from snapshot\naws lightsail create-disk-from-snapshot \\ --disk-name your-server-new-boot-disk \\ --disk-name your-server-new-snapshot-201905192200 \\ --availability-zone us-east-1a --size-in-gb 50 Attach Disk\naws lightsail attach-disk \\ --disk-name your-server-new-boot-disk \\ --instance-name your-server \\ --disk-path /dev/sda1 Create instance from snapshot\naws lightsail create-instance-snapshot \\ --instance-snaphot-name your-server-new-snapshot-201905192200 --instance-name your-server Attach Static IP Address\naws lightsail attach-static-ip \\ --static-ip-name your-ip-name \\ --instance-name your-server ","permalink":"http://uly.me/posts/aws-cli-lightsail/","summary":"\u003cp\u003eGet instance details\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail get-instance --instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eGet instance state\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail get-instance-state --instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a snapshot\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail create-instance-snapshot \\\n--instance-snapshot-name your-server-new-snapshot-201905192200 \\\n--instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate disk from snapshot\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail create-disk-from-snapshot \\\n--disk-name your-server-new-boot-disk \\\n--disk-name your-server-new-snapshot-201905192200 \\\n--availability-zone us-east-1a\n--size-in-gb 50\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAttach Disk\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail attach-disk \\\n--disk-name your-server-new-boot-disk \\\n--instance-name your-server \\\n--disk-path /dev/sda1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate instance from snapshot\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws lightsail create-instance-snapshot \\\n--instance-snaphot-name your-server-new-snapshot-201905192200\n--instance-name your-server\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAttach Static IP Address\u003c/p\u003e","title":"aws cli lightsail"},{"content":"Get a count of the number of files in a directory.\n# using ls ls | wc -l ls -Aq | wc -l # include hidden files find . ! -name . -prune -print | grep -c / find .//. ! -name . -print | grep -c // # using tree if installed. yum install tree. apt-get install tree tree ","permalink":"http://uly.me/posts/count-number-of-files-in-directory/","summary":"\u003cp\u003eGet a count of the number of files in a directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# using ls\nls | wc -l\nls -Aq | wc -l\n# include hidden files \nfind . ! -name . -prune -print | grep -c /\nfind .//. ! -name . -print | grep -c //\n# using tree if installed. yum install tree. apt-get install tree\ntree \n\u003c/code\u003e\u003c/pre\u003e","title":"count number of files in directory"},{"content":"How to Split Text into Columns in Excel.\nSelect the cell or column that contains the text you want to split. Select Data \u0026gt; Text to Columns. In the Convert Text to Columns Wizard, select Delimited \u0026gt; Next. Select the Delimiters for your data. For example, Comma and Space. You can see a preview of your data in the Data preview window. Select Next. Select the Column data format or use what Excel chose for you. Select the Destination, which is where you want the split data to appear on your worksheet. Select Finish. ","permalink":"http://uly.me/posts/split-text-into-columns-in-excel/","summary":"\u003cp\u003eHow to Split Text into Columns in Excel.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eSelect the cell or column that contains the text you want to split.\u003c/li\u003e\n\u003cli\u003eSelect Data \u0026gt; Text to Columns.\u003c/li\u003e\n\u003cli\u003eIn the Convert Text to Columns Wizard, select Delimited \u0026gt; Next.\u003c/li\u003e\n\u003cli\u003eSelect the Delimiters for your data. For example, Comma and Space.\u003c/li\u003e\n\u003cli\u003eYou can see a preview of your data in the Data preview window.\u003c/li\u003e\n\u003cli\u003eSelect Next.\u003c/li\u003e\n\u003cli\u003eSelect the Column data format or use what Excel chose for you.\u003c/li\u003e\n\u003cli\u003eSelect the Destination, which is where you want the split data to appear on your worksheet.\u003c/li\u003e\n\u003cli\u003eSelect Finish.\u003c/li\u003e\n\u003c/ol\u003e","title":"split text into columns in excel"},{"content":"You can setup AWS Glacier via S3 bucket replication. Create a S3 bucket and slap this bucket policy.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Id\u0026#34;: \u0026#34;S3PolicyId1\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;IPAllow\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-storage-name/*\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;IpAddress\u0026#34;: { \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.0.0.0/8\u0026#34; } } }, { \u0026#34;Sid\u0026#34;: \u0026#34;DenyIncorrectEncryptionHeader\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;s3:PutObject\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-storage-name/*\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;StringNotEquals\u0026#34;: { \u0026#34;s3:x-amz-server-side-encryption\u0026#34;: \u0026#34;AES256\u0026#34; } } }, { \u0026#34;Sid\u0026#34;: \u0026#34;DenyUnEncryptedObjectUploads\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;s3:PutObject\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-name/*\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;Null\u0026#34;: { \u0026#34;s3:x-amz-server-side-encryption\u0026#34;: \u0026#34;true\u0026#34; } } } ] } Add this policy to your IAM user or role.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-name/*\u0026#34; }, { \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;s3:List*\u0026#34;, \u0026#34;s3:Get*\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::*\u0026#34; } ] } Finally, add a lifecycle policy to move your files from Standard to Glacier storage type.\n","permalink":"http://uly.me/posts/aws-glacier-setup-via-s3/","summary":"\u003cp\u003eYou can setup AWS Glacier via S3 bucket replication. Create a S3 bucket and slap this bucket policy.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Id\u0026#34;: \u0026#34;S3PolicyId1\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;IPAllow\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Allow\u0026#34;,\n            \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;,\n            \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-storage-name/*\u0026#34;,\n            \u0026#34;Condition\u0026#34;: {\n                \u0026#34;IpAddress\u0026#34;: {\n                    \u0026#34;aws:SourceIp\u0026#34;: \u0026#34;10.0.0.0/8\u0026#34;\n                }\n            }\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;DenyIncorrectEncryptionHeader\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;,\n            \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;,\n            \u0026#34;Action\u0026#34;: \u0026#34;s3:PutObject\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-storage-name/*\u0026#34;,\n            \u0026#34;Condition\u0026#34;: {\n                \u0026#34;StringNotEquals\u0026#34;: {\n                    \u0026#34;s3:x-amz-server-side-encryption\u0026#34;: \u0026#34;AES256\u0026#34;\n                }\n            }\n        },\n        {\n            \u0026#34;Sid\u0026#34;: \u0026#34;DenyUnEncryptedObjectUploads\u0026#34;,\n            \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;,\n            \u0026#34;Principal\u0026#34;: \u0026#34;*\u0026#34;,\n            \u0026#34;Action\u0026#34;: \u0026#34;s3:PutObject\u0026#34;,\n            \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:s3:::your-bucket-name/*\u0026#34;,\n            \u0026#34;Condition\u0026#34;: {\n                \u0026#34;Null\u0026#34;: {\n                    \u0026#34;s3:x-amz-server-side-encryption\u0026#34;: \u0026#34;true\u0026#34;\n                }\n            }\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd this policy to your IAM user or role.\u003c/p\u003e","title":"aws glacier setup via s3"},{"content":"Here’s how to create a GCP Disk Image from a Boot Drive.\nFirst, stop the instance. If you can’t, stop the applications/database from writing to disks. Run sudo sync . Create From Disk gcloud compute images create the-new-image-name \\ --source-disk the-source-boot-disk \\ --source-disk-zone us-central1-a \\ --family the-image-family \\ [--force] Create From Image gcloud compute images create the-new-image-name \\ --source-image the-source-image \\ --source-image-project the-project-where-the-image-is-located \\ --family the-image-family Create From Snapshot gcloud compute images create the-new-image-name \\ --source-snapshot the-source-snapshot For more info.\n","permalink":"http://uly.me/posts/gcp-create-images/","summary":"\u003cp\u003eHere’s how to create a GCP Disk Image from a Boot Drive.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eFirst, stop the instance.\u003c/li\u003e\n\u003cli\u003eIf you can’t, stop the applications/database from writing to disks.\u003c/li\u003e\n\u003cli\u003eRun sudo sync .\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"create-from-disk\"\u003eCreate From Disk\u003c/h3\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute images create the-new-image-name \\\n   --source-disk the-source-boot-disk \\\n   --source-disk-zone us-central1-a \\\n   --family the-image-family \\\n   [--force]\n\u003c/code\u003e\u003c/pre\u003e\u003ch3 id=\"create-from-image\"\u003eCreate From Image\u003c/h3\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute images create the-new-image-name \\\n  --source-image the-source-image \\\n  --source-image-project the-project-where-the-image-is-located \\\n  --family the-image-family\n\u003c/code\u003e\u003c/pre\u003e\u003ch3 id=\"create-from-snapshot\"\u003eCreate From Snapshot\u003c/h3\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute images create the-new-image-name \\\n  --source-snapshot the-source-snapshot\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor more \u003ca href=\"https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images\"\u003einfo\u003c/a\u003e.\u003c/p\u003e","title":"gcp create images"},{"content":"AWS EFS runs on burst credits when choosing burst mode, which is about 99% of most implementations. The reason for this is that provisioned throughput is very expensive. It’s a $6000 per month commitment. In burst mode, if the EFS volume is too small with heavy IO usage, the burst credits will nose dive. You will eventually run out of burst credits resulting in very poor IO performance. It will be slower than a floppy disk drive. We all know how old that technology is. In order to sustain your burst credits, you’ll need to add data, because more data means you’ll earn burst credits at a higher clip. Here’s how to calculate the ideal file size for an EFS system.\nIdentify your throughput needs by looking at your historical usage. From the Amazon CloudWatch console, check the sum statistic of the TotalIOBytes metric with daily aggregation, for the past 14 days. Identify the day with the largest value for TotalIOBytes. Divide this number by 24 hours, 60 minutes, 60 seconds, and 1024 bytes to get the average KiB/second your application required for that day. Calculate the file system size (in GiB) required to sustain this average throughput by dividing the average throughput number (in KiB/s) by the baseline throughput number (50 KiB/s/GiB) that EFS provides. For example, let’s say you have a 500 Gib of TotalIOBytes.\n500 x 1024 x 1024 x 1024 / (24 x 60 x 60 x 1024) = 6068.15 Kib/s\n6068.15 / 50 Kib/s = 121 Gib\nYou will need about 121 GB of EFS volume size to maintain your burst credits.\n","permalink":"http://uly.me/posts/calculating-the-ideal-efs-file-size/","summary":"\u003cp\u003eAWS EFS runs on burst credits when choosing burst mode, which is about 99% of most implementations. The reason for this is that provisioned throughput is very expensive. It’s a $6000 per month commitment. In burst mode, if the EFS volume is too small with heavy IO usage, the burst credits will nose dive. You will eventually run out of burst credits resulting in very poor IO performance. It will be slower than a floppy disk drive. We all know how old that technology is. In order to sustain your burst credits, you’ll need to add data, because more data means you’ll earn burst credits at a higher clip. Here’s how to calculate the ideal file size for an EFS system.\u003c/p\u003e","title":"calculating the ideal efs file size"},{"content":"The following are steps on how to change the network of an instance from one VPC to another. This is assuming you want to keep the same server name, but will need to make a network change. Unfortunately, changing networks will require creating a new instance. The following are the steps to make that change.\nKeep track of all the disks. Keep all disks including boot. Stop the instance. Create an image of the boot drive. Wait for it to complete. Create a similar instance, but do not execute. Make the network changes. Save the GCloud CLI command. Delete the instance. Run the saved command from step 4. This creates a new instance. Stop the instance. Detach the boot disk. Attach all the other disks. Boot the instance. ","permalink":"http://uly.me/posts/gcp-change-vpc-of-instance/","summary":"\u003cp\u003eThe following are steps on how to change the network of an instance from one VPC to another. This is assuming you want to keep the same server name, but will need to make a network change. Unfortunately, changing networks will require creating a new instance. The following are the steps to make that change.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eKeep track of all the disks.\u003c/li\u003e\n\u003cli\u003eKeep all disks including boot.\u003c/li\u003e\n\u003cli\u003eStop the instance.\u003c/li\u003e\n\u003cli\u003eCreate an image of the boot drive. Wait for it to complete.\u003c/li\u003e\n\u003cli\u003eCreate a similar instance, but do not execute.\u003c/li\u003e\n\u003cli\u003eMake the network changes. Save the GCloud CLI command.\u003c/li\u003e\n\u003cli\u003eDelete the instance.\u003c/li\u003e\n\u003cli\u003eRun the saved command from step 4. This creates a new instance.\u003c/li\u003e\n\u003cli\u003eStop the instance.\u003c/li\u003e\n\u003cli\u003eDetach the boot disk.\u003c/li\u003e\n\u003cli\u003eAttach all the other disks.\u003c/li\u003e\n\u003cli\u003eBoot the instance.\u003c/li\u003e\n\u003c/ol\u003e","title":"gcp change vpc of instance"},{"content":"How to list files that’s human readable in GB.\nls -lrt --block-size=G l = long format t = sort time/date r = reverse order –block-size=M (Mb) or G (Gb) ","permalink":"http://uly.me/posts/list-files-human-readable/","summary":"\u003cp\u003eHow to list files that’s human readable in GB.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003els -lrt --block-size=G\n\u003c/code\u003e\u003c/pre\u003e\u003cul\u003e\n\u003cli\u003el = long format\u003c/li\u003e\n\u003cli\u003et = sort time/date\u003c/li\u003e\n\u003cli\u003er = reverse order\u003c/li\u003e\n\u003cli\u003e–block-size=M (Mb) or G (Gb)\u003c/li\u003e\n\u003c/ul\u003e","title":"list files human readable"},{"content":"The /etc/fstab file allow volumes to be automatically mounted on bootup. Add nofail in your automated mounts to prevent instances from hanging on boot. Nofail makes the instance to boot even if there are errors with the mounted volume.\nUUID=aebf131c-6957-451e-8d34-ec978d9581ae /data xfs defaults,nofail 0 2 ","permalink":"http://uly.me/posts/add-nofail/","summary":"\u003cp\u003eThe /etc/fstab file allow volumes to be automatically mounted on bootup. Add nofail in your automated mounts to prevent instances from hanging on boot. Nofail makes the instance to boot even if there are errors with the mounted volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eUUID=aebf131c-6957-451e-8d34-ec978d9581ae  /data  xfs  defaults,nofail  0  2\n\u003c/code\u003e\u003c/pre\u003e","title":"add nofail"},{"content":"Here’s how to create a disk from a snapshot via Google SDK.\ngcloud compute disks create new-server-disk-2 \\ --project=project-name \\ --source-snapshot=server-disk-2 \\ --zone=us-central1-b ","permalink":"http://uly.me/posts/gcp-create-disk-from-snapshot/","summary":"\u003cp\u003eHere’s how to create a disk from a snapshot via Google SDK.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks create new-server-disk-2 \\\n--project=project-name \\\n--source-snapshot=server-disk-2 \\\n--zone=us-central1-b\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp create disk from snapshot"},{"content":"A must see for anyone trying to use SSSD on SLES12 systems.\nA little bit lengthy, but worth every bit of your half hour.\n","permalink":"http://uly.me/posts/sssd-on-sles12/","summary":"\u003cp\u003eA must see for anyone trying to use SSSD on SLES12 systems.\u003c/p\u003e\n\u003ciframe width=\"720\" height=\"420\" src=\"https://www.youtube.com/embed/z9ZBWMoZw-E?feature=oembed\"\u003e\u003c/iframe\u003e\n\u003cp\u003eA little bit lengthy, but worth every bit of your half hour.\u003c/p\u003e","title":"sssd on sles12"},{"content":"File system command differences between ext3 and xfs.\nTask ext4 xfs Creating a file system mkfs.ext4 mkfs.xfs Mounting a file system mount mount Resizing a file system resize2fs xfs_growfs Repairing a file system e2fsck xfs_repair Changing the label on a file system e2label xfs_admin -L Reporting on disk space and file usage quota quota Debugging a file system debugfs xfs_db Saving critical file system metadata to a file e2image xfs_metadump ","permalink":"http://uly.me/posts/xfs-vs-ext4-commands/","summary":"\u003cp\u003eFile system command differences between ext3 and xfs.\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003eTask\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eext4\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003exfs\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eCreating a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003emkfs.ext4\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003emkfs.xfs\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eMounting a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003emount\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003emount\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eResizing a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eresize2fs\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003exfs_growfs\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eRepairing a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ee2fsck\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003exfs_repair\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eChanging the label on a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ee2label\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003exfs_admin -L\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eReporting on disk space and file usage\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003equota\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003equota\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eDebugging a file system\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003edebugfs\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003exfs_db\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eSaving critical file system metadata to a file\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ee2image\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003exfs_metadump\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cdiv style=\"clear:both\"\u003e\u003c/div\u003e","title":"xfs vs ext4 commands"},{"content":"Here are several online RTMP players:\nWowza Flash Player Wowza Test Player HLSTester HLSPlayer I prefer the Wowza test players. The last two has annoying ads.\n","permalink":"http://uly.me/posts/online-rtmp-players/","summary":"\u003cp\u003eHere are several online RTMP players:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://www.wowza.com/resources/3.6.0/examples/LiveVideoStreaming/FlashRTMPPlayer/player.html\"\u003eWowza Flash Player\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.wowza.com/testplayers\"\u003eWowza Test Player\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.hlstester.com/\"\u003eHLSTester\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.hlsplayer.net/rtmp-player\"\u003eHLSPlayer\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eI prefer the Wowza test players. The last two has annoying ads.\u003c/p\u003e","title":"online rtmp players"},{"content":"Here’s the Terraform script to encrypt an unencrypted volume. It creates a snapshot, encrypts a snapshot, and encrypts the volume.\n# # Set Variables # variable \u0026#34;volume\u0026#34; { description = \u0026#34;The Volume to encrypt: vol-12345678901234567\u0026#34; } variable \u0026#34;region\u0026#34; { description = \u0026#34;The Region: us-east-2\u0026#34; } variable \u0026#34;az\u0026#34; { description = \u0026#34;The AZ: us-east-2a\u0026#34; } # # Set Credentials # provider \u0026#34;aws\u0026#34; { access_key = \u0026#34;put-your-access-key-here\u0026#34; secret_key = \u0026#34;put-your-secret-key-here\u0026#34; region = \u0026#34;${var.region}\u0026#34; } /* # # Create Unencrypted Volume # resource \u0026#34;aws_ebs_volume\u0026#34; \u0026#34;unencrypted_volume\u0026#34; { availability_zone = \u0026#34;${var.az}\u0026#34; size = 10 tags = { Name = \u0026#34;Unencrypted_Volume\u0026#34; } } */ # # Create Unencrypted Snapshot # resource \u0026#34;aws_ebs_snapshot\u0026#34; \u0026#34;unencrypted_snapshot\u0026#34; { #volume_id = \u0026#34;${aws_ebs_volume.unencrypted_volume.id}\u0026#34; volume_id = \u0026#34;${var.volume}\u0026#34; tags = { Name = \u0026#34;Unencrypted_Snapshot\u0026#34; } } # # Create Encrypted Snapshot # resource \u0026#34;aws_ebs_snapshot_copy\u0026#34; \u0026#34;encrypted_snapshot\u0026#34; { source_snapshot_id = \u0026#34;${aws_ebs_snapshot.unencrypted_snapshot.id}\u0026#34; source_region = \u0026#34;${var.region}\u0026#34; encrypted = true tags = { Name = \u0026#34;Encrypted_Snapshot\u0026#34; } } # # Created Encrypted Volume # resource \u0026#34;aws_ebs_volume\u0026#34; \u0026#34;encrypted_volume\u0026#34; { availability_zone = \u0026#34;${var.az}\u0026#34; snapshot_id = \u0026#34;${aws_ebs_snapshot_copy.encrypted_snapshot.id}\u0026#34; tags = { Name = \u0026#34;Encrypted_Volume\u0026#34; } } ","permalink":"http://uly.me/posts/encrypt-volume-via-terraform/","summary":"\u003cp\u003eHere’s the Terraform script to encrypt an unencrypted volume. It creates a snapshot, encrypts a snapshot, and encrypts the volume.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#\n# Set Variables\n#\nvariable \u0026#34;volume\u0026#34; {\n  description = \u0026#34;The Volume to encrypt: vol-12345678901234567\u0026#34;\n}\nvariable \u0026#34;region\u0026#34; {\n  description = \u0026#34;The Region: us-east-2\u0026#34;\n}\nvariable \u0026#34;az\u0026#34; {\n  description = \u0026#34;The AZ: us-east-2a\u0026#34;\n}\n\n#\n# Set Credentials\n#\nprovider \u0026#34;aws\u0026#34; {\n\taccess_key = \u0026#34;put-your-access-key-here\u0026#34;\n\tsecret_key = \u0026#34;put-your-secret-key-here\u0026#34;\n\tregion = \u0026#34;${var.region}\u0026#34;\n}\n\n/*\n#\n# Create Unencrypted Volume\n#\nresource \u0026#34;aws_ebs_volume\u0026#34; \u0026#34;unencrypted_volume\u0026#34; {\n  availability_zone = \u0026#34;${var.az}\u0026#34;\n  size              = 10\n  tags = {\n    Name = \u0026#34;Unencrypted_Volume\u0026#34;\n  }\n}\n*/\n\n#\n# Create Unencrypted Snapshot\n#\nresource \u0026#34;aws_ebs_snapshot\u0026#34; \u0026#34;unencrypted_snapshot\u0026#34; {\n  #volume_id = \u0026#34;${aws_ebs_volume.unencrypted_volume.id}\u0026#34;\n  volume_id = \u0026#34;${var.volume}\u0026#34;\n  tags = {\n    Name = \u0026#34;Unencrypted_Snapshot\u0026#34;\n  }\n}\n\n#\n# Create Encrypted Snapshot\n#\nresource \u0026#34;aws_ebs_snapshot_copy\u0026#34; \u0026#34;encrypted_snapshot\u0026#34; {\n  source_snapshot_id = \u0026#34;${aws_ebs_snapshot.unencrypted_snapshot.id}\u0026#34;\n  source_region      = \u0026#34;${var.region}\u0026#34;\n  encrypted = true\n  tags = {\n    Name = \u0026#34;Encrypted_Snapshot\u0026#34;\n  }\n}\n\n#\n# Created Encrypted Volume\n#\nresource \u0026#34;aws_ebs_volume\u0026#34; \u0026#34;encrypted_volume\u0026#34; {\n  availability_zone = \u0026#34;${var.az}\u0026#34;\n  snapshot_id = \u0026#34;${aws_ebs_snapshot_copy.encrypted_snapshot.id}\u0026#34;\n  tags = {\n    Name = \u0026#34;Encrypted_Volume\u0026#34;\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"encrypt volume via terraform"},{"content":"Where did I install Terraform?\ncd /usr/local/bin/ terraform --version ","permalink":"http://uly.me/posts/terraform-installation/","summary":"\u003cp\u003eWhere did I install Terraform?\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /usr/local/bin/\nterraform --version\n\u003c/code\u003e\u003c/pre\u003e","title":"terraform installation"},{"content":"What’s in the /etc/sudoers.d/ directory? It’s a group of files with the following format as displayed in the code below. In the example, the file allows a Linux group or an AD group to assume the role of root, via the sudo command. As long as the group uses the correct format, and is located inside the /etc/sudoers.d/ directory, that group will have access to root.\n%groupname ALL=(ALL) NOPASSWD: ALL ","permalink":"http://uly.me/posts/sudoers-directory/","summary":"\u003cp\u003eWhat’s in the /etc/sudoers.d/ directory? It’s a group of files with the following format as displayed in the code below. In the example, the file allows a Linux group or an AD group to assume the role of root, via the sudo command. As long as the group uses the correct format, and is located inside the /etc/sudoers.d/ directory, that group will have access to root.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e%groupname  ALL=(ALL)   NOPASSWD: ALL\n\u003c/code\u003e\u003c/pre\u003e","title":"sudoers directory"},{"content":"SSL certificates comes in multiple formats. Some providers will hand you over certificates in PFX format which comes in a single file. If you need to import it to AWS Certificate Manager, you will need to convert it from PFX to PEM format. The following set of commands uses OpenSSL and pkcs12 to convert a SSL certificate from PFX to PEM format.\nopenssl pkcs12 -in cert.pfx -nocerts -out key.pem openssl rsa -in key.pem -out server.key openssl pkcs12 -in cert.pfx -clcerts -nokeys -out cert.pem openssl pkcs12 -in cert.pfx -nodes -nokeys -out chain.pem It result in 3 files.\nserver.key is the private key cert.pem is the certificate cert.pem and chain.pem are the full chain. Once you have them, you can the proceed to import it to ACM.\nSSL Certificate Import\n","permalink":"http://uly.me/posts/convert-pfx-to-pem-format/","summary":"\u003cp\u003eSSL certificates comes in multiple formats. Some providers will hand you over certificates in PFX format which comes in a single file. If you need to import it to AWS Certificate Manager, you will need to convert it from PFX to PEM format. The following set of commands uses OpenSSL and pkcs12 to convert a SSL certificate from PFX to PEM format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eopenssl pkcs12 -in cert.pfx -nocerts -out key.pem\nopenssl rsa -in key.pem -out server.key\nopenssl pkcs12 -in cert.pfx -clcerts -nokeys -out cert.pem\nopenssl pkcs12 -in cert.pfx -nodes -nokeys -out chain.pem\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt result in 3 files.\u003c/p\u003e","title":"convert pfx to pem format"},{"content":"Find out who is logged in to the system.\n$ w $ who ","permalink":"http://uly.me/posts/whos-logged-in/","summary":"\u003cp\u003eFind out who is logged in to the system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ w\n$ who\n\u003c/code\u003e\u003c/pre\u003e","title":"who is logged in?"},{"content":"Find the biggest files in the current directory. Sort by from large to small. Display only the top 20. Display in human readable format.\nfind -type f -exec du -Sh {} + | sort -rh | head -n 20 ","permalink":"http://uly.me/posts/find-the-biggest-file/","summary":"\u003cp\u003eFind the biggest files in the current directory. Sort by from large to small. Display only the top 20. Display in human readable format.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efind -type f -exec du -Sh {} + | sort -rh | head -n 20\n\u003c/code\u003e\u003c/pre\u003e","title":"find the biggest file"},{"content":"A couple of personal statistics scripts.\n# create stats. can be run from cron. /var/www/statsmaker/create.sh # fix. must supply date. /var/www/statsmaker/fix.sh 190201 ","permalink":"http://uly.me/posts/statsmaker/","summary":"\u003cp\u003eA couple of personal statistics scripts.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# create stats. can be run from cron.\n/var/www/statsmaker/create.sh\n# fix. must supply date.\n/var/www/statsmaker/fix.sh 190201\n\u003c/code\u003e\u003c/pre\u003e","title":"statsmaker"},{"content":"Here’s how to reverse sort WP_Query. Order by ID. Reverse sort by ASC intead of DESC.\n$args = array ( \u0026#39;cat\u0026#39; =\u0026gt; 8, \u0026#39;year\u0026#39; =\u0026gt; $year, \u0026#39;orderby\u0026#39; =\u0026gt; \u0026#39;ID\u0026#39;, \u0026#39;order\u0026#39; =\u0026gt; \u0026#39;ASC\u0026#39;, \u0026#39;posts_per_page\u0026#39; =\u0026gt; -1, \u0026#39;paged\u0026#39; =\u0026gt; $paged, \u0026#39;s\u0026#39; =\u0026gt; $searchterm ); $category_posts = new WP_Query($args); ","permalink":"http://uly.me/posts/wp_query-reverse-sort/","summary":"\u003cp\u003eHere’s how to reverse sort WP_Query. Order by ID. Reverse sort by ASC intead of DESC.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e  $args = array (\n    \u0026#39;cat\u0026#39; =\u0026gt; 8, \n    \u0026#39;year\u0026#39; =\u0026gt; $year, \n    \u0026#39;orderby\u0026#39; =\u0026gt; \u0026#39;ID\u0026#39;,\n    \u0026#39;order\u0026#39; =\u0026gt; \u0026#39;ASC\u0026#39;, \n    \u0026#39;posts_per_page\u0026#39; =\u0026gt; -1, \n    \u0026#39;paged\u0026#39; =\u0026gt; $paged, \n    \u0026#39;s\u0026#39; =\u0026gt; $searchterm \n  );\n  $category_posts = new WP_Query($args);\n\u003c/code\u003e\u003c/pre\u003e","title":"wp_query reverse sort"},{"content":"Here’s how to create a Linux group with a specific ID. Group name is nginx in this example. ID is 1000.\ngroupadd nginx -g 1000 ","permalink":"http://uly.me/posts/create-group-with-id/","summary":"\u003cp\u003eHere’s how to create a Linux group with a specific ID. Group name is nginx in this example. ID is 1000.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egroupadd nginx -g 1000\n\u003c/code\u003e\u003c/pre\u003e","title":"create group with id"},{"content":"Vim is a text editor. Edit the ~.vimrc\n# vim ~.vimrc colo desert syntax on ","permalink":"http://uly.me/posts/change-vim-colors/","summary":"\u003cp\u003eVim is a text editor. Edit the ~.vimrc\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# vim ~.vimrc\ncolo desert\nsyntax on\n\u003c/code\u003e\u003c/pre\u003e","title":"change vim colors"},{"content":"How to get last month’s value. Useful with Bash scripts.\nLASTMONTH = $(date +%Y%m -d \u0026#39;1 month ago\u0026#39;) echo $LASTMONTH # Output is ... 201902 ","permalink":"http://uly.me/posts/a-month-ago/","summary":"\u003cp\u003eHow to get last month’s value. Useful with Bash scripts.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eLASTMONTH = $(date +%Y%m -d \u0026#39;1 month ago\u0026#39;)\necho $LASTMONTH\n# Output is ...\n201902\n\u003c/code\u003e\u003c/pre\u003e","title":"a month ago"},{"content":"I’ve been wanting to look at Wowza logs for a very long time. I just spent a couple of hours writing a Bash script that generates a stats report. It parses the Wowza log file for the IP addresses, and runs them and against a site called ipinfo.io to get the viewer’s geo location. The output is filtered, sorted, takes a count, and finally generates a webpage. Here’s the Bash script.\n# Can be placed in cron to run. create-wowza-report.sh wowzastreamingengine_access.log #!/bin/bash # check for missing argument if [ -z \u0026#34;$1\u0026#34; ] then echo \u0026#34;No arguments supplied. Format: create-wowza-report.sh wowzastreamingengine_access.log\u0026#34; exit 1 fi # get the ips from the wowza log file awk \u0026#39;{print $17}\u0026#39; $1 \u0026gt; output1.txt # exclude invalid ips grep \u0026#39;[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\u0026#39; output1.txt \u0026gt; output2.txt # sort unique ips cat output2.txt | sort -u | uniq \u0026gt; ips.txt # pause for 1s sleep 1s # empty file just in case \u0026gt; output3.txt # set filename filename=\u0026#34;ips.txt\u0026#34; # read filename and get geo info while read -r ipaddress; do curl ipinfo.io/\u0026#34;$ipaddress\u0026#34; 2\u0026gt;/dev/null | awk -F\u0026#39;\u0026#34;\u0026#39; \u0026#39;$2==\u0026#34;city\u0026#34;{printf(\u0026#34;%s, \u0026#34;, $4)}$2==\u0026#34;region\u0026#34;{print $4}\u0026#39; \u0026gt;\u0026gt; output3.txt done output4.txt # sort output alphabetically cat output4.txt | sort \u0026gt; output5.txt # get a count of connections count=$(wc -l $filename.php \u0026lt;title\u0026gt;Wowza Streaming Stats on $date\u0026lt;/title\u0026gt; \u0026lt;h1\u0026gt;Live Streaming Stats\u0026lt;/h1\u0026gt; \u0026lt;?php include(\u0026#39;$filename.txt\u0026#39;);??\u0026gt; EOF # move files to web directory cp $filename.* /var/www/html # cleanup files rm output*.txt rm ips.txt ","permalink":"http://uly.me/posts/parsing-wowza-logs/","summary":"\u003cp\u003eI’ve been wanting to look at Wowza logs for a very long time. I just spent a couple of hours writing a Bash script that generates a stats report. It parses the Wowza log file for the IP addresses, and runs them and against a site called ipinfo.io to get the viewer’s geo location. The output is filtered, sorted, takes a count, and finally generates a webpage. Here’s the Bash script.\u003c/p\u003e","title":"parsing wowza logs"},{"content":"If you’re still running older versions of CodeIgniter, here are a couple of tips to make it work with PHP7.\nMake sure to install all PHP tools and libraries that comes with PHP7. I was missing curl. Change your database driver from mysql to mysqli (application/config/config.php). Fix the /system/core/Common.php error or as some prefer, upgrade to a newer version. Considering v2.1.3 is very old (currently 3.1.10) , I’m surprised it works with PHP7 with just a few modifications.\n","permalink":"http://uly.me/posts/codeigniter-2-1-3-on-php7/","summary":"\u003cp\u003eIf you’re still running older versions of CodeIgniter, here are a couple of tips to make it work with PHP7.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eMake sure to install all PHP tools and libraries that comes with PHP7. I was missing curl.\u003c/li\u003e\n\u003cli\u003eChange your database driver from mysql to mysqli (application/config/config.php).\u003c/li\u003e\n\u003cli\u003eFix the /system/core/Common.php \u003ca href=\"https://stackoverflow.com/questions/28348879/only-variable-references-should-be-returned-by-reference-codeigniter#28348880\"\u003eerror\u003c/a\u003e or as some prefer, upgrade to a newer version.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eConsidering v2.1.3 is very old (currently 3.1.10) , I’m surprised it works with PHP7 with just a few modifications.\u003c/p\u003e","title":"codeigniter 2.1.3 on php7"},{"content":"Here’s the AWS CLI to get a list of encrypted or unencrypted volumes.\n# list of encrypted volumes aws ec2 describe-volumes \\ --filters Name=encrypted,Values=true \\ --region us-east-1 --profile default \\ --query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text # list of unencrypted volumes aws ec2 describe-volumes \\ --filters Name=encrypted,Values=false \\ --region us-east-1 --profile default \\ --query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text # count the list of encrypted volumes. use wc -l to get a count. aws ec2 describe-volumes \\ --filters Name=encrypted,Values=true \\ --region us-east-1 --profile default \\ --query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text | wc -l ","permalink":"http://uly.me/posts/list-of-encrypted-volumes/","summary":"\u003cp\u003eHere’s the AWS CLI to get a list of encrypted or unencrypted volumes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# list of encrypted volumes\naws ec2 describe-volumes \\\n--filters Name=encrypted,Values=true \\\n--region us-east-1 --profile default \\\n--query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text\n# list of unencrypted volumes\naws ec2 describe-volumes \\\n--filters Name=encrypted,Values=false \\\n--region us-east-1 --profile default \\\n--query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text\n# count the list of encrypted volumes. use wc -l to get a count.\naws ec2 describe-volumes \\\n--filters Name=encrypted,Values=true \\\n--region us-east-1 --profile default \\\n--query \u0026#34;Volumes[*].{ID:VolumeId}\u0026#34; --output text | wc -l\n\u003c/code\u003e\u003c/pre\u003e","title":"list of encrypted volumes"},{"content":"Here the steps to encrypt an unencrypted volume.\nTake a snapshot of the unencrypted volume. Make a copy of that snapshot and turn on encryption. Create a volume of the encrypted snapshot. Stop the instance. Detach the original unencrypted volume from the instance. Attach the newly created encrypted volume to the instance. Start the instance. AWS CLI\n# CREATE A SNAPSHOT aws ec2 create-snapshot \\ --volume-id vol-1234567890abcdef0 \\ --description \u0026#34;This is my snapshot\u0026#34; # COPY SNAPSHOT aws ec2 copy-snapshot \\ --source-region us-west-2 --source-snapshot-id snap-066877671789bd71b \\ --region us-east-1 --description \u0026#34;This is my copied snapshot.\u0026#34; # CREATE A VOLUME aws ec2 create-volume \\ --region us-east-1 --availability-zone us-east-1a \\ --snapshot-id snap-066877671789bd71b --volume-type io1 --iops 1000 # STOP AN INSTANCE aws ec2 stop-instances --instance-ids i-1234567890abcdef0 # DETACH A VOLUME aws ec2 detach-volume --volume-id vol-1234567890abcdef0 # ATTACH A VOLUME aws ec2 attach-volume --volume-id vol-1234567890abcdef0 \\ --instance-id i-01474ef662b89480 --device /dev/sdf # START AN INSTANCE aws ec2 start-instances --instance-ids i-1234567890abcdef0 ","permalink":"http://uly.me/posts/steps-to-encrypt-volumes/","summary":"\u003cp\u003eHere the steps to encrypt an unencrypted volume.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eTake a snapshot of the unencrypted volume.\u003c/li\u003e\n\u003cli\u003eMake a copy of that snapshot and turn on encryption.\u003c/li\u003e\n\u003cli\u003eCreate a volume of the encrypted snapshot.\u003c/li\u003e\n\u003cli\u003eStop the instance.\u003c/li\u003e\n\u003cli\u003eDetach the original unencrypted volume from the instance.\u003c/li\u003e\n\u003cli\u003eAttach the newly created encrypted volume to the instance.\u003c/li\u003e\n\u003cli\u003eStart the instance.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eAWS CLI\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# CREATE A SNAPSHOT\naws ec2 create-snapshot \\\n--volume-id vol-1234567890abcdef0 \\\n--description \u0026#34;This is my snapshot\u0026#34;\n\n# COPY SNAPSHOT\naws ec2 copy-snapshot \\\n--source-region us-west-2 --source-snapshot-id snap-066877671789bd71b \\\n--region us-east-1 --description \u0026#34;This is my copied snapshot.\u0026#34;\n\n# CREATE A VOLUME\naws ec2 create-volume \\\n--region us-east-1 --availability-zone us-east-1a \\\n--snapshot-id snap-066877671789bd71b --volume-type io1 --iops 1000\n\n# STOP AN INSTANCE\naws ec2 stop-instances --instance-ids i-1234567890abcdef0\n\n# DETACH A VOLUME\naws ec2 detach-volume --volume-id vol-1234567890abcdef0\n\n# ATTACH A VOLUME\naws ec2 attach-volume --volume-id vol-1234567890abcdef0 \\\n--instance-id i-01474ef662b89480 --device /dev/sdf\n\n# START AN INSTANCE\naws ec2 start-instances --instance-ids i-1234567890abcdef0\n\u003c/code\u003e\u003c/pre\u003e","title":"steps to encrypt volumes"},{"content":"Give Instances access to other cloud services using scopes.\ngcloud alpha compute instances set-scopes instance-name \\ --project project-name --zone us-central1-a \\ --scopes=cloud-platform,cloud-source-repos,compute-rw,storage-rw ","permalink":"http://uly.me/posts/gcp-instance-scopes/","summary":"\u003cp\u003eGive Instances access to other cloud services using scopes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud alpha compute instances set-scopes instance-name \\\n--project project-name --zone us-central1-a \\\n--scopes=cloud-platform,cloud-source-repos,compute-rw,storage-rw\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp instance scopes"},{"content":"The following are instructions on how to extend a disk volume with LVM.\n# aws cli extend volume aws ec2 modify-volume --region us-east-1 \\ --volume-id vol-xxxxxxxxxxxx --size 15 \\ --volume-type gp2 # check volumes before lsblk # extend via growpart growpart /dev/xvdf 1 # check volumes after lsblk # resize physical volume pvresize /dev/xvdf1 # check physical volume pvscan # extend logical volume lvresize -l +100%FREE /dev/data/data # check logical volume lvscan # check mounts df -Th # resize file system resize2fs /dev/data/data # or xfs_growfs /dev/mapper/root xfs_growfs /dev/xvda1 # check mounts again for new size df -Th ","permalink":"http://uly.me/posts/lvm-extend-physical-volume/","summary":"\u003cp\u003eThe following are instructions on how to extend a disk volume with LVM.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# aws cli extend volume\naws ec2 modify-volume --region us-east-1 \\\n--volume-id vol-xxxxxxxxxxxx --size 15 \\\n--volume-type gp2\n# check volumes before\nlsblk\n# extend via growpart\ngrowpart /dev/xvdf 1\n# check volumes after\nlsblk\n# resize physical volume\npvresize /dev/xvdf1\n# check physical volume\npvscan\n# extend logical volume\nlvresize -l +100%FREE /dev/data/data\n# check logical volume\nlvscan\n# check mounts\ndf -Th\n# resize file system\nresize2fs /dev/data/data\n# or\nxfs_growfs /dev/mapper/root\nxfs_growfs /dev/xvda1\n# check mounts again for new size\ndf -Th\n\u003c/code\u003e\u003c/pre\u003e","title":"lvm extend physical volume"},{"content":"Find out which files or directories are using up disk resources.\n# display the biggest files find -type f -exec du -Sh {} + | sort -rh | head -n 5 # display the biggest directories du -Sh | sort -rh | head -5 ","permalink":"http://uly.me/posts/list-big-files/","summary":"\u003cp\u003eFind out which files or directories are using up disk resources.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# display the biggest files\nfind -type f -exec du -Sh {} + | sort -rh | head -n 5\n# display the biggest directories\ndu -Sh | sort -rh | head -5\n\u003c/code\u003e\u003c/pre\u003e","title":"list big files"},{"content":"Here’s how to add a firewall rule in Google Cloud Platform CLI\ngcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\ --description=\u0026#34;firewall-description\u0026#34; \\ --priority \u0026#34;1000\u0026#34; \\ --direction INGRESS \\ --action allow \\ --network \u0026#34;network-name\u0026#34; \\ --target-service-accounts=\u0026#34;service@account.net\u0026#34; \\ --source-ranges=\u0026#34;10.0.0.0/8\u0026#34; \\ --rules tcp:9001 Describe firewall rule.\ngcloud compute firewall-rules describe firewall-name Delete firewall rule.\ngcloud compute firewall-rules delete firewall-name ","permalink":"http://uly.me/posts/gcp-cli-create-firewall/","summary":"\u003cp\u003eHere’s how to add a firewall rule in Google Cloud Platform CLI\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules create \u0026#34;firewall-name\u0026#34; \\\n--description=\u0026#34;firewall-description\u0026#34; \\\n--priority \u0026#34;1000\u0026#34; \\\n--direction INGRESS \\\n--action allow \\\n--network \u0026#34;network-name\u0026#34; \\\n--target-service-accounts=\u0026#34;service@account.net\u0026#34; \\\n--source-ranges=\u0026#34;10.0.0.0/8\u0026#34; \\\n--rules tcp:9001\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDescribe firewall rule.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules describe firewall-name\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDelete firewall rule.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute firewall-rules delete firewall-name\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp cli create firewall"},{"content":"Here’s the CLI commands to start and stop Google Cloud instances.\ngcloud compute instances start server-name --zone=us-central1-c gcloud compute instances stop server-name --zone=us-central1-c gcloud compute instances reset server-name --zone=us-central1-c ","permalink":"http://uly.me/posts/gcp-cli-start-stop-instances/","summary":"\u003cp\u003eHere’s the CLI commands to start and stop Google Cloud instances.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute instances start server-name --zone=us-central1-c\ngcloud compute instances stop server-name --zone=us-central1-c\ngcloud compute instances reset server-name --zone=us-central1-c\n\u003c/code\u003e\u003c/pre\u003e","title":"gcp cli start stop instances"},{"content":"Steps for creating a local RPM package installation.\n# download plugin yum install yum-plugin-downloadonly # download package and dependencies yum install --downloadonly reiserfs # download package and dependencies to a specific directory yum install --downloadonly --downloaddir=/home/ec2-user package # download multiple packages yum install --downloadonly --downloaddir=/root/mypackages/ package1 package2 # finally install package rpm -ivh -r /home/ec2-user package.rpm ","permalink":"http://uly.me/posts/local-rpm-install/","summary":"\u003cp\u003eSteps for creating a local RPM package installation.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# download plugin\nyum install yum-plugin-downloadonly\n# download package and dependencies\nyum install --downloadonly reiserfs\n# download package and dependencies to a specific directory\nyum install --downloadonly --downloaddir=/home/ec2-user package\n# download multiple packages\nyum install --downloadonly --downloaddir=/root/mypackages/ package1 package2\n# finally install package\nrpm -ivh -r /home/ec2-user package.rpm\n\u003c/code\u003e\u003c/pre\u003e","title":"local rpm install"},{"content":"Here’s an example on how to run MySQL commands from Bash.\nmysql dbname -e \u0026#34;UPDATE wp_options SET option_value=\u0026#39;http://domain.com\u0026#39; WHERE option_name=\u0026#39;home\u0026#39;\u0026#34;; mysql dbname -e \u0026#34;UPDATE wp_options SET option_value=\u0026#39;http://domain.com\u0026#39; WHERE option_name=\u0026#39;siteurl\u0026#39;\u0026#34;; The example updates WordPress’ home and siteurl. Script contains no password. It’s using .my.cnf config file.\n","permalink":"http://uly.me/posts/run-sql-in-bash/","summary":"\u003cp\u003eHere’s an example on how to run MySQL commands from Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql dbname -e \u0026#34;UPDATE wp_options SET option_value=\u0026#39;http://domain.com\u0026#39; WHERE option_name=\u0026#39;home\u0026#39;\u0026#34;;\nmysql dbname -e \u0026#34;UPDATE wp_options SET option_value=\u0026#39;http://domain.com\u0026#39; WHERE option_name=\u0026#39;siteurl\u0026#39;\u0026#34;;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe example updates WordPress’ home and siteurl. Script contains no password. It’s using .my.cnf config file.\u003c/p\u003e","title":"run sql in bash"},{"content":"Add a disk volume via cloud console. Then perform the following commands:\n# check the new block lsblk # format fdisk /dev/sdc # create file system mkfs.xfs -f /dev/sdc1 # get uuid blkid /dev/sdc1 # vi /etc/fstab UUID=\u0026#34;xxxxxxxxxxxxxxxxxxxxx\u0026#34; /mnt/directory xfs defaults 0 0 # mount mount -a ","permalink":"http://uly.me/posts/adding-a-xfs-volume/","summary":"\u003cp\u003eAdd a disk volume via cloud console. Then perform the following commands:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check the new block\nlsblk\n# format\nfdisk /dev/sdc\n# create file system\nmkfs.xfs -f /dev/sdc1\n# get uuid\nblkid /dev/sdc1\n# vi /etc/fstab\nUUID=\u0026#34;xxxxxxxxxxxxxxxxxxxxx\u0026#34; /mnt/directory xfs defaults 0 0\n# mount\nmount -a\n\u003c/code\u003e\u003c/pre\u003e","title":"adding a xfs volume"},{"content":"Lastlog displays the latest login information of all users in the system. You can’t view the lastlog file since it’s not an ascii file. You’ll need to run the actual command to view what’s in it. The program will spit out a list that may be longer than your terminal buffer. In that case, it’s best to pipe the output to “more” or better yet, use the “grep” command to isolate the user.\nlastlog | more lastlog | grep johndoe ","permalink":"http://uly.me/posts/lastlog/","summary":"\u003cp\u003eLastlog displays the latest login information of all users in the system. You can’t view the lastlog file since it’s not an ascii file. You’ll need to run the actual command to view what’s in it. The program will spit out a list that may be longer than your terminal buffer. In that case, it’s best to pipe the output to “more” or better yet, use the “grep” command to isolate the user.\u003c/p\u003e","title":"lastlog"},{"content":"Everything you need to know about block devices, e.g. UUID\nblkid # or blkid /dev/xvda You can also run file -s. You need to be root.\nfile -s /dev/xvda1 ","permalink":"http://uly.me/posts/print-block-device-attributes/","summary":"\u003cp\u003eEverything you need to know about block devices, e.g. UUID\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eblkid\n# or\nblkid /dev/xvda\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also run file -s. You need to be root.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efile -s /dev/xvda1\n\u003c/code\u003e\u003c/pre\u003e","title":"print block device attributes"},{"content":"You can check when the system was last patch using the following.\n# check RPM when the last updates were ran. rpm -qa --last | grep kernel # this is a bit of a stretch, but typically a reboot is performed after an upgrade. uptime ","permalink":"http://uly.me/posts/checking-last-patch/","summary":"\u003cp\u003eYou can check when the system was last patch using the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# check RPM when the last updates were ran.\nrpm -qa --last | grep kernel\n# this is a bit of a stretch, but typically a reboot is performed after an upgrade.\nuptime\n\u003c/code\u003e\u003c/pre\u003e","title":"checking last patch"},{"content":"Here’s a command to scan for any errors, warnings and panics on the system. If the file is too large, pipe it to more.\nsudo grep -E -i -r \u0026#39;error|warning|panic\u0026#39; /var/log sudo grep -E -i -r \u0026#39;error|warning|panic\u0026#39; /var/log \u0026gt;error-warning-panic.log cat error-warning-panic.log | more ","permalink":"http://uly.me/posts/scan-for-error-warning-and-panic/","summary":"\u003cp\u003eHere’s a command to scan for any errors, warnings and panics on the system. If the file is too large, pipe it to more.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo grep -E -i -r \u0026#39;error|warning|panic\u0026#39; /var/log\nsudo grep -E -i -r \u0026#39;error|warning|panic\u0026#39; /var/log \u0026gt;error-warning-panic.log\ncat error-warning-panic.log | more\n\u003c/code\u003e\u003c/pre\u003e","title":"scan for error, warning and panic"},{"content":"Are the icons too big in MacOS Launchpad? You can customize them. Here are the commands.\n# change the launchpad icon size by changing the columns and rows defaults write com.apple.dock springboard-columns -int 10 defaults write com.apple.dock springboard-rows -int 10 killall Dock # reset the launchpd defaults write com.apple.dock ResetLaunchPad -bool TRUE killall Dock # reset to defaults defaults delete com.apple.dock springboard-columns defaults delete com.apple.dock springboard-rows killall Dock ","permalink":"http://uly.me/posts/macos-custom-launchpad/","summary":"\u003cp\u003eAre the icons too big in MacOS Launchpad? You can customize them. Here are the commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# change the launchpad icon size by changing the columns and rows\ndefaults write com.apple.dock springboard-columns -int 10\ndefaults write com.apple.dock springboard-rows -int 10\nkillall Dock\n# reset the launchpd\ndefaults write com.apple.dock ResetLaunchPad -bool TRUE\nkillall Dock\n# reset to defaults\ndefaults delete com.apple.dock springboard-columns \ndefaults delete com.apple.dock springboard-rows\nkillall Dock\n\u003c/code\u003e\u003c/pre\u003e","title":"macos custom launchpad"},{"content":"Great article how to style your Bash prompt. Make sure you are using Bash shell, because you could be using another shell. Use this to display your current shell. Just type “bash” to start using Bash shell.\necho $0 bash I use the prompt style below. See the result underneath PS1. You may have to exit and re-enter your Terminal to see results.\nPS1=\u0026#34;\\u@\\h:\\w: \u0026#34; ulysses@localhost:/var/www: ","permalink":"http://uly.me/posts/styling-the-bash-prompt/","summary":"\u003cp\u003eGreat \u003ca href=\"https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html\"\u003earticle\u003c/a\u003e how to style your Bash prompt. Make sure you are using Bash shell, because you could be using another shell. Use this to display your current shell. Just type “bash” to start using Bash shell.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho $0\nbash\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI use the prompt style below. See the result underneath PS1. You may have to exit and re-enter your Terminal to see results.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ePS1=\u0026#34;\\u@\\h:\\w: \u0026#34;\nulysses@localhost:/var/www: \n\u003c/code\u003e\u003c/pre\u003e","title":"styling the bash prompt"},{"content":"Show a list of EFS file systems within a region.\naws efs describe-file-systems \\ --region us-east-1 Filter by Name and FileSystemId.\naws efs describe-file-systems \\ --query \u0026#39;FileSystems[*].[Name,FileSystemId]\u0026#39; ","permalink":"http://uly.me/posts/aws-cli-efs-describe-file-systems/","summary":"\u003cp\u003eShow a list of EFS file systems within a region.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws efs describe-file-systems \\\n--region us-east-1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFilter by Name and FileSystemId.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws efs describe-file-systems \\\n--query \u0026#39;FileSystems[*].[Name,FileSystemId]\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli efs describe file systems"},{"content":"How to display tags of EFS file system.\naws efs describe-tags \\ --file-system-id fs-xxxxxxxx \\ --query \u0026#39;Tags[?Key==`tagname`].{Name:Key,Value:Value}\u0026#39; ","permalink":"http://uly.me/posts/aws-cli-efs-describe-tags/","summary":"\u003cp\u003eHow to display tags of EFS file system.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws efs describe-tags \\\n--file-system-id fs-xxxxxxxx \\\n--query \u0026#39;Tags[?Key==`tagname`].{Name:Key,Value:Value}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli efs describe tags"},{"content":"Rebuild tree with Reiserfsck\nreiserfsck --rebuild-tree /dev/sda1 ","permalink":"http://uly.me/posts/reiserfsck-rebuild-tree/","summary":"\u003cp\u003eRebuild tree with Reiserfsck\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ereiserfsck --rebuild-tree /dev/sda1\n\u003c/code\u003e\u003c/pre\u003e","title":"reiserfsck rebuild tree"},{"content":"How to check RPM if packages are installed.\nrpm -qa --last rpm -qa --last | more rpm -qa --last | grep \u0026#34;package name\u0026#34; ","permalink":"http://uly.me/posts/rpm-check-packages/","summary":"\u003cp\u003eHow to check RPM if packages are installed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa --last \nrpm -qa --last | more\nrpm -qa --last | grep \u0026#34;package name\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"rpm check packages"},{"content":"Remmina is the RDP (remote desktop software) for Windows server on Linux. Here’s how to install.\nsudo add-apt-repository ppa:remmina-ppa-team/remmina-next sudo apt-get update sudo apt-get install remmina remmina-plugin-* libfreerdp-plugins-standard If you don’t see the RDP option, kill the process and restart Remmina.\n","permalink":"http://uly.me/posts/remmina-install/","summary":"\u003cp\u003eRemmina is the RDP (remote desktop software) for Windows server on Linux. Here’s how to install.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo add-apt-repository ppa:remmina-ppa-team/remmina-next\nsudo apt-get update\nsudo apt-get install remmina remmina-plugin-* libfreerdp-plugins-standard\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you don’t see the RDP option, kill the process and restart Remmina.\u003c/p\u003e","title":"remmina install"},{"content":"How to remove repos in Yum. Just delete the repo file in /etc/yum.repos.d.\nrm /etc/yum.repos.d/repo-name.repo ","permalink":"http://uly.me/posts/yum-remove-repo/","summary":"\u003cp\u003eHow to remove repos in Yum. Just delete the repo file in /etc/yum.repos.d.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erm /etc/yum.repos.d/repo-name.repo\n\u003c/code\u003e\u003c/pre\u003e","title":"yum remove repo"},{"content":"Install ReiserFS\nrpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm yum update yum install kmod-reiserfs kmod-reiserfs Make a ReiserFS\nfdisk /dev/xvdf n, p, 1 [return] [return] mkreiserfs /dev/xvdf1 mount -t reiserfs /dev/xvdf1 /data Other Reiserfs commands\nreiserfsck /dev/xvdf1 resize_reiserfs /dev/xvdf1 ","permalink":"http://uly.me/posts/reiserfs/","summary":"\u003cp\u003eInstall ReiserFS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org\nrpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm\nyum update\nyum install kmod-reiserfs kmod-reiserfs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake a ReiserFS\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efdisk /dev/xvdf\nn, p, 1\n[return]\n[return]\nmkreiserfs /dev/xvdf1\nmount -t reiserfs /dev/xvdf1 /data\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOther Reiserfs commands\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ereiserfsck /dev/xvdf1\nresize_reiserfs /dev/xvdf1\n\u003c/code\u003e\u003c/pre\u003e","title":"reiserfs"},{"content":"Get the weather report right from your terminal.\ncurl wttr.in Here’s the output.\n","permalink":"http://uly.me/posts/weather-report-from-the-terminal/","summary":"\u003cp\u003eGet the weather report right from your terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecurl wttr.in\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the output.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/02/weather.png\"\u003e\u003c/p\u003e","title":"weather report from the terminal"},{"content":"Here’s the shortcut key combination for managing windows and workspaces in Linux Mint 18.\nPress the “Ctrl + Alt + Down” keys to display all open windows. Press the “Ctrl + Alt + Up” keys to display all workspaces. Press the “Ctrl + Alt + Left or Right” keys to move between workspaces. Very useful.\n","permalink":"http://uly.me/posts/linux-mint-windows-and-workspaces/","summary":"\u003cp\u003eHere’s the shortcut key combination for managing windows and workspaces in Linux Mint 18.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ePress the “Ctrl + Alt + Down” keys to display all open windows.\u003c/li\u003e\n\u003cli\u003ePress the “Ctrl + Alt + Up” keys to display all workspaces.\u003c/li\u003e\n\u003cli\u003ePress the “Ctrl + Alt + Left or Right” keys to move between workspaces.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eVery useful.\u003c/p\u003e","title":"linux mint windows and workspaces"},{"content":"Run Docker without sudo. Add user to docker group. Login as docker using newgrp.\nsudo gpasswd -a $user docker newgrp docker You can now run the following commands without sudo.\ndocker ps docker images Every time you open a new terminal , just run.\nnewgrp docker ","permalink":"http://uly.me/posts/run-docker-without-sudo/","summary":"\u003cp\u003eRun Docker without sudo. Add user to docker group. Login as docker using newgrp.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo gpasswd -a $user docker\nnewgrp docker\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can now run the following commands without sudo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edocker ps\ndocker images\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEvery time you open a new terminal , just run.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enewgrp docker\n\u003c/code\u003e\u003c/pre\u003e","title":"run docker without sudo"},{"content":"There are two ways to store git credentials. One is temporary and the other permanent. You can store your git credentials unencrypted on disk forever or in cache memory temporarily.\nTemporary. Store for 15 minutes.\ngit config credential.helper \u0026#39;cache --timeout=900\u0026#39; Permanent.\ngit config credential.helper store git push http://example.com/repo.git Username: \u0026lt;type username=\u0026#34;\u0026#34; your=\u0026#34;\u0026#34;\u0026gt; Password: \u0026lt;type password=\u0026#34;\u0026#34; your=\u0026#34;\u0026#34;\u0026gt; \u0026lt;/type\u0026gt;\u0026lt;/type\u0026gt; Next time you use git, you will not be prompted for a password.\n","permalink":"http://uly.me/posts/storing-git-credentials/","summary":"\u003cp\u003eThere are two ways to store git credentials. One is temporary and the other permanent. You can store your git credentials unencrypted on disk forever or in cache memory temporarily.\u003c/p\u003e\n\u003cp\u003eTemporary. Store for 15 minutes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit config credential.helper \u0026#39;cache --timeout=900\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePermanent.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit config credential.helper store\ngit push http://example.com/repo.git\nUsername: \u0026lt;type username=\u0026#34;\u0026#34; your=\u0026#34;\u0026#34;\u0026gt;\nPassword: \u0026lt;type password=\u0026#34;\u0026#34; your=\u0026#34;\u0026#34;\u0026gt;\n\u0026lt;/type\u0026gt;\u0026lt;/type\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNext time you use git, you will not be prompted for a password.\u003c/p\u003e","title":"storing git credentials"},{"content":"Unfortunately, you can’t run Bash scripts in GitBash the normal way. Here’s the workaround. You have to use sh script.sh\n# Normal use ./script.sh # Running it in GitBash sh script.sh ","permalink":"http://uly.me/posts/run-bash-script-in-gitbash/","summary":"\u003cp\u003eUnfortunately, you can’t run Bash scripts in GitBash the normal way. Here’s the workaround. You have to use sh script.sh\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Normal use\n./script.sh\n# Running it in GitBash\nsh script.sh\n\u003c/code\u003e\u003c/pre\u003e","title":"run bash script in gitbash"},{"content":"Here are several commands to check memory in Linux.\nfree -m cat /proc/meminfo vmstat -s top ","permalink":"http://uly.me/posts/check-memory-in-linux/","summary":"\u003cp\u003eHere are several commands to check memory in Linux.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efree -m\ncat /proc/meminfo\nvmstat -s\ntop\n\u003c/code\u003e\u003c/pre\u003e","title":"check memory in linux"},{"content":"The following commands will extend Linux Boot drive without a reboot.\nList block devices. Check disk sizes.\nlsblk df -h Determine file system type: xfs, ext2, ext3 or ext4.\nfile -s /dev/xvda1 # or df -Th Extend volume from the console or command line.\naws ec2 modify-volume --region us-east-1 \\ --volume-id vol-xxxxxxxxxxxx --size 10 \\ --volume-type gp2 Resize Linux partition.\n# for /dev/xvda1 growpart /dev/xvda 1 # for /dev/xvda2 growpart /dev/xvda 2 # for ext2, ext3, ext4 resize2fs /dev/xvda1 # for xfs xfs_growfs /dev/mapper/root xfs_growfs /dev/xvda1 Check if new file size is being displayed.\nlsblk df -Th ","permalink":"http://uly.me/posts/extend-linux-boot/","summary":"\u003cp\u003eThe following commands will extend Linux Boot drive without a reboot.\u003c/p\u003e\n\u003cp\u003eList block devices. Check disk sizes.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003elsblk\ndf -h\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDetermine file system type: xfs, ext2, ext3 or ext4.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efile -s /dev/xvda1\n# or\ndf -Th\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExtend volume from the console or command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 modify-volume --region us-east-1 \\\n--volume-id vol-xxxxxxxxxxxx --size 10 \\\n--volume-type gp2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResize Linux partition.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# for /dev/xvda1\ngrowpart /dev/xvda 1\n# for /dev/xvda2\ngrowpart /dev/xvda 2\n# for ext2, ext3, ext4\nresize2fs /dev/xvda1\n# for xfs \nxfs_growfs /dev/mapper/root\nxfs_growfs /dev/xvda1\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCheck if new file size is being displayed.\u003c/p\u003e","title":"extend linux boot"},{"content":"AWS made more money than McDonalds and Qualcomm in 2018. And that’s not counting the retail business Amazon.com. For this fourth quarter, Amazon reported $7.43 billion in revenue from its cloud-computing business, up 45.3% from the same period a year earlier. For the full 2018 year, AWS brought in $25.7 billion, a 47% jump on the 2017 year.\n","permalink":"http://uly.me/posts/aws-quarterly-report/","summary":"\u003cp\u003eAWS made more money than McDonalds and Qualcomm in 2018. And that’s not counting the retail business Amazon.com. For this fourth quarter, Amazon reported $7.43 billion in revenue from its cloud-computing business, up 45.3% from the same period a year earlier. For the full 2018 year, AWS brought in $25.7 billion, a 47% jump on the 2017 year.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/02/aws.jpg\"\u003e\u003c/p\u003e","title":"aws quarterly report"},{"content":"Here’s the command to create a dummy file in Linux. This creates a 1GB or a 2GB file. Adjust the count to achieve the file size.\n# 1GB dd if=/dev/zero of=/path/to/dummyfile bs=1M count=1024 # 2GB dd if=/dev/zero of=/path/to/dummyfile bs=1M count=2048 ","permalink":"http://uly.me/posts/create-a-dummy-file/","summary":"\u003cp\u003eHere’s the command to create a dummy file in Linux. This creates a 1GB or a 2GB file. Adjust the count to achieve the file size.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# 1GB\ndd if=/dev/zero of=/path/to/dummyfile bs=1M count=1024\n# 2GB\ndd if=/dev/zero of=/path/to/dummyfile bs=1M count=2048\n\u003c/code\u003e\u003c/pre\u003e","title":"create a dummy file"},{"content":"Here’s the command to empty or clear Linux’s buffer or cache. Run it as root.\nfree \u0026amp;\u0026amp; sync \u0026amp;\u0026amp; echo 3 \u0026gt; /proc/sys/vm/drop_caches \u0026amp;\u0026amp; free ","permalink":"http://uly.me/posts/empty-buffer-or-cache/","summary":"\u003cp\u003eHere’s the command to empty or clear Linux’s buffer or cache. Run it as root.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efree \u0026amp;\u0026amp; sync \u0026amp;\u0026amp; echo 3 \u0026gt; /proc/sys/vm/drop_caches \u0026amp;\u0026amp; free\n\u003c/code\u003e\u003c/pre\u003e","title":"empty buffer or cache"},{"content":"Here’s the command to mount and unmount AWS EFS. Assuming the EFS IP address is 10.0.0.23.\nMount:\nmount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.0.0.23:/ /efs Umount:\n# lazy unmount umount -l /efs # force unmount umount -f /efs You may have to force it if it’s busy.\n","permalink":"http://uly.me/posts/mount-and-unmount-efs/","summary":"\u003cp\u003eHere’s the command to mount and unmount AWS EFS. Assuming the EFS IP address is 10.0.0.23.\u003c/p\u003e\n\u003cp\u003eMount:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.0.0.23:/ /efs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eUmount:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# lazy unmount\numount -l /efs\n# force unmount\numount -f /efs\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may have to force it if it’s busy.\u003c/p\u003e","title":"mount and unmount efs"},{"content":"Here’s a handy command to see if Linux was patched recently.\nrpm -qa --last | head A typical result would look something like this.\nname-of-patch Sun 20 Jan 2019 05:36:31 PM UTC name-of-patch Fri 18 Jan 2019 02:52:51 PM UTC ","permalink":"http://uly.me/posts/when-linux-was-last-patched/","summary":"\u003cp\u003eHere’s a handy command to see if Linux was patched recently.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003erpm -qa --last | head\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eA typical result would look something like this.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ename-of-patch          Sun 20 Jan 2019 05:36:31 PM UTC\nname-of-patch          Fri 18 Jan 2019 02:52:51 PM UTC\n\u003c/code\u003e\u003c/pre\u003e","title":"when linux was last patched"},{"content":"When resizing disks, here are the commands for each respected file system.\nFor xfs:\nxfs_growfs /dev/vgname/lgname For ext 2/3/4:\nresize2fs /dev/vgname/lgname ","permalink":"http://uly.me/posts/xfs-vs-ext-2-3-4/","summary":"\u003cp\u003eWhen resizing disks, here are the commands for each respected file system.\u003c/p\u003e\n\u003cp\u003eFor xfs:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003exfs_growfs /dev/vgname/lgname\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor ext 2/3/4:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eresize2fs /dev/vgname/lgname\n\u003c/code\u003e\u003c/pre\u003e","title":"xfs vs ext 2/3/4"},{"content":"Extending a LVM logical volume can be tricky. Extending a physical volume especially a boot drive is even more challenging. To make things simple, you can just easily add a new physical disk to your physical volume group. Here are the steps:\n# add disk to your instance. fdisk /dev/sdh pvcreate /dev/sdh1 vgextend system /dev/sdh1 lvextend -l +100%FREE /dev/system/opt resize2fs /dev/system/opt The fdisk command requires a few steps inside such as creating a new partition, changing the partition to type to “8e” which is Linux LVM, and then writing your changes to disk.\nThe rest are pretty much self explanatory. It’s about creating a physical volume, extending the volume group, extending the logical volume, and then finally resizing the file system.\n","permalink":"http://uly.me/posts/extend-lvm-volume/","summary":"\u003cp\u003eExtending a LVM logical volume can be tricky. Extending a physical volume especially a boot drive is even more challenging. To make things simple, you can just easily add a new physical disk to your physical volume group. Here are the steps:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# add disk to your instance. \nfdisk /dev/sdh\npvcreate /dev/sdh1\nvgextend system /dev/sdh1\nlvextend -l +100%FREE /dev/system/opt\nresize2fs /dev/system/opt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe fdisk command requires a few steps inside such as creating a new partition, changing the partition to type to “8e” which is Linux LVM, and then writing your changes to disk.\u003c/p\u003e","title":"extend lvm volume"},{"content":"I recently started using Linux Mint again. Although it contains many excellent apps, there are a few things that are missing. So, here’s a list of programs that I have installed ✅ or will be installing on Linux Mint in the near future.\n✅ sublime text 3 ✅ lastpass ✅ discord ✅ aws cli ✅ ffmpeg ✅ handbrake ✅ git ✅ vim ✅ emacs ✅ tor ✅ slack ✅ docker virtualbox ","permalink":"http://uly.me/posts/apps-to-install-on-linux-mint/","summary":"\u003cp\u003eI recently started using Linux Mint again. Although it contains many excellent apps, there are a few things that are missing. So, here’s a list of programs that I have installed ✅ or will be installing on Linux Mint in the near future.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e✅ sublime text 3\u003c/li\u003e\n\u003cli\u003e✅ lastpass\u003c/li\u003e\n\u003cli\u003e✅ discord\u003c/li\u003e\n\u003cli\u003e✅ aws cli\u003c/li\u003e\n\u003cli\u003e✅ ffmpeg\u003c/li\u003e\n\u003cli\u003e✅ handbrake\u003c/li\u003e\n\u003cli\u003e✅ git\u003c/li\u003e\n\u003cli\u003e✅ vim\u003c/li\u003e\n\u003cli\u003e✅ emacs\u003c/li\u003e\n\u003cli\u003e✅ tor\u003c/li\u003e\n\u003cli\u003e✅ slack\u003c/li\u003e\n\u003cli\u003e✅ docker\u003c/li\u003e\n\u003cli\u003evirtualbox\u003c/li\u003e\n\u003c/ul\u003e","title":"apps to install on linux mint"},{"content":"Starting with version 4, Samba can now run as a domain controller. It can support Windows and Linux clients. You can compile it from source or install it via package managers such as rpm, yum and apt. You can always use it as a standard shared drive and even use it as a print server.\n","permalink":"http://uly.me/posts/samba-4-domain-controller/","summary":"\u003cp\u003eStarting with version 4, \u003ca href=\"https://www.samba.org/samba/\"\u003eSamba\u003c/a\u003e can now run as a domain controller. It can support Windows and Linux clients. You can compile it from source or install it via package managers such as rpm, yum and apt. You can always use it as a standard shared drive and even use it as a print server.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/01/samba.png\"\u003e\u003c/p\u003e","title":"samba 4 domain controller"},{"content":"The Gutenberg Youtube embed lacks a few things. The alignment doesn’t seem to be working, at least in the theme I’m using. I’m using Generate-Pro, a Genesis child theme. By default, it’s left-aligned. I have to add this div to make it centered.\n\u0026lt;div style=\u0026#34;text-align:center\u0026#34;\u0026gt; \u0026lt;/div\u0026gt; If you want right aligned, use this div.\n\u0026lt;div style=\u0026#34;text-align:right\u0026#34;\u0026gt; \u0026lt;/div\u0026gt; ","permalink":"http://uly.me/posts/gutenberg-youtube-embed/","summary":"\u003cp\u003eThe Gutenberg Youtube embed lacks a few things. The alignment doesn’t seem to be working, at least in the theme I’m using. I’m using Generate-Pro, a Genesis child theme. By default, it’s left-aligned. I have to add this div to make it centered.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;div style=\u0026#34;text-align:center\u0026#34;\u0026gt;\n\u0026lt;/div\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want right aligned, use this div.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;div style=\u0026#34;text-align:right\u0026#34;\u0026gt;\n\u0026lt;/div\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e","title":"gutenberg youtube embed"},{"content":"Bring Putty to the next level. Thanks to Solarwinds.\nSolar-Putty\n","permalink":"http://uly.me/posts/solar-putty/","summary":"\u003cp\u003eBring Putty to the next level. Thanks to Solarwinds.\u003c/p\u003e\n\u003ciframe width=\"720\" height=\"420\" src=\"https://www.youtube.com/embed/2xsqsNHGU8E?feature=oembed\" \u003e\u003c/iframe\u003e\n\u003cp\u003eSolar-Putty\u003c/p\u003e","title":"solar-putty"},{"content":"If you’re confused about the different formats and files that the Certificate Manager will accept in AWS, this site explains it fairly well. The Certificate Manager contains 3 fields during the import process. Certificate body, Certificate private key, and Certificate chain.\nServer certificate \u0026gt; Intermediate certificate \u0026gt; Root certificate\nPrivate RSA Key Chain consists of Root and Intermediate ","permalink":"http://uly.me/posts/ssl-certificates-explained/","summary":"\u003cp\u003eIf you’re confused about the different formats and files that the Certificate Manager will accept in AWS, this \u003ca href=\"https://helpdesk.ssls.com/hc/en-us/articles/115001391705-How-to-install-a-SSL-certificate-on-AWS\"\u003esite\u003c/a\u003e explains it fairly well. The Certificate Manager contains 3 fields during the import process. Certificate body, Certificate private key, and Certificate chain.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/01/cm.png\"\u003e\u003c/p\u003e\n\u003cp\u003eServer certificate \u0026gt; Intermediate certificate \u0026gt; Root certificate\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ePrivate RSA Key\u003c/li\u003e\n\u003cli\u003eChain consists of Root and Intermediate\u003c/li\u003e\n\u003c/ul\u003e","title":"ssl certificates explained"},{"content":"Regex is really cool. You can do amazing things with it, but if you’re starting new, it’s quite daunting task. If you ever find one that works, you better hang on to it for dear life. Here’s one that I know is working. It reads data from a file, and compares and matches a variable to a certain pattern. In the example below, the variable I’m searching for, must contain a string with the following characters “server-w.” They also must be followed by at least one number or a set of numbers.\ncat filename | while read LINE; do if [[ $LINE =~ server-w-*.[0-9] ]]; then echo \u0026#34;Do not backup $LINE\u0026#34; else echo \u0026#34;Backup $LINE\u0026#34; fi done If you need help with Regex, check out a couple of sites below that allows you to test your regex skills. Regex and RegExr.\n","permalink":"http://uly.me/posts/regex-match/","summary":"\u003cp\u003eRegex is really cool. You can do amazing things with it, but if you’re starting new, it’s quite daunting task. If you ever find one that works, you better hang on to it for dear life. Here’s one that I know is working. It reads data from a file, and compares and matches a variable to a certain pattern. In the example below, the variable I’m searching for, must contain a string with the following characters “server-w.” They also must be followed by at least one number or a set of numbers.\u003c/p\u003e","title":"regex match"},{"content":"AWS just introduced Backup, a new managed service for backing up AWS resources. You can now create backup policies of EC2, RDS, DynamoDB, and EFS systems. The default backup uses S3 buckets, but storage can be moved to Glacier or it can be expired. The backup service is initially available in Virginia, Ohio, Oregon and Ireland.\nAWS Backup\n","permalink":"http://uly.me/posts/aws-backup/","summary":"\u003cp\u003eAWS just introduced \u003ca href=\"https://aws.amazon.com/backup/\"\u003eBackup\u003c/a\u003e, a new managed service for backing up AWS resources. You can now create backup policies of EC2, RDS, DynamoDB, and EFS systems. The default backup uses S3 buckets, but storage can be moved to Glacier or it can be expired. The backup service is initially available in Virginia, Ohio, Oregon and Ireland.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/01/aws-backup.png\"\u003e\u003c/p\u003e\n\u003cp\u003eAWS Backup\u003c/p\u003e","title":"aws backup"},{"content":"Looking for a text editor for editing code? Check out Sublime Text 3. You can install the text editor using several package managers depending on your Linux distro. There’s apt, yum, zypper, pacman and dnf. Here’s the Apt install of Sublime Text 3.\necho \u0026#34;deb https://download.sublimetext.com/ apt/stable/\u0026#34; | sudo tee /etc/apt/sources.list.d/sublime-text.list sudo apt-get update sudo apt-get install sublime-text ","permalink":"http://uly.me/posts/sublime-text-3/","summary":"\u003cp\u003eLooking for a text editor for editing code? Check out \u003ca href=\"https://www.sublimetext.com/\"\u003eSublime Text 3\u003c/a\u003e. You can install the text editor using several package managers depending on your Linux distro. There’s apt, yum, zypper, pacman and dnf. Here’s the Apt install of Sublime Text 3.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eecho \u0026#34;deb https://download.sublimetext.com/ apt/stable/\u0026#34; | sudo tee /etc/apt/sources.list.d/sublime-text.list\nsudo apt-get update\nsudo apt-get install sublime-text\n\u003c/code\u003e\u003c/pre\u003e","title":"sublime text 3"},{"content":"If you like to try out different flavors of Linux as well as other distros, install them in a virtual environment like VirtualBox. In this way you avoid messing up your system since installation will be inside a container. VirtualBox can run in Windows, Mac and Linux. I’m currently running it on Linux Mint 19. If you are curious, the instructions are here to install VirtualBox 6 in Linux Mint 19.\nVirtualBox 6.0\n","permalink":"http://uly.me/posts/virtualbox-6-in-mint-19/","summary":"\u003cp\u003eIf you like to try out different flavors of Linux as well as other distros, install them in a virtual environment like VirtualBox. In this way you avoid messing up your system since installation will be inside a container. VirtualBox can run in Windows, Mac and Linux. I’m currently running it on Linux Mint 19. If you are curious, the instructions are \u003ca href=\"https://www.osradar.com/install-virtualbox-6-ubuntu-18-04-linux-mint-19/\"\u003ehere\u003c/a\u003e to install VirtualBox 6 in Linux Mint 19.\u003c/p\u003e","title":"virtualbox 6 in mint 19"},{"content":"How to check for an argument in a script in Bash.\nif [ -z \u0026#34;$1\u0026#34; ] ; then echo \u0026#34;there are no arguments\u0026#34; else echo \u0026#34;there is an argument\u0026#34; fi ","permalink":"http://uly.me/posts/check-argument-in-bash/","summary":"\u003cp\u003eHow to check for an argument in a script in Bash.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif [ -z \u0026#34;$1\u0026#34; ] ; then\n  echo \u0026#34;there are no arguments\u0026#34;\nelse\n  echo \u0026#34;there is an argument\u0026#34;\nfi\n\u003c/code\u003e\u003c/pre\u003e","title":"check argument in bash"},{"content":"Perform this command to reset a Linux account that has been locked out due to multiple login failures. This involves resetting the pam_tally back down to zero. Some systems use pam_tally2. First, check what’s the current tally.\nCurrent tally:\npam_tally --user=username pam_tally2 --user=username To reset:\npam_tally --user=username --reset pam_tally2 --user=username --reset ","permalink":"http://uly.me/posts/reset-locked-out-linux-user/","summary":"\u003cp\u003ePerform this command to reset a Linux account that has been locked out due to multiple login failures. This involves resetting the pam_tally back down to zero. Some systems use pam_tally2. First, check what’s the current tally.\u003c/p\u003e\n\u003cp\u003eCurrent tally:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epam_tally --user=username\npam_tally2 --user=username\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo reset:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epam_tally --user=username --reset\npam_tally2 --user=username --reset\n\u003c/code\u003e\u003c/pre\u003e","title":"reset locked out linux user"},{"content":"Etcher allows you to safely and easily burn images to SD and USB drives. It has a simple interface, and and exclusively available on the Mac OS platform. Burning an image has never been easy. Just select an image (ISO), select a drive, and flash the image.\nEtcher interface\n","permalink":"http://uly.me/posts/etcher/","summary":"\u003cp\u003eEtcher allows you to safely and easily burn images to SD and USB drives. It has a simple interface, and and exclusively available on the Mac OS platform. Burning an image has never been easy. Just select an image (ISO), select a drive, and flash the image.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/01/etcher.png\"\u003e\u003c/p\u003e\n\u003cp\u003eEtcher interface\u003c/p\u003e","title":"etcher"},{"content":"If you need to change your system’s hostname, use hostname or hostnamectl commands.\nhostname servername hostnamectl set-hostname servername You can add the hostname to these 2 files and reboot.\nvi /etc/hostname vi /etc/hosts reboot Without a reboot. Add the hostname to these 2 files.\nvi /etc/hostname vi /etc/hosts And add a hostname entry to 127.0.0.1 in /etc/hosts.\n127.0.0.1 servername That’s all she wrote.\n","permalink":"http://uly.me/posts/hostname/","summary":"\u003cp\u003eIf you need to change your system’s hostname, use hostname or hostnamectl commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehostname servername\nhostnamectl set-hostname servername\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can add the hostname to these 2 files and reboot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evi /etc/hostname\nvi /etc/hosts\nreboot\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWithout a reboot. Add the hostname to these 2 files.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evi /etc/hostname\nvi /etc/hosts\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAnd add a hostname entry to 127.0.0.1 in /etc/hosts.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e127.0.0.1 servername\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThat’s all she wrote.\u003c/p\u003e","title":"hostname"},{"content":"Just got done installing Linux Mint 19.1 Tessa Cinnamon edition. It’s a long-term support release with support until 2023. Here are some of the new features. I use Etcher on the Mac to write to the USB. I then booted via USB to install Linux Mint on the new machine. Linux Mint was done installing in less than 10 minutes. I went with Cinnamon since it was a darker theme.\nLinux Mint 19 Cinnamon\n","permalink":"http://uly.me/posts/linux-mint-19-1/","summary":"\u003cp\u003eJust got done installing \u003ca href=\"http://linuxmint.com\"\u003eLinux Mint\u003c/a\u003e 19.1 Tessa Cinnamon edition. It’s a long-term support release with support until 2023. Here are some of the new \u003ca href=\"https://www.linuxmint.com/rel_tessa_cinnamon_whatsnew.php\"\u003efeatures\u003c/a\u003e. I use Etcher on the Mac to write to the USB. I then booted via USB to install Linux Mint on the new machine. Linux Mint was done installing in less than 10 minutes. I went with Cinnamon since it was a darker theme.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2019/01/linuxmint.png\"\u003e\u003c/p\u003e\n\u003cp\u003eLinux Mint 19 Cinnamon\u003c/p\u003e","title":"linux mint 19.1"},{"content":"I recently upgraded my system which involved a new motherboard. I brought over the old hard drive from my previous machine to the new one. I booted it. Bang! And just like that Microsoft deactivated my account. I called them. They said they have no record of it based on the email addresses that I’ve provided.\nI told them that I’ve upgraded from Windows 7 to Windows 10 a few years back. Microsoft proceeded to tell me that I needed to provide them my Windows 7 product key. Now, I have to look for it. I have no idea where it is. If I can’t find it. I won’t be able to activate it. I’m sure I’m not the only who got screwed for upgrading their hardware.\nWindows 10 Activation\nEssentially, I’m back to using Linux again, which by the way don’t have draconian methods for simple things like hardware changes.\n","permalink":"http://uly.me/posts/windows-10-activation/","summary":"\u003cp\u003eI recently upgraded my system which involved a new motherboard. I brought over the old hard drive from my previous machine to the new one. I booted it. Bang! And just like that Microsoft deactivated my account. I called them. They said they have no record of it based on the email addresses that I’ve provided.\u003c/p\u003e\n\u003cp\u003eI told them that I’ve upgraded from Windows 7 to Windows 10 a few years back. Microsoft proceeded to tell me that I needed to provide them my Windows 7 product key. Now, I have to look for it. I have no idea where it is. If I can’t find it. I won’t be able to activate it. I’m sure I’m not the only who got screwed for upgrading their hardware.\u003c/p\u003e","title":"windows 10 activation"},{"content":"Here’s a neat command to append a job to a crontab within a Bash script.\ncrontab -l | { cat; echo \u0026#34;0 1 * * * /dir/script.sh \u0026gt; /logs/script.cronlog 2\u0026gt;\u0026amp;1\u0026#34;; } | crontab - To validate, perform crontab -l to see if your changes are there.\ncrontab -l ","permalink":"http://uly.me/posts/adding-to-crontab-in-bash/","summary":"\u003cp\u003eHere’s a neat command to append a job to a crontab within a Bash script.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab -l | { cat; echo \u0026#34;0 1 * * * /dir/script.sh \u0026gt; /logs/script.cronlog 2\u0026gt;\u0026amp;1\u0026#34;; } | crontab -\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo validate, perform crontab -l to see if your changes are there.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecrontab -l\n\u003c/code\u003e\u003c/pre\u003e","title":"adding to crontab in bash"},{"content":"Cloud Filestore is a managed file service by Google Cloud. It’s a shared file system similar to Amazon’s Elastic File System offering. Users of Cloud Filestore will experience something similar to when using a NAS drive (network attached storage). Filestore is used for both Compute and Kubernetes Engine instances. Unlike EFS where storage is unlimited, you have to specify a storage size when creating a new Filestore.\nCreate a Filestore:\ngcloud beta filestore instances create nfs-server \\ --project=your-project-id \\ --location=your-region \\ --tier=STANDARD \\ --file-share=name=\u0026#34;vol1\u0026#34;,capacity=1TB \\ --network=name=\u0026#34;default\u0026#34;,reserved-ip-range=\u0026#34;10.0.0.0/29\u0026#34; Delete a Filestore:\ngcloud beta filestore instances delete nfs-server --project=your-project-id --location=your-region Instance clients can connect to the Filestore using a NFS client.\nsudo apt-get -y update sudo apt-get -y install nfs-common sudo mkdir /mnt/test sudo mount 10.0.0.59:/vol1 /mnt/test sudo chmod go+rw /mnt/test ","permalink":"http://uly.me/posts/cloud-filestore/","summary":"\u003cp\u003eCloud Filestore is a managed file service by Google Cloud. It’s a shared file system similar to Amazon’s Elastic File System offering. Users of Cloud Filestore will experience something similar to when using a NAS drive (network attached storage). Filestore is used for both Compute and Kubernetes Engine instances. Unlike EFS where storage is unlimited, you have to specify a storage size when creating a new Filestore.\u003c/p\u003e\n\u003cp\u003eCreate a Filestore:\u003c/p\u003e","title":"cloud filestore"},{"content":"Just ordered parts for a new system.\nCPU: AMD – Ryzen 7 1700X 3.4 GHz 8-Core Processor Cooler: Cooler Master – ML240L RGB 66.7 CFM Liquid CPU Cooler Motherboard: Asus – STRIX B350-F GAMING ATX AM4 Motherboard Memory: G.Skill – Trident Z RGB 16 GB (2 x 8 GB) DDR4-3000 Memory Storage: ADATA – Ultimate SU800 256 GB 2.5″ Solid State Drive Case: FSP Group – CMT520 ATX Mid Tower Case Power Supply: Rosewill – 600 W 80+ Semi-Modular ATX Power Supply PCPartPicker: parts list.\nWill need a new GPU. Will get one later. Can’t wait to put it together.\n","permalink":"http://uly.me/posts/new-pc/","summary":"\u003cp\u003eJust ordered parts for a new system.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCPU: AMD – Ryzen 7 1700X 3.4 GHz 8-Core Processor\u003c/li\u003e\n\u003cli\u003eCooler: Cooler Master – ML240L RGB 66.7 CFM Liquid CPU Cooler\u003c/li\u003e\n\u003cli\u003eMotherboard: Asus – STRIX B350-F GAMING ATX AM4 Motherboard\u003c/li\u003e\n\u003cli\u003eMemory: G.Skill – Trident Z RGB 16 GB (2 x 8 GB) DDR4-3000 Memory\u003c/li\u003e\n\u003cli\u003eStorage: ADATA – Ultimate SU800 256 GB 2.5″ Solid State Drive\u003c/li\u003e\n\u003cli\u003eCase: FSP Group – CMT520 ATX Mid Tower Case\u003c/li\u003e\n\u003cli\u003ePower Supply: Rosewill – 600 W 80+ Semi-Modular ATX Power Supply\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003ePCPartPicker: \u003ca href=\"https://pcpartpicker.com/list/jCBF9J\"\u003eparts list\u003c/a\u003e.\u003c/p\u003e","title":"new pc"},{"content":"I fired up my old Linux PC which runs on Linux Mint. I noticed the default Firefox browser is quite old. It needs an upgrade, which is expected since this Linux Mint version is 18.1. The current version is 19.1. So, here are the steps to upgrade Firefox in Linux Mint.\nDownload Firefox.\nwget https://www.mozilla.org/en-US/firefox/download/thanks/ Extract.\ncd ~/Downloads/ tar xjf firefox-64.0.2.tar.bz2 Move Firefox.\nmv firefox /opt/firefox Create a symbolic link.\nln -s /opt/firefox/firefox /usr/bin/firefox The old icons should still work. Enjoy.\n","permalink":"http://uly.me/posts/upgrade-firefox-in-linux-mint/","summary":"\u003cp\u003eI fired up my old Linux PC which runs on Linux Mint. I noticed the default Firefox browser is quite old. It needs an upgrade, which is expected since this Linux Mint version is 18.1. The current version is 19.1. So, here are the steps to upgrade Firefox in Linux Mint.\u003c/p\u003e\n\u003cp\u003eDownload Firefox.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ewget https://www.mozilla.org/en-US/firefox/download/thanks/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eExtract.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd ~/Downloads/\ntar xjf firefox-64.0.2.tar.bz2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMove Firefox.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emv firefox /opt/firefox\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a symbolic link.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eln -s /opt/firefox/firefox /usr/bin/firefox\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe old icons should still work. Enjoy.\u003c/p\u003e","title":"upgrade firefox in linux mint"},{"content":"If you work with the vi or vim editors in Linux, sometimes it’s nice to be able to see the line numbers display on the editor.\nTurn it on.\nvim filename :set number Turn it off.\nvim filename :set nonumber ","permalink":"http://uly.me/posts/vi-display-line-numbers/","summary":"\u003cp\u003eIf you work with the vi or vim editors in Linux, sometimes it’s nice to be able to see the line numbers display on the editor.\u003c/p\u003e\n\u003cp\u003eTurn it on.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim filename\n:set number\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTurn it off.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003evim filename\n:set nonumber\n\u003c/code\u003e\u003c/pre\u003e","title":"vi display line numbers"},{"content":"Better late than never. How to display all open windows in Windows. Just press the Windows key + Tab.\n","permalink":"http://uly.me/posts/windows-tab/","summary":"\u003cp\u003eBetter late than never. How to display all open windows in Windows. Just press the Windows key + Tab.\u003c/p\u003e","title":"windows + tab"},{"content":"Resolv.conf is a computer file used by various operating systems as a DNS resolver. The file is in plain text. It’s usually generated by the system administrator or a network program. The file is located in the /etc/ directory and contains the search domain as well a list of nameservers.\nHere’s an example of the /etc/resolv.conf file.\nsearch domain.com local.lan nameserver 1.1.1.1 nameserver 8.8.8.8 nameserver 9.9.9.9 If you have problems resolving domain names, check this file first.\n","permalink":"http://uly.me/posts/resolv-conf/","summary":"\u003cp\u003eResolv.conf is a computer file used by various operating systems as a DNS resolver. The file is in plain text. It’s usually generated by the system administrator or a network program. The file is located in the /etc/ directory and contains the search domain as well a list of nameservers.\u003c/p\u003e\n\u003cp\u003eHere’s an example of the /etc/resolv.conf file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esearch domain.com local.lan\nnameserver 1.1.1.1\nnameserver 8.8.8.8\nnameserver 9.9.9.9\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you have problems resolving domain names, check this file first.\u003c/p\u003e","title":"resolv.conf"},{"content":"My previous post lightly talked about about adding SSL certificates via the AWS Console. This post talks about adding your own SSL certificate to Certificate Manager via the AWS CLI. The CLI which makes it super simple to manage. It also allows for automation as well.\naws acm import-certificate \\ --certificate fileb://Certificate.pem \\ --certificate-chain fileb://CertificateChain.pem \\ --private-key fileb://PrivateKey.pem If successful, it will return ARN or Amazon Resource Name.\n","permalink":"http://uly.me/posts/certificate-management-import/","summary":"\u003cp\u003eMy previous post lightly talked about about adding SSL certificates via the AWS Console. This post talks about adding your own SSL certificate to Certificate Manager via the AWS CLI. The CLI which makes it super simple to manage. It also allows for automation as well.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws acm import-certificate \\\n--certificate fileb://Certificate.pem \\\n--certificate-chain fileb://CertificateChain.pem \\\n--private-key fileb://PrivateKey.pem\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf successful, it will return ARN or Amazon Resource Name.\u003c/p\u003e","title":"certificate management import"},{"content":"If you have SSL on your website, you can import your own SSL certificates into CloudFront, which is a content delivery network service by AWS. You will need to work a few AWS services to get it working.\nCloudFront – create a distribution Route 53 – create a hosted zone and add a CNAME Certificate Manager – import your SSL certificate Finally, on the WordPress side, enable the use CloudFront in your SuperCache plugin.\nSeems simple, but you’ll need some patience to get it working.\nLook at your HTML source to see if your CDN is really working.\n","permalink":"http://uly.me/posts/cloudfront-ssl-certificates/","summary":"\u003cp\u003eIf you have SSL on your website, you can import your own SSL certificates into CloudFront, which is a content delivery network service by AWS. You will need to work a few AWS services to get it working.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCloudFront – create a distribution\u003c/li\u003e\n\u003cli\u003eRoute 53 – create a hosted zone and add a CNAME\u003c/li\u003e\n\u003cli\u003eCertificate Manager – import your SSL certificate\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFinally, on the WordPress side, enable the use CloudFront in your SuperCache plugin.\u003c/p\u003e","title":"cloudfront ssl certificates"},{"content":"Just documenting how to restart SSSD service. SSSD is a service that allows Active Directory groups access to Linux systems.\nsystemctl restart sssd.service For other or older Linux distros, you may have to use this:\nservice sssd restart You can always try the other if one doesn’t work.\n","permalink":"http://uly.me/posts/restart-sssd-service/","summary":"\u003cp\u003eJust documenting how to restart SSSD service. SSSD is a service that allows Active Directory groups access to Linux systems.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esystemctl restart sssd.service\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor other or older Linux distros, you may have to use this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eservice sssd restart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can always try the other if one doesn’t work.\u003c/p\u003e","title":"restart sssd service"},{"content":"Block Lab is a plugin that allows you to create custom blocks within the WordPress Gutenberg editor. You can create blocks for content or code that you repeatedly use in an effort to simplify publishing. To create a custom plugin, you will need to create a block first. Once you named a block, you can add fields to that block and pass the variables to the block templates. The template contains the code that you need to send to the Gutenberg editor in the form of blocks. Here’s an example of a Block and Template.\nMy Custom Block\nCustom block\nTemplate: block-my-custom-block.php\nThe “block_field” function echoes the variables passed from the blocks to the template.\n\u0026lt;h4\u0026gt;\u0026lt;?php block_field( \u0026#39;heading\u0026#39; )??\u0026gt;\u0026lt;/h4\u0026gt; In some instances, you may have to mute the echo. In this example, I’m using the function in a comparison.\n\u0026lt;h4\u0026gt;\u0026lt;?php if (block_field( \u0026#39;heading\u0026#39;, $echo = false ) == \u0026#34;\u0026#34;): else: block_field( \u0026#39;heading\u0026#39; ); endif; ??\u0026gt;\u0026lt;/h4\u0026gt; ","permalink":"http://uly.me/posts/block-lab/","summary":"\u003cp\u003eBlock Lab is a plugin that allows you to create custom blocks within the WordPress Gutenberg editor. You can create blocks for content or code that you repeatedly use in an effort to simplify publishing. To create a custom plugin, you will need to create a block first. Once you named a block, you can add fields to that block and pass the variables to the block templates. The template contains the code that you need to send to the Gutenberg editor in the form of blocks. Here’s an example of a Block and Template.\u003c/p\u003e","title":"block lab"},{"content":"JSON and YAML are used in AWS CloudFormation. Some people prefer YAML for its simplicity. It’s easy to read and code. However, YAML has its own little quirks. It relies heavily on indentation for its structure. If you don’t use the proper spaces, it will fail. I ran into an issue when I ran CloudFormation in AWS. The example below display the contents of my userdata.\nThis piece of code will NOT work in CloudFormation.\nFn::Base64: !Sub | #!/bin/bash -xe yum update -y mkdir /data cd /data aws s3 cp s3://efs-s3-backup-engine . sleep 30s initiate.sh This is valid. It’s all about indentation.\nFn::Base64: !Sub | #!/bin/bash -xe yum update -y mkdir /data cd /data aws s3 cp s3://efs-s3-backup-engine . sleep 30s initiate.sh By the way, tabs are to be avoided like the plague.\n","permalink":"http://uly.me/posts/yaml-indentation/","summary":"\u003cp\u003eJSON and YAML are used in AWS CloudFormation. Some people prefer YAML for its simplicity. It’s easy to read and code. However, YAML has its own little quirks. It relies heavily on indentation for its structure. If you don’t use the proper spaces, it will fail. I ran into an issue when I ran CloudFormation in AWS. The example below display the contents of my userdata.\u003c/p\u003e\n\u003cp\u003eThis piece of code will NOT work in CloudFormation.\u003c/p\u003e","title":"yaml indentation"},{"content":"How do you create a crontab entry via a Bash script? That’s a good question. Here is one solution:\n(crontab -l 2\u0026gt;/dev/null; echo \u0026#34;* 11 * * * /path/to/job -with args\u0026#34;) | crontab - If you want to run it as a specific user, use the following:\n(crontab -l -u user 2\u0026gt;/dev/null; echo \u0026#34;* 11 * * * /path/to/job -with args\u0026#34;) | crontab - ","permalink":"http://uly.me/posts/create-a-crontab-via-script/","summary":"\u003cp\u003eHow do you create a crontab entry via a Bash script? That’s a good question. Here is one solution:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e(crontab -l 2\u0026gt;/dev/null; echo \u0026#34;* 11 * * * /path/to/job -with args\u0026#34;) | crontab -\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want to run it as a specific user, use the following:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e(crontab -l -u user 2\u0026gt;/dev/null; echo \u0026#34;* 11 * * * /path/to/job -with args\u0026#34;) | crontab -\n\u003c/code\u003e\u003c/pre\u003e","title":"create a crontab via script"},{"content":"Hashicorp has a product called Terraform, which is a provisioning tool for the cloud. It works with most major providers like AWS, GCP, Azure and many more. Unlike CloudFormation, Resource Manager and Deployment Manager, Terraform will work with not just its own, but with many cloud providers. Here’s an example of how to provision a single instance to AWS, and assign an elastic IP to it. The cloud resources in the example were redacted. Placeholder values were placed instead for security purposes.\nprovider \u0026#34;aws\u0026#34; { access_key = \u0026#34;xxxxxxxx\u0026#34; secret_key = \u0026#34;xxxxxxxxxxxxxxxxxxxxxxxxxx\u0026#34; region = \u0026#34;us-east-2\u0026#34; } resource \u0026#34;aws_instance\u0026#34; \u0026#34;server1\u0026#34; { ami = \u0026#34;ami-xxxxxxxxxxxxxx\u0026#34; key_name = \u0026#34;tfc-ohio\u0026#34; instance_type = \u0026#34;c5.2xlarge\u0026#34; subnet_id = \u0026#34;subnet-xxxxxxxx\u0026#34; security_groups\t= [\u0026#34;sg-xxxxxxxxxxxxxxx\u0026#34;] private_ip = \u0026#34;10.0.4.100\u0026#34; tags { Name = \u0026#34;Server One\u0026#34; } } resource \u0026#34;aws_eip_association\u0026#34; \u0026#34;server1-eip\u0026#34; { instance_id = \u0026#34;${aws_instance.server1.id}\u0026#34; allocation_id = \u0026#34;eipalloc-xxxxxxxx\u0026#34; } To provision an instance, just run:\nterraform apply When you are done, just run:\nterraform destroy ","permalink":"http://uly.me/posts/terraform/","summary":"\u003cp\u003eHashicorp has a product called \u003ca href=\"https://learn.hashicorp.com/terraform/\"\u003eTerraform\u003c/a\u003e, which is a provisioning tool for the cloud. It works with most major providers like AWS, GCP, Azure and many more. Unlike \u003ca href=\"https://aws.amazon.com/cloudformation/\"\u003eCloudFormation\u003c/a\u003e, \u003ca href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/\"\u003eResource Manager\u003c/a\u003e and \u003ca href=\"https://cloud.google.com/deployment-manager/docs/\"\u003eDeployment Manager\u003c/a\u003e, Terraform will work with not just its own, but with many cloud providers. Here’s an example of how to provision a single instance to AWS, and assign an elastic IP to it. The cloud resources in the example were redacted. Placeholder values were placed instead for security purposes.\u003c/p\u003e","title":"terraform"},{"content":"Kubernetes has documentation on how to deploy WordPress on its platform. The setup is using Persistent Volumes for both WordPress and MySQL on MiniKube. Although the setup is not recommended for a production environment, it is a good start to get yourself familiar with Kubernetes. For production environments, they do recommend running WordPress on a Kubernetes cluster using the Helm package manager. Here’s the WordPress-MySQL deployment on MiniKube.\napiVersion: v1 kind: Service metadata: name: wordpress-mysql labels: app: wordpress spec: ports: - port: 3306 selector: app: wordpress tier: mysql clusterIP: None --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-pv-claim labels: app: wordpress spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi --- apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: name: wordpress-mysql labels: app: wordpress spec: selector: matchLabels: app: wordpress tier: mysql strategy: type: Recreate template: metadata: labels: app: wordpress tier: mysql spec: containers: - image: mysql:5.6 name: mysql env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: mysql-pass key: password ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql-pv-claim ","permalink":"http://uly.me/posts/wordpress-on-kubernetes/","summary":"\u003cp\u003e\u003ca href=\"http://kubernetes.io\"\u003eKubernetes\u003c/a\u003e has documentation on how to deploy \u003ca href=\"http://wordpress.org\"\u003eWordPress\u003c/a\u003e on its platform. The setup is using Persistent Volumes for both WordPress and MySQL on \u003ca href=\"https://github.com/kubernetes/minikube\"\u003eMiniKube\u003c/a\u003e. Although the setup is not recommended for a production environment, it is a good start to get yourself familiar with Kubernetes. For production environments, they do recommend running WordPress on a Kubernetes cluster using the \u003ca href=\"https://github.com/helm/charts/tree/master/stable/wordpress\"\u003eHelm\u003c/a\u003e package manager. Here’s the WordPress-MySQL \u003ca href=\"https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/\"\u003edeployment on MiniKube.\u003c/a\u003e\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapiVersion: v1\nkind: Service\nmetadata:\n  name: wordpress-mysql\n  labels:\n    app: wordpress\nspec:\n  ports:\n    - port: 3306\n  selector:\n    app: wordpress\n    tier: mysql\n  clusterIP: None\n---\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: mysql-pv-claim\n  labels:\n    app: wordpress\nspec:\n  accessModes:\n    - ReadWriteOnce\n  resources:\n    requests:\n      storage: 20Gi\n---\napiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2\nkind: Deployment\nmetadata:\n  name: wordpress-mysql\n  labels:\n    app: wordpress\nspec:\n  selector:\n    matchLabels:\n      app: wordpress\n      tier: mysql\n  strategy:\n    type: Recreate\n  template:\n    metadata:\n      labels:\n        app: wordpress\n        tier: mysql\n    spec:\n      containers:\n      - image: mysql:5.6\n        name: mysql\n        env:\n        - name: MYSQL_ROOT_PASSWORD\n          valueFrom:\n            secretKeyRef:\n              name: mysql-pass\n              key: password\n        ports:\n        - containerPort: 3306\n          name: mysql\n        volumeMounts:\n        - name: mysql-persistent-storage\n          mountPath: /var/lib/mysql\n      volumes:\n      - name: mysql-persistent-storage\n        persistentVolumeClaim:\n          claimName: mysql-pv-claim\n\u003c/code\u003e\u003c/pre\u003e","title":"wordpress on kubernetes"},{"content":"Here’s the AWS CLI command for deleting a snapshot.\naws ec2 delete-snapshot \\ --snapshot-id snap-xxxxxxxxxxxxxxx \\ --profile default ","permalink":"http://uly.me/posts/ec2-delete-snapshots/","summary":"\u003cp\u003eHere’s the AWS CLI command for deleting a snapshot.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 delete-snapshot \\\n--snapshot-id snap-xxxxxxxxxxxxxxx \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e","title":"ec2 delete snapshots"},{"content":"If you have a ton of snapshots, they tend to be difficult to find within the AWS console. Although AWS has optimized the snapshot view, it’s still in beta. Filtering a volume id is still a problem. It might be faster just to use the AWS CLI to display snapshot information. Here’s an example of how to display snapshots given a certain volume id.\naws ec2 describe-snapshots \\ --filters Name=volume-id,Values=vol-xxxxxxxxxxxxxx \\ --query \u0026#34;Snapshots[*].{ID:SnapshotId,Time:StartTime,Progress:Progress}\u0026#34; \\ --profile default The result is something like this.\n{ \u0026#34;Progress\u0026#34;: \u0026#34;99%\u0026#34;, \u0026#34;ID\u0026#34;: \u0026#34;snap-xxxxxxxxxxxxxxx\u0026#34;, \u0026#34;Time\u0026#34;: \u0026#34;2018-12-25T10:19:51.385Z\u0026#34; }, { \u0026#34;Progress\u0026#34;: \u0026#34;99%\u0026#34;, \u0026#34;ID\u0026#34;: \u0026#34;snap-xxxxxxxxxxxxxxx\u0026#34;, \u0026#34;Time\u0026#34;: \u0026#34;2018-12-24T09:35:09.357Z\u0026#34; } ","permalink":"http://uly.me/posts/ec2-describe-snapshots/","summary":"\u003cp\u003eIf you have a ton of snapshots, they tend to be difficult to find within the AWS console. Although AWS has optimized the snapshot view, it’s still in beta. Filtering a volume id is still a problem. It might be faster just to use the AWS CLI to display snapshot information. Here’s an example of how to display snapshots given a certain volume id.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-snapshots \\\n--filters Name=volume-id,Values=vol-xxxxxxxxxxxxxx \\\n--query \u0026#34;Snapshots[*].{ID:SnapshotId,Time:StartTime,Progress:Progress}\u0026#34; \\\n--profile default\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe result is something like this.\u003c/p\u003e","title":"ec2 describe snapshots"},{"content":"I found a new WordPress plugin that allows you to add custom blocks within the Gutenberg editor. You can create any block that you want by using the same templating code you’re already familiar with in WordPress. You can work with CSS, PHP, plugin shortcodes, etc. It’s a beautiful plugin with endless possibilities. The plugin is called Block Lab.\n","permalink":"http://uly.me/posts/building-a-custom-block/","summary":"\u003cp\u003eI found a new WordPress plugin that allows you to add custom blocks within the Gutenberg editor. You can create any block that you want by using the same templating code you’re already familiar with in WordPress. You can work with CSS, PHP, plugin shortcodes, etc. It’s a beautiful plugin with endless possibilities. The plugin is called \u003ca href=\"https://getblocklab.com/\"\u003eBlock Lab\u003c/a\u003e.\u003c/p\u003e\n\u003ciframe width=\"720\" height=\"420\" src=\"https://www.youtube.com/embed/cmWnMBF0ly0?feature=oembed\"\u003e\u003c/iframe\u003e","title":"building a custom block"},{"content":"If you need to comment out multiple lines in Sublime Text 2 or 3, there’s a short keystroke that you can use. First, you need to highlight the block (multiple lines) that you want to comment out, then press Ctrl + /. You can press it again to toggle on and off.\nLine 1 Line 2 Line 3 Pressing Ctrl + / will comment out the highlighted block.\n#Line 1 #Line 2 #Line 3 Press Ctrl + / again to toggle it back.\n","permalink":"http://uly.me/posts/sublime-text-comment-multiple-lines/","summary":"\u003cp\u003eIf you need to comment out multiple lines in Sublime Text 2 or 3, there’s a short keystroke that you can use. First, you need to highlight the block (multiple lines) that you want to comment out, then press Ctrl + /. You can press it again to toggle on and off.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eLine 1\nLine 2\nLine 3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePressing Ctrl + / will comment out the highlighted block.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#Line 1\n#Line 2\n#Line 3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003ePress Ctrl + / again to toggle it back.\u003c/p\u003e","title":"sublime text comment multiple lines"},{"content":"If you want to auto mount the EFS volumes when the instance is created, add the following script to userdata:\n#cloud-config repo_upgrade: all packages: - amazon-efs-utils runcmd: - file_system_id_01=fs-12345678 - file_system_id_02=fs-34593405 - efs_directory_01=/mnt/efs - efs_directory_02=/mnt/efs2 - mkdir -p ${efs_directory_01} - mkdir -p ${efs_directory_02} - echo \u0026#34;${file_system_id_01}:/ ${efs_directory_01} efs tls,_netdev\u0026#34; \u0026gt;\u0026gt; /etc/fstab - echo \u0026#34;${file_system_id_02}:/ ${efs_directory_02} efs tls,_netdev\u0026#34; \u0026gt;\u0026gt; /etc/fstab - mount -a -t efs defaults Just add more if you have more mounts.\n","permalink":"http://uly.me/posts/aws-efs-userdata/","summary":"\u003cp\u003eIf you want to auto mount the EFS volumes when the instance is created, add the following script to userdata:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e#cloud-config\nrepo_upgrade: all\n\npackages:\n- amazon-efs-utils\n\nruncmd:\n- file_system_id_01=fs-12345678\n- file_system_id_02=fs-34593405\n- efs_directory_01=/mnt/efs\n- efs_directory_02=/mnt/efs2\n\n- mkdir -p ${efs_directory_01}\n- mkdir -p ${efs_directory_02}\n\n- echo \u0026#34;${file_system_id_01}:/ ${efs_directory_01} efs tls,_netdev\u0026#34; \u0026gt;\u0026gt; /etc/fstab\n- echo \u0026#34;${file_system_id_02}:/ ${efs_directory_02} efs tls,_netdev\u0026#34; \u0026gt;\u0026gt; /etc/fstab\n\n- mount -a -t efs defaults\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eJust add more if you have more mounts.\u003c/p\u003e","title":"aws efs userdata"},{"content":"Google Cloud Platform just recently released a beta feature called detaching and attaching boot disks. Previously, boot disks were permanently attached to their VM instances. Now you have the ability to detach boot disk from your instance and attach it to another instance without deleting the original instance. You can also replace the boot disks for an instance rather than recreating the entire instance. I’ve tested it on my test account, and it works quite nicely.\nI have 2 servers called blue-server and red-server. I’m detaching the disks on blue-server and attaching it to the red-server.\ngcloud compute instances detach-disk blue-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances attach-disk cyan-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances detach-disk cyan-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances attach-disk blue-server --disk=blue-server-disk --zone us-central1-c Results:\nGCP: Attach and Detach Disks\nThis new GCP feature is still beta. There might be a few quirks here and there, but overall, it’s a must have feature if you are managing OS.\n","permalink":"http://uly.me/posts/gcp-attach-detach-disks/","summary":"\u003cp\u003eGoogle Cloud Platform just recently released a beta feature called detaching and attaching boot disks. Previously, boot disks were permanently attached to their VM instances. Now you have the ability to detach boot disk from your instance and attach it to another instance without deleting the original instance. You can also replace the boot disks for an instance rather than recreating the entire instance. I’ve tested it on my test account, and it works quite nicely.\u003c/p\u003e","title":"gcp attach detach disks"},{"content":"If you’re using Finder on a Mac OS, the quickest way to display and hide hidden files is by using the Command + Shift + . (or the period) key combination. This key combination will toggle on and off the hidden files inside the Finder. By the way, this is only applicable if you have the Mac Sierra OS and above. I like the clean look better (without the hidden files), but the Command + Shift + . is pretty handy if you need to quickly look at hidden files.\nFinder: Command + Shift + .\n","permalink":"http://uly.me/posts/cmd-shift-dot/","summary":"\u003cp\u003eIf you’re using Finder on a Mac OS, the quickest way to display and hide hidden files is by using the Command + Shift + . (or the period) key combination. This key combination will toggle on and off the hidden files inside the Finder. By the way, this is only applicable if you have the Mac Sierra OS and above. I like the clean look better (without the hidden files), but the Command + Shift + . is pretty handy if you need to quickly look at hidden files.\u003c/p\u003e","title":"cmd shift dot"},{"content":"If you have the instance id, you can print out the details like this:\naws ec2 describe-instances --instance-ids i-xxxxxxxxxxxxx \\ --region us-east-1 --profile default ","permalink":"http://uly.me/posts/aws-cli-describe-instances-2/","summary":"\u003cp\u003eIf you have the instance id, you can print out the details like this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eaws ec2 describe-instances --instance-ids i-xxxxxxxxxxxxx \\\n--region us-east-1 --profile default\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli describe instances"},{"content":"I’m running a “source” command inside a Bash script. The script is running fine on its own, but when I try running it inside a crontab, it doesn’t work. I’m using the source command just to load variables in a file, so I don’t have to edit multiple files. As it turns out, the regular shell in crontab does not quite understand the source command, and it’s the very reason the script fails. Here’s an example.\nsource /home/user/server.conf I ended up removing the source line, and hardcoding the variables instead of loading it from a file.\nserver=\u0026#34;servername\u0026#34; ","permalink":"http://uly.me/posts/bash-source-in-cron/","summary":"\u003cp\u003eI’m running a “source” command inside a Bash script. The script is running fine on its own, but when I try running it inside a crontab, it doesn’t work. I’m using the source command just to load variables in a file, so I don’t have to edit multiple files. As it turns out, the regular shell in crontab does not quite understand the source command, and it’s the very reason the script fails. Here’s an example.\u003c/p\u003e","title":"bash source in cron"},{"content":"I was banging my head against the wall (not quite literally, but it was close) trying to come up with a S3 lifecycle configuration from scratch. I needed a JSON file that I can run in a bash script, so I can apply the lifecycle rules to a few dozen S3 buckets. Obviously, trying to create one from scratch wasn’t the wisest choice in my part. As it turns out, you can setup a temporary bucket and use the console to recreate the lifecycle, then export the lifecycle JSON file. Duh! Genius! Here’s the command to export the lifecycle configuration.\naws s3api get-bucket-lifecycle-configuration \\ --bucket bucket-name The output would be in a JSON format similar to this:\n{ \u0026#34;Rules\u0026#34;: [ { \u0026#34;Status\u0026#34;: \u0026#34;Enabled\u0026#34;, \u0026#34;NoncurrentVersionExpiration\u0026#34;: { \u0026#34;NoncurrentDays\u0026#34;: 90 }, \u0026#34;NoncurrentVersionTransitions\u0026#34;: [ { \u0026#34;NoncurrentDays\u0026#34;: 7, \u0026#34;StorageClass\u0026#34;: \u0026#34;INTELLIGENT_TIERING\u0026#34; } ], \u0026#34;Filter\u0026#34;: { \u0026#34;Prefix\u0026#34;: \u0026#34;\u0026#34; }, \u0026#34;Expiration\u0026#34;: { \u0026#34;ExpiredObjectDeleteMarker\u0026#34;: true }, \u0026#34;AbortIncompleteMultipartUpload\u0026#34;: { \u0026#34;DaysAfterInitiation\u0026#34;: 7 }, \u0026#34;ID\u0026#34;: \u0026#34;EFS S3 Backup Lifecycle Rules\u0026#34; } ] } ","permalink":"http://uly.me/posts/aws-cli-bucket-lifecycle-configuration/","summary":"\u003cp\u003eI was banging my head against the wall (not quite literally, but it was close) trying to come up with a S3 lifecycle configuration from scratch. I needed a JSON file that I can run in a bash script, so I can apply the lifecycle rules to a few dozen S3 buckets. Obviously, trying to create one from scratch wasn’t the wisest choice in my part. As it turns out, you can setup a temporary bucket and use the console to recreate the lifecycle, then export the lifecycle JSON file. Duh! Genius! Here’s the command to export the lifecycle configuration.\u003c/p\u003e","title":"aws cli bucket lifecycle configuration"},{"content":"If you have a ton of EC2 instances, one way to get results quickly is to run to use AWS CLI such as “describe-instances.” Here’s an example on how to get a list of instances with a tag name equal to some value. In addition, you limit the display only results you want displayed.\n$ aws ec2 describe-instances \\ --query \u0026#39;Reservations[].Instances[].Tags[?Key==`Name`].Value\u0026#39; \\ --filter Name=tag:Project,Values=web \\ --region us-east-1 \\ --profile default \\ --output text This returns values of the “Name” tag name in instances where they occur.\n","permalink":"http://uly.me/posts/aws-cli-describe-instances/","summary":"\u003cp\u003eIf you have a ton of EC2 instances, one way to get results quickly is to run to use AWS CLI such as “describe-instances.” Here’s an example on how to get a list of instances with a tag name equal to some value. In addition, you limit the display only results you want displayed.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws ec2 describe-instances \\\n--query \u0026#39;Reservations[].Instances[].Tags[?Key==`Name`].Value\u0026#39; \\\n--filter Name=tag:Project,Values=web \\\n--region us-east-1 \\\n--profile default \\\n--output text\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis returns values of the “Name” tag name in instances where they occur.\u003c/p\u003e","title":"aws cli: describe instances"},{"content":"AWS recently released a new S3 feature called Intelligent-Tiering. It’s designed to optimize storage costs automatically when data access patterns change, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings by moving data between two access tiers, frequent access and infrequent access, when access patterns change. To activate, all you need to do create or edit your current S3 lifecycle.\nTransition to Intelligent-Tiering\n","permalink":"http://uly.me/posts/aws-s3-intelligent-tiering/","summary":"\u003cp\u003eAWS recently released a new S3 feature called Intelligent-Tiering. It’s designed to optimize storage costs automatically when data access patterns change, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings by moving data between two access tiers, frequent access and infrequent access, when access patterns change. To activate, all you need to do create or edit your current S3 lifecycle.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2018/12/it2.png\"\u003e\u003c/p\u003e\n\u003cp\u003eTransition to Intelligent-Tiering\u003c/p\u003e","title":"aws s3 intelligent-tiering"},{"content":"To turn on S3 versioning from the AWS CLI, just run the following command:\n$ aws s3api put-bucket-versioning --bucket mybucket \\ ----versioning-configuration Status=Enabled ","permalink":"http://uly.me/posts/aws-cli-s3-versioning/","summary":"\u003cp\u003eTo turn on S3 versioning from the AWS CLI, just run the following command:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws s3api put-bucket-versioning --bucket mybucket \\\n----versioning-configuration Status=Enabled\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli s3 versioning"},{"content":"I use split views on Windows quite a bit at work. On my Mac at home, not so much. Here are the instructions if you’re curious how it’s done on the MacOS. I’ve done it a few times, but just like many things, if you don’t use it enough, you tend to forget it. So, here’s a quick post for a search on the blog later.\nEnter the Split View Hold down the full-screen button in the upper-left corner of a window. As you hold the button, the window shrinks and you can drag it to the left or right side of the screen. Release the button, then click another window to begin using both windows side by side Here’s the full screen button.\n","permalink":"http://uly.me/posts/split-view-on-mac/","summary":"\u003cp\u003eI use split views on Windows quite a bit at work. On my Mac at home, not so much. Here are the instructions if you’re curious how it’s done on the MacOS. I’ve done it a few times, but just like many things, if you don’t use it enough, you tend to forget it. So, here’s a quick post for a search on the blog later.\u003c/p\u003e\n\u003ch2 id=\"enter-the-split-view\"\u003eEnter the Split View\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eHold down the full-screen button in the upper-left corner of a window.\u003c/li\u003e\n\u003cli\u003eAs you hold the button, the window shrinks and you can drag it to the left or right side of the screen.\u003c/li\u003e\n\u003cli\u003eRelease the button, then click another window to begin using both windows side by side\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"https://uly.me/wp-content/uploads/2018/12/fullscreen.jpg\"\u003e\u003c/p\u003e","title":"split view on mac"},{"content":"Creating a bucket via the AWS Console takes only a few clicks. If you’re creating a bucket via shell script, you will need to use the AWS CLI (command line interface). So, here’s the script to create a S3 bucket via the AWS CLI within shell. Now the bucket name has to be globally unique similar to a domain name. If someone already has claimed it, you will need to use an alternative name.\naws s3api create-bucket --bucket bucket-name --region us-east-2 create-bucket-configuration LocationConstraint=us-east-2 ","permalink":"http://uly.me/posts/aws-cli-create-bucket/","summary":"\u003cp\u003eCreating a bucket via the AWS Console takes only a few clicks. If you’re creating a bucket via shell script, you will need to use the AWS CLI (command line interface). So, here’s the script to create a S3 bucket via the AWS CLI within shell. Now the bucket name has to be globally unique similar to a domain name. If someone already has claimed it, you will need to use an alternative name.\u003c/p\u003e","title":"aws cli create bucket"},{"content":"Here’s the CLI command to set server-side AES-256 encryption on a bucket.\n$ aws s3api put-bucket-encryption --bucket bucket-name \\ --server-side-encryption-configuration \\ \u0026#39;{\u0026#34;Rules\u0026#34;: [{\u0026#34;ApplyServerSideEncryptionByDefault\u0026#34;: {\u0026#34;SSEAlgorithm\u0026#34;: \u0026#34;AES256\u0026#34;}}]}\u0026#39; You can apply this to any existing bucket.\n","permalink":"http://uly.me/posts/aws-cli-encrypt-bucket/","summary":"\u003cp\u003eHere’s the CLI command to set server-side AES-256 encryption on a bucket.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ aws s3api put-bucket-encryption --bucket bucket-name \\\n--server-side-encryption-configuration \\\n\u0026#39;{\u0026#34;Rules\u0026#34;: [{\u0026#34;ApplyServerSideEncryptionByDefault\u0026#34;: {\u0026#34;SSEAlgorithm\u0026#34;: \u0026#34;AES256\u0026#34;}}]}\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can apply this to any existing bucket.\u003c/p\u003e","title":"aws cli encrypt bucket"},{"content":"Here’s how to add a lifecycle management to S3 buckets via the CLI. In this example, expiration is set to 7 days. S3 will auto delete expired objects.\n$aws s3api put-bucket-lifecycle-configuration \\ --bucket bucketname --lifecycle-configuration file://lifecycle.json The lifecycle is defined in this JSON file.\n{ \u0026#34;Rules\u0026#34;: [ { \u0026#34;ID\u0026#34;: \u0026#34;Expires in 7 DAYS\u0026#34;, \u0026#34;Prefix\u0026#34;: \u0026#34;\u0026#34;, \u0026#34;Status\u0026#34;: \u0026#34;Enabled\u0026#34;, \u0026#34;Expiration\u0026#34;: { \u0026#34;Days\u0026#34;: 7 } } ] } ","permalink":"http://uly.me/posts/aws-cli-s3-lifecycle/","summary":"\u003cp\u003eHere’s how to add a lifecycle management to S3 buckets via the CLI. In this example, expiration is set to 7 days. S3 will auto delete expired objects.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$aws s3api put-bucket-lifecycle-configuration \\\n--bucket bucketname --lifecycle-configuration file://lifecycle.json\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe lifecycle is defined in this JSON file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n  \u0026#34;Rules\u0026#34;: [ \n    {\n       \u0026#34;ID\u0026#34;: \u0026#34;Expires in 7 DAYS\u0026#34;, \n       \u0026#34;Prefix\u0026#34;: \u0026#34;\u0026#34;, \n       \u0026#34;Status\u0026#34;: \u0026#34;Enabled\u0026#34;, \n       \u0026#34;Expiration\u0026#34;: { \n         \u0026#34;Days\u0026#34;: 7\n         }\n    } \n  ] \n}\n\u003c/code\u003e\u003c/pre\u003e","title":"aws cli s3 lifecycle"},{"content":"Here’s a nice command to get rid of line duplicates in a file. I’m sending the output to a temporary file then renaming it back to the original file.\nThe reason is, it’s probably not a good idea to overwrite a file that you are editing. It’s much safer to send the output to another file.\n$ awk \u0026#39;!seen[$0]++\u0026#39; filename.txt \u0026gt; filename.temp $ mv filename.temp filename.txt A much cleaner approach is to use this. It will edit the file in place.\nawk -i inplace \u0026#39;!seen[$0]++\u0026#39; filename.txt ","permalink":"http://uly.me/posts/clean-duplicates-in-file/","summary":"\u003cp\u003eHere’s a nice command to get rid of line duplicates in a file. I’m sending the output to a temporary file then renaming it back to the original file.\u003c/p\u003e\n\u003cp\u003eThe reason is, it’s probably not a good idea to overwrite a file that you are editing. It’s much safer to send the output to another file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ awk \u0026#39;!seen[$0]++\u0026#39; filename.txt \u0026gt; filename.temp\n$ mv filename.temp filename.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eA much cleaner approach is to use this. It will edit the file in place.\u003c/p\u003e","title":"clean duplicates in file"},{"content":"tlk.io is a simple chat page that you can embed on your site. If all you are seeing is a blank screen, I may have a fix for it. I don’t think it’s documented anywhere. I did not see it on tlk.io’s website. Here’s the code that they want you to embed. Of course, you have to use your own data-channel instead of the default “hey.”\n\u0026lt;div data-channel=\u0026#34;hey\u0026#34; id=\u0026#34;tlkio\u0026#34; style=\u0026#34;width:100%;height:400px;\u0026#34;\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;script async=\u0026#34;\u0026#34; src=\u0026#34;http://tlk.io/embed.js\u0026#34; type=\u0026#34;text/javascript\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; The above code will not work if your site is secured via SSL. You’ll need to change the embed.js reference to https. In this case, it would be something like this.\n\u0026lt;div data-channel=\u0026#34;hey\u0026#34; id=\u0026#34;tlkio\u0026#34; style=\u0026#34;width:100%;height:400px;\u0026#34;\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;script async=\u0026#34;\u0026#34; src=\u0026#34;https://tlk.io/embed.js\u0026#34; type=\u0026#34;text/javascript\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; The code will work in WordPress as well.\n","permalink":"http://uly.me/posts/tlk-io-embed/","summary":"\u003cp\u003etlk.io is a simple chat page that you can embed on your site. If all you are seeing is a blank screen, I may have a fix for it. I don’t think it’s documented anywhere. I did not see it on tlk.io’s website. Here’s the code that they want you to embed. Of course, you have to use your own data-channel instead of the default “hey.”\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;div data-channel=\u0026#34;hey\u0026#34; id=\u0026#34;tlkio\u0026#34; style=\u0026#34;width:100%;height:400px;\u0026#34;\u0026gt;\u0026lt;/div\u0026gt;\n\u0026lt;script async=\u0026#34;\u0026#34; src=\u0026#34;http://tlk.io/embed.js\u0026#34; type=\u0026#34;text/javascript\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe above code will not work if your site is secured via SSL. You’ll need to change the embed.js reference to https. In this case, it would be something like this.\u003c/p\u003e","title":"tlk.io embed"},{"content":"Here’s my revised WordPress permissions. Originally, I had it set to:\n$ sudo chown -R www-data:www-data /var/www $ find /var/www -type d -exec sudo chmod 755 {} \\; $ find /var/www -type f -exec sudo chmod 644 {} \\; This is a very safe setup as recommended by quite a few WordPress security gurus.\nHowever, here’s the issue. When you try to FTP as “ulysses” user, it won’t let you overwrite files, because it doesn’t have write access to the “/var/www” directory since it’s owned by www-data. To fix the permission issue, first you have to add the “ulysses” user to the www-data group. See below. In addition, you’ll need to change ownership of the files and directories to the “ulysses” user and give “ulysses” user full access to the files. Change file permissions to 775, and directory permissions to 664.\n$ sudo usermod -a -G www-data ulysses $ sudo chown -R ulysses:www-data /var/www $ find /var/www -type d -exec sudo chmod 775 {} \\; $ find /var/www -type f -exec sudo chmod 664 {} \\; Everything is all and good, until you try to add a plugin within the WordPress console. It’s now asking for your FTP credentials which most people don’t have setup. The simple fix here is to the following line in your wp-config.php file.\n$ vi /var/www/html/wp-config.php # Add the following ... define(\u0026#39;FS_METHOD\u0026#39;, \u0026#39;direct\u0026#39;); While you are at it, you should also change wp-config.php permissions to 660. Some people recommend 600, but then you’ll end up with the same permission issue as before, user “ulysses” will not have access to the wp-config.php file. So 660 is the preferred value.\n$ sudo chmod 660 /var/www/html/wp-config.php That should take care of everything.\n","permalink":"http://uly.me/posts/revised-wordpress-permissions/","summary":"\u003cp\u003eHere’s my revised WordPress permissions. Originally, I had it set to:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo chown -R www-data:www-data /var/www\n$ find /var/www -type d -exec sudo chmod 755 {} \\;\n$ find /var/www -type f -exec sudo chmod 644 {} \\;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis is a very safe setup as recommended by quite a few WordPress security gurus.\u003c/p\u003e\n\u003cp\u003eHowever, here’s the issue. When you try to FTP as “ulysses” user, it won’t let you overwrite files, because it doesn’t have write access to the “/var/www” directory since it’s owned by www-data. To fix the permission issue, first you have to add the “ulysses” user to the www-data group. See below. In addition, you’ll need to change ownership of the files and directories to the “ulysses” user and give “ulysses” user full access to the files. Change file permissions to 775, and directory permissions to 664.\u003c/p\u003e","title":"revised wordpress permissions"},{"content":"Beginning with WordPress 5, Gutenberg will be part of the WordPress core. If you want a preview, install it as a plugin. What is Gutenberg?\nThe Gutenberg WordPress editor is a new page builder that is being designed to integrate with WordPress core. Gutenberg will add content blocks and page builder-like functionality to every up-to-date WordPress website. When in use, it will replace TinyMCE as the default content editor. With Gutenberg, content is added in blocks of various types from the WordPress backend. This is a quote block.\nFrom: iThemes\nThis is numerical list.\nHello Goodbye ","permalink":"http://uly.me/posts/using-the-gutenberg-editor/","summary":"\u003cp\u003eBeginning with WordPress 5, Gutenberg will be part of the WordPress core. If you want a preview, install it as a plugin. What is Gutenberg?\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThe Gutenberg WordPress editor is a new page builder that is being designed to integrate with WordPress core. Gutenberg will add content blocks and page builder-like functionality to every up-to-date WordPress website. When in use, it will replace TinyMCE as the default content editor. With Gutenberg, content is added in blocks of various types from the WordPress backend. This is a quote block.\u003c/p\u003e","title":"using the gutenberg editor"},{"content":"I have a 8GB USB drive that displays only as 200MB. I have to run diskpart as an Administrator from my Windows 10 computer. I selected the disk, and then cleaned it. After that, go back to disk management, and then reformat the entire partition to FAT32. USB drive is now showing 7.9GB.\nHere’s the fix.\n","permalink":"http://uly.me/posts/200mb-usb-drive/","summary":"\u003cp\u003eI have a 8GB USB drive that displays only as 200MB. I have to run diskpart as an Administrator from my Windows 10 computer. I selected the disk, and then cleaned it. After that, go back to disk management, and then reformat the entire partition to FAT32. USB drive is now showing 7.9GB.\u003c/p\u003e\n\u003cp\u003eHere’s the \u003ca href=\"https://answers.microsoft.com/en-us/windows/forum/windows_8-hardware/usb-sandisk-8-gb-device-showing-as-200mb-how-do-i/f631df0d-9068-4f2d-820e-a6cbe9b464c3\"\u003efix\u003c/a\u003e.\u003c/p\u003e","title":"200mb usb drive"},{"content":"Just playing around with Python. This program a simple calculation of a video’s 16:9 aspect ratio.\nJust supply the width or height in pixels, it will display the 16:9 resolution.\nHere’s the code.\nimport math print(\u0026#34;===================================================\u0026#34;) print(\u0026#34;This program will calculate a video\u0026#39;s aspect ratio.\u0026#34;) print(\u0026#34;===================================================\u0026#34;) height_or_width = input(\u0026#39;Choose a height or width (h, w) to calculate? \u0026#39;) if height_or_width == \u0026#34;h\u0026#34;: video_height = float(input(\u0026#34;Enter a video height in px: \u0026#34;)) video_width = video_height * 1.7777777777777 print(\u0026#34;\u0026#34;) print(\u0026#34;The video aspect ratio is: {:.0f} x {:.0f}\u0026#34;.format(video_width, video_height)) print(\u0026#34;\u0026#34;) elif height_or_width == \u0026#34;w\u0026#34;: video_width = float(input(\u0026#34;Enter a video width in px: \u0026#34;)) video_height = video_width / 1.7777777777777 print(\u0026#34;\u0026#34;) print(\u0026#34;The video aspect ratio is: {:.0f} x {:.0f}\u0026#34;.format(video_width, video_height)) print(\u0026#34;\u0026#34;) else: print(\u0026#39;Thanks for playing .... \u0026#39;) print(\u0026#39;\u0026#39;) The output:\n","permalink":"http://uly.me/posts/python-169-aspect-ratio/","summary":"\u003cp\u003eJust playing around with Python. This program a simple calculation of a video’s 16:9 aspect ratio.\u003c/p\u003e\n\u003cp\u003eJust supply the width or height in pixels, it will display the 16:9 resolution.\u003c/p\u003e\n\u003cp\u003eHere’s the code.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimport math\n\nprint(\u0026#34;===================================================\u0026#34;)\nprint(\u0026#34;This program will calculate a video\u0026#39;s aspect ratio.\u0026#34;)\nprint(\u0026#34;===================================================\u0026#34;)\n\nheight_or_width = input(\u0026#39;Choose a height or width (h, w) to calculate? \u0026#39;)\n\nif height_or_width == \u0026#34;h\u0026#34;:\n\tvideo_height = float(input(\u0026#34;Enter a video height in px: \u0026#34;))\n\tvideo_width = video_height * 1.7777777777777\n\tprint(\u0026#34;\u0026#34;)\n\tprint(\u0026#34;The video aspect ratio is: {:.0f} x {:.0f}\u0026#34;.format(video_width, video_height))\n\tprint(\u0026#34;\u0026#34;)\n\nelif height_or_width == \u0026#34;w\u0026#34;:\n\tvideo_width = float(input(\u0026#34;Enter a video width in px: \u0026#34;))\n\tvideo_height = video_width / 1.7777777777777\n\tprint(\u0026#34;\u0026#34;)\n\tprint(\u0026#34;The video aspect ratio is: {:.0f} x {:.0f}\u0026#34;.format(video_width, video_height))\n\tprint(\u0026#34;\u0026#34;)\n\nelse:\n\tprint(\u0026#39;Thanks for playing .... \u0026#39;)\n\tprint(\u0026#39;\u0026#39;)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe output:\u003c/p\u003e","title":"python: 16:9 aspect ratio"},{"content":"I decided to start learning another programming language. Python! Reading up with some docs now.\nBy the way, Python 2.7 is already installed on the recent Mac OS. If you have Mavericks or a later OS, you’re good.\n","permalink":"http://uly.me/posts/learning-python/","summary":"\u003cp\u003eI decided to start learning another programming language. \u003ca href=\"https://www.python.org/doc/\"\u003ePython\u003c/a\u003e! Reading up with some docs now.\u003c/p\u003e\n\u003cp\u003eBy the way, Python 2.7 is already installed on the recent Mac OS. If you have Mavericks or a later OS, you’re good.\u003c/p\u003e","title":"learning python"},{"content":"If you have 2 Macs, you can get to the other one by using Screen Sharing. Just go System Preferences \u0026gt; Sharing \u0026gt; Remote Management. From there you can choose the type of access the remote user will have. You can also limit it to just one user or allow all if you have multiple users.\nTo access the desktop from a remote desktop, just open up a Safari browser and enter in the URL box: vnc://192.168.1.222. Substitute the IP Address of the remote desktop that you want to control remotely. I works on Chrome as well. Wished I did this earlier.\nThere’s no need to purchase any software. They’re already in the OS.\n","permalink":"http://uly.me/posts/remote-desktop-sharing-on-mac/","summary":"\u003cp\u003eIf you have 2 Macs, you can get to the other one by using Screen Sharing. Just go System Preferences \u0026gt; Sharing \u0026gt; Remote Management. From there you can choose the type of access the remote user will have. You can also limit it to just one user or allow all if you have multiple users.\u003c/p\u003e\n\u003cp\u003eTo access the desktop from a remote desktop, just open up a Safari browser and enter in the URL box: vnc://192.168.1.222. Substitute the IP Address of the remote desktop that you want to control remotely. I works on Chrome as well. Wished I did this earlier.\u003c/p\u003e","title":"remote desktop sharing on mac"},{"content":"Amazon Web Services is now offering managed databases in LightSail.\nIf you have a small website or just want to develop something quickly, it might be worth a try creating a simple database in LightSail.\n","permalink":"http://uly.me/posts/lightsail-manage-databases/","summary":"\u003cp\u003eAmazon Web Services is now offering managed databases in LightSail.\u003c/p\u003e\n\u003cp\u003eIf you have a small website or just want to develop something quickly, it might be worth a try creating a simple database in \u003ca href=\"https://aws.amazon.com/blogs/aws/new-managed-databases-for-amazon-lightsail/\"\u003eLightSail\u003c/a\u003e.\u003c/p\u003e","title":"lightsail manage databases"},{"content":"Here’s how to force a rewrite pages to https except for a couple of pages.\nRewriteEngine On RewriteCond %{HTTPS} =off RewriteCond %{REQUEST_URI} !^\\/page1\\/ RewriteCond %{REQUEST_URI} !^\\/page2\\/ RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} \\/page1\\/ [OR] RewriteCond %{REQUEST_URI} \\/page2\\/ RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301] The first rule-set will redirect all pages not /page1/ or /page2/ to the same URL but https://.\nThe second rule will make sure that /page1/ and /page2/ are redirected back to http:// if accessed via https://.\nHere’s the Stackdriver source.\n","permalink":"http://uly.me/posts/force-rewrite-to-https-except-for-page/","summary":"\u003cp\u003eHere’s how to force a rewrite pages to https except for a couple of pages.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eRewriteEngine On\n\nRewriteCond %{HTTPS} =off\nRewriteCond %{REQUEST_URI} !^\\/page1\\/\nRewriteCond %{REQUEST_URI} !^\\/page2\\/\nRewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]    \n\nRewriteCond %{HTTPS} =on\nRewriteCond %{REQUEST_URI} \\/page1\\/ [OR]\nRewriteCond %{REQUEST_URI} \\/page2\\/\nRewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe first rule-set will redirect all pages not /page1/ or /page2/ to the same URL but https://.\u003cbr\u003e\nThe second rule will make sure that /page1/ and /page2/ are redirected back to http:// if accessed via https://.\u003c/p\u003e","title":"force rewrite to https except for page"},{"content":"It’s not always clear how to find out when your SSL certificate is expiring. Openssl should be able to tell you.\n$ openssl x509 -enddate -noout -in certificate.crt ","permalink":"http://uly.me/posts/ssl-expiry/","summary":"\u003cp\u003eIt’s not always clear how to find out when your SSL certificate is expiring. Openssl should be able to tell you.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ openssl x509 -enddate -noout -in certificate.crt\n\u003c/code\u003e\u003c/pre\u003e","title":"ssl expiry"},{"content":"Fresh news from today. IBM buys Redhat for $34 billion.\nHere’s the latest news.\n","permalink":"http://uly.me/posts/ibm-buys-redhat/","summary":"\u003cp\u003eFresh news from today. \u003ca href=\"https://devops.com/ibm-acquires-red-hat-to-create-devops-behemoth/\"\u003eIBM buys Redhat\u003c/a\u003e for $34 billion.\u003c/p\u003e\n\u003cp\u003eHere’s the \u003ca href=\"https://www.google.com/search?q=red+hat\u0026amp;source=lnms\u0026amp;tbm=nws\u0026amp;sa=X\u0026amp;ved=0ahUKEwjZwJ6c9qreAhUFq1kKHYnsBRsQ_AUIDigB\u0026amp;biw=1650\u0026amp;bih=886\"\u003elatest news\u003c/a\u003e.\u003c/p\u003e","title":"ibm buys redhat"},{"content":"Sometimes you just want something simple. There’s no need to configure sendmail every time you build a box.\nInstead, you can install and use ssmtp coupled with a Gmail account.\n","permalink":"http://uly.me/posts/working-with-ssmtp/","summary":"\u003cp\u003eSometimes you just want something simple. There’s no need to configure sendmail every time you build a box.\u003c/p\u003e\n\u003cp\u003eInstead, you can install and use \u003ca href=\"https://www.nixtutor.com/linux/send-mail-with-gmail-and-ssmtp/\"\u003essmtp\u003c/a\u003e coupled with a Gmail account.\u003c/p\u003e","title":"working with ssmtp"},{"content":"If you’re working with LVM, here’s everything you need to know about Logical Volume Manager. Thanks to Centos.\nLVM Documentation.\n","permalink":"http://uly.me/posts/lvm-documentation/","summary":"\u003cp\u003eIf you’re working with LVM, here’s everything you need to know about Logical Volume Manager. Thanks to Centos.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/\"\u003eLVM Documentation\u003c/a\u003e.\u003c/p\u003e","title":"lvm documentation"},{"content":"The standard GSUtil installation recommended by Google wasn’t working. I found an alternative way to install GSUtil using wget to download, and tar to unzip. You might need to add a path if you install it on a non-standard directory.\nAlternative way to install GSUtil on Linux.\n","permalink":"http://uly.me/posts/gsutil-installation/","summary":"\u003cp\u003eThe standard GSUtil installation recommended by Google wasn’t working. I found an alternative way to install GSUtil using wget to download, and tar to unzip. You might need to add a path if you install it on a non-standard directory.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"http://www.aodba.com/install-google-cloud-storage-tool-gsutil-linux-centos/\"\u003eAlternative way to install GSUtil on Linux\u003c/a\u003e.\u003c/p\u003e","title":"gsutil installation"},{"content":"Attaching an EBS volume to an existing instance is quite easy. You can easily add them via the AWS Console. With just a few clicks, you can add an EBS volume in no time. Just click the Create Volume button, indicate the size of the volume, choose which availability zone (preferably the same AZ where your instance resides), and enable encryption if you decide to do so. You can also add an EBS volume from an existing snapshot.\nThere are 2 steps to attaching an EBS volume to an existing instance.\nStep 1. Attach an EBS volume.\nHow to attach an EBS to an existing Instance.\nStep 2. Make the EBS volume available to your instance whether it’s Linux or Windows. This requires SSH access.\nMaking an EBS volume available to Linux.\nMaking an EBS volume available to Windows.\n","permalink":"http://uly.me/posts/attach-an-ebs-volume-to-an-instance/","summary":"\u003cp\u003eAttaching an EBS volume to an existing instance is quite easy. You can easily add them via the AWS Console. With just a few clicks, you can add an EBS volume in no time. Just click the Create Volume button, indicate the size of the volume, choose which availability zone (preferably the same AZ where your instance resides), and enable encryption if you decide to do so. You can also add an EBS volume from an existing snapshot.\u003c/p\u003e","title":"attach an ebs volume to an instance"},{"content":"There are several cases where there will be a need to stop a RDS instance. It could be due to testing, development activity, or simply to save money. Whatever the reasons may be, you’ll need to be aware of the limitations when stopping RDS instances. Here are several cases where it may become an issue.\nYou can’t stop a DB instance that has a Read Replica, or that is a Read Replica. You can’t stop a DB instance that is in a Multi-AZ deployment. You can’t stop a DB instance that uses Microsoft SQL Server Mirroring. You can’t modify a stopped DB instance. You can’t delete an option group that is associated with a stopped DB instance. You can’t delete a DB parameter group that is associated with a stopped DB instance. ","permalink":"http://uly.me/posts/limitations-when-stopping-rds/","summary":"\u003cp\u003eThere are several cases where there will be a need to stop a RDS instance. It could be due to testing, development activity, or simply to save money. Whatever the reasons may be, you’ll need to be aware of the limitations when stopping RDS instances. Here are several cases where it may become an issue.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eYou can’t stop a DB instance that has a Read Replica, or that is a Read Replica.\u003c/li\u003e\n\u003cli\u003eYou can’t stop a DB instance that is in a Multi-AZ deployment.\u003c/li\u003e\n\u003cli\u003eYou can’t stop a DB instance that uses Microsoft SQL Server Mirroring.\u003c/li\u003e\n\u003cli\u003eYou can’t modify a stopped DB instance.\u003c/li\u003e\n\u003cli\u003eYou can’t delete an option group that is associated with a stopped DB instance.\u003c/li\u003e\n\u003cli\u003eYou can’t delete a DB parameter group that is associated with a stopped DB instance.\u003c/li\u003e\n\u003c/ul\u003e","title":"limitations when stopping rds"},{"content":"You can test a network port connection using the “nc” command on Linux and “telnet” on Windows.\nFormat:\n$ nc -zv domain.com port\nC:\u0026gt; telnet domain.com port\n$ nc -zv domain.com 80 Connection to domain.com 80 port [tcp/http] succeeded! C:\\\u0026gt; telnet -zv domain.com 80 Connecting To domain.com...Could not open connection to the host, on port 80: Connect failed For Telnet, if a connection is successful, it returns no message.\n","permalink":"http://uly.me/posts/testing-a-network-port-connection/","summary":"\u003cp\u003eYou can test a network port connection using the “nc” command on Linux and “telnet” on Windows.\u003c/p\u003e\n\u003cp\u003eFormat:\u003cbr\u003e\n$ nc -zv domain.com port\u003cbr\u003e\nC:\u0026gt; telnet domain.com port\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ nc -zv domain.com 80\nConnection to domain.com 80 port [tcp/http] succeeded!\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eC:\\\u0026gt; telnet -zv domain.com 80\nConnecting To domain.com...Could not open connection to the host, on port 80: Connect failed\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eFor Telnet, if a connection is successful, it returns no message.\u003c/p\u003e","title":"testing a network port connection"},{"content":"Here’s a Bash and Perl script for sorting domains and subdomains.\nCommand:\n$ cat filename | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; What’s in the domains.txt?\n$ cat domains.txt domain.com abc.com xyz.com bbb.com mail.gmail.com ess.sfss.org csub.edu gmail.com Result:\n$ cat domains.txt | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; abc.com bbb.com domain.com gmail.com mail.gmail.com xyz.com csub.edu ess.sfss.org You can also pipe the result to another file.\n$ cat filename | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; \u0026gt; output.txt Source.\n","permalink":"http://uly.me/posts/domain-sorter/","summary":"\u003cp\u003eHere’s a Bash and Perl script for sorting domains and subdomains.\u003c/p\u003e\n\u003cp\u003eCommand:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat filename | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWhat’s in the domains.txt?\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat domains.txt\ndomain.com\nabc.com\nxyz.com\nbbb.com\nmail.gmail.com\ness.sfss.org\ncsub.edu\ngmail.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eResult:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat domains.txt | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39;\nabc.com\nbbb.com\ndomain.com\ngmail.com\nmail.gmail.com\nxyz.com\ncsub.edu\ness.sfss.org\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can also pipe the result to another file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ cat filename | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; | sort | perl -ple\u0026#39;$_=join\u0026#34;.\u0026#34;,reverse split/\\./\u0026#39; \u0026gt; output.txt\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e\u003ca href=\"https://www.perlmonks.org/?node_id=299555\"\u003eSource\u003c/a\u003e.\u003c/p\u003e","title":"domain sorter"},{"content":"Here’s a Perl script for removing duplicates in a file.\nperl -ne \u0026#39;print unless $dup{$_}++;\u0026#39; input_file \u0026gt; output_file ","permalink":"http://uly.me/posts/remove-duplicate-in-a-file/","summary":"\u003cp\u003eHere’s a Perl script for removing duplicates in a file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eperl -ne \u0026#39;print unless $dup{$_}++;\u0026#39; input_file \u0026gt; output_file\n\u003c/code\u003e\u003c/pre\u003e","title":"remove duplicate in a file"},{"content":"Here’s the command to create an image from an existing VM instance. You can create an image from disks, snapshots, images or from a cloud storage file. You can use images you built to launch and restore VM instances, as well as create Instance Templates.\ngcloud compute --project=your-project images create your-server --source-disk=your-server --source-disk-zone=us-central1-c ","permalink":"http://uly.me/posts/create-image-on-gcp/","summary":"\u003cp\u003eHere’s the command to create an image from an existing VM instance. You can create an image from disks, snapshots, images or from a cloud storage file. You can use images you built to launch and restore VM instances, as well as create Instance Templates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute --project=your-project images create your-server --source-disk=your-server --source-disk-zone=us-central1-c\n\u003c/code\u003e\u003c/pre\u003e","title":"create image on gcp"},{"content":"Here’s the gcloud command to create a snapshot of your GCP instance.\ngcloud compute disks snapshot your-server \\ --snapshot-names=your-server-180808 \\ --project=your-project \\ --zone=us-central1-c ","permalink":"http://uly.me/posts/take-a-gcp-snapshot/","summary":"\u003cp\u003eHere’s the gcloud command to create a snapshot of your GCP instance.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud compute disks snapshot your-server \\\n--snapshot-names=your-server-180808 \\\n--project=your-project \\\n--zone=us-central1-c\n\u003c/code\u003e\u003c/pre\u003e","title":"take a gcp snapshot"},{"content":"Here are the steps on how to clone a Google Cloud Platform (GCP) repository. This is assuming you already installed Google Cloud SDK.\ngcloud init gcloud source repos clone name_of_repo --project=project_name cd name_of_repo git commit -a -m \u0026#34;your comment\u0026#34; git push -u origin master ","permalink":"http://uly.me/posts/cloning-a-gcp-repo/","summary":"\u003cp\u003eHere are the steps on how to clone a Google Cloud Platform (GCP) repository. This is assuming you already installed Google Cloud SDK.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egcloud init\ngcloud source repos clone name_of_repo --project=project_name\ncd name_of_repo\ngit commit -a -m \u0026#34;your comment\u0026#34;\ngit push -u origin master\n\u003c/code\u003e\u003c/pre\u003e","title":"cloning a gcp repo"},{"content":"When working with version control, sometimes you would like to know what files were committed locally vs what’s on the master origin repository. One way to know the difference is to use the git diff or the git log commands. Here are the commands to check the differences between the local and master origin repositories. Diff is better in my opinion since it actually displays the code changes instead of just displaying the commit ID.\n$ git diff origin/master..HEAD $ git log origin/master..HEAD ","permalink":"http://uly.me/posts/git-diff/","summary":"\u003cp\u003eWhen working with version control, sometimes you would like to know what files were committed locally vs what’s on the master origin repository. One way to know the difference is to use the git diff or the git log commands. Here are the commands to check the differences between the local and master origin repositories. Diff is better in my opinion since it actually displays the code changes instead of just displaying the commit ID.\u003c/p\u003e","title":"git diff"},{"content":"If you need to special characters encoded in a URL, these sites really come handy. Why is there a need to encode? URLs accepts only alphanumeric characters and a limited number of special characters. For example, : and / are common characters you’ll find in URLs. Meanwhile spaces are not allowed, but instead are represented as %20 when encoded. There are other special characters that will need to be encoded.\nHere are a couple of sites to help you encode:\nhttps://www.urlencoder.org/\nhttps://www.url-encode-decode.com/\n","permalink":"http://uly.me/posts/url-encode/","summary":"\u003cp\u003eIf you need to special characters encoded in a URL, these sites really come handy. Why is there a need to encode? URLs accepts only alphanumeric characters and a limited number of special characters. For example, : and / are common characters you’ll find in URLs. Meanwhile spaces are not allowed, but instead are represented as %20 when encoded. There are other special characters that will need to be encoded.\u003c/p\u003e","title":"url encode"},{"content":"If you have multiple VPCs located in geographically diverse regions, you can connect them together using a new service called Transit VPCs. It’s a logically isolated VPC which can act as a bridge for launching and transferring data between regions. It can work as global transit center between other VPCs within your organization. Learn more by reading about it from AWS announcement.\n","permalink":"http://uly.me/posts/aws-transit-vpcs/","summary":"\u003cp\u003eIf you have multiple VPCs located in geographically diverse regions, you can connect them together using a new service called Transit VPCs. It’s a logically isolated VPC which can act as a bridge for launching and transferring data between regions. It can work as global transit center between other VPCs within your organization. Learn more by reading about it from AWS \u003ca href=\"https://aws.amazon.com/blogs/aws/aws-solution-transit-vpc/\"\u003eannouncement\u003c/a\u003e.\u003c/p\u003e","title":"aws transit vpcs"},{"content":"How about running GKE (Google Kubernetes Engine) on your own data center. Why would anyone do that while everyone else is moving to the cloud. Well, Google is creating a stepping stone to move enterprises to the cloud. What a better way than to build a bridge that will shorten the gap. GKE On-Prem service will include access to all GKE cloud features, including the ability to register, manage clusters and monitoring via a service called Stackdriver. GKE On-Prem will include a direct line to the GCP Marketplace, which has support for Kubernetes-based applications.\n","permalink":"http://uly.me/posts/gke-on-prem/","summary":"\u003cp\u003eHow about running GKE (Google Kubernetes Engine) on your own data center. Why would anyone do that while everyone else is moving to the cloud. Well, Google is creating a stepping stone to move enterprises to the cloud. What a better way than to build a bridge that will shorten the gap. \u003ca href=\"https://cloud.google.com/gke-on-prem/\"\u003eGKE On-Prem\u003c/a\u003e service will include access to all GKE cloud features, including the ability to register, manage clusters and monitoring via a service called Stackdriver. GKE On-Prem will include a direct line to the GCP Marketplace, which has support for Kubernetes-based applications.\u003c/p\u003e","title":"gke on-prem"},{"content":"CodeCommit is a version control system hosted in AWS that you can use privately to store and manage your source code, documents or binary files. You can get free (as in beer) unlimited repositories, if you have less than 5 users, and if your storage is less than 50 GB-month, and you have less than 10,000 git requests per month. If you have more than 5 users, it’s $1 a month per user. Still not bad. Here’s CodeCommit pricing.\nCreate a repository in CodeCommit via the Console or the CLI.\naws codecommit create-repository --repository-name myrepo --repository-description \u0026#34;My repository\u0026#34; Create in another region.\naws codecommit create-repository --region us-west-2 --repository-name myrepo --repository-description \u0026#34;My repository\u0026#34; Enjoy.\n","permalink":"http://uly.me/posts/create-a-repository-in-codecommit/","summary":"\u003cp\u003e\u003ca href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\"\u003eCodeCommit\u003c/a\u003e is a version control system hosted in AWS that you can use privately to store and manage your source code, documents or binary files. You can get free (as in beer) unlimited repositories, if you have less than 5 users, and if your storage is less than 50 GB-month, and you have less than 10,000 git requests per month. If you have more than 5 users, it’s $1 a month per user. Still not bad. Here’s CodeCommit \u003ca href=\"https://aws.amazon.com/codecommit/pricing/\"\u003epricing\u003c/a\u003e.\u003c/p\u003e","title":"create a repository in codecommit"},{"content":"Although you can access CodeCommit from the AWS Console, the most efficient way to access it, is via SSH. Assuming you already have an IAM user, as well as Git installed on your local machine, it’s time to setup a SSH connection to CodeCommit by performing the following commands.\nGenerate a RSA key pair Copy the public key to the clipboard. Upload the SSH public key to the AWS IAM Console. You’ll receive a SSH Key ID. Create a config file chmod 600 config Test connection Clone repo To get more details regarding SSH access to CodeCommit, visit the AWS docs.\n","permalink":"http://uly.me/posts/ssh-to-codecommit/","summary":"\u003cp\u003eAlthough you can access CodeCommit from the AWS Console, the most efficient way to access it, is via SSH. Assuming you already have an IAM user, as well as Git installed on your local machine, it’s time to setup a SSH connection to CodeCommit by performing the following commands.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eGenerate a RSA key pair\u003c/li\u003e\n\u003cli\u003eCopy the public key to the clipboard.\u003c/li\u003e\n\u003cli\u003eUpload the SSH public key to the AWS IAM Console.\u003c/li\u003e\n\u003cli\u003eYou’ll receive a SSH Key ID.\u003c/li\u003e\n\u003cli\u003eCreate a config file\u003c/li\u003e\n\u003cli\u003echmod 600 config\u003c/li\u003e\n\u003cli\u003eTest connection\u003c/li\u003e\n\u003cli\u003eClone repo\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eTo get more details regarding SSH access to CodeCommit, visit the AWS \u003ca href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html\"\u003edocs\u003c/a\u003e.\u003c/p\u003e","title":"ssh to codecommit"},{"content":"AWS has a service that turns text into speech called Polly. You can choose what type of voice, language and gender. AWS recently added a simple form, for an easy text to speech conversion and download. The form is limited to 3000 characters or less. The converted file is a MP3 format. For larger texts, the converted audio file will be stored in a S3 bucket for later retrieval. Using Amazon Polly along with Translate will be a cool experiment. AWS Translate is a natural language translation service.\n","permalink":"http://uly.me/posts/amazon-polly/","summary":"\u003cp\u003eAWS has a service that turns text into speech called \u003ca href=\"https://aws.amazon.com/polly/\"\u003ePolly\u003c/a\u003e. You can choose what type of voice, language and gender. AWS recently added a simple form, for an easy text to speech conversion and download. The form is limited to 3000 characters or less. The converted file is a MP3 format. For larger texts, the converted audio file will be stored in a S3 bucket for later retrieval. Using Amazon Polly along with Translate will be a cool experiment. AWS Translate is a natural language translation service.\u003c/p\u003e","title":"amazon polly"},{"content":"Amazon tends to be dipping in their toes into everything. Remember Whole Foods. If that wasn’t enough, Amazon started competing with drugstores six months ago when it acquired Pillpack. Shares of Walgreens and CVS went down 9 percent as a result. Now, Amazon is saying that they want to compete with network companies like Cisco, Juniper and Arista. Potentially, Amazon can sell networking data switches at deep discounts ranging anywhere from 50% up to 80% discount. That’s bad news for some networking companies.\n","permalink":"http://uly.me/posts/amazon-selling-routers/","summary":"\u003cp\u003eAmazon tends to be dipping in their toes into everything. Remember Whole Foods. If that wasn’t enough, Amazon started competing with drugstores six months ago when it acquired Pillpack. Shares of Walgreens and CVS went down 9 percent as a result. Now, Amazon is saying that they want to compete with network companies like Cisco, Juniper and Arista. Potentially, Amazon can sell networking data switches at deep discounts ranging anywhere from 50% up to 80% discount. That’s bad news for some networking companies.\u003c/p\u003e","title":"amazon selling routers"},{"content":"RDS is a managed service by AWS. Patching is performed infrequently. Sometimes, it takes a few months. AWS performs these updates during the maintenance period. If no maintenance period was specified during DB creation, it will be assigned a default period. When patching is performed, AWS may need to stop and reboot your RDS instance right after patches are applied. To avoid potential downtime, make sure your RDS instances are configured in a Multi-AZ environment. Patching will be applied on each RDS instance separately, therefore avoiding downtime for your application.\n","permalink":"http://uly.me/posts/aws-rds-patching/","summary":"\u003cp\u003eRDS is a managed service by AWS. Patching is performed infrequently. Sometimes, it takes a few months. AWS performs these updates during the maintenance period. If no maintenance period was specified during DB creation, it will be assigned a default period. When patching is performed, AWS may need to stop and reboot your RDS instance right after patches are applied. To avoid potential downtime, make sure your RDS instances are configured in a Multi-AZ environment. Patching will be applied on each RDS instance separately, therefore avoiding downtime for your application.\u003c/p\u003e","title":"aws rds patching"},{"content":"Every once in a while, you may need to do some cleanup and perform maintenance in AWS. One area where you can do some cleanup is the security groups. To check if security groups are in-used, is by way of the AWS Console. You can filter the security group via Instances. But that is not going to be enough. Security groups are also used in RDS as well as in load balancers. Overall, you have to be extra careful not to delete a security group that’s in-use. Fortunately, AWS will prompt you if you try to delete a security group that is still in-use. It’s a safety feature that can potentially save you from headaches.\n","permalink":"http://uly.me/posts/deleting-aws-security-groups/","summary":"\u003cp\u003eEvery once in a while, you may need to do some cleanup and perform maintenance in AWS. One area where you can do some cleanup is the security groups. To check if security groups are in-used, is by way of the AWS Console. You can filter the security group via Instances. But that is not going to be enough. Security groups are also used in RDS as well as in load balancers. Overall, you have to be extra careful not to delete a security group that’s in-use. Fortunately, AWS will prompt you if you try to delete a security group that is still in-use. It’s a safety feature that can potentially save you from headaches.\u003c/p\u003e","title":"deleting aws security groups"},{"content":"Ubuntu 16.04 has a feature called Snap packaging. Snaps are containerized software packages that are simple to create, and easy to install on all major Linux systems. Snap packages are self-contained and separate from your system files. There are no complex dependencies or interference. The packages are safe to run since snap packages and their data are separate from your system files. Updates are automatic and only download what has changed. You can revert to a previous version at any time. Any updates can also be reversed.\nTo install snap in Ubuntu, run this command from the Terminal.\n$ sudo apt install snapd To install snap packages, run the following:\n$ sudo snap install packagename To get a list of packages installed on your system:\n$ snap list To automatically update the packages, just run the following:\n$ sudo snap refresh packagename To revert changes or remove a package, perform the following:\n$ sudo snap revert packagename $ sudo snap remove packagename Super easy to use.\n","permalink":"http://uly.me/posts/snap-packages/","summary":"\u003cp\u003eUbuntu 16.04 has a feature called Snap packaging. Snaps are containerized software packages that are simple to create, and easy to install on all major Linux systems. Snap packages are self-contained and separate from your system files. There are no complex dependencies or interference. The packages are safe to run since snap packages and their data are separate from your system files. Updates are automatic and only download what has changed. You can revert to a previous version at any time. Any updates can also be reversed.\u003c/p\u003e","title":"snap packages"},{"content":"This is what happens when AI takes over billing issues. The element of leniency, fairness and humanity goes out the window. Such is the case when servers were automatically shut down by Google Cloud due to a billing issue. Services were shut down because of a credit card problem. The email sent by Google to the company even threatened to delete the project if the billing issue is not resolved in three days. Read article.\n","permalink":"http://uly.me/posts/gcp-billing-issues/","summary":"\u003cp\u003eThis is what happens when AI takes over billing issues. The element of leniency, fairness and humanity goes out the window. Such is the case when servers were automatically shut down by Google Cloud due to a billing issue. Services were shut down because of a credit card problem. The email sent by Google to the company even threatened to delete the project if the billing issue is not resolved in three days. Read \u003ca href=\"https://medium.com/@serverpunch/why-you-should-not-use-google-cloud-75ea2aec00de\"\u003earticle\u003c/a\u003e.\u003c/p\u003e","title":"gcp billing issues"},{"content":"Gitlab is moving from Microsoft Azure to Google Cloud Platform mainly due to its integration with Google Kubernetes Engine. Gitlab believes Kubernetes is the future and makes their platform to massively scale as it grows. The move is scheduled on July 28. Gitlab plans to use their Geo product for the migration of Gitlab.com. For more, read the article.\n","permalink":"http://uly.me/posts/gitlab-moves-to-gcp/","summary":"\u003cp\u003eGitlab is moving from Microsoft Azure to Google Cloud Platform mainly due to its integration with Google Kubernetes Engine. Gitlab believes Kubernetes is the future and makes their platform to massively scale as it grows. The move is scheduled on July 28. Gitlab plans to use their Geo product for the migration of Gitlab.com. For more, read the \u003ca href=\"https://about.gitlab.com/2018/06/25/moving-to-gcp/\"\u003earticle\u003c/a\u003e.\u003c/p\u003e","title":"gitlab moves to gcp"},{"content":"How to failover a website without actually doing a failover? It’s actually easier than you think. The key is to trick your computer that it’s pointing to a failover website. You can easily do this by editing your hosts file and adding a DNS entry. In both Linux and MacOS, you can edit the /etc/hosts file and add the failover site like the following below.\n# /etc/hosts # failover site # xxx.xxx.xxx.xxx yourdomain.com xxx.xxx.xxx.xxx is the IP address of your failover site.\nIf you need to test the failover site, just uncomment the IP address.\nReplace a comment if you’re done testing.\n","permalink":"http://uly.me/posts/failover-test/","summary":"\u003cp\u003eHow to failover a website without actually doing a failover? It’s actually easier than you think. The key is to trick your computer that it’s pointing to a failover website. You can easily do this by editing your hosts file and adding a DNS entry. In both Linux and MacOS, you can edit the /etc/hosts file and add the failover site like the following below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# /etc/hosts\n# failover site\n# xxx.xxx.xxx.xxx   yourdomain.com\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003exxx.xxx.xxx.xxx is the IP address of your failover site.\u003cbr\u003e\nIf you need to test the failover site, just uncomment the IP address.\u003cbr\u003e\nReplace a comment if you’re done testing.\u003c/p\u003e","title":"failover test"},{"content":"It took about 2,000 Digital Ocean droplets, 13 minutes of compute time, and about $7 dollars worth of cloud resources, to break the Enigma code which were used by the Nazis in World War 2. The code was written in Python and ran as minions. The minions did the 99% of the grunt work. The droplets ran 41 million password combinations per second. What took years for Allied forces to break the code can now be decoded in just 13 minutes. Read the article.\n","permalink":"http://uly.me/posts/the-enigma-machine/","summary":"\u003cp\u003eIt took about 2,000 Digital Ocean droplets, 13 minutes of compute time, and about $7 dollars worth of cloud resources, to break the Enigma code which were used by the Nazis in World War 2. The code was written in Python and ran as minions. The minions did the 99% of the grunt work. The droplets ran 41 million password combinations per second. What took years for Allied forces to break the code can now be decoded in just 13 minutes. Read the \u003ca href=\"https://blog.digitalocean.com/how-2000-droplets-broke-the-enigma-code-in-13-minutes/\"\u003earticle\u003c/a\u003e.\u003c/p\u003e","title":"the enigma machine"},{"content":"How to restrict a S3 bucket to certain group of users. Edit the bucket policy and add the following.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Id\u0026#34;: \u0026#34;bucketPolicy\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;NotPrincipal\u0026#34;: { \u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxx:user/username\u0026#34;, \u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxx:root\u0026#34;, }, \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;, \u0026#34;Resource\u0026#34;: [ \u0026#34;arn:aws:s3:::bucketname\u0026#34;, \u0026#34;arn:aws:s3:::bucketname/*\u0026#34; ] } ] } Replace xxxxxxxxxx with your AWS account number.\nReplace bucketname with your S3 bucket.\nReplace username with your IAM user.\nRoot is your AWS root account.\nAccounts must be valid.\n","permalink":"http://uly.me/posts/restrict-bucket-to-users/","summary":"\u003cp\u003eHow to restrict a S3 bucket to certain group of users. Edit the bucket policy and add the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e{\n    \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;,\n    \u0026#34;Id\u0026#34;: \u0026#34;bucketPolicy\u0026#34;,\n    \u0026#34;Statement\u0026#34;: [\n        {\n            \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;,\n            \u0026#34;NotPrincipal\u0026#34;: {\n                \u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxx:user/username\u0026#34;,\n                \u0026#34;AWS\u0026#34;: \u0026#34;arn:aws:iam::xxxxxxxxxx:root\u0026#34;,\n            },\n            \u0026#34;Action\u0026#34;: \u0026#34;s3:*\u0026#34;,\n            \u0026#34;Resource\u0026#34;: [\n                \u0026#34;arn:aws:s3:::bucketname\u0026#34;,\n                \u0026#34;arn:aws:s3:::bucketname/*\u0026#34;\n            ]\n        }\n    ]\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReplace xxxxxxxxxx with your AWS account number.\u003cbr\u003e\nReplace bucketname with your S3 bucket.\u003cbr\u003e\nReplace username with your IAM user.\u003cbr\u003e\nRoot is your AWS root account.\u003cbr\u003e\nAccounts must be valid.\u003c/p\u003e","title":"restrict bucket to users"},{"content":"I recently moved my website hosting from Linode to AWS LightSail. Part of the move was working with Route 53 for DNS, as well as setting up my domain’s email, e.g. the MX record. I’m using ProtonMail for email and they require that I add multiple TXT records. Part of the problem is Route 53 will not allow duplicate TXT records. After a few searches, I learned that you can enter in multiple values in the TXT record as long as you place them on multiple lines. That solved the problem for me.\n","permalink":"http://uly.me/posts/multiple-txt-dns-records/","summary":"\u003cp\u003eI recently moved my website hosting from Linode to AWS LightSail. Part of the move was working with Route 53 for DNS, as well as setting up my domain’s email, e.g. the MX record. I’m using ProtonMail for email and they require that I add multiple TXT records. Part of the problem is Route 53 will not allow duplicate TXT records. After a few searches, I learned that you can enter in multiple values in the TXT record as long as you place them on multiple lines. That solved the problem for me.\u003c/p\u003e","title":"multiple txt dns records"},{"content":"Certbot is an easy-to-use automatic client that fetches and deploys SSL/TLS certificates for your webserver. Certbot was developed by EFF and others as a client for Let’s Encrypt and was previously known as “the official Let’s Encrypt client” or “the Let’s Encrypt Python client.” Certbot will also work with any other CAs that support the ACME protocol.\nJust choose your webserver, e.g. Apache, Nginx or IIS, as well as your operating system. Here’s the instruction for Ubuntu 16.04 LTS.\n$ sudo apt-get update $ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install python-certbot-apache To install the certificate\nsudo certbot --apache To renew certificate\n$ sudo certbot renew ","permalink":"http://uly.me/posts/certbot/","summary":"\u003cp\u003eCertbot is an easy-to-use automatic client that fetches and deploys SSL/TLS certificates for your webserver. Certbot was developed by EFF and others as a client for Let’s Encrypt and was previously known as “the official Let’s Encrypt client” or “the Let’s Encrypt Python client.” Certbot will also work with any other CAs that support the ACME protocol.\u003c/p\u003e\n\u003cp\u003eJust choose your webserver, e.g. Apache, Nginx or IIS, as well as your operating system. Here’s the instruction for Ubuntu 16.04 LTS.\u003c/p\u003e","title":"certbot"},{"content":"Microsoft acquired Github today for $7.5 billion. Github was founded in 2008. It stores and manages code in repositories using Git, a distributed version control software developed by Linus Torvalds. It has 28 million users and 85 million projects. Github public repositories are free. Private repositories start at $7 per month for developers. For teams, it starts at $9 per user/month and up to $21 per user/month. If you like to run your own Git repository, check out GitLab. Just install it on a Linux server.\n","permalink":"http://uly.me/posts/github-acquired-by-microsoft/","summary":"\u003cp\u003eMicrosoft acquired Github today for $7.5 billion. \u003ca href=\"http://github.com\"\u003eGithub\u003c/a\u003e was founded in 2008. It stores and manages code in repositories using Git, a distributed version control software developed by Linus Torvalds. It has 28 million users and 85 million projects. Github public repositories are free. Private repositories start at $7 per month for developers. For teams, it starts at $9 per user/month and up to $21 per user/month. If you like to run your own Git repository, check out \u003ca href=\"https://about.gitlab.com/\"\u003eGitLab\u003c/a\u003e. Just install it on a Linux server.\u003c/p\u003e","title":"github acquired by microsoft"},{"content":"To unlock a locked account, you need to run pam_tally2, which is a tool that keeps tracked of failed logins. Pam_tally2 is installed on most Linux systems. To unlock an account, just run the following commands:\npam_tally2 --user=ulysses --reset Have the user login again. It should work.\nSome systems might be using an older pam_tally. The command for that will be.\npam_tally --user=ulysses --reset=0 ","permalink":"http://uly.me/posts/reset-pam_tally2/","summary":"\u003cp\u003eTo unlock a locked account, you need to run pam_tally2, which is a tool that keeps tracked of failed logins. Pam_tally2 is installed on most Linux systems. To unlock an account, just run the following commands:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epam_tally2 --user=ulysses --reset\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHave the user login again. It should work.\u003c/p\u003e\n\u003cp\u003eSome systems might be using an older pam_tally. The command for that will be.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003epam_tally --user=ulysses --reset=0\n\u003c/code\u003e\u003c/pre\u003e","title":"reset pam_tally2"},{"content":"I picked up a free SSL certificate from SSLForFree.com. It’s good for 90 days. Not a bad deal. Wished it was longer. Without further ado, the site is now running on https! Check out the secure lock next to my domain! I’ve added a redirect to force visitors to use https instead. It’s a good exercise on how to convert any site from http to https. I learned how to configure Apache and how to use certificates. Anyways, plan to do them for my other websites.\n","permalink":"http://uly.me/posts/free-ssl-certificates/","summary":"\u003cp\u003eI picked up a free SSL certificate from SSLForFree.com. It’s good for 90 days. Not a bad deal. Wished it was longer. Without further ado, the site is now running on https! Check out the secure lock next to my domain! I’ve added a redirect to force visitors to use https instead. It’s a good exercise on how to convert any site from http to https. I learned how to configure Apache and how to use certificates. Anyways, plan to do them for my other websites.\u003c/p\u003e","title":"free ssl certificates"},{"content":"Occasionally, I’m asked to provide a random list of characters that will be used as a salt for hashing a password or some data of some sort. The primary function of salts are to create a random one-way function typically used to fight against dictionary or rainbow table attacks. Here’s a neat command that you can generate from the Bash shell. It will generate a 32 random character string.\n$ tr -c -d \u0026#39;0123456789abcdefghijklmnopqrstuvwxyz\u0026#39; /urandom | dd bs=32 count=1 2\u0026gt;/dev/null;echo The result is: ynhgunq3ppnirhhp3vxpmvdw5b2uuc2f\n","permalink":"http://uly.me/posts/random-salt/","summary":"\u003cp\u003eOccasionally, I’m asked to provide a random list of characters that will be used as a salt for hashing a password or some data of some sort. The primary function of salts are to create a random one-way function typically used to fight against dictionary or rainbow table attacks. Here’s a neat command that you can generate from the Bash shell. It will generate a 32 random character string.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ tr -c -d \u0026#39;0123456789abcdefghijklmnopqrstuvwxyz\u0026#39; /urandom | dd bs=32 count=1 2\u0026gt;/dev/null;echo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe result is: ynhgunq3ppnirhhp3vxpmvdw5b2uuc2f\u003c/p\u003e","title":"random salt"},{"content":"I had issues with cron. The jobs were not running, so it seemed. It turned out that they were in fact running. The jobs were firing off based on schedule. The problem was, cron didn’t have the correct path to the commands. I realized this when I looked at a couple of log files, in /var/mail and /var/log/syslog to look for clues. The fix was to include the path in cron.\nEdit cron.\ncrontab -e Add the shell and path at the top of the file.\nSHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ","permalink":"http://uly.me/posts/cronjob-not-running/","summary":"\u003cp\u003eI had issues with cron. The jobs were not running, so it seemed. It turned out that they were in fact running. The jobs were firing off based on schedule. The problem was, cron didn’t have the correct path to the commands. I realized this when I looked at a couple of log files, in /var/mail and /var/log/syslog to look for clues. The fix was to include the path in cron.\u003c/p\u003e","title":"cronjob not running"},{"content":"If you’re asked to change the password expiry or password inactivity for a Linux user, the following command will fix it. It’s ideal in situations where you don’t want the password to expire or you don’t want a user to go inactive. It’s also useful if you want a user to be running automated scripts. Here’s the chage command and its available options.\n# chage -m 0 -M 99999 -I -1 -E -1 johndoe -m 0 will set the minimum number of days between password change to 0\n-M 99999 will set the maximum number of days between password change to 99999\n-I -1 (number minus one) will set the “Password inactive” to never\n-E -1 (number minus one) will set “Account expires” to never.\nTo validate a user options, run the following:\n# chage --list johndoe Last password change : Apr 4, 2018 Password expires : never Password inactive : never Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 99999 Number of days of warning before password expires : 7 ","permalink":"http://uly.me/posts/password-expiry/","summary":"\u003cp\u003eIf you’re asked to change the password expiry or password inactivity for a Linux user, the following command will fix it. It’s ideal in situations where you don’t want the password to expire or you don’t want a user to go inactive. It’s also useful if you want a user to be running automated scripts. Here’s the chage command and its available options.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# chage -m 0 -M 99999 -I -1 -E -1 johndoe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003e-m 0 will set the minimum number of days between password change to 0\u003cbr\u003e\n-M 99999 will set the maximum number of days between password change to 99999\u003cbr\u003e\n-I -1 (number minus one) will set the “Password inactive” to never\u003cbr\u003e\n-E -1 (number minus one) will set “Account expires” to never.\u003c/p\u003e","title":"password expiry"},{"content":"Here’s the proper way to host multiple websites (domains) on single host with a single IP address. Technically, you can have multiple Apache configuration files that you can enable within Apache, but you can easily simplify and combine them into a single Apache configuration file. You can separate each domain by creating multiple virtualhost sections as shown in the example below.\n\u0026lt;virtualhost\u0026gt; DocumentRoot \u0026#34;/www/example1\u0026#34; ServerName www.example.com # Other directives here \u0026lt;/virtualhost\u0026gt; \u0026lt;virtualhost\u0026gt; DocumentRoot \u0026#34;/www/example2\u0026#34; ServerName www.example.org # Other directives here \u0026lt;/virtualhost\u0026gt; If you’re interested, read up on Apache’s website about virtual hosts.\n","permalink":"http://uly.me/posts/multiple-virtualhosts/","summary":"\u003cp\u003eHere’s the proper way to host multiple websites (domains) on single host with a single IP address. Technically, you can have multiple Apache configuration files that you can enable within Apache, but you can easily simplify and combine them into a single Apache configuration file. You can separate each domain by creating multiple virtualhost sections as shown in the example below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;virtualhost\u0026gt;\n    DocumentRoot \u0026#34;/www/example1\u0026#34;\n    ServerName www.example.com\n    # Other directives here\n\u0026lt;/virtualhost\u0026gt;\n\n\u0026lt;virtualhost\u0026gt;\n    DocumentRoot \u0026#34;/www/example2\u0026#34;\n    ServerName www.example.org\n    # Other directives here\n\u0026lt;/virtualhost\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you’re interested, read up on Apache’s website about \u003ca href=\"https://httpd.apache.org/docs/2.4/vhosts/examples.html\"\u003evirtual hosts\u003c/a\u003e.\u003c/p\u003e","title":"multiple virtualhosts"},{"content":"As a Cloud Engineer, I get a few requests to extend an EBS volume. For example, the application owner wants to double the size of the /data volume from 10GB to 20GB. The nice part about extending an EBS volume is that it can all be done on the fly without bringing down the instance. Adding more storage can be done via the AWS Console. Check out this article from AWS about modifying an EBS volume. But that’s just the first part. Although you’ve doubled the disk space, you still have to let the system know it now has doubled it’s disk space. The second part is to grow or resize the file system. Here’s the other article on how to extend a file system.\n# expand growpart /dev/xvdb # for ext2, ext3 and ext4 resize2fs /dev/xvdb # for xfs xfs_growfs -d /dev/xvdb ","permalink":"http://uly.me/posts/extend-an-ebs-volume/","summary":"\u003cp\u003eAs a Cloud Engineer, I get a few requests to extend an EBS volume. For example, the application owner wants to double the size of the /data volume from 10GB to 20GB. The nice part about extending an EBS volume is that it can all be done on the fly without bringing down the instance. Adding more storage can be done via the AWS Console. Check out this \u003ca href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/console-modify.html\"\u003earticle\u003c/a\u003e from AWS about modifying an EBS volume. But that’s just the first part. Although you’ve doubled the disk space, you still have to let the system know it now has doubled it’s disk space. The second part is to grow or resize the file system. Here’s the other \u003ca href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html\"\u003earticle\u003c/a\u003e on how to extend a file system.\u003c/p\u003e","title":"extend an ebs volume"},{"content":"JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. YAML is a flexible, human readable file format that is ideal for storing object trees. YAML stands for “YAML Ain’t Markup Language”. It is easier to read than JSON, and can contain richer meta data. If you would like to switch formats, for example from JSON to YAML or vice versa, there are numerous website out there that can convert your code from one format to another. Check out this json2yaml converter.\n","permalink":"http://uly.me/posts/convert-json-to-yaml/","summary":"\u003cp\u003eJSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. YAML is a flexible, human readable file format that is ideal for storing object trees. YAML stands for “YAML Ain’t Markup Language”. It is easier to read than JSON, and can contain richer meta data. If you would like to switch formats, for example from JSON to YAML or vice versa, there are numerous website out there that can convert your code from one format to another. Check out this \u003ca href=\"https://www.json2yaml.com/\"\u003ejson2yaml\u003c/a\u003e converter.\u003c/p\u003e","title":"convert json to yaml"},{"content":"Some Linux distributions don’t turn on cron automatically for users. To give certain users access to cron, add them to cron.allow.\nEdit cron.allow.\n$ sudo nano /etc/cron.allow Add one user per line.\njohndoe Save and close.\n","permalink":"http://uly.me/posts/cron-allow/","summary":"\u003cp\u003eSome Linux distributions don’t turn on cron automatically for users. To give certain users access to cron, add them to cron.allow.\u003c/p\u003e\n\u003cp\u003eEdit cron.allow.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo nano /etc/cron.allow\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd one user per line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ejohndoe\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSave and close.\u003c/p\u003e","title":"cron allow"},{"content":"If you work with vi, nano or any other command line editor, deleting a line is a fairly easy thing to do. If the file is too large, deleting the content line by line is not fun. There’s a better way to empty a file without deleting it. Here are several ways.\n$ \u0026gt; filename $ truncate -s 0 filename $ echo \u0026#34;\u0026#34; \u0026gt; filename ","permalink":"http://uly.me/posts/empty-a-file/","summary":"\u003cp\u003eIf you work with vi, nano or any other command line editor, deleting a line is a fairly easy thing to do. If the file is too large, deleting the content line by line is not fun. There’s a better way to empty a file without deleting it. Here are several ways.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ \u0026gt; filename\n$ truncate -s 0 filename\n$ echo \u0026#34;\u0026#34; \u0026gt; filename\n\u003c/code\u003e\u003c/pre\u003e","title":"empty a file"},{"content":"The /etc/sudoers file gives users the ability to run commands that are typically reserved for administrators. The commands require a password or no password, depending on how you set them up in the sudoers file. The sudoers file can’t be edited using any text editor. You have to use visudo.\n$ visudo Add groups to access sudo.\n# Allow users in techgroup to run all commands %techgroup ALL=(ALL) NOPASSWD: ALL # Allow users in techgroup without a password %techgroup ALL=(ALL) NOPASSWD: ALL # Allow users in techgroup to shutdown the system %techgroup localhost=/sbin/shutdown -h now #includedir /etc/sudoers.d Typically you have to add your groups in the sudoers file. Notice the last line. Sudoers will include config files found under the /etc/sudoers.d directory. In certain circumstances, there are others pieces of software such as compliance software CFEngine that writes over changes in the sudoers file. If this is the case, then you have to add your groups in a file inside the /etc/sudoers.d directory.\n","permalink":"http://uly.me/posts/sudoers/","summary":"\u003cp\u003eThe /etc/sudoers file gives users the ability to run commands that are typically reserved for administrators. The commands require a password or no password, depending on how you set them up in the sudoers file. The sudoers file can’t be edited using any text editor. You have to use visudo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ visudo\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd groups to access sudo.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Allow users in techgroup to run all commands\n%techgroup   ALL=(ALL)   NOPASSWD: ALL\n# Allow users in techgroup without a password\n%techgroup   ALL=(ALL)   NOPASSWD: ALL\n# Allow users in techgroup to shutdown the system\n%techgroup   localhost=/sbin/shutdown -h now\n#includedir /etc/sudoers.d\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTypically you have to add your groups in the sudoers file. Notice the last line. Sudoers will include config files found under the /etc/sudoers.d directory. In certain circumstances, there are others pieces of software such as compliance software CFEngine that writes over changes in the sudoers file. If this is the case, then you have to add your groups in a file inside the /etc/sudoers.d directory.\u003c/p\u003e","title":"sudoers"},{"content":"When setting up your cloud infrastructure, you can check if your instances have access to the database by performing this command.\n$ nc -zv 10.0.0.45 3306 $ nc -zv domain.com 3306 $ nc -zv endpoint.amazonaws.com 3306 If connection has succeeded, you’ll get a message like this in Linux and MacOS …\nConnection to endpoint.amazonaws.com 3306 port [tcp/mysql] succeeded! On Windows, you can use Telnet to test your DB connection.\nC:\\\u0026gt;telnet endpoint.amazonaws.com 3306 If connection has succeeded, the result is “no message.” If there’s a problem, you’ll get this ….\nConnecting To endpoint.amazonaws.com...Could not open connection to the host, on port 3306: Connect failed ","permalink":"http://uly.me/posts/check-db-connection-on-aws/","summary":"\u003cp\u003eWhen setting up your cloud infrastructure, you can check if your instances have access to the database by performing this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ nc -zv 10.0.0.45 3306\n$ nc -zv domain.com 3306\n$ nc -zv endpoint.amazonaws.com 3306\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf connection has succeeded, you’ll get a message like this in Linux and MacOS …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eConnection to endpoint.amazonaws.com 3306 port [tcp/mysql] succeeded!\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOn Windows, you can use Telnet to test your DB connection.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eC:\\\u0026gt;telnet endpoint.amazonaws.com 3306\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf connection has succeeded, the result is “no message.” If there’s a problem, you’ll get this ….\u003c/p\u003e","title":"check db connection on aws"},{"content":"If you find yourself commenting out multiple lines in BASH, there is a simple way of commenting them out using the HERE DOCUMENT feature. Typically you use the hash (#) tag to comment out each line, but that can get tiresome especially if have hundreds of lines. Here’s a better option. Use the HERE DOCUMENT feature in BASH. Anything in between the HERE DOCUMENT will be ignored by BASH and treated as comments.\nIf you need to reverse them, then just do the following. In this way, you only have to touch 2 lines instead of multiple lines.\n","permalink":"http://uly.me/posts/comment-multiple-lines-in-bash/","summary":"\u003cp\u003eIf you find yourself commenting out multiple lines in BASH, there is a simple way of commenting them out using the HERE DOCUMENT feature. Typically you use the hash (#) tag to comment out each line, but that can get tiresome especially if have hundreds of lines. Here’s a better option. Use the HERE DOCUMENT feature in BASH. Anything in between the HERE DOCUMENT will be ignored by BASH and treated as comments.\u003c/p\u003e","title":"comment multiple lines in bash"},{"content":"Laravel is a MVC framework for PHP. The latest Laravel release is version 5.5 in July 2017. Laravel 5.5 requires PHP 7 and higher. The latest stable release of PHP is 7.1. The following instructions walks you through how to install Laravel 5.5 on Ubuntu 16.04 LTS.\nUpdate\nsudo apt-get update sudo apt-get upgrade Install Apache\n# install apache sudo apt-get install apache2 # start apache sudo systemctl start apache2 # enable on startup sudo systemctl enable apache2 Install PHP 7\nsudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt install php7.1 php7.1-xml php7.1-mbstring php7.1-mysql php7.1-json php7.1-curl sudo apt install php7.1-cli php7.1-common php7.1-mcrypt php7.1-gd libapache2-mod-php7.1 php7.1-zip Install Composer\ncurl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/bin/composer Change Permissions\n# add new user to www-data group sudo useradd -g www-data ubuntu # add existing user to www-data group sudo usermod -a -G www-data ubuntu # change ownership sudo chown -R ubuntu:www-data /var/www # change permissions sudo chmod -R g+rwx /var/www Install Laravel 5.5 via Composer\ncomposer create-project laravel/laravel /var/www/html/web Make Storage Writeable\nsudo chmod -R 777 /var/www/html/web/storage Set Document Root in Apache\nsudo nano /etc/apache2/sites-available/000-default.conf # change DocumentRoot to laravel/public DocumentRoot \u0026#34;/var/www/html/laravel/public\u0026#34; # Save and Exit Restart Apache\nsudo systemctl restart apache2 There you have it. Laravel 5.5 on Ubuntu 16.04 LTS. Enjoy.\n","permalink":"http://uly.me/posts/install-laravel-5-5-on-ubuntu-16-04/","summary":"\u003cp\u003eLaravel is a MVC framework for PHP. The latest Laravel release is version 5.5 in July 2017. Laravel 5.5 requires PHP 7 and higher. The latest stable release of PHP is 7.1. The following instructions walks you through how to install Laravel 5.5 on Ubuntu 16.04 LTS.\u003c/p\u003e\n\u003cp\u003eUpdate\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get update\nsudo apt-get upgrade\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall Apache\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# install apache\nsudo apt-get install apache2\n# start apache\nsudo systemctl start apache2\n# enable on startup\nsudo systemctl enable apache2\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall PHP 7\u003c/p\u003e","title":"install laravel 5.5 on ubuntu 16.04"},{"content":"If you’re getting tired of seeing this …\n$ You have new mail in /var/spool/mail/username You can delete by running this command from the Terminal\n$ \u0026gt; /var/spool/mail/username ","permalink":"http://uly.me/posts/delete-linux-mail-from-terminal/","summary":"\u003cp\u003eIf you’re getting tired of seeing this …\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ You have new mail in /var/spool/mail/username\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou can delete by running this command from the Terminal\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ \u0026gt; /var/spool/mail/username\n\u003c/code\u003e\u003c/pre\u003e","title":"delete linux mail from terminal"},{"content":"I was trying to copy a large file from AWS S3 bucket to the smallest Amazon Lightsail instance using the AWS CLI. It was throwing out an error saying “Killedted 3.8 Mib/113.4 Mib (5.0 Mib/s) with 1 file(s) remaining.” For some reason, the copy was being killed or terminated. I was thinking that maybe the small instance was not enough to copy or move large files. I’m glad I found a workaround. Here’s the command I was doing, and the fix.\nThe Error\n$ aws s3 cp s3://bucketname/directory/largefile.mp4 largefile.mp4 $ Killedted 3.8 MiB/113.4 MiB (5.0 MiB/s) with 1 file(s) remaining The Fix\n$ aws configure set default.s3.max_concurrent_requests 4 The default is 10 which was too much for a small instance.\n","permalink":"http://uly.me/posts/aws-s3-killedted/","summary":"\u003cp\u003eI was trying to copy a large file from AWS S3 bucket to the smallest Amazon Lightsail instance using the AWS CLI. It was throwing out an error saying “Killedted 3.8 Mib/113.4 Mib (5.0 Mib/s) with 1 file(s) remaining.” For some reason, the copy was being killed or terminated. I was thinking that maybe the small instance was not enough to copy or move large files. I’m glad I found a \u003ca href=\"https://github.com/aws/aws-cli/issues/1775\"\u003eworkaround\u003c/a\u003e. Here’s the command I was doing, and the fix.\u003c/p\u003e","title":"aws s3 killedted"},{"content":"When formatting thumb drives, Windows give you the flexibility to choose which format to use, whether it’s NTFS, FAT32, and exFAT. Windows will support all three formats. There are advantages and disadvantages to each format. I’m not going to cover in detail the differences between all three. You can read them here. Here is where it makes sense though. If you need full compatibility, especially if you’re switching between Windows and Mac, then I recommend that you use the exFAT format. It’s readable and writeable on both Windows and MacOS. The only downside is Linux. For full compatibility, you need to install a couple of packages called exfat-fuse and exfat-utils in your Linux distro. You can use this guide. Hopefully, this short article and the linked articles, benefits you, in terms of choosing the correct format that’s best for your needs.\n","permalink":"http://uly.me/posts/exfat-compatibility/","summary":"\u003cp\u003eWhen formatting thumb drives, Windows give you the flexibility to choose which format to use, whether it’s NTFS, FAT32, and exFAT. Windows will support all three formats. There are advantages and disadvantages to each format. I’m not going to cover in detail the differences between all three. You can read them \u003ca href=\"https://www.howtogeek.com/235596/whats-the-difference-between-fat32-exfat-and-ntfs/\"\u003ehere\u003c/a\u003e. Here is where it makes sense though. If you need full compatibility, especially if you’re switching between Windows and Mac, then I recommend that you use the exFAT format. It’s readable and writeable on both Windows and MacOS. The only downside is Linux. For full compatibility, you need to install a couple of packages called exfat-fuse and exfat-utils in your Linux distro. You can use this \u003ca href=\"https://www.howtogeek.com/235655/how-to-mount-and-use-an-exfat-drive-on-linux/\"\u003eguide\u003c/a\u003e. Hopefully, this short article and the linked articles, benefits you, in terms of choosing the correct format that’s best for your needs.\u003c/p\u003e","title":"exfat compatibility"},{"content":"I recently started playing around with Jekyll.\nJekyll is a flat-file CMS that doesn’t need a database. You don’t even need to know HTML to work with it. You just write your content using the Markdown language on any text editor. Once you’re done editing, you run “jekyll build” and Jekyll takes care of the rest. Since Jekyll files are stored on flat-files, you have quite a few choices where to host your website. You can host it on just about any hosting provider. You can have it hosted on Github for free, or better yet can run it as a serverless website on Amazon S3. Serverless meaning, it’s not running on a web server since S3 can host static files. In addition, you can take advantage of Cloudfront for its content distribution to speed up your website, and give it high availability.\nSo, here’s a demo of Jekyll running on AWS S3 and Cloudfront.\nYou can learn more about Jekyll by visiting their website.\n","permalink":"http://uly.me/posts/serverless-jekyll-on-aws/","summary":"\u003cp\u003eI recently started playing around with \u003ca href=\"https://jekyllrb.com/\"\u003eJekyll\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eJekyll is a flat-file CMS that doesn’t need a database. You don’t even need to know HTML to work with it. You just write your content using the Markdown language on any text editor. Once you’re done editing, you run “jekyll build” and Jekyll takes care of the rest. Since Jekyll files are stored on flat-files, you have quite a few choices where to host your website. You can host it on just about any hosting provider. You can have it hosted on \u003ca href=\"http://github.com\"\u003eGithub\u003c/a\u003e for free, or better yet can run it as a serverless website on \u003ca href=\"https://aws.amazon.com/s3/\"\u003eAmazon S3\u003c/a\u003e. Serverless meaning, it’s not running on a web server since S3 can host static files. In addition, you can take advantage of \u003ca href=\"https://aws.amazon.com/cloudfront/?nc2=h_m1\"\u003eCloudfront\u003c/a\u003e for its content distribution to speed up your website, and give it high availability.\u003c/p\u003e","title":"serverless jekyll on aws"},{"content":"AWS plans to run VMWare virtualization software on top of AWS cloud sometime in the near future. Some reports the joint project to start in mid-2017, but others are saying as late as early 2018. The project is the result of the hybrid cloud partnership announced in the fall of last year. The deal will bolster both companies with AWS most likely attracting more customers and VMWare retaining its customer base as the partnership becomes a reality in the next few months.\nInvestopedia’s article explains:\nThe software deal would reflect a move past the two companies’ current cloud-only partnership and AWS’ first large-scale effort to develop software for corporate data centers. The new product would make it easier for enterprises to move on-premise apps to the cloud and recover data from Amazon in case of disasters. In the past couple of years, Amazon has added various cloud support services and related offerings for on-premise data centers.\n","permalink":"http://uly.me/posts/aws-and-vmware/","summary":"\u003cp\u003eAWS plans to run VMWare virtualization software on top of AWS cloud sometime in the near future. Some reports the joint project to start in mid-2017, but others are saying as late as early 2018. The project is the result of the hybrid cloud partnership announced in the fall of last year. The deal will bolster both companies with AWS most likely attracting more customers and VMWare retaining its customer base as the partnership becomes a reality in the next few months.\u003c/p\u003e","title":"aws and vmware"},{"content":"Docker containers are awesome. Docker allows you to quickly create development environments in a matter of minutes. Docker gives you the ability to package, ship and share your docker image to anyone. Once your docker image is on the Docker repository, anyone can pull it down and run it on their own operating system.\nTo keep track of running containers on your system, you can type ‘docker ps -a’ on your terminal.\n$ docker ps -a # gives a result similar to this ... CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f322d2370415 moul/icecast \u0026#34;/start.sh\u0026#34; 2 hours ago Up 2 hours 0.0.0.0:8000-\u0026gt;8000/tcp icecast_icecast_1 If you would like to SSH to a running Docker container, just run the following from the terminal.\ndocker exec -t -i f322d2370415 /bin/bash # it will take you to this ... root@f322d2370415:/# f322d2370415 is the Container ID, while /bin/bash is the shell that you would like to use.\n","permalink":"http://uly.me/posts/ssh-to-a-docker-container/","summary":"\u003cp\u003eDocker containers are awesome. Docker allows you to quickly create development environments in a matter of minutes. Docker gives you the ability to package, ship and share your docker image to anyone. Once your docker image is on the Docker repository, anyone can pull it down and run it on their own operating system.\u003c/p\u003e\n\u003cp\u003eTo keep track of running containers on your system, you can type ‘docker ps -a’ on your terminal.\u003c/p\u003e","title":"ssh to a docker container"},{"content":"Amazon Web Services has an API via a CLI (command line interface) which give users the ability to manage servers from a remote host. The AWS CLI must be installed and authenticated to AWS on the host computer. Once a user is logged in to AWS, they can perform certain management tasks such as starting and stopping EC2 instances.\nHow to start EC2 instance from AWS CLI\nRequires an image id, instance count, instance type, key and security group.\naws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type c4.2xlarge --key-name your-key —security-group-ids sg-xxxxxxxx How to Associate an Elastic IP Address to an Instance\nRequires an instance id and Elastic IP address.\naws ec2 associate-address --instance-id i-xxxxxxxxxxxxxxxx --public-ip xxx.xxx.xxx.xxx How to Terminate an Instance\nRequires an instance id(s).\naws ec2 terminate-instances --instance-ids i-xxxxxxxxxxxxxxxx ","permalink":"http://uly.me/posts/start-ec2-ami-from-aws-cli/","summary":"\u003cp\u003eAmazon Web Services has an API via a CLI (command line interface) which give users the ability to manage servers from a remote host. The AWS CLI must be installed and authenticated to AWS on the host computer. Once a user is logged in to AWS, they can perform certain management tasks such as starting and stopping EC2 instances.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eHow to start EC2 instance from AWS CLI\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eRequires an image id, instance count, instance type, key and security group.\u003c/p\u003e","title":"start ec2 ami from aws cli"},{"content":"The AWS CLI spits out a JSON output after each successful execution. If you need to grab the result, assign it to a variable, and use it for your subsequent scripts, you need some kind of JSON parser. You can use a tool like jq which will process or filter out the result for you. From jq’s website,\njq is a tool for processing JSON inputs, applying the given filter to its JSON text inputs and producing the filter’s results as JSON on standard output. The simplest filter is ., which is the identity filter, copying jq’s input to its output unmodified (except for formatting).\nIn this example, we will use the AWS CLI to give us a list of running EC2 instances. We will then dump the output into a file called output.json. We will then filter out the “InstanceId” by running it through cat and the jq processor. We will then assign the result to a variable called INSTANCE, and then finally use that variable to associate our instance to an Elastic IP Address.\naws ec2 describe-instances --filters Name=instance-state-name,Values=running \u0026gt; output.json INSTANCEID=$(cat output.json | jq \u0026#39;.Reservations[].Instances[] | {InstanceId} | .InstanceId\u0026#39; --raw-output) aws ec2 associate-address --instance-id $INSTANCEID --public-ip xxx.xxx.xxx.xxx Filtering a nested JSON can be a bit tricky. In this particular case, we are using a filter you’ll find inside the single quote right after the jq command. To remove quotes from our result, I’m using –raw-output switch. Finally, I then associate our instance to an elastic public IP address.\njq is a very handy tool.\n","permalink":"http://uly.me/posts/jq-proccessor/","summary":"\u003cp\u003eThe AWS CLI spits out a JSON output after each successful execution. If you need to grab the result, assign it to a variable, and use it for your subsequent scripts, you need some kind of JSON parser. You can use a tool like jq which will process or filter out the result for you. From jq’s \u003ca href=\"https://stedolan.github.io/jq/\"\u003ewebsite\u003c/a\u003e,\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003ejq is a tool for processing JSON inputs, applying the given filter to its JSON text inputs and producing the filter’s results as JSON on standard output. The simplest filter is ., which is the identity filter, copying jq’s input to its output unmodified (except for formatting).\u003c/p\u003e","title":"jq proccessor"},{"content":"Boto3 is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.\nTo install on Mac\nsudo easy_install pip sudo pip install —ignore-installed six boto3 You need to set up your credentials and config file to authenticate to AWS first. The files are:\n.aws/credentials\n.aws/config\nAfter it’s installed and configured, try using Boto3 to fetch your AWS S3 buckets.\nimport boto3 s3 = boto3.resource(\u0026#39;s3\u0026#39;) for bucket in s3.buckets.all(): print(bucket.name) Your S3 buckets will be listed after execution.\nBoto3 has access to other AWS resources like EC2, meaning you can start and stop instances via Python and Boto3.\n","permalink":"http://uly.me/posts/install-boto3-aws-sdk-for-python/","summary":"\u003cp\u003eBoto3 is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.\u003c/p\u003e\n\u003cp\u003eTo install on Mac\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo easy_install pip\nsudo pip install —ignore-installed six boto3\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou need to set up your credentials and config file to authenticate to AWS first. The files are:\u003c/p\u003e","title":"install boto3 aws sdk for python"},{"content":"I have a couple of WordPress blogs that are running multisite. I decided I don’t need the other blogs. So, I converted both sites to the standard or single WordPress site. The good news is that there’s no need to reinstall WordPress. It requires just a simple edit of a couple of WordPress files. The conversion was not as bad as I initially thought. Just follow the steps below.\n5 Easy Steps\nBack up your database — just in case.\nDelete the blogs you don’t want.\nEdit wp-config.php.\nEdit .htaccess.\nClean up your database.\nBacking up your database — just in case. You can use several tools for backing up your blogs. You can use PHPMyAdmin or a WordPress backup plugin. You can also use the WordPress Export feature to save the blog in XML format in case you want to restore it in the future.\nDelete the blogs you don’t want – Go to All blogs in the WordPress Dashboard. If you have multiple blogs, it will be listed here. Delete the ones you don’t want.\nEdit wp-config.php. Remove the Multisite entries in wp-config.php.\ndefine( \u0026#39;MULTISITE\u0026#39;, true ); define( \u0026#39;SUBDOMAIN_INSTALL\u0026#39;, false ); $base = \u0026#39;/wordpress/\u0026#39;; define( \u0026#39;DOMAIN_CURRENT_SITE\u0026#39;, \u0026#39;localhost\u0026#39; ); define( \u0026#39;PATH_CURRENT_SITE\u0026#39;, \u0026#39;/wordpress/\u0026#39; ); define( \u0026#39;SITE_ID_CURRENT_SITE\u0026#39;, 1 ); define( \u0026#39;BLOG_ID_CURRENT_SITE\u0026#39;, 1 ); Change your .htaccess to the standard WordPress configuration. # BEGIN WordPress \u0026lt;ifmodule mod_rewrite.c=\u0026#34;\u0026#34;\u0026gt; RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] \u0026lt;/ifmodule\u0026gt; # END WordPress Finally, remove the database tables that are no longer needed. wp_blogs wp_blog_versions wp_registration_log wp_signups wp_site wp_sitemeta ","permalink":"http://uly.me/posts/multisite-to-single-site/","summary":"\u003cp\u003eI have a couple of WordPress blogs that are running multisite. I decided I don’t need the other blogs. So, I converted both sites to the standard or single WordPress site. The good news is that there’s no need to reinstall WordPress. It requires just a simple edit of a couple of WordPress files. The conversion was not as bad as I initially thought. Just follow the steps below.\u003c/p\u003e\n\u003cp\u003e5 Easy Steps\u003c/p\u003e","title":"multisite to single site"},{"content":"Linux is quite stable, but there are times that you may have to restart an application or a service after a configuration change. For the change to take effect, a restart of a service is required. The good news is starting and stopping services in Linux are quite easy.\nThe old way.\n# Starting and stopping MySQL $ sudo /etc/init.d/mysql start $ sudo /etc/init.d/mysql stop $ sudo /etc/init.d/mysql restart # Starting and stopping Apache $ sudo /etc/init.d/apache2 start $ sudo /etc/init.d/apache2 stop $ sudo /etc/init.d/apache2 restart # Starting and stopping the network $ sudo /etc/init.d/networking start $ sudo /etc/init.d/networking stop $ sudo /etc/init.d/networking restart Via service for Debian|Ubuntu distros\n# Starting and stopping MySQL $ sudo service mysql start $ sudo service mysql stop $ sudo service mysql restart # Starting and stopping Apache $ sudo service apache2 start $ sudo service apache2 stop $ sudo service apache2 restart # Starting and stopping the network $ sudo service networking start $ sudo service networking stop $ sudo service networking restart Via Systemctl for CentOS|Redhat distros\n# Starting and stopping MySQL $ sudo systemctl start mysqld $ sudo systemctl stop mysqld $ sudo systemctl restart mysqld # Starting and stopping Apache $ sudo systemctl start httpd $ sudo systemctl stop httpd $ sudo systemctl restart httpd # Starting and stopping the network $ sudo systemctl start network $ sudo systemctl stop network $ sudo systemctl restart network ","permalink":"http://uly.me/posts/starting-and-stopping-services/","summary":"\u003cp\u003eLinux is quite stable, but there are times that you may have to restart an application or a service after a configuration change. For the change to take effect, a restart of a service is required. The good news is starting and stopping services in Linux are quite easy.\u003c/p\u003e\n\u003cp\u003eThe old way.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Starting and stopping MySQL\n$ sudo /etc/init.d/mysql start\n$ sudo /etc/init.d/mysql stop\n$ sudo /etc/init.d/mysql restart\n# Starting and stopping Apache\n$ sudo /etc/init.d/apache2 start\n$ sudo /etc/init.d/apache2 stop\n$ sudo /etc/init.d/apache2 restart\n# Starting and stopping the network\n$ sudo /etc/init.d/networking start\n$ sudo /etc/init.d/networking stop\n$ sudo /etc/init.d/networking restart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVia service for Debian|Ubuntu distros\u003c/p\u003e","title":"starting and stopping services"},{"content":"Here’s a neat little PHP script that compares a set date/time to the current time. The time() function sets the $now variable to the current Unix timestamp. The strtotime() function converts a date string to a Unix timestamp. The result is assigned to the $setdate variable. The two variables containing Unix timestamps are then compared. A simple if-then statement determines if the date is in the past or future.\ndate_default_timezone_set(\u0026#39;America/Los_Angeles\u0026#39;); $setdate = strtotime(\u0026#34;May 9, 2017 12:27PM\u0026#34;); $now = time(); if ( $setdate \u0026gt; $now ) : echo \u0026#39;Future date\u0026#39;; else : echo \u0026#39;Past date\u0026#39;; endif; You may have to change the default timezone if your server is in a different timezone.\n","permalink":"http://uly.me/posts/comparing-time/","summary":"\u003cp\u003eHere’s a neat little PHP script that compares a set date/time to the current time. The time() function sets the $now variable to the current Unix timestamp. The strtotime() function converts a date string to a Unix timestamp. The result is assigned to the $setdate variable. The two variables containing Unix timestamps are then compared. A simple if-then statement determines if the date is in the past or future.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edate_default_timezone_set(\u0026#39;America/Los_Angeles\u0026#39;);\n$setdate = strtotime(\u0026#34;May 9, 2017 12:27PM\u0026#34;);\n$now = time();\nif ( $setdate \u0026gt; $now ) : echo \u0026#39;Future date\u0026#39;; else : echo \u0026#39;Past date\u0026#39;; endif;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou may have to change the default timezone if your server is in a different timezone.\u003c/p\u003e","title":"comparing time"},{"content":"If you record videos of your desktop, especially the Terminal, it’s a challenge to get your window to fit properly in a 16:9 format. Without the proper tool, eyeballing a window to fit a certain resolution is a difficult task to do.\nOne of the tools I use to set my window to a resolution that I want is to use my browser as a guide. There are several websites out there that allow you to set your browser to any size or resolution. Head over to resizemybrowser.com. They have several presets in varying resolutions.\nIf you don’t like any of their presets, then you can create your own. In addition, you can also manually adjust your current window to any size you want. The website gives you feedback of your resolution in real time. Once you set your browser to the right size, then you can match your Terminal with the size of your browser.\n","permalink":"http://uly.me/posts/resize-window-to-any-resolution/","summary":"\u003cp\u003eIf you record videos of your desktop, especially the Terminal, it’s a challenge to get your window to fit properly in a 16:9 format. Without the proper tool, eyeballing a window to fit a certain resolution is a difficult task to do.\u003c/p\u003e\n\u003cp\u003eOne of the tools I use to set my window to a resolution that I want is to use my browser as a guide. There are several websites out there that allow you to set your browser to any size or resolution. Head over to \u003ca href=\"http://resizemybrowser.com/\"\u003eresizemybrowser.com\u003c/a\u003e. They have several presets in varying resolutions.\u003c/p\u003e","title":"resize window to any resolution"},{"content":"The advantage of running Amazon Linux on AWS is that you already have the AWS CLI (command line interface) loaded as part of the image. In addition, Amazon Linux has rolling updates. It means you don’t have to perform major upgrades as you go to from one version to another. It’s all part of the process when you perform periodical updates. However, if you’re running Ubuntu, it’s no slouch. It’s a popular distro which many administrators have chosen to use due to its simplicity and robust repository. So, if you’re running Ubuntu, you might want to install the AWS CLI to give you the tools you need similar to what Amazon Linux has. Here’s how to install AWS CLI on Ubuntu.\n$ sudo apt install awscli You will need to run the configuration before you can start using AWS CLI. See example below.\n$ sudo aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-west-2 Default output format [None]: json Obviously, you will need your own Access Key and Secret Key that you’ll need to generate from your AWS Console under IAM.\n","permalink":"http://uly.me/posts/install-aws-cli-on-ubuntu/","summary":"\u003cp\u003eThe advantage of running Amazon Linux on AWS is that you already have the AWS CLI (command line interface) loaded as part of the image. In addition, Amazon Linux has rolling updates. It means you don’t have to perform major upgrades as you go to from one version to another. It’s all part of the process when you perform periodical updates. However, if you’re running Ubuntu, it’s no slouch. It’s a popular distro which many administrators have chosen to use due to its simplicity and robust repository. So, if you’re running Ubuntu, you might want to install the AWS CLI to give you the tools you need similar to what Amazon Linux has. Here’s how to install AWS CLI on Ubuntu.\u003c/p\u003e","title":"install aws cli on ubuntu"},{"content":"If you want to run a couple of cron jobs, you may need to check if your server is using your timezone. You can determine the server’s timezone by simply typing the system’s date command. You’ll see right away if your server is using the same timezone.\n$ date Sun Apr 23 21:21:24 PDT 2017 If it isn’t, then you need to change it so it’s in sync with cron jobs. To change timezone, run dpkg-reconfigure tzdata. You’ll be asked to choose a region and the nearest city. In this example, I’m picking the Americas/Los Angeles combination. Choose your own region and city.\n$ sudo dpkg-reconfigure tzdata Current default time zone: \u0026#39;America/Los_Angeles\u0026#39; Local time is now: Sun Apr 23 21:24:57 PDT 2017. Universal Time is now: Mon Apr 24 04:24:57 UTC 2017. You may need to restart cron so that the new timezone can take effect.\n$ sudo service cron restart ","permalink":"http://uly.me/posts/ubuntu-server-timezone/","summary":"\u003cp\u003eIf you want to run a couple of cron jobs, you may need to check if your server is using your timezone. You can determine the server’s timezone by simply typing the system’s date command. You’ll see right away if your server is using the same timezone.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ date\nSun Apr 23 21:21:24 PDT 2017\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf it isn’t, then you need to change it so it’s in sync with cron jobs. To change timezone, run dpkg-reconfigure tzdata. You’ll be asked to choose a region and the nearest city. In this example, I’m picking the Americas/Los Angeles combination. Choose your own region and city.\u003c/p\u003e","title":"ubuntu server timezone"},{"content":"If you use CSS, it can sometimes get repetitive. One way of streamlining your code is to use Sass. Sass is a CSS extension that gives users power and elegance. Sass allows the use of variables, nested rules, mixins, inline imports, and many more in your code by cutting down on some repetitive tasks. Let me show you how it’s done. Below is an example of how to use Sass using variables.\nSass Variables – an example using the same hex color over and over again.\n$link-color: #054943; a, a:active { color: $link-color; } pre { color: $link-color; } #page { color: $link-color; } .list { color: $link-color; } With Sass’ preprocessor, the original will output a result like this:\na, a:active { color: #054943; } pre { color: #054943; } #page { color: #054943; } .list { color: #054943; } If you need to change the color in the future, you just need to change one line.\nTo start Using Sass, just issue the command below. Sass will watch input.scss and generate output.css.\n$ sass input.scss output.css If you use Github for versioning, you may have to ignore a few files, like the Sass cache, the mapping file and the input.scss itself, from showing up on your Github repository. To learn Sass, visit the website and read the documentation. To start using Sass, just install.\n","permalink":"http://uly.me/posts/sass-basics/","summary":"\u003cp\u003eIf you use CSS, it can sometimes get repetitive. One way of streamlining your code is to use Sass. Sass is a CSS extension that gives users power and elegance. Sass allows the use of variables, nested rules, mixins, inline imports, and many more in your code by cutting down on some repetitive tasks. Let me show you how it’s done. Below is an example of how to use Sass using variables.\u003c/p\u003e","title":"sass basics"},{"content":"Canonical made announcement today that it’s planning to do away with its Unity Desktop starting with the Ubuntu 18.04 release. Don’t worry, Canonical is not doing away with its own Linux Desktop. This means they are not going to develop anymore of its Unity Desktop environment. The Ubuntu desktop will be switching back to the Gnome desktop, which was its default desktop environment before going with Unity six years ago.\nIn addition, Canonical will also end its support for Unity8 which was targeted phones and tablets. Unity8 was meant to converge the desktop with phones and tablets. As far as the desktop, Canonical dominated the Linux desktop years ago according to Distrowatch.com. I think going with Unity pushed some users to switch over to other distros such as Linux Mint. I was one of them.\nDespite the tumbles Canonical has made on the desktop, the Ubuntu Server is still a big hit on the cloud.\n","permalink":"http://uly.me/posts/ubuntu-switching-to-gnome/","summary":"\u003cp\u003eCanonical made announcement today that it’s planning to do away with its Unity Desktop starting with the Ubuntu 18.04 release. Don’t worry, Canonical is not doing away with its own Linux Desktop. This means they are not going to develop anymore of its Unity Desktop environment. The Ubuntu desktop will be switching back to the Gnome desktop, which was its default desktop environment before going with Unity six years ago.\u003c/p\u003e","title":"ubuntu switching to gnome"},{"content":"NextCloud is an open-source next-generation file sharing and file synching web-application that you can run and install on your own Linux server. It’s similar to Dropbox, the file-sharing cloud application. The big difference between Dropbox and NextCloud is that you get to run your own cloud storage on your own server. The following are instructions on how to install NextCloud on an Ubuntu Server 16.04 LTS server.\nRun Updates First\n$ sudo apt-get update $ sudo apt-get upgrade -y $ sudo apt-get dist-upgrade -y Install Apache\n$ sudo apt-get install apache2 Install MySQL Server\n$ sudo apt-get install mysql-server mysql-client $ sudo mysql_secure_installation Install PHP\n$ sudo apt-get install php libapache2-mod-php php-mbstring php-zip php-xml php-mysql php-gd $ sudo apt-get install php-json php-curl php-intl php-mcrypt php-imagick php-dom unzip Edit php.ini change the memory limit and upload and post file sizes to something bigger. Restart Apache.\n$ sudo nano /etc/php/7.0/apache2/php.ini memory_limit = 512M upload_max_filesize = 500M post_max_size = 500M $ sudo service apache2 restart Create Database and User. Flush privileges.\n$ mysql -u root -p mysql\u0026gt; create database nextcloud; mysql\u0026gt; grant all privileges on nextcloud.* to \u0026#39;ncuser\u0026#39;@\u0026#39;localhost\u0026#39; identified by \u0026#39;password\u0026#39;; mysql\u0026gt; flush privileges; mysql\u0026gt; exit; Download and Install the latest Nextcloud. Give permissions to Apache.\n$ cd /var/www/html $ sudo wget https://download.nextcloud.com/server/releases/nextcloud-11.0.2.zip $ sudo unzip nextcloud-11.0.2.zip $ sudo chown -R www-data:www-data nextcloud Setup Apache\n$ sudo nano /etc/apache2/sites-available/nextcloud.conf Alias / \u0026#34;/var/www/html/nextcloud/\u0026#34; Options +FollowSymlinks AllowOverride All Dav Off SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud Enable Nextcloud. Disable default.\n$ sudo a2ensite nextcloud.conf $ sudo a2dissite 000-default.conf Enable the following\n$ sudo a2enmod rewrite $ sudo a2enmod headers $ sudo a2enmod env $ sudo a2enmod dir $ sudo a2enmod mime $ sudo service apache2 restart Open your browser and access your server via IP address or domain name to complete the NextCloud install.\nYou will be asked to enter a new username and password. Also enter your database credentials to complete the installation.\n","permalink":"http://uly.me/posts/nextcloud-install/","summary":"\u003cp\u003eNextCloud is an open-source next-generation file sharing and file synching web-application that you can run and install on your own Linux server. It’s similar to Dropbox, the file-sharing cloud application. The big difference between Dropbox and NextCloud is that you get to run your own cloud storage on your own server. The following are instructions on how to install NextCloud on an Ubuntu Server 16.04 LTS server.\u003c/p\u003e\n\u003cp\u003eRun Updates First\u003c/p\u003e","title":"nextcloud install"},{"content":"Here’s a quick PHP script to check if your web server can connect to your MySQL database. It’s a neat little script if you don’t have any application installed yet, and you just want to see if your web server setup can quickly connect to the database. All you have to do is create a new file called connect.php, and place the following code inside. Just change the username, password and database. Most likely the hostname will be localhost.\n$ sudo nano /var/www/html/connect.php $username = \u0026#34;user\u0026#34;; $password = \u0026#34;password\u0026#34;; $hostname = \u0026#34;hostname\u0026#34;; $database = \u0026#34;database\u0026#34;; $dbhandle = mysql_connect($hostname, $username, $password) or die(\u0026#34;Unable to connect to MySQL\u0026#34;); echo \u0026#34;Successfully Connected to the MySQL Database.\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#34;; $selected = mysql_select_db(\u0026#34;$dbname\u0026#34;, $dbhandle) or die(\u0026#34;Could not select database\u0026#34;); echo \u0026#34;Successfully Connected to Database called: $database\u0026#34;; It’s also available on my Github gist.\n","permalink":"http://uly.me/posts/quick-database-check/","summary":"\u003cp\u003eHere’s a quick PHP script to check if your web server can connect to your MySQL database. It’s a neat little script if you don’t have any application installed yet, and you just want to see if your web server setup can quickly connect to the database. All you have to do is create a new file called connect.php, and place the following code inside. Just change the username, password and database. Most likely the hostname will be localhost.\u003c/p\u003e","title":"quick database check"},{"content":"This is the installation of Laravel 5.4 on an Ubuntu Server 16.04 LTS. Laravel requires that you run Apache, MySQL and PHP. In this installation, I’m using the following versions: Apache 2.4.18, MySQL 5.7.17 and PHP 7.0.15. The installation of Laravel has changed over the years. I wished the installation was simpler. You can try Forge, but it’s not free. It also requires that you have an account at Linode, Digital Ocean or AWS. Forge costs $15 per month and Forge Plus is $30 per month. If you don’t want to pay, I’m afraid you are going to have to install Laravel yourself. Laravel installation may vary based on the distro you’re using. These instructions are for the Ubuntu Server 16.04 LTS.\nRun Update\nsudo apt-get update sudo apt-get upgrade Install Apache\nsudo apt-get install apache2 sudo a2enmod rewrite sudo service apache2 restart Install MySQL\nsudo apt-get install mysql-server sudo mysql_secure_installation Install PHP\nsudo apt-get install php libapache2-mod-php php-mbstring php-zip php-xml php-mysql Install Composer\nsudo curl -sS https://getcomposer.org/installer | sudo php — —install-dir=/usr/local/bin —filename=composer # you may have to move composer manually if it doesn\u0026#39;t work sudo mv composer.phar /usr/local/bin/composer # check if composer is accessible globally composer -V Install Laravel Installer\ncomposer global require \u0026#34;laravel/installer\u0026#34; # Using alias instead of $PATH echo \u0026#39;alias laravel=\u0026#34;~/.composer/vendor/bin/laravel\u0026#34;\u0026#39; \u0026gt;\u0026gt; ~/.bashrc source ~/.bashrc # add source ~/.bashrc to .profile to load automatically echo \u0026#39;source ~/.bashrc\u0026#39; \u0026gt;\u0026gt; ~/.profile # restart apache sudo service apache2 restart # check if laravel is accessible globally laravel Install New Laravel Project\n# set permissions cd /var/www/ sudo chown -R ubuntu:ubuntu /var/www/html sudo chmod -R 755 /var/www/html # install new project cd /var/www/html laravel new project # give apache permissions sudo chgrp -R www-data /var/www/html/project/storage sudo chgrp -R www-data /var/www/html/project/bootstrap/cache Configure Apache\ncd /etc/apache2/sites-available sudo cp 000-default.conf project.conf sudo nano project.conf # \u0026lt;virtualhost\u0026gt; ServerName local.project.com ServerAdmin admin@project.com DocumentRoot /var/www/html/project/public \u0026lt;directory\u0026gt; AllowOverride All \u0026lt;/directory\u0026gt; ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined \u0026lt;/virtualhost\u0026gt; # sudo a2ensite project.conf sudo a2dissite 000-default.conf sudo service apache2 restart Finally, you can now access Laravel from the browser from the server IP address or domain.\n","permalink":"http://uly.me/posts/laravel-5-4-install/","summary":"\u003cp\u003eThis is the installation of Laravel 5.4 on an Ubuntu Server 16.04 LTS. Laravel requires that you run Apache, MySQL and PHP. In this installation, I’m using the following versions: Apache 2.4.18, MySQL 5.7.17 and PHP 7.0.15. The installation of Laravel has changed over the years. I wished the installation was simpler. You can try Forge, but it’s not free. It also requires that you have an account at Linode, Digital Ocean or AWS. Forge costs $15 per month and Forge Plus is $30 per month. If you don’t want to pay, I’m afraid you are going to have to install Laravel yourself. Laravel installation may vary based on the distro you’re using. These instructions are for the Ubuntu Server 16.04 LTS.\u003c/p\u003e","title":"laravel 5.4 install"},{"content":"Just a quick demo how to work with AWS LightSail. LightSail is AWS lightweight VPS at a fixed price point. You can install just the OS. You can choose either Amazon Linux or Ubuntu OS. If you prefer, you can install any of the several ready-made applications provided by AWS in conjunction with Bitnami. In this example, I installed Ubuntu and Apache just demonstrate how to easy it is to work with LightSail.\n","permalink":"http://uly.me/posts/working-with-aws-lightsail/","summary":"\u003cp\u003eJust a quick demo how to work with AWS LightSail. LightSail is AWS lightweight VPS at a fixed price point. You can install just the OS. You can choose either Amazon Linux or Ubuntu OS. If you prefer, you can install any of the several ready-made applications provided by AWS in conjunction with Bitnami. In this example, I installed Ubuntu and Apache just demonstrate how to easy it is to work with LightSail.\u003c/p\u003e","title":"working with aws lightsail"},{"content":"The WordPress Genesis theme uses featured images on its posts on several of its themes. If you’re curious as to where the Genesis theme stores the image links on the database, you’ll need to go to a couple of WordPress tables to find them. First and foremost, you’ll need to get the ID of your WordPress post. You can easily find this by hovering over the edit link and checking the ID number.\nLet’s pretend the post ID is 110. You will then need to find the meta_value in the wp_postmeta table.\nTable: wp_postmeta\nmeta_id post_id meta_key meta_value 544 110 _thumbnail_id 45 SELECT meta_value FROM wp_postmeta WHERE meta_key=\u0026#39;_thumbnail_id\u0026#39; and post_id=110; The result is 45. Now that you have the meta_value, you can then search for the link from the wp_posts table.\nTable: wp_posts\nID post_type guid 45 attachment http://yourdomain.com/wp-content/uploads/2017/03/featured-image.jpg SELECT guid FROM wp_posts WHERE post_type=\u0026#39;attachment\u0026#39; and id=45; The result will be the URL of the image, e.g. http://yourdomain.com/wp-content/uploads/2017/03/featured-image.jpg.\nIt’s an odd place to store the image link, but that’s where it is.\n","permalink":"http://uly.me/posts/where-featured-images-are-stored/","summary":"\u003cp\u003eThe WordPress Genesis theme uses featured images on its posts on several of its themes. If you’re curious as to where the Genesis theme stores the image links on the database, you’ll need to go to a couple of WordPress tables to find them. First and foremost, you’ll need to get the ID of your WordPress post. You can easily find this by hovering over the edit link and checking the ID number.\u003c/p\u003e","title":"where featured images are stored"},{"content":"There are situations when you have to do a mass find and replace on your database. Let’s say you’re really, really bad speller. You just recently found out that you’ve been spelling a word for wrongly for years. To avoid embarrassment, you decide to do a search and replace. Unfortunately, you found out that there are hundreds of posts that contains that misspelled word. Instead of editing each post which is time consuming, you decide to run a mass find and replace against the database. In this example, we will replace the word ‘dawg’ with ‘dog.’\nUPDATE wp_posts SET post_content = REPLACE ( post_content, \u0026#39;dawg\u0026#39;, \u0026#39;dog\u0026#39;); I highly recommend that you back up your database first. I also recommend that you run it on a test database first before running it on a production environment, because a mass update is quite dangerous if you’re not sure what you are doing. If you’re a WordPress user, there’s a plugin called Search and Replace that will do the same thing. That might be easier for most people who don’t have access to MySQL command line or PHPMyAdmin.\n","permalink":"http://uly.me/posts/mass-find-and-replace/","summary":"\u003cp\u003eThere are situations when you have to do a mass find and replace on your database. Let’s say you’re really, really bad speller. You just recently found out that you’ve been spelling a word for wrongly for years. To avoid embarrassment, you decide to do a search and replace. Unfortunately, you found out that there are hundreds of posts that contains that misspelled word. Instead of editing each post which is time consuming, you decide to run a mass find and replace against the database. In this example, we will replace the word ‘dawg’ with ‘dog.’\u003c/p\u003e","title":"mass find and replace"},{"content":"I found this little nugget in the WordPress Codex called wp_is_mobile(). It will detect the user browser’s agent and will return a true or a false if it’s a mobile device. This is helpful if you would like to customized code specifically for a mobile device. Let’s say you have a media player and you want it to have a specific width for desktops and another width for mobile devices. So, here’s the code to detect if it’s a mobile device.\nif ( wp_is_mobile() ) : $player_width = \u0026#39;270\u0026#39;; else : $player_width = \u0026#39;400\u0026#39;; endif; You can then use the variable $player_width in your media player configuration to set the width of the player. However, if you read the Codex, it says that tablets are considered as mobile devices, which is perfectly fine for my purposes here. It’s ok to use this tiny little function in your WordPress templates, but it’s not recommended for media queries.\n","permalink":"http://uly.me/posts/wordpress-mobile-detect/","summary":"\u003cp\u003eI found this little nugget in the \u003ca href=\"https://codex.wordpress.org/Function_Reference/wp_is_mobile\"\u003eWordPress Codex\u003c/a\u003e called wp_is_mobile(). It will detect the user browser’s agent and will return a true or a false if it’s a mobile device. This is helpful if you would like to customized code specifically for a mobile device. Let’s say you have a media player and you want it to have a specific width for desktops and another width for mobile devices. So, here’s the code to detect if it’s a mobile device.\u003c/p\u003e","title":"wordpress mobile detect"},{"content":"I have a Linux box with a 1TB drive. I divided it into 4 different partitions at 250GB each. It’s currently running Linux Mint, Gitlab, Nextcloud and the Unifi Cloud Controller on each partition. Obviously, I can’t run all 4 partitions at the same time. I have to choose one from a selection in the Grub, a multi-boot loader. It would have been easier to run Virtualbox on just one Linux install, but it’s older CPU. I don’t think it could handle multiple OS running at the same time.\nUnfortunately, one of the partitions got corrupted. I tried running the utility called badblocks to figure out if there are any bad sectors on the drive that can be marked bad, but the test result turned out to be surprisingly good. There were absolutely no errors and no bad blocks. Next, I tried using the recovery process, but that didn’t work either. It seems the only way to fix the problem was to reinstall Linux. A bummer.\nDuring the install, I ran into the problem with the partition not being properly marked for formatting. It seems the only way to get around that issue was to delete the partition and to repartition it. Nevertheless, it would have been an interesting dilemma if I had any important data on that partition. It’s a good thing that I didn’t. So, if you ever get into a problem where it says “your partition is not marked for formatting”, you may have to go through the process of deleting the partition and then recreating one, in order to proceed with a fresh install.\n","permalink":"http://uly.me/posts/not-marked-for-formatting/","summary":"\u003cp\u003eI have a Linux box with a 1TB drive. I divided it into 4 different partitions at 250GB each. It’s currently running Linux Mint, Gitlab, Nextcloud and the Unifi Cloud Controller on each partition. Obviously, I can’t run all 4 partitions at the same time. I have to choose one from a selection in the Grub, a multi-boot loader. It would have been easier to run Virtualbox on just one Linux install, but it’s older CPU. I don’t think it could handle multiple OS running at the same time.\u003c/p\u003e","title":"not marked for formatting"},{"content":"If you’re working on the command line, listing a directory to display permissions of files is not always the most user-friendly. Here’s an example of listing the files in a directory using the ‘ls -al’ command.\n$ ls -al total 20 drwxrwsr-x 2 ulysses www-data 4096 Feb 26 13:31 . drwxrwsr-x 10 ulysses www-data 4096 Feb 26 02:30 .. -rw-rw-r-- 1 ulysses www-data 0 Feb 26 13:31 display.txt -rwxrwxr-x 1 ulysses ulysses 659 Dec 3 06:40 sync_com.sh -rw-r--r-- 1 ulysses ulysses 181 Feb 26 13:26 sync_db.sh -rwxrwxr-x 1 ulysses ulysses 244 Feb 26 13:23 sync_s3.sh There has to be a better way to display permissions?\nWell, there is. It’s a command called “stat” that displays the detailed status about a file or file system. On one of the switches of the stat command, is an option that allows you to display the file status in human readable format. Here’s an example using the stat from the command line.\n$ stat -c \u0026#39;%A %a %n\u0026#39; * 664 display.txt 775 sync_com.sh 644 sync_db.sh 775 sync_s3.sh The result is a list of files in a directory with the file permissions in human readable format!\n","permalink":"http://uly.me/posts/display-octal-permissions/","summary":"\u003cp\u003eIf you’re working on the command line, listing a directory to display permissions of files is not always the most user-friendly. Here’s an example of listing the files in a directory using the ‘ls -al’ command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ ls -al\ntotal 20\ndrwxrwsr-x  2 ulysses www-data 4096 Feb 26 13:31 .\ndrwxrwsr-x 10 ulysses www-data 4096 Feb 26 02:30 ..\n-rw-rw-r--  1 ulysses www-data    0 Feb 26 13:31 display.txt\n-rwxrwxr-x  1 ulysses ulysses   659 Dec  3 06:40 sync_com.sh\n-rw-r--r--  1 ulysses ulysses   181 Feb 26 13:26 sync_db.sh\n-rwxrwxr-x  1 ulysses ulysses   244 Feb 26 13:23 sync_s3.sh\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere has to be a better way to display permissions?\u003c/p\u003e","title":"display octal permissions"},{"content":"Apache comes with a logrotate utility. You can customize the way logrotate behaves by editing the /etc/logrotate.d/apache file. The logrotate utility has many options. In this example, we are rotating the log files that are located at the /var/www/domain.com/log/ directory. We are instructing the log files to rotate monthly for a total of 24 times. We are compressing the files by zipping them. We are using the date extension as part of the filename. We are also delaying the compression until the log has been rotated at least twice. Finally, Apache is restarted.\n$ sudo nano /etc/logrotate.d/apache /var/www/domain.com/*.log { monthly missingok rotate 24 dateext compress delaycompress notifempty create 640 root adm sharedscripts postrotate if /etc/init.d/apache2 status \u0026gt; /dev/null ; then \\ /etc/init.d/apache2 reload \u0026gt; /dev/null; \\ fi; endscript prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\ run-parts /etc/logrotate.d/httpd-prerotate; \\ fi; \\ endscript } To learn more about the logrotate utility, please visit the documentation.\n","permalink":"http://uly.me/posts/how-to-rotate-apache-logs/","summary":"\u003cp\u003eApache comes with a logrotate utility. You can customize the way logrotate behaves by editing the /etc/logrotate.d/apache file. The logrotate utility has many options. In this example, we are rotating the log files that are located at the /var/www/domain.com/log/ directory. We are instructing the log files to rotate monthly for a total of 24 times. We are compressing the files by zipping them. We are using the date extension as part of the filename. We are also delaying the compression until the log has been rotated at least twice. Finally, Apache is restarted.\u003c/p\u003e","title":"how to rotate apache logs"},{"content":"If you would like to launch a new career as a front-end developer, which programming language would you choose? You have multiple options, but nothing could be as popular as PHP and Node.js. An article from ComputerWorld examines the strengths and weaknesses of both languages. Each language has their own pluses and minuses. PHP is simpler, with a deeper code base, easy access to databases, and it’s boosted by HHVM and the Hack language. Node.js is based on Javascript with thinner service calls. It works with JSON, and raw speed is unparalleled. Both languages has it’s own MVC frameworks. Perhaps, a hybrid solution of PHP and Node.js might be the best approach on some projects. It really depends on what you’re trying to achieve. If you want to code fast, you may choose PHP. If application raw speed is in order, then you may want to consider using Node.js.\n","permalink":"http://uly.me/posts/php-vs-node-js/","summary":"\u003cp\u003eIf you would like to launch a new career as a front-end developer, which programming language would you choose? You have multiple options, but nothing could be as popular as PHP and Node.js. An \u003ca href=\"http://www.computerworld.com/article/3167857/application-development/php-vs-nodejs-epic-battle-for-developer-mind-share.html\"\u003earticle\u003c/a\u003e from ComputerWorld examines the strengths and weaknesses of both languages. Each language has their own pluses and minuses. PHP is simpler, with a deeper code base, easy access to databases, and it’s boosted by HHVM and the Hack language. Node.js is based on Javascript with thinner service calls. It works with JSON, and raw speed is unparalleled. Both languages has it’s own MVC frameworks. Perhaps, a hybrid solution of PHP and Node.js might be the best approach on some projects. It really depends on what you’re trying to achieve. If you want to code fast, you may choose PHP. If application raw speed is in order, then you may want to consider using Node.js.\u003c/p\u003e","title":"php vs node.js"},{"content":"Grub is a menu program that allows Linux users the ability to choose from a multi-boot system. The original Grub program allowed administrators the ability to edit the menu listing from the command line. Sadly, when Grub 2 was implemented, editing files no longer had the same effect. The files are being overwritten by the system. Any changes to the menu listing file is discarded.\nWhat’s the fix?\nOne of the easiest way customize the Grub 2 menu listing is to use an application called Grub Customizer.\nTo install, perform the following commands:\n$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer $ sudo apt-get update $ sudo apt-get install grub-customizer Once installed, access the program from the menu under Administration (Linux Mint 18).\nRemove the entries you don’t want. Rename the entries to something meaningful to you.\n","permalink":"http://uly.me/posts/grub-customizer/","summary":"\u003cp\u003eGrub is a menu program that allows Linux users the ability to choose from a multi-boot system. The original Grub program allowed administrators the ability to edit the menu listing from the command line. Sadly, when Grub 2 was implemented, editing files no longer had the same effect. The files are being overwritten by the system. Any changes to the menu listing file is discarded.\u003c/p\u003e\n\u003cp\u003eWhat’s the fix?\u003c/p\u003e\n\u003cp\u003eOne of the easiest way customize the Grub 2 menu listing is to use an application called Grub Customizer.\u003c/p\u003e","title":"grub customizer"},{"content":"Git is the most popular version control software for managing your code. If you’re looking for the best version control system out there, Git is the pretty much the de-facto standard of version control. Although you can run Git locally without a server, you’ll need some kind of repository to share your code with others.\nEnter Github. Github provide free and paid Git repositories. Github public repositories are free, while private ones require subscription. For $7 dollars a month, you can have up to 5 private repositories. For $50 per month, you can use up to 50 repositories.\nIf you want to run your own Git repository either on the cloud or on your own private network (it’s more secure this way), then you’ll need to look at Gitlab’s Community Edition (Github.com is proprietary). Gitlab requires that you install their software on a Linux server (I’m using Ubuntu Server).\nI tried running Gitlab CE on the cheapest server ($5 per month) I can find at Digital Ocean. It works but, it’s painfully slow. I don’t recommend it. The $5 per month server only has 1 CPU core and 512 MB of RAM. I recommend that you go for a system that has 2 CPU cores and 2GB of RAM. This system will cost $20 per month.\nBy the way, if you don’t want managing your own server, you can simply sign up with Gitlab.com. It’s free! They offer unlimited private and public repositories up to 10GB of disk space per project. Of course, Gitlab has other products. For a paid subscription you can get enterprise support and more advanced features.\nVisit Gitlab for more details.\n","permalink":"http://uly.me/posts/gitlab-community-edition/","summary":"\u003cp\u003e\u003ca href=\"https://git-scm.com/\"\u003eGit\u003c/a\u003e is the most popular version control software for managing your code. If you’re looking for the best version control system out there, Git is the pretty much the de-facto standard of version control. Although you can run Git locally without a server, you’ll need some kind of repository to share your code with others.\u003c/p\u003e\n\u003cp\u003eEnter \u003ca href=\"http://github.com\"\u003eGithub\u003c/a\u003e. Github provide free and paid Git repositories. Github public repositories are free, while private ones require subscription. For $7 dollars a month, you can have up to 5 private repositories. For $50 per month, you can use up to 50 repositories.\u003c/p\u003e","title":"gitlab community edition"},{"content":"Here’s the recommended permissions for WordPress.\nPermissions Directories = 755\nFiles = 644\nInstall From Scratch If you’re starting from scratch, follow the instructions below.\nAssuming you’re logged in as normal user. Use sudo to execute commands as superuser.\ncd /var/www/ sudo wget https://wordpress.org/latest.tar.gz sudo tar -xzvf latest.tar.gz sudo chown -R www-data:www-data wordpress Fix Current If your permissions are wrong, then perform the following.\nsudo find /var/www/wordpress/ -type d -exec chmod 755 {} \\ sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \\ ","permalink":"http://uly.me/posts/fix-wordpress-permissions/","summary":"\u003cp\u003eHere’s the recommended permissions for \u003ca href=\"https://codex.wordpress.org/Hardening_WordPress\"\u003eWordPress\u003c/a\u003e.\u003c/p\u003e\n\u003ch4 id=\"permissions\"\u003ePermissions\u003c/h4\u003e\n\u003cp\u003eDirectories = 755\u003cbr\u003e\nFiles = 644\u003c/p\u003e\n\u003ch4 id=\"install-from-scratch\"\u003eInstall From Scratch\u003c/h4\u003e\n\u003cp\u003eIf you’re starting from scratch, follow the instructions below.\u003c/p\u003e\n\u003cp\u003eAssuming you’re logged in as normal user. Use sudo to execute commands as superuser.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd /var/www/\nsudo wget https://wordpress.org/latest.tar.gz\nsudo tar -xzvf latest.tar.gz\nsudo chown -R www-data:www-data wordpress\n\u003c/code\u003e\u003c/pre\u003e\u003ch4 id=\"fix-current\"\u003eFix Current\u003c/h4\u003e\n\u003cp\u003eIf your permissions are wrong, then perform the following.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo find /var/www/wordpress/ -type d -exec chmod 755 {} \\\nsudo find /var/www/wordpress/ -type f -exec chmod 644 {} \\\n\u003c/code\u003e\u003c/pre\u003e","title":"fix wordpress permissions"},{"content":"Nextcloud is the next generation open source file storage and file synching platform. It’s similar to Dropbox, Google Drive and Microsoft OneDrive. The main difference is that you run the software on your own server. This is a perfect solution if you’re worried about mass surveillance. It’s safe enough to place on the cloud. Better yet, you can run it on your local network at home. It behaves somewhat similar to a NAS (Network Attached Storage) but with a better web interface, and a few more apps.\nIn addition, you can install the client software on your Desktop (PC, MAC and Linux) or to any mobile device (iOS, Android and Windows). The clients automatically sync data to the server software that’s installed on a Linux server. Files can also be accessed using WebDav as well. It has an online office, a video chat feature and Outlook email integration, but I’m not really interested with those additional features. I use it primarily for storage and file synching only. It works great by the way.\nGive Nextcloud a try.\n","permalink":"http://uly.me/posts/nextcloud/","summary":"\u003cp\u003eNextcloud is the next generation open source file storage and file synching platform. It’s similar to Dropbox, Google Drive and Microsoft OneDrive. The main difference is that you run the software on your own server. This is a perfect solution if you’re worried about mass surveillance. It’s safe enough to place on the cloud. Better yet, you can run it on your local network at home. It behaves somewhat similar to a NAS (Network Attached Storage) but with a better web interface, and a few more apps.\u003c/p\u003e","title":"nextcloud"},{"content":"What do you do when you get this message “the following packages are being kept back.” And what exactly does it mean?\nWhen performing updates in Ubuntu, you typically run these two commands from the command line.\n$ sudo apt-get update $ sudo apt-get upgrade If there are updates, it will sometimes ask you to type “Y” or “yes.”\nSometimes you get this message.\n$ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done The following packages have been kept back: linux-headers-server linux-image-server linux-server 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. This means that these packages were not installed or kept back because they have additional packages that are introduced, and the upgrades depend on them.\nYou can fix this by running:\n$ sudo apt-get dist-upgrade Or you can individually install the packages you want instead of globally.\n$ sudo apt-get install package-name ","permalink":"http://uly.me/posts/packages-have-been-kept-back/","summary":"\u003cp\u003eWhat do you do when you get this message “the following packages are being kept back.” And what exactly does it mean?\u003c/p\u003e\n\u003cp\u003eWhen performing updates in Ubuntu, you typically run these two commands from the command line.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo apt-get update\n$ sudo apt-get upgrade\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf there are updates, it will sometimes ask you to type “Y” or “yes.”\u003c/p\u003e\n\u003cp\u003eSometimes you get this message.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo apt-get upgrade                                                                                                \nReading package lists... Done                                                                                                          \nBuilding dependency tree                                                                                                               \nReading state information... Done                                                                                                      \nThe following packages have been kept back:                                                                                            \n  linux-headers-server linux-image-server linux-server                                                                                 \n0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThis means that these packages were not installed or kept back because they have additional packages that are introduced, and the upgrades depend on them.\u003c/p\u003e","title":"packages have been kept back"},{"content":"FFmpeg is a complete cross-platform command-line tool for recording, converting and streaming audio and video files. FFmpeg is widely used for converting files from one format to another. It also used by some to record videos from the screen or camera. It’s also used by others to live stream a recorded file or camera to a RTMP streaming server such as Wowza, YouTube or Facebook Live.\nHow to record your camera to a video file.\n$ ffmpeg -f avfoundation -i \u0026#34;1:0\u0026#34; -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg $ ffmpeg -f avfoundation -i \u0026#34;2:0\u0026#34; -t 00:00:15 -s 1280x720 -r 30 -b:v 3500k -b:a 128k out.mpg Options\n-i = “video:audio”\n-t = duration\n-r = fps\n-b:v = video bitrate\n-b:a = audio bitrate\nHow to stream a video file to a RTMP server\n$ ffmpeg -re -i input.mp4 -vcodec libx264 -preset veryfast -maxrate 1500k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream How to live stream your screen monitor to a RTMP server\n$ ffmpeg -f avfoundation -i \u0026#34;2:0\u0026#34; -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream How to stream your camera to a RTMP server\n$ ffmpeg -f avfoundation -i \u0026#34;1:0\u0026#34; -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://yourserver:1935/live/mystream To learn details of FFmpeg options, read the documentation.\nIf you need assistance with the install, please see my previous post.\n","permalink":"http://uly.me/posts/how-to-live-stream-using-ffmpeg/","summary":"\u003cp\u003eFFmpeg is a complete cross-platform command-line tool for recording, converting and streaming audio and video files. FFmpeg is widely used for converting files from one format to another. It also used by some to record videos from the screen or camera. It’s also used by others to live stream a recorded file or camera to a RTMP streaming server such as Wowza, YouTube or Facebook Live.\u003c/p\u003e\n\u003cp\u003eHow to record your camera to a video file.\u003c/p\u003e","title":"how to live stream using ffmpeg"},{"content":"Homebrew is the missing package manager for the Mac OS. It’s missing because the MacOS doesn’t have one. Homebrew is the MacOS equivalent of apt-get or aptitude in Ubuntu Linux. With Homebrew installed on your MacOS, you can easily install and uninstall programs, packages, and utilities via the command line. For example, to install the wget, apache, git and ffmpeg, you can run the following commands from the Terminal.\n$ brew install wget $ brew install apache $ brew install git $ brew install ffmpeg If you don’t have Homebrew installed, run the following command from the Terminal.\n$ ruby -e \u0026#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\u0026#34; If for some unexplained reason you’re having problems with Homebrew, you can uninstall and reinstall it.\n$ rm -rf /usr/local/Cellar /usr/local/.git \u0026amp;\u0026amp; brew cleanup $ ruby -e \u0026#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\u0026#34; ","permalink":"http://uly.me/posts/homebrew/","summary":"\u003cp\u003eHomebrew is the missing package manager for the Mac OS. It’s missing because the MacOS doesn’t have one. Homebrew is the MacOS equivalent of apt-get or aptitude in Ubuntu Linux. With Homebrew installed on your MacOS, you can easily install and uninstall programs, packages, and utilities via the command line. For example, to install the wget, apache, git and ffmpeg, you can run the following commands from the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ brew install wget\n$ brew install apache\n$ brew install git\n$ brew install ffmpeg\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you don’t have Homebrew installed, run the following command from the Terminal.\u003c/p\u003e","title":"homebrew"},{"content":"If you’re looking for a simple way to detect if a WordPress page belongs to a certain category, you can use a WordPress function called in_category(). In this example code below, the script will detect if a post belongs to the “news” category. If it does, it will send an output to the WordPress header. If it isn’t, it will send an alternate output.\nfunction urr_add_to_header() { if ( in_category( \u0026#39;news\u0026#39; )) { echo \u0026#39;\u0026lt;script\u0026gt;Add your news Javascript here\u0026lt;/script\u0026gt;\u0026#39;; } else { echo \u0026#39;\u0026lt;script\u0026gt;Add your alternate Javascript here\u0026lt;/script\u0026gt;\u0026#39;; } } add_action( \u0026#39;wp_head\u0026#39;, \u0026#39;urr_add_to_header\u0026#39;, 100 ); It’s a simple function that has many uses. You can accomplish quite a bit with the in_category() function along with a few WordPress hooks.\n","permalink":"http://uly.me/posts/the-in_category-function/","summary":"\u003cp\u003eIf you’re looking for a simple way to detect if a WordPress page belongs to a certain category, you can use a WordPress function called in_category(). In this example code below, the script will detect if a post belongs to the “news” category. If it does, it will send an output to the WordPress header. If it isn’t, it will send an alternate output.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction urr_add_to_header() \n{\n  if ( in_category( \u0026#39;news\u0026#39; )) \n  {\n    echo \u0026#39;\u0026lt;script\u0026gt;Add your news Javascript here\u0026lt;/script\u0026gt;\u0026#39;;\n  } else {\n    echo \u0026#39;\u0026lt;script\u0026gt;Add your alternate Javascript here\u0026lt;/script\u0026gt;\u0026#39;;\n  }\n}\nadd_action( \u0026#39;wp_head\u0026#39;, \u0026#39;urr_add_to_header\u0026#39;, 100 );\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIt’s a simple function that has many uses. You can accomplish quite a bit with the in_category() function along with a few WordPress hooks.\u003c/p\u003e","title":"the in_category function"},{"content":"If you’re logged in to a server via SSH, you can securely copy a file using SCP command tool or also known as “secure copy” to your local desktop, and vice versa. SCP uses SSH for data transfer, authentication and security. Here are several examples on how to use the SCP command line tool if you would like to securely transfer a file to and from your server. You’ll be asked for the user’s password for authentication.\nExamples\n# Copy the file \u0026#34;foobar.txt\u0026#34; from a remote host to the local host $ scp username@remotehost.com:foobar.txt /your/local/directory # Copy the file \u0026#34;foobar.txt\u0026#34; from the local host to a remote host $ scp foobar.txt username@remotehost.com:/some/remote/directory The downside of using SCP is that it is slow. It has been known to be slow. Here’s a quote from Spikelab’s blog.\nSCP and the underlying SSH2 protocol implementation in OpenSSH is network performance limited by statically defined internal flow control buffers. These buffers often end up acting as a bottleneck for network throughput of SCP, especially on long and high bandwidth network links.\nDespite the poor performance, it’s really not that bad with a tiny bit of patience.\nThe tradeoff is that you can safely transfer files without sacrificing your security.\n","permalink":"http://uly.me/posts/secure-copy/","summary":"\u003cp\u003eIf you’re logged in to a server via SSH, you can securely copy a file using SCP command tool or also known as “secure copy” to your local desktop, and vice versa. SCP uses SSH for data transfer, authentication and security. Here are several examples on how to use the SCP command line tool if you would like to securely transfer a file to and from your server. You’ll be asked for the user’s password for authentication.\u003c/p\u003e","title":"secure copy"},{"content":"Previously, I wrote about installing and accessing Amazon S3 (Simple Storage Service) from Ubuntu using s3cmd command line tool. Interestingly enough, the S3cmd command line tool is also available on the Mac, since MacOS is based on NeXT, which was based on BSD, which is a major variant of Unix. Anyways, you can install s3cmd on the Mac so you can access to Amazon S3 via the command line.\nHow to Install\n$ sudo sudo python setup.py install Configure\n$ s3cmd --configure The configuration will ask you to provide your access key and secret key. You can get those keys from your AWS account or your AWS administrator.\nOnce it’s configured and you have access to the S3, you can try the following commands.\n# list the files $ s3cmd ls # get file sizes in human form $ s3cmd du -H s3://yourbucket # create a new bucket $ s3cmd mb s3://newbucket # put file into bucket $ s3cmd put filename.ext s3://bucket/folder # get file from bucket $ s3cmd get s3://yourbucket/yourfolder/yourfile # delete file from bucket $ s3cmd del s3://yourbucket/yourfolder/yourfile There are a lot more commands you can explore. Here’s the documentation.\n","permalink":"http://uly.me/posts/install-s3cmd-on-mac/","summary":"\u003cp\u003ePreviously, I wrote about installing and accessing Amazon S3 (Simple Storage Service) from \u003ca href=\"http://uly.me/install-s3cmd-on-ubuntu/\"\u003eUbuntu\u003c/a\u003e using s3cmd command line tool. Interestingly enough, the S3cmd command line tool is also available on the Mac, since MacOS is based on NeXT, which was based on BSD, which is a major variant of Unix. Anyways, you can install s3cmd on the Mac so you can access to Amazon S3 via the command line.\u003c/p\u003e\n\u003cp\u003eHow to Install\u003c/p\u003e","title":"install s3cmd on mac"},{"content":"WordPress comes with its own media player. It supports M4a, MP4, OGG, WebM, FLV, WMV, MP3, WAV and WMA formats. In addition, you can also embed videos from a dozen external sites such as YouTube, Vimeo, etc. WordPress will automatically embed the video when you add it to your post. You can change the dimensions of your videos by overriding the width and the height of the media player.\nEdit the functions.php file, and add the following code.\nfunction override_video_dimensions( $out, $pairs, $atts ) { $out[\u0026#39;width\u0026#39;] = \u0026#39;640\u0026#39;; $out[\u0026#39;height\u0026#39;] = \u0026#39;360\u0026#39;; return $out; } add_filter( \u0026#39;shortcode_atts_video\u0026#39;, \u0026#39;override_video_dimensions\u0026#39;, 10, 3 ); Here’s how to add YouTube videos in WordPress.\n","permalink":"http://uly.me/posts/override-wordpress-video-dimensions/","summary":"\u003cp\u003eWordPress comes with its own media player. It supports M4a, MP4, OGG, WebM, FLV, WMV, MP3, WAV and WMA formats. In addition, you can also embed videos from a dozen external sites such as YouTube, Vimeo, etc. WordPress will automatically embed the video when you add it to your post. You can change the dimensions of your videos by overriding the width and the height of the media player.\u003c/p\u003e\n\u003cp\u003eEdit the functions.php file, and add the following code.\u003c/p\u003e","title":"override wordpress video dimensions"},{"content":"I wanted to try Ghost, a CMS and blogging platform, which is an alternative for WordPress. Unlike WordPress which runs on PHP, Ghost runs on top of Node.js, a fast, scalable and extremely efficient Javascript runtime platform. Ember.js is used for the administration area making for a slick and smooth user experience. Ghost uses Handlebars, a powerful and logicless templating language.\nInstallation of Ghost on Digital Ocean is a breeze since there’s already a one-click Ghost app available from a list of ready-to-made list of app images. You can get a Ghost site up and running in less than 2 minutes.\nHow does it compare to WordPress?\nIf you’re new to blogging and you want something setup fast, Ghost may very well be your blogging platform. It’s has a simple but yet powerful interface. If you’re WordPress user, you may find the simplicity a little bit underwhelming. As far as themes and plugins, you will need to search for them online. There are free and paid Ghost themes.\nIf you’re thinking about extending the functionality of Ghost, you’ll need to learn Javascript. There are also dozens of apps online that you can install. Ghost is not as robust as WordPress, but if you want a no-nonsense blog, give Ghost a try. You may like it more than WordPress.\n","permalink":"http://uly.me/posts/ghost-blogging-platform/","summary":"\u003cp\u003eI wanted to try Ghost, a CMS and blogging platform, which is an alternative for WordPress. Unlike WordPress which runs on PHP, Ghost runs on top of Node.js, a fast, scalable and extremely efficient Javascript runtime platform. Ember.js is used for the administration area making for a slick and smooth user experience. Ghost uses Handlebars, a powerful and logicless templating language.\u003c/p\u003e\n\u003cp\u003eInstallation of Ghost on Digital Ocean is a breeze since there’s already a one-click Ghost app available from a list of ready-to-made list of app images. You can get a Ghost site up and running in less than 2 minutes.\u003c/p\u003e","title":"ghost blogging platform"},{"content":"WordPress is a content management system for running blogs or websites. Meanwhile, Docker is a software container platform for building, shipping and running applications or utilities. Since there are thousands of Docker images already built, installing an application such as WordPress is fairly easy. In this article, I will show you how to install WordPress, MySQL, PHPMyadmin in a Docker environment. First things first, install Docker. Docker is agnostic, meaning it really doesn’t matter what platform you use, whether you’re on Windows, Linux or the Mac. Download Docker Docker. Install.\nCreate A Project Folder\n$ mkdir wordpress $ cd wordpress Create a Docker Compose file\nThe docker file for composing an image is called docker-compose.yml. It’s a YAML file that contains instructions on what to do and apps to use.\n$ nano docker-compose.yml Type in the following configuration in the YAML file. In this example, I’m telling docker to install WordPress, MySQL and PHPMyAdmin and using the following TCP ports, credentials, and volumes.\nwordpress: image: wordpress links: - wordpress_db:mysql ports: - 8080:80 volumes: - ~/Docker/wordpress/html:/var/www/html wordpress_db: image: mariadb environment: MYSQL_ROOT_PASSWORD: password phpmyadmin: image: corbinu/docker-phpmyadmin links: - wordpress_db:mysql ports: - 8181:80 environment: MYSQL_USERNAME: root MYSQL_ROOT_PASSWORD: password Run Docker Compose\n$ docker-compose up -d The installation may take anywhere from 5-10 mins or longer. So, grab a cup of coffee.\nAccess WordPress\nOnce installed, open up your browser and access WordPress and PHPMyadmin\nhttp://localhost:8080 http://localhost:8181 You can access the WordPress files from your project’s “wordpress/html” directory.\nThat’s it.\n","permalink":"http://uly.me/posts/wordpress-on-docker/","summary":"\u003cp\u003eWordPress is a content management system for running blogs or websites. Meanwhile, Docker is a software container platform for building, shipping and running applications or utilities. Since there are thousands of Docker images already built, installing an application such as WordPress is fairly easy. In this article, I will show you how to install WordPress, MySQL, PHPMyadmin in a Docker environment. First things first, install Docker. Docker is agnostic, meaning it really doesn’t matter what platform you use, whether you’re on Windows, Linux or the Mac. Download Docker \u003ca href=\"https://www.docker.com/products/overview\"\u003eDocker\u003c/a\u003e. Install.\u003c/p\u003e","title":"wordpress on docker"},{"content":"When adding a new repository in Ubuntu, you can go the PPA route by using the add-apt-repository command. If you’re getting a missing add-apt-repository command, it’s probably not installed. You need to install the “software-properties-common” and “python-software-properties” packages from the Terminal. By the way, if you’re curious, PPA means personal package archive. PPAs are repositories hosted on Launchpad which you can use to install or upgrade packages that are not available in the official Ubuntu repositories. Just think of them as extended repositories.\nIf you’re getting a missing add-apt-repository command, just install the following:\n$ sudo apt-get install software-properties-common python-software-properties Once installed, you can then add other repositories that you want.\nLet’s say you want to install Sublime Text 2, a real popular text editor.\nYou can install Sublime Text 2 via the PPA route using the following.\n$ sudo add-apt-repository ppa:webupd8team/sublime-text-2 $ sudo apt-get update $ sudo apt-get install sublime-text-2 Or install the latest Gimp release:\nsudo add-apt-repository ppa:otto-kesselgulasch/gimp sudo apt-get update sudo apt-get install gimp To revert the changes:\nsudo apt-get install ppa-purge sudo ppa-purge ppa:otto-kesselgulasch/gimp ","permalink":"http://uly.me/posts/missing-add-apt-repository-command/","summary":"\u003cp\u003eWhen adding a new repository in Ubuntu, you can go the PPA route by using the add-apt-repository command. If you’re getting a missing add-apt-repository command, it’s probably not installed. You need to install the “software-properties-common” and “python-software-properties” packages from the Terminal. By the way, if you’re curious, PPA means personal package archive. PPAs are repositories hosted on Launchpad which you can use to install or upgrade packages that are not available in the official Ubuntu repositories. Just think of them as extended repositories.\u003c/p\u003e","title":"missing add-apt-repository command"},{"content":"If you’re running a Linux server, here’s one way of checking as to which ports are open to the public. You can use netstat for that purpose. Netstat is a command-line network utility tool that displays network connections for tcp, routing tables, and a number of network interfaces. It’s available on Linux, MacOS and Windows.\nIn Linux and MacOS, type the following via the Terminal.\nnetstat -tupln # # -l = only services which are listening on some port # -n = show port number, don\u0026#39;t try to resolve the service name # -t = tcp ports # -u = udp ports # -p = name of the program # If you’re in Windows, open up Powershell and type in:\nnetstat -ano | find \u0026#34;LISTENING\u0026#34; # or netstat -o 5 Don’t be surprised as to what your computer is doing.\n","permalink":"http://uly.me/posts/check-open-ports/","summary":"\u003cp\u003eIf you’re running a Linux server, here’s one way of checking as to which ports are open to the public. You can use netstat for that purpose. Netstat is a command-line network utility tool that displays network connections for tcp, routing tables, and a number of network interfaces. It’s available on Linux, MacOS and Windows.\u003c/p\u003e\n\u003cp\u003eIn Linux and MacOS, type the following via the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003enetstat -tupln\n#\n# -l = only services which are listening on some port\n# -n = show port number, don\u0026#39;t try to resolve the service name\n# -t = tcp ports\n# -u = udp ports\n# -p = name of the program\n#\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you’re in Windows, open up Powershell and type in:\u003c/p\u003e","title":"check open ports"},{"content":"If you have trouble emptying the trash this morning, here’s a helpful tip.\nYour OS is essentially telling you the file is in use, but the application is close.\nNothing like running rm -rf on the trash folder.\n# Go the trash directory and delete all! cd ~/.Trash rm -rf * The file is gone!\n","permalink":"http://uly.me/posts/cant-empty-the-trash-can/","summary":"\u003cp\u003eIf you have trouble emptying the trash this morning, here’s a helpful tip.\u003c/p\u003e\n\u003cp\u003eYour OS is essentially telling you the file is in use, but the application is close.\u003c/p\u003e\n\u003cp\u003eNothing like running rm -rf on the trash folder.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Go the trash directory and delete all!\ncd ~/.Trash\nrm -rf *\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe file is gone!\u003c/p\u003e","title":"could not empty the trash can"},{"content":"I have a website called Surfcali.com. It’s a website that provides tide table information for select California beaches. The tide information on the website is auto-generated by the xtide program which is available on most Linux distributions.\nYou can install xtide on Ubuntu by typing this command from the Terminal.\nsudo apt-get install xtide Instead of explaining how the website is implemented using lots of words, it’s probably much easier to explain it via video.\nSo, here’s a short video of how Surfcali.com was put together.\nVideo\n","permalink":"http://uly.me/posts/implementing-surfcali-com/","summary":"\u003cp\u003eI have a website called Surfcali.com. It’s a website that provides tide table information for select California beaches. The tide information on the website is auto-generated by the xtide program which is available on most Linux distributions.\u003c/p\u003e\n\u003cp\u003eYou can install xtide on Ubuntu by typing this command from the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install xtide\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstead of explaining how the website is implemented using lots of words, it’s probably much easier to explain it via video.\u003c/p\u003e","title":"implementing surfcali.com"},{"content":"If you have a video that you would like to share with others, how do you optimize it for the web. I’m using a simple open-source program called Handbrake which you can download for free. It’s available from handbrake.fr. Handbrake is available on Windows, Mac and Linux. Based on my experience with working with Handbrake, I was able to shrink my videos to less than 10% of the original size without sacrificing quality.\nHere’s a short video of how to optimize your videos for the web using Handbrake.\nVideo\n","permalink":"http://uly.me/posts/optimize-your-videos-for-the-web/","summary":"\u003cp\u003eIf you have a video that you would like to share with others, how do you optimize it for the web. I’m using a simple open-source program called Handbrake which you can download for free. It’s available from \u003ca href=\"http://handbrake.fr\"\u003ehandbrake.fr\u003c/a\u003e. Handbrake is available on Windows, Mac and Linux. Based on my experience with working with Handbrake, I was able to shrink my videos to less than 10% of the original size without sacrificing quality.\u003c/p\u003e","title":"optimize your videos for the web"},{"content":"The App Store on my iPad was displaying a white blank screen. I’m not sure what caused it.\nIt may have been my router. It stopped giving out dynamic IP addresses. For some reason it affected the App Store.\nThe only way I was able to fix it, was to go to my iPad’s Settings \u0026gt; and select iTunes \u0026amp; App Store.\nClick on the Apple ID (email address) and then Sign Out. Reboot the iPad. Once the iPad has rebooted, the App Store started working again. Weird.\n","permalink":"http://uly.me/posts/app-store-blank-screen/","summary":"\u003cp\u003eThe App Store on my iPad was displaying a white blank screen. I’m not sure what caused it.\u003c/p\u003e\n\u003cp\u003eIt may have been my router. It stopped giving out dynamic IP addresses. For some reason it affected the App Store.\u003c/p\u003e\n\u003cp\u003eThe only way I was able to fix it, was to go to my iPad’s \u003cstrong\u003eSettings\u003c/strong\u003e \u0026gt; and select \u003cstrong\u003eiTunes \u0026amp; App Store\u003c/strong\u003e.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eClick on the Apple ID (email address) and then \u003cstrong\u003eSign Out\u003c/strong\u003e.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eReboot\u003c/strong\u003e the iPad.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eOnce the iPad has rebooted, the App Store started working again. Weird.\u003c/p\u003e","title":"app store blank screen"},{"content":"Whitespace, line breaks, spaces and tabs are collapsed by default in HTML documents. To add space, we can add “\u0026amp;nbsp;” which translates to space, to add some separation between elements. In addition \u0026lt;br/\u0026gt; or line breaks can also be utilized to add space. There is a HTML property called white-space which can be used to configure how the whitespace inside the element is displayed. The following is a list of whitespace options.\nSyntax /* Keyword values */ white-space: normal; white-space: nowrap; white-space: pre; white-space: pre-wrap; white-space: pre-line; /* Global values */ white-space: inherit; white-space: initial; white-space: unset; Usage p { white-space: normal } white-space: normal This is the default format. No breaks between paragraphs.\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.#### white-space: nowrap With nowrap, paragraph lines are extended out. No wrapping. No breaks between paragraphs.\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.#### white-space: pre-line With pre-line, breaks are inserted between paragraphs. Paragraphs are wrapped.\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. The couple of examples above shows how elements can be styled using the white-space property.","permalink":"http://uly.me/posts/css-white-space-property/","summary":"\u003cp\u003eWhitespace, line breaks, spaces and tabs are collapsed by default in HTML documents. To add space, we can add “\u0026amp;nbsp;” which translates to space, to add some separation between elements. In addition \u0026lt;br/\u0026gt; or line breaks can also be utilized to add space. There is a HTML property called \u003cstrong\u003ewhite-space\u003c/strong\u003e which can be used to configure how the whitespace inside the element is displayed. The following is a list of whitespace options.\u003c/p\u003e","title":"css white-space property"},{"content":"A HTML table can be difficult to read, especially if there are hundreds of rows. Reading across a row can sometimes be a challenge. One way of making the table more legible is to alternate the background color of each row. By the way, the plugin used on this blog to display code uses zebra stripes. Zebra stripping can be done by toggling a variable and alternately displaying an odd or even CSS class as it goes through the loop.\nThe Code:\n// set variable initially to \u0026#34;odd.\u0026#34; // loop 4 times for demo purposes. // toggle CSS classes while in a loop. $c = \u0026#34;odd\u0026#34;; $count = 0; echo \u0026#34; | Data | |---| \u0026#34;; The Result:\n| Data | |---| | Data | | Data | | Data | The Style:\n.odd { background-color: #fff; } .even { background-color: #eee; } To see it in action, visit CodePad.\n","permalink":"http://uly.me/posts/how-to-zebra-stripe-a-table/","summary":"\u003cp\u003eA HTML table can be difficult to read, especially if there are hundreds of rows. Reading across a row can sometimes be a challenge. One way of making the table more legible is to alternate the background color of each row. By the way, the plugin used on this blog to display code uses zebra stripes. Zebra stripping can be done by toggling a variable and alternately displaying an odd or even CSS class as it goes through the loop.\u003c/p\u003e","title":"how to zebra stripe a table"},{"content":"WP-CLI is a set of command-line tools for managing WordPress websites. With just a few simple commands, you can manage WordPress from the command line without the need to login to the Admin Dashboard and navigate the pages. You can install, update and delete plugins and themes, perform backups, configure standard and multisite installs and much more — all without ever using a web browser.\nHow to install WP-CLI\n$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar Make WP-CLI Executable\n$ chmod +x wp-cli.phar Rename wp-cli.phar to wp and move to a folder where it can be executed globally.\n$ sudo mv wp-cli.phar /usr/local/bin/wp How to Install and Activate Theme from the command line\n$ wp theme install twentytwelve $ wp theme activate twentytwelve How to Install, Activate, Deactivate a Plugin\n$ wp plugin install hello-dolly $ wp plugin activate hello-dolly $ wp plugin deactivate hello-dolly How to update WordPress to the latest core release\n$ wp core update How to list the last 5 posts\n$ wp post list --post_type=post --posts_per_page=5 --format=json The command above will spit out an array in JSON format.\nRead the rest of WP-CLI documentation.\n","permalink":"http://uly.me/posts/wp-cli/","summary":"\u003cp\u003eWP-CLI is a set of command-line tools for managing WordPress websites. With just a few simple commands, you can manage WordPress from the command line without the need to login to the Admin Dashboard and navigate the pages. You can install, update and delete plugins and themes, perform backups, configure standard and multisite installs and much more — all without ever using a web browser.\u003c/p\u003e\n\u003cp\u003eHow to install WP-CLI\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake WP-CLI Executable\u003c/p\u003e","title":"wp-cli"},{"content":"phpMyAdmin is an open-source MySQL database administration application written in PHP. The software allows database administrators, web administrators, application programmers to perform several database functions via the browser. Functions such as browse and drop databases and tables, views fields and indexes, create, copy, drop, rename and alter databases, tables, fields and indexes, perform queries, update and delete, to name just a few.\nSince phpMyAdmin has direct access to your database, it needs to be secure. By default, phpMyAdmin is secured using it’s built-in login feature. If you like to make it even more secure, you can add .htaccess password protection to it by simply adding .htaccess file to the phpmyadmin pages and creating username and password file to go along with it. The following instructions will show you how to add .htaccess protection to phpMyAdmin.\nEdit the phpMyAdmin Apache conf file.\nsudo nano /etc/phpmyadmin/apache.conf Add the following in the /usr/share/phpmyadmin directory section.\n\u0026lt;directory\u0026gt; \u0026lt;ifmodule mod_authn_file.c=\u0026#34;\u0026#34;\u0026gt; AuthType Basic AuthName \u0026#34;phpMyAdmin\u0026#34; AuthUserFile /etc/phpmyadmin/htpasswd.protect \u0026lt;/ifmodule\u0026gt; Require valid-user \u0026lt;/directory\u0026gt; Make sure the htpasswd file is not accessible from the web.\nCreate the htpasswd file. You’ll be asked to enter the password twice.\nsudo htpasswd -c /etc/phpmyadmin/htpasswd.protect username Finally, to make sure your changes are in effect, reboot Apache.\nsudo service apache2 restart ","permalink":"http://uly.me/posts/password-protect-phpmyadmin/","summary":"\u003cp\u003ephpMyAdmin is an open-source MySQL database administration application written in PHP. The software allows database administrators, web administrators, application programmers to perform several database functions via the browser. Functions such as browse and drop databases and tables, views fields and indexes, create, copy, drop, rename and alter databases, tables, fields and indexes, perform queries, update and delete, to name just a few.\u003c/p\u003e\n\u003cp\u003eSince phpMyAdmin has direct access to your database, it needs to be secure. By default, phpMyAdmin is secured using it’s built-in login feature. If you like to make it even more secure, you can add .htaccess password protection to it by simply adding .htaccess file to the phpmyadmin pages and creating username and password file to go along with it. The following instructions will show you how to add .htaccess protection to phpMyAdmin.\u003c/p\u003e","title":"password protect phpmyadmin"},{"content":"Passing variables via the URL in PHP can be dangerous. This is the case if you don’t properly filter and sanitize your inputs. This could lead to potential database exploits via SQL injections. If you are using a download script, someone might be able traverse your directories and gain access to your system files. After all, you don’t want anyone looking at your passwd file. Back to PHP, it’s ideal if that we avoid passing variables via URL. We can use sessions.\nPassing Variables via URL\n// A variable is passed from one page to another via a link. \u0026lt;a href=\u0026#34;page2.php?file=sample.txt\u0026#34;\u0026gt;Link\u0026lt;/a\u0026gt; // Someone can traverse the directory and access system files. \u0026lt;a href=\u0026#34;page2.php?file=../../../../../etc/passwd\u0026#34;\u0026gt;Link\u0026lt;/a\u0026gt; Passing variables via Sessions\n// Page 1 // start a session session_start(); // set filename $file = \u0026#39;sample.txt\u0026#39;; $_SESSION[\u0026#39;file\u0026#39;]=$file; \u0026lt;a href=\u0026#34;page2.php\u0026#34;\u0026gt;Page 2\u0026lt;/a\u0026gt; // Page 2 // start a session session_start(); $file=$_SESSION[\u0026#39;file\u0026#39;]); // display filename echo $file; // remove a session variable unset($_SESSION[\u0026#39;file\u0026#39;]); // unset entire session session_destroy(); Viewer must accept cookie for sessions to work.\nSessions are not foolproof. They can be hijacked, but they are a heck more secure than passing variables via the URL.\n","permalink":"http://uly.me/posts/passing-variables-using-session/","summary":"\u003cp\u003ePassing variables via the URL in PHP can be dangerous. This is the case if you don’t properly filter and sanitize your inputs. This could lead to potential database exploits via SQL injections. If you are using a download script, someone might be able traverse your directories and gain access to your system files. After all, you don’t want anyone looking at your passwd file. Back to PHP, it’s ideal if that we avoid passing variables via URL. We can use sessions.\u003c/p\u003e","title":"passing variables using session"},{"content":"This article will show you how to make a WordPress Page viewable by the admin only. This is really quite handy if you’re creating a custom WordPress Template. You can make certain parts or the entire page viewable by the admin only by placing the code below in your WordPress Page Template.\nif ( current_user_can( \u0026#39;manage_options\u0026#39; ) ) { // display text here for user with admin privilege } else { // display text here for user without admin privilege } There has been some confusion whether to use is_admin() instead of current_user_can(‘manage_options’). is_admin() is a conditional to check if the user is in the Dashboard or in the Administration Panel. It’s just a boolean conditional that will return true if the URL being accessed is in the admin section.\nif ( is_admin() ) { // returns true that user is in the admin panel } else { // returns false if otherwise } It’s best to use current_user_can(‘manage_options’) when checking if user is an admin.\n","permalink":"http://uly.me/posts/viewable-by-admin-only/","summary":"\u003cp\u003eThis article will show you how to make a WordPress Page viewable by the admin only. This is really quite handy if you’re creating a custom WordPress Template. You can make certain parts or the entire page viewable by the admin only by placing the code below in your WordPress Page Template.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif ( current_user_can( \u0026#39;manage_options\u0026#39; ) ) {\n    // display text here for user with admin privilege\n} else {\n    // display text here for user without admin privilege\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere has been some confusion whether to use \u003ca href=\"https://codex.wordpress.org/Function_Reference/is_admin\"\u003eis_admin()\u003c/a\u003e instead of \u003ca href=\"https://codex.wordpress.org/Function_Reference/current_user_can\"\u003ecurrent_user_can(‘manage_options’)\u003c/a\u003e. is_admin() is a conditional to check if the user is in the Dashboard or in the Administration Panel. It’s just a boolean conditional that will return true if the URL being accessed is in the admin section.\u003c/p\u003e","title":"viewable by admin only"},{"content":"I’ve been using the Mac OS for six years now. Prior to that, I was an Ubuntu user for 10 years. I do miss working with Linux. Part of the reason I switched, I was tired of constantly fixing the Ubuntu desktop. Every time there was a new release, something was broken and I needed to fix it. Then Ubuntu Unity desktop came along. That essentially was the last straw. I dabbled with Mint a little bit, but it only lasted for a couple of months.\nThese past few months, I’ve been trying to rekindle my love for Linux. I’m trying out two distros. I’m running Ubuntu 16.04 LTS and Linux Mint 18, dual booting each distro sharing a 1TB hard drive. Each distro is taking up 500GB. Both are running the Cinnamon desktop. There are a few issues here and there. It’s not quite the polish product yet. On both instances, I had to install the Chromium browser because Firefox, the default browser, is not just up to snuff.\nOverall, Ubuntu and Linux Mint have improved tremendously since I last used them. The Sound and WiFi network settings are much, much more easier to configure than the previous iterations. If you were ask me which distro do I prefer now, I can’t give you an answer at the moment. Time will tell. It’s going to take a while to get used to navigating and using the Cinnamon desktop effectively. Maybe a follow up post is in order.\n","permalink":"http://uly.me/posts/dual-booting-ubuntu-and-mint/","summary":"\u003cp\u003eI’ve been using the Mac OS for six years now. Prior to that, I was an Ubuntu user for 10 years. I do miss working with Linux. Part of the reason I switched, I was tired of constantly fixing the Ubuntu desktop. Every time there was a new release, something was broken and I needed to fix it. Then Ubuntu Unity desktop came along. That essentially was the last straw. I dabbled with Mint a little bit, but it only lasted for a couple of months.\u003c/p\u003e","title":"dual booting ubuntu and mint"},{"content":"Browsers behave differently when it comes to linking media files. Sometimes it will play them directly on the browser. Sometimes it will download them. Each browser seems to have their own rules. So, how do we force all browsers to download media files with just a click of a link.\nA simple link like the one below simply won’t work.\n\u0026lt;a href=\u0026#34;video.mp4\u0026#34;\u0026gt;Download\u0026lt;/a\u0026gt; One way of forcing downloads is to use a PHP function called readfile.\nWe have a file below called dl.php. We pass the filename to it, as well as set the path and URL.\n$filename = $_GET[\u0026#39;file\u0026#39;]; $filepath = \u0026#34;http://domain.com/download/\u0026#34;; $url = $filepath.$filename; header(\u0026#34;Content-disposition: attachment; filename=\u0026#34;.$filename.\u0026#34;\u0026#34;); header(\u0026#34;Content-type: application/octet-stream\u0026#34;); readfile(\u0026#34;\u0026#34;.$url.\u0026#34;\u0026#34;); Our HTML download link will look like this.\n\u0026lt;a href=\u0026#34;dl.php?file=video.mp4\u0026#34;\u0026gt;Download\u0026lt;/a\u0026gt; It’s one way of forcing a download via the PHP route.\n","permalink":"http://uly.me/posts/how-to-force-downloads/","summary":"\u003cp\u003eBrowsers behave differently when it comes to linking media files. Sometimes it will play them directly on the browser. Sometimes it will download them. Each browser seems to have their own rules. So, how do we force all browsers to download media files with just a click of a link.\u003c/p\u003e\n\u003cp\u003eA simple link like the one below simply won’t work.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;a href=\u0026#34;video.mp4\u0026#34;\u0026gt;Download\u0026lt;/a\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOne way of forcing downloads is to use a \u003ca href=\"http://php.net\"\u003ePHP\u003c/a\u003e function called \u003ca href=\"http://php.net/manual/en/function.readfile.php\"\u003ereadfile\u003c/a\u003e.\u003c/p\u003e","title":"how to force downloads"},{"content":"Exim4 is a MTA or message transfer agent that runs on Linux systems. It’s freely available under GNU Linux. If you need to run mail from a server or send an email through an app, you’ll need to install Exim4. It can be installed in place of Sendmail or Postfix.\nTo install Exim4, open up your Terminal.\n$ sudo apt install exim4 Configure Exim4.\n$ sudo dpkg-reconfigure exim4-config You’ll be asked several questions.\nSelect “internet site” for type of mail configuration. Enter your domain name when asked about system mail name. Answer “127.0.0.1 ; ::1” when asked about incoming SMTP connections Answer the default answers for the next 3 questions. Answer “No” for Dial on demand. Answer “mbox” for delivery method for local mail. Answer “yes” to split configuration into small files. If you need to reconfigure Exim4, just re-run the reconfigure command.\nDon’t try to edit the /var/lib/exim4/config.autogenerated file.\nTest if Exim4 is sending out emails.\n$ mail -s \u0026#34;Your Subject\u0026#34; recepient@email.com $ Hello there. This is the body of the message. Type Ctrl-D to send the message.\nAnother way to test if Exim4 is working is to use WordPress. There’s a lost password link below the login page. Click on that. Supply a valid user email address. You should received an email directly from WordPress.\n","permalink":"http://uly.me/posts/install-exim4-on-ubuntu-server/","summary":"\u003cp\u003eExim4 is a MTA or message transfer agent that runs on Linux systems. It’s freely available under GNU Linux. If you need to run mail from a server or send an email through an app, you’ll need to install Exim4. It can be installed in place of Sendmail or Postfix.\u003c/p\u003e\n\u003cp\u003eTo install Exim4, open up your Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo apt install exim4\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eConfigure Exim4.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo dpkg-reconfigure exim4-config\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou’ll be asked several questions.\u003c/p\u003e","title":"install exim4 on ubuntu server"},{"content":"Several months ago, I’ve installed an app called CleanMyMac. Big mistake. I didn’t like it much. I deleted it shortly after. The uninstall didn’t quite exactly remove everything. This morning, I updated my computer with the latest Mac updates. It required a reboot. Sure enough, the CleanMyMac notifications came back. Apparently, there’s some pieces of the app that are still running on my machine.\nThe only way I was able to delete anything related to the CleanMyMac app was to use a couple of tools. One is called Find Any File, a handy utility for finding obscure files in your OS. The other is the handy tool called the Terminal. Start with the Find Any File app and search for files that contain the words “CleanMyMac” and “macaw.” The Find Any File app will show you a list of files and their locations. You should be able to delete the files directly from the app. However, there are some files that are write-protected. They can be deleted using a sudo account on the Terminal.\nOpen up your Terminal and start deleting the files using “sudo rm” command. You’ll be ask to provide the admin password. Don’t forget to empty the Trash.\nThat should do the trick.\n","permalink":"http://uly.me/posts/remove-cleanmymac/","summary":"\u003cp\u003eSeveral months ago, I’ve installed an app called \u003ca href=\"http://macpaw.com/cleanmymac\"\u003eCleanMyMac\u003c/a\u003e. Big mistake. I didn’t like it much. I deleted it shortly after. The uninstall didn’t quite exactly remove everything. This morning, I updated my computer with the latest Mac updates. It required a reboot. Sure enough, the CleanMyMac notifications came back. Apparently, there’s some pieces of the app that are still running on my machine.\u003c/p\u003e\n\u003cp\u003eThe only way I was able to delete anything related to the CleanMyMac app was to use a couple of tools. One is called \u003ca href=\"http://apps.tempel.org/FindAnyFile/\"\u003eFind Any File\u003c/a\u003e, a handy utility for finding obscure files in your OS. The other is the handy tool called the \u003ca href=\"https://en.wikipedia.org/wiki/Terminal_(OS_X)\"\u003eTerminal\u003c/a\u003e. Start with the Find Any File app and search for files that contain the words “CleanMyMac” and “macaw.” The Find Any File app will show you a list of files and their locations. You should be able to delete the files directly from the app. However, there are some files that are write-protected. They can be deleted using a sudo account on the Terminal.\u003c/p\u003e","title":"remove cleanmymac"},{"content":"I’m thinking about using the Linux desktop again after 4 years of inactivity. The MacOS was the desktop of choice. I’ve been happy with the switch. I don’t anticipate abandoning it any time soon. Lately I thought about sharpening up my Linux skills after having been dormant for years. I need a Linux platform that I can work with. Ubuntu is my default, but there are other distros equally interesting. Mint, Debian and Fedora come to mind. Instead of having multiple boot partitions, I might install Ubuntu as the base distro and install Virtualbox. Other distros can be fired up as virtual machines. In that way, it’s simple to manage. I just need a heftier machine that can handle several VMs running at the same time. That’s the plan for the next several weeks.\n","permalink":"http://uly.me/posts/the-return-of-the-linux-desktop/","summary":"\u003cp\u003eI’m thinking about using the Linux desktop again after 4 years of inactivity. The \u003ca href=\"http://www.apple.com/osx/\"\u003eMacOS\u003c/a\u003e was the desktop of choice. I’ve been happy with the switch. I don’t anticipate abandoning it any time soon. Lately I thought about sharpening up my Linux skills after having been dormant for years. I need a Linux platform that I can work with. \u003ca href=\"http://ubuntu.com\"\u003eUbuntu\u003c/a\u003e is my default, but there are other distros equally interesting. \u003ca href=\"https://www.linuxmint.com/\"\u003eMint\u003c/a\u003e, \u003ca href=\"https://www.debian.org/\"\u003eDebian\u003c/a\u003e and \u003ca href=\"https://getfedora.org/\"\u003eFedora\u003c/a\u003e come to mind. Instead of having multiple boot partitions, I might install Ubuntu as the base distro and install \u003ca href=\"https://www.virtualbox.org/\"\u003eVirtualbox\u003c/a\u003e. Other distros can be fired up as virtual machines. In that way, it’s simple to manage. I just need a heftier machine that can handle several VMs running at the same time. That’s the plan for the next several weeks.\u003c/p\u003e","title":"the return of the linux desktop"},{"content":"One of the worst things that could happen to your blog is losing your login credentials. It’s a rare event, but it does happen occasionally. This is particularly true if you run hundreds of blogs and websites. Keeping track of all usernames and passwords can be a bit of a challenge.\nIf you have forgotten your WordPress password, you can quickly recover it, by using the “Lost your password” link underneath the login form. In my case, WordPress mail was not working. So, not only I can’t remember my password, but I also can’t send out lost passwords via email.\nThankfully, I had access to PHPMyadmin, a MySQL database administration tool.\nLog in to PHPMyadmin. Access the WordPress database and look for the wp_users table. Edit the admin user and change the “user_pass” field. The WordPress password field uses the MD5 encryption instead of being in the clear.\nSave your changes. Log in to WordPress.\n","permalink":"http://uly.me/posts/change-wordpress-password/","summary":"\u003cp\u003eOne of the worst things that could happen to your blog is losing your login credentials. It’s a rare event, but it does happen occasionally. This is particularly true if you run hundreds of blogs and websites. Keeping track of all usernames and passwords can be a bit of a challenge.\u003c/p\u003e\n\u003cp\u003eIf you have forgotten your WordPress password, you can quickly recover it, by using the “Lost your password” link underneath the login form. In my case, WordPress mail was not working. So, not only I can’t remember my password, but I also can’t send out lost passwords via email.\u003c/p\u003e","title":"change wordpress password"},{"content":"The following instructions will perform the latest Icecast2 server upgrade on your Ubuntu Server via the PPA route.\nLogin to your Ubuntu Server via SSH. Substitute your own username and server. $ ssh ulysses@server.com Add Icecast2 PPA to your sources list. Since I’m running Ubuntu 12.04, I’ll use the 12.04 repository here. $ sudo sh -c \u0026#34;echo deb http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04 ./ \u0026gt; /etc/apt/sources.list.d/icecast.list\u0026#34; Add the GPG key to the apt sources keyring. I’ll use the 12.04 release key here as well. $ wget -qO - http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04/Release.key | sudo apt-key add - Run Update to begin the upgrade process to the latest version of Icecast2. $ sudo apt-get update $ sudo apt-get upgrade The Icecast2 install script will run and ask you to overwrite your previous configuration. It’s up to you to keep or overwrite the file.\nIf you’re using your previous configuration file, it may throw out some errors and warnings, which you will probably need to fix.\nFinally, test your Icecast2 server by sending a stream to it.\n","permalink":"http://uly.me/posts/upgrading-icecast2/","summary":"\u003cp\u003eThe following instructions will perform the latest Icecast2 server upgrade on your Ubuntu Server via the PPA route.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eLogin to your Ubuntu Server via SSH. Substitute your own username and server.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ ssh ulysses@server.com\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"2\"\u003e\n\u003cli\u003eAdd Icecast2 PPA to your sources list. Since I’m running Ubuntu 12.04, I’ll use the 12.04 repository here.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo sh -c \u0026#34;echo deb http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04 ./ \u0026gt; /etc/apt/sources.list.d/icecast.list\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"3\"\u003e\n\u003cli\u003eAdd the GPG key to the apt sources keyring. I’ll use the 12.04 release key here as well.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ wget -qO - http://download.opensuse.org/repositories/home:/dm8tbr/xUbuntu_12.04/Release.key | sudo apt-key add -\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"4\"\u003e\n\u003cli\u003eRun Update to begin the upgrade process to the latest version of Icecast2.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ sudo apt-get update\n$ sudo apt-get upgrade\n\u003c/code\u003e\u003c/pre\u003e\u003col start=\"5\"\u003e\n\u003cli\u003e\n\u003cp\u003eThe Icecast2 install script will run and ask you to overwrite your previous configuration. It’s up to you to keep or overwrite the file.\u003c/p\u003e","title":"upgrading icecast2"},{"content":"Niginx is primarily a web server, but it can also run as a proxy server, load balancer and a HTTP cache.\nIf you’re running on Debian, Ubuntu, Red Hat or CentOS, the following are several ways of restarting Nginx.\n# /etc/init.d/nginx restart # /etc/init.d/nginx reload # service nginx restart # service nginx reload # nginx -s reload The last example is more universal and will run in any Linux flavor.\n","permalink":"http://uly.me/posts/restarting-nginx/","summary":"\u003cp\u003eNiginx is primarily a web server, but it can also run as a proxy server, load balancer and a HTTP cache.\u003c/p\u003e\n\u003cp\u003eIf you’re running on Debian, Ubuntu, Red Hat or CentOS, the following are several ways of restarting Nginx.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# /etc/init.d/nginx restart\n# /etc/init.d/nginx reload\n# service nginx restart\n# service nginx reload\n# nginx -s reload\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe last example is more universal and will run in any Linux flavor.\u003c/p\u003e","title":"restarting nginx"},{"content":"I’m working on a client site running WordPress but without any access to FTP. It’s an interesting dilemma because WordPress will allow you to add new themes and plugins via its interface. It does so by allowing you to upload zipped files of the themes and plugins. Obviously, you don’t want to keep doing this especially you want to add just one file to the theme.\nI needed to create a new page template on the Genesis platform. My client is using the Enterprise Pro child theme. There’s a command in PHP called ‘touch’ which allows you to create a new file. You can insert this command on the top of your theme’s header file in WordPress. Since I’m using Genesis, the child theme doesn’t have a header, therefore I had to do insert the command in the parent theme.\nIn the WordPress Dashboard under Appearance, choose the Editor. On the top right-hand side of the page, select the Genesis parent theme from the dropdown menu to edit. Click on the ‘Theme Header’ to edit, and add this line of code on top of the header.php file.\ntouch(\u0026#39;wp-content/themes/enterprise-pro/template.php\u0026#39;); The command has to run once, so you’ll need to access the website at least once. Remove the line of code afterwards. The PHP ‘touch’ function will create a new empty file called template.php inside the Enterprise Pro theme. You can check it by navigating the editor once again, and selecting this time the ‘Enterprise Pro’ theme. Look for the new file called ‘template.php.’\nIn my case, I decided to change the page template to another filename, so I ended running it for the second time by inserting the rename function on the header.php file once again. Here’s the command to rename template.php to newtemplate.php.\nrename(\u0026#39;wp-content/themes/enterprise-pro/template.php\u0026#39;, \u0026#39;wp-content/themes/enterprise-pro/newtemplate.php\u0026#39;); Anyway, it works, but use this with extreme caution. If you’re not familiar with PHP and WordPress, you can render the entire website useless if you somehow inserted the wrong PHP code. There’s no FTP to back out the files. The WordPress Dashboard may no longer work. So, work on your own peril.\n","permalink":"http://uly.me/posts/add-files-in-wordpress-without-ftp/","summary":"\u003cp\u003eI’m working on a client site running WordPress but without any access to FTP. It’s an interesting dilemma because WordPress will allow you to add new themes and plugins via its interface. It does so by allowing you to upload zipped files of the themes and plugins. Obviously, you don’t want to keep doing this especially you want to add just one file to the theme.\u003c/p\u003e\n\u003cp\u003eI needed to create a new page template on the Genesis platform. My client is using the Enterprise Pro child theme. There’s a command in PHP called ‘touch’ which allows you to create a new file. You can insert this command on the top of your theme’s header file in WordPress. Since I’m using Genesis, the child theme doesn’t have a header, therefore I had to do insert the command in the parent theme.\u003c/p\u003e","title":"add files in wordpress without ftp"},{"content":"PHP is installed by default on all Macs since OS X version 10.0.0. You can install and use MAMP, but if you prefer to use the pre-loaded version of PHP, then you may need to update it to the latest stable release. Fortunately, there’s a binary package out there that will simplify your life.\nIf you like to install PHP 5.6 stable release, all you need to do is run the following from the command line:\ncurl -s http://php-osx.liip.ch/install.sh | bash -s 5.6 If you feel adventurous, you can try PHP 7 stable release.\ncurl -s http://php-osx.liip.ch/install.sh | bash -s 7.0 The installer packager will ask you for your password. PHP will be installed in /usr/local/php5.\nEdit your .profile and include the PATH of the new PHP version.\nnano ~/.profile Insert the following:\nexport PATH=/usr/local/php5/bin:$PATH To be sure your using the new version, check the PHP version:\nphp -v You should see something similar to this:\nPHP 5.6.19 (cli) (built: Mar 4 2016 22:35:42) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans You now have the latest PHP 5.6 stable release.\n","permalink":"http://uly.me/posts/update-php-stable-release-on-mac/","summary":"\u003cp\u003ePHP is installed by default on all Macs since OS X version 10.0.0. You can install and use MAMP, but if you prefer to use the pre-loaded version of PHP, then you may need to update it to the latest stable release. Fortunately, there’s a binary package out there that will simplify your life.\u003c/p\u003e\n\u003cp\u003eIf you like to install PHP 5.6 stable release, all you need to do is run the following from the command line:\u003c/p\u003e","title":"update php stable release on mac"},{"content":"One of my projects this week requires editing a blob. A blob is a binary large object used primarily for storing images, audio and other media types in the database. Unfortunately, the application didn’t allow me to edit a blob. So off to the PHPMyAdmin I went. PHPMyAdmin is a MySQL administration tool.\nBy default, the blob entries in PHPMyAdmin can’t be edited. Simple texts in blobs are sometimes scrambled. In order to make changes to the blob entries, we need to reconfigure PHPMyAdmin by editing the configuration file.\nEdit the /etc/phpmyadmin/config.inc.php file.\n$ sudo nano /etc/phpmyadmin/config.inc.php Add the following entries at the end of the file.\n$cfg[\u0026#39;ProtectBinary\u0026#39;] = FALSE; $cfg[\u0026#39;DisplayBinaryAsHex\u0026#39;] = FALSE; $cfg[\u0026#39;ShowBlob\u0026#39;] = TRUE; There is no need to restart any services. Changes are automatically reflected in PHPMyAdmin.\n","permalink":"http://uly.me/posts/editing-a-blob-in-phpmyadmin/","summary":"\u003cp\u003eOne of my projects this week requires editing a blob. A blob is a binary large object used primarily for storing images, audio and other media types in the database. Unfortunately, the application didn’t allow me to edit a blob. So off to the PHPMyAdmin I went. PHPMyAdmin is a MySQL administration tool.\u003c/p\u003e\n\u003cp\u003eBy default, the blob entries in PHPMyAdmin can’t be edited. Simple texts in blobs are sometimes scrambled. In order to make changes to the blob entries, we need to reconfigure PHPMyAdmin by editing the configuration file.\u003c/p\u003e","title":"editing a blob in phpmyadmin"},{"content":"Today, I would like to share with you how to create a WordPress countdown plugin of a future date and time. The plugin output displays the number of days, hours, minutes and seconds left. The plugin uses a WordPress shortcode that you can insert inside your post. A Shortcode makes it easier to display results in WordPress.\nOutput: [counting_down_the_days]\nHere’s the plugin code:\n/* Plugin Name: Counting Down the Days Plugin URI: http://uly.me Description: php countdown Version: 1.0 Author: Ulysses Ronquillo Author URI: http://uly.me */ // place your php code here function urr_countdown_days() { date_default_timezone_set(\u0026#39;Americas/New_York\u0026#39;); $date = strtotime(\u0026#34;January 27, 2017 7:15 PM\u0026#34;); $remaining = $date - time(); $days_remaining = floor($remaining / 86400); $hours_remaining = floor(($remaining % 86400) / 3600); $minutes_remaining = floor(($remaining-($days_remaining*60*60*24)-($hours_remaining*60*60))/60); $seconds_remaining = floor(($remaining-($days_remaining*60*60*24)-($hours_remaining*60*60))-($minutes_remaining*60)); return \u0026#39;There are \u0026#39;.$days_remaining.\u0026#39; days and \u0026#39;.$hours_remaining.\u0026#39; hours and \u0026#39;.$minutes_remaining.\u0026#39; minutes and \u0026#39;.$seconds_remaining.\u0026#39; seconds left.\u0026#39;; } add_shortcode(\u0026#39;counting_down_the_days\u0026#39;,\u0026#39;urr_countdown_days\u0026#39;); The PHP date function is used to calculate the days, hours, minutes and seconds remaining and returns the output. The script is one of many PHP examples online on how to perform countdowns. This was one of the more popular ones. The script also uses the PHP floor function to get the lowest integer while ignoring the leftover fraction or remainder. To use the plugin, place the shortcode ‘counting_down_the_days’ (wrap it in square brackets) anywhere inside your WordPress post.\nOutput: [counting_down_the_days]\nIf you set a date in the past, the output will say, “Set a future date!”\n","permalink":"http://uly.me/posts/counting-down-the-days/","summary":"\u003cp\u003eToday, I would like to share with you how to create a WordPress countdown plugin of a future date and time. The plugin output displays the number of days, hours, minutes and seconds left. The plugin uses a WordPress shortcode that you can insert inside your post. A Shortcode makes it easier to display results in WordPress.\u003c/p\u003e\n\u003cp\u003eOutput: [counting_down_the_days]\u003c/p\u003e\n\u003cp\u003eHere’s the plugin code:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/*\nPlugin Name: Counting Down the Days\nPlugin URI: http://uly.me\nDescription: php countdown\nVersion: 1.0\nAuthor: Ulysses Ronquillo\nAuthor URI: http://uly.me\n*/\n\n// place your php code here\n\nfunction urr_countdown_days() { \n\ndate_default_timezone_set(\u0026#39;Americas/New_York\u0026#39;);\n$date = strtotime(\u0026#34;January 27, 2017 7:15 PM\u0026#34;);\n$remaining         = $date - time();\n$days_remaining    = floor($remaining / 86400);\n$hours_remaining   = floor(($remaining % 86400) / 3600);\n$minutes_remaining = floor(($remaining-($days_remaining*60*60*24)-($hours_remaining*60*60))/60);\n$seconds_remaining = floor(($remaining-($days_remaining*60*60*24)-($hours_remaining*60*60))-($minutes_remaining*60));\n\nreturn \u0026#39;There are \u0026#39;.$days_remaining.\u0026#39; days and \u0026#39;.$hours_remaining.\u0026#39; hours and \u0026#39;.$minutes_remaining.\u0026#39; minutes and \u0026#39;.$seconds_remaining.\u0026#39; seconds left.\u0026#39;;\n\n}\nadd_shortcode(\u0026#39;counting_down_the_days\u0026#39;,\u0026#39;urr_countdown_days\u0026#39;);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe PHP date function is used to calculate the days, hours, minutes and seconds remaining and returns the output. The script is one of many PHP examples online on how to perform countdowns. This was one of the more popular ones. The script also uses the PHP floor function to get the lowest integer while ignoring the leftover fraction or remainder. To use the plugin, place the shortcode ‘counting_down_the_days’ (wrap it in square brackets) anywhere inside your WordPress post.\u003c/p\u003e","title":"counting down the days"},{"content":"I’m running Ubiquiti’s Unifi Cotroller on one of my websites. I did the sudo apt-get update to perform an update recently and found out that the Ubiquiti’s repository is broken. As it turns out, Ubiquiti has changed the location of their repository to the following location:\ndeb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti You have to edit the /etc/apt/sources.list file to change the previous entry with the one above.\nAfter the change, the update and upgrade went very well.\n","permalink":"http://uly.me/posts/ubiquiti-ubuntu-repository/","summary":"\u003cp\u003eI’m running Ubiquiti’s Unifi Cotroller on one of my websites. I did the sudo apt-get update to perform an update recently and found out that the Ubiquiti’s repository is broken. As it turns out, Ubiquiti has changed the location of their repository to the following location:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003edeb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou have to edit the /etc/apt/sources.list file to change the previous entry with the one above.\u003c/p\u003e\n\u003cp\u003eAfter the change, the update and upgrade went very well.\u003c/p\u003e","title":"ubiquiti ubuntu repository"},{"content":"The following are instructions on how to change your MySQL password from the Unix command line.\nLogin to MySQL and access MySQL table.\nmysql -u root -p use mysql; Change the password for any user, flush privileges and quit.\nupdate user set password=PASSWORD(\u0026#39;new_password\u0026#39;) where User=\u0026#39;root\u0026#39;; flush privileges; quit Make sure to make password changes on your applications as well.\nIn WordPress, edit the wp-config.php file to change database password.\n","permalink":"http://uly.me/posts/change-mysql-password/","summary":"\u003cp\u003eThe following are instructions on how to change your MySQL password from the Unix command line.\u003c/p\u003e\n\u003cp\u003eLogin to MySQL and access MySQL table.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003emysql -u root -p\nuse mysql;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eChange the password for any user, flush privileges and quit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eupdate user set password=PASSWORD(\u0026#39;new_password\u0026#39;) where User=\u0026#39;root\u0026#39;;\nflush privileges;\nquit\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake sure to make password changes on your applications as well.\u003c/p\u003e\n\u003cp\u003eIn WordPress, edit the wp-config.php file to change database password.\u003c/p\u003e","title":"change mysql password"},{"content":"There are times when we need to limit text to a certain length. For example, we want to limit the length of the titles in the footer section. If we don’t limit the length, the text spills over to the next line and screws up the formatting and the look of the website. To limit the text length, we will use CSS3.\nLet’s say, we have a div class called footer-widgets. Inside, we have an unordered list. We can limit the text to just 245 characters. If the design is responsive, the footer section could reconfigure itself and at times be greater than 245px. If that’s the case, we will display the entire string instead. We will set the minimum width to 245px, overflow to hidden, white-space to nowrap, and text overflow to ellipsis.\nHere’s the CSS code:\n.footer-widgets li { text-overflow: ellipsis; min-width: 245px; white-space: nowrap; overflow:hidden; } This code works well if you’re using a responsive design. Your footer area can expand or contract depending on your responsive design. The text will truncate if if the footer area is less than 245px, and it will display the entire text if it’s over 245px.\nI have it implemented on this blog. Check out the footer section.\n","permalink":"http://uly.me/posts/limit-text-on-wordpress/","summary":"\u003cp\u003eThere are times when we need to limit text to a certain length. For example, we want to limit the length of the titles in the footer section. If we don’t limit the length, the text spills over to the next line and screws up the formatting and the look of the website. To limit the text length, we will use CSS3.\u003c/p\u003e\n\u003cp\u003eLet’s say, we have a div class called footer-widgets. Inside, we have an unordered list. We can limit the text to just 245 characters. If the design is responsive, the footer section could reconfigure itself and at times be greater than 245px. If that’s the case, we will display the entire string instead. We will set the minimum width to 245px, overflow to hidden, white-space to nowrap, and text overflow to ellipsis.\u003c/p\u003e","title":"limit text on wordpress"},{"content":"WordPress 4.3.1 is a security fix for some cross-site scripting vulnerabilities and a potential privilege issue.\nPer WordPress.org:\nWordPress versions 4.3 and earlier are vulnerable to a cross-site scripting vulnerability when processing shortcode tags (CVE-2015-5714). Reported by Shahar Tal and Netanel Rubin of Check Point. A separate cross-site scripting vulnerability was found in the user list table. Reported by Ben Bidner of the WordPress security team. Finally, in certain cases, users without proper permissions could publish private posts and make them sticky (CVE-2015-5715). Reported by Shahar Tal and Netanel Rubin of Check Point.\nUpdate all your WordPress installations.\n","permalink":"http://uly.me/posts/wordpress-4-3-1/","summary":"\u003cp\u003eWordPress 4.3.1 is a security fix for some cross-site scripting vulnerabilities and a potential privilege issue.\u003c/p\u003e\n\u003cp\u003ePer \u003ca href=\"https://wordpress.org/news/2015/09/wordpress-4-3-1/\"\u003eWordPress.org\u003c/a\u003e:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eWordPress versions 4.3 and earlier are vulnerable to a cross-site scripting vulnerability when processing shortcode tags (CVE-2015-5714). Reported by Shahar Tal and Netanel Rubin of Check Point. A separate cross-site scripting vulnerability was found in the user list table. Reported by Ben Bidner of the WordPress security team. Finally, in certain cases, users without proper permissions could publish private posts and make them sticky (CVE-2015-5715). Reported by Shahar Tal and Netanel Rubin of Check Point.\u003c/p\u003e","title":"wordpress 4.3.1"},{"content":"I was looking at my SQL statements the other day. I was doing a bunch of comparisons with a certain field that contain a pattern of words. My original SQL was quite tedious as displayed below. After much thought, I was able to pare it down to something much simpler. The newer SQL statement is much shorter and to the point. It uses the operator LIKE to search for a pattern.\nOLD SQL\nSELECT * FROM mytable WHERE ( product=\u0026#34;model-1\u0026#34; or product=\u0026#34;model-2\u0026#34; or product=\u0026#34;model-3\u0026#34; or product=\u0026#34;model-4\u0026#34; or product=\u0026#34;model-5\u0026#34; or product=\u0026#34;model-6\u0026#34; ) AND id=105 NEW SQL\nSELECT * FROM mytable WHERE product LIKE \u0026#34;%model%\u0026#34; AND id=105 The newer SQL is a vast improvement over the previous one. I was also forced to use parenthesis around the previous SQL statement to group together the OR comparisons. Without the parenthesis, my results were inaccurate because the AND had precedence over the OR. With an improved SQL, there’s no need to use parenthesis. Obviously the LIKE operator only works if there’s a pattern. I use % to make the search more liberal, otherwise it would look for an exact match.\n","permalink":"http://uly.me/posts/using-like-in-sql/","summary":"\u003cp\u003eI was looking at my SQL statements the other day. I was doing a bunch of comparisons with a certain field that contain a pattern of words. My original SQL was quite tedious as displayed below. After much thought, I was able to pare it down to something much simpler. The newer SQL statement is much shorter and to the point. It uses the operator LIKE to search for a pattern.\u003c/p\u003e","title":"using like in sql"},{"content":"The Genesis theme is a WordPress theme from StudioPress. I recently worked on a project where there was a need to redirect the URL title to another URL. Essentially, there are two separate WordPress installs on the server, one install had WordPress on the root directory, the other on a sub-directory. The URL title of the WordPress on a sub-directory needed to point to the root directory. So, here’s the fix that you need to add in the functions.php for Genesis themes.\n//* Modify the header URL - HTML5 Version add_filter( \u0026#39;genesis_seo_title\u0026#39;, \u0026#39;child_header_title\u0026#39;, 10, 3 ); function child_header_title( $title, $inside, $wrap ) { $inside = sprintf( \u0026#39;\u0026lt;a href=\u0026#34;http://example.com/\u0026#34; title=\u0026#34;%s\u0026#34;\u0026gt;%s\u0026lt;/a\u0026gt;\u0026#39;, esc_attr( get_bloginfo( \u0026#39;name\u0026#39; ) ), get_bloginfo( \u0026#39;name\u0026#39; ) ); return sprintf( \u0026#39;%2$s%1$s\u0026gt;\u0026#39;, $wrap, $inside ); } Just add this piece of code to the functions.php file of your Genesis child theme.\n","permalink":"http://uly.me/posts/modify-header-on-genesis-themes/","summary":"\u003cp\u003eThe Genesis theme is a WordPress theme from StudioPress. I recently worked on a project where there was a need to redirect the URL title to another URL. Essentially, there are two separate WordPress installs on the server, one install had WordPress on the root directory, the other on a sub-directory. The URL title of the WordPress on a sub-directory needed to point to the root directory. So, here’s the fix that you need to add in the functions.php for Genesis themes.\u003c/p\u003e","title":"modify header on genesis themes"},{"content":"There’s a bug on Google Chrome with the latest WordPress Dashboard. The bug has been submitted to WordPress’ bug tracker. However, the case is closed since the error occurs only in Chrome. Other browsers are rendering it just fine. There is a workaround by disabling “slimming paint” in Chrome.\nPlace this text in the URL of your Chrome browser:\nchrome://flags/#disable-slimming-paint Disable it.\nThe bug will remain until you restart Chrome.\n","permalink":"http://uly.me/posts/chrome-bug-with-wordpress-dashboard/","summary":"\u003cp\u003eThere’s a bug on Google Chrome with the latest WordPress Dashboard. The bug has been submitted to WordPress’ bug tracker. However, the \u003ca href=\"https://core.trac.wordpress.org/ticket/33784\"\u003ecase is closed\u003c/a\u003e since the error occurs only in Chrome. Other browsers are rendering it just fine. There is a workaround by disabling “slimming paint” in Chrome.\u003c/p\u003e\n\u003cp\u003ePlace this text in the URL of your Chrome browser:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003echrome://flags/#disable-slimming-paint\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDisable it.\u003c/p\u003e\n\u003cp\u003eThe bug will remain until you restart Chrome.\u003c/p\u003e","title":"chrome bug with wordpress dashboard"},{"content":"Back in February of 2015, Google added mobile-friendly sites as a criteria to their page rankings. Google have updated their algorithms, and mobile-friendly design will have significant impact to search results. To test and make sure your site is mobile-friendly, here’s a website that will analyze your website design and display the results.\nMobile-Friendly Test\n","permalink":"http://uly.me/posts/mobile-friendly-test/","summary":"\u003cp\u003eBack in February of 2015, Google added \u003ca href=\"http://googlewebmastercentral.blogspot.in/2015/02/finding-more-mobile-friendly-search.html\"\u003emobile-friendly sites\u003c/a\u003e as a criteria to their page rankings. Google have updated their algorithms, and mobile-friendly design will have significant impact to search results. To test and make sure your site is mobile-friendly, here’s a website that will analyze your website design and display the results.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://www.google.com/webmasters/tools/mobile-friendly/\"\u003eMobile-Friendly Test\u003c/a\u003e\u003c/p\u003e","title":"mobile friendly test"},{"content":"Bloginfo is a WordPress function that you can use on WordPress templates to display a number of things such as the home page, the blog description, the main feed, comments feed, admin email address, template directory, site url, pingback url, etc. You can display bloginfo via PHP just like this:\n\u0026lt;?php bloginfo(\u0026#39;url\u0026#39;); ??\u0026gt; Assuming the blog’s home page is located at http://example.com/home, here’s a list of options.\nadmin_email = admin@example.com atom_url = http://www.example.com/home/feed/atom charset = UTF-8 comments_atom_url = http://www.example.com/home/comments/feed/atom comments_rss2_url = http://www.example.com/home/comments/feed description = Just another WordPress blog home = http://www.example.com/home (DEPRECATED! use url option instead) html_type = text/html language = en-US name = Testpilot pingback_url = http://www.example.com/home/wp/xmlrpc.php rdf_url = http://www.example.com/home/feed/rdf rss2_url = http://www.example.com/home/feed rss_url = http://www.example.com/home/feed/rss siteurl = http://www.example.com/home (DEPRECATED! use url option instead) stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo stylesheet_url = http://www.example.com/home/wp/wp-content/themes/largo/style.css template_directory = http://www.example.com/home/wp/wp-content/themes/largo template_url = http://www.example.com/home/wp/wp-content/themes/largo text_direction = ltr url = http://www.example.com/home version = 3.5 wpurl = http://www.example.com/home/wp As mentioned previously, you can use the bloginfo function anywhere within your WordPress templates.\n","permalink":"http://uly.me/posts/getting-to-know-bloginfo/","summary":"\u003cp\u003eBloginfo is a WordPress function that you can use on WordPress templates to display a number of things such as the home page, the blog description, the main feed, comments feed, admin email address, template directory, site url, pingback url, etc. You can display bloginfo via PHP just like this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;?php bloginfo(\u0026#39;url\u0026#39;); ??\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAssuming the blog’s home page is located at \u003ca href=\"http://example.com/home\"\u003ehttp://example.com/home\u003c/a\u003e, here’s a list of options.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eadmin_email          = admin@example.com\natom_url             = http://www.example.com/home/feed/atom\ncharset              = UTF-8\ncomments_atom_url    = http://www.example.com/home/comments/feed/atom\ncomments_rss2_url    = http://www.example.com/home/comments/feed\ndescription          = Just another WordPress blog\nhome                 = http://www.example.com/home (DEPRECATED! use url option instead)\nhtml_type            = text/html\nlanguage             = en-US\nname                 = Testpilot\npingback_url         = http://www.example.com/home/wp/xmlrpc.php\nrdf_url              = http://www.example.com/home/feed/rdf\nrss2_url             = http://www.example.com/home/feed\nrss_url              = http://www.example.com/home/feed/rss\nsiteurl              = http://www.example.com/home (DEPRECATED! use url option instead)\nstylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo\nstylesheet_url       = http://www.example.com/home/wp/wp-content/themes/largo/style.css\ntemplate_directory   = http://www.example.com/home/wp/wp-content/themes/largo\ntemplate_url         = http://www.example.com/home/wp/wp-content/themes/largo\ntext_direction       = ltr\nurl                  = http://www.example.com/home\nversion              = 3.5\nwpurl                = http://www.example.com/home/wp\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAs mentioned previously, you can use the bloginfo function anywhere within your WordPress templates.\u003c/p\u003e","title":"getting to know bloginfo"},{"content":"Laravel Forge was recently upgraded with several new features. You can now edit your .env file directly from within Forge. It’s easier and faster than adding each environmental variable. In addition, you can also create and manage Nginx load balancing servers to balance your application load. With Forge, you can now deploy a new server in just minutes from any of the three cloud hosting service providers: Linode, Digital Ocean and now Amazon Web Services.\n","permalink":"http://uly.me/posts/laravel-forge-edit-env/","summary":"\u003cp\u003eLaravel Forge was recently upgraded with several new features. You can now edit your .env file directly from within Forge. It’s easier and faster than adding each environmental variable. In addition, you can also create and manage Nginx load balancing servers to balance your application load. With Forge, you can now deploy a new server in just minutes from any of the three cloud hosting service providers: Linode, Digital Ocean and now Amazon Web Services.\u003c/p\u003e","title":"laravel forge edit .env"},{"content":"If you’re running WordPress on Nginx, you may have an issue with WordPress permalinks. This article explains nicely what you need to do to configure Nginx. What the article failed to do is mention the Nginx configuration filename and its location. The filename is nginx.conf, and it’s usually located in the directory /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx, depending on your Linux distro.\n# WordPress installed on root directory location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } # WordPress installed on /blog sub-directory location /blog/ { try_files $uri $uri/ /blog/index.php?$args; } You need to reload Nginx for changes to take effect. For Ubuntu:\n$ sudo service nginx restart # or $ sudo /etc/init.d/nginx restart ","permalink":"http://uly.me/posts/wordpress-permalinks-on-nginx-2/","summary":"\u003cp\u003eIf you’re running WordPress on Nginx, you may have an issue with WordPress permalinks. This \u003ca href=\"http://nginxlibrary.com/wordpress-permalinks/\"\u003earticle\u003c/a\u003e explains nicely what you need to do to configure Nginx. What the article failed to do is mention the Nginx configuration filename and its location. The filename is nginx.conf, and it’s usually located in the directory /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx, depending on your Linux distro.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# WordPress installed on root directory\nlocation / {\n  index index.php index.html index.htm;\n  try_files $uri $uri/ /index.php?$args;\n}\n\n# WordPress installed on /blog sub-directory\nlocation /blog/ {\n    try_files $uri $uri/ /blog/index.php?$args;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou need to reload Nginx for changes to take effect. For Ubuntu:\u003c/p\u003e","title":"wordpress permalinks on nginx"},{"content":"Migrations in Laravel is like having version control of your database. It gives you the ability to create, modify and share a schema, as well as drop tables. Since it has version control, you can migrate and rollback your database changes with just a couple of CLI commands. Here’s a couple of examples.\nTo migrate:\n$ php artisan migrate To rollback:\n$ php artisan migrate:rollback In addition, you can also create a new migration table.\n$ php artisan make:migration create_users_table --create=\u0026#34;users\u0026#34; It will create a file similar to this:\napp/database/migrations/2015_01_01_213247_create_articles_table.php\nwhich you can modify and add fields.\n","permalink":"http://uly.me/posts/migrations-in-laravel/","summary":"\u003cp\u003eMigrations in Laravel is like having version control of your database. It gives you the ability to create, modify and share a schema, as well as drop tables. Since it has version control, you can migrate and rollback your database changes with just a couple of CLI commands. Here’s a couple of examples.\u003c/p\u003e\n\u003cp\u003eTo migrate:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ php artisan migrate\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo rollback:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$ php artisan migrate:rollback\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn addition, you can also create a new migration table.\u003c/p\u003e","title":"migrations in laravel"},{"content":"Laravel recently started using the PSR-2 style guide. PSR-2 is a coding style agreed upon by many PHP framework developers. It’s an extension of the original PSR-1, which basically has 3 main conventions.\nClasses are upper Camel case. Methods are lower Camel case. Constants are written in caps like VERSION_NUMBER. PSR-2 expands this by using these standards\nIndents are 4 spaces instead of tabs. Keep line lengths at 80 characters. Soft limit of 120 characters. Use one blank line after a namespace declaration. Use a blank line after a group of declarations. Opening braces for classes MUST go on the next line. Closing brace must be on its own line. Opening braces for methods must go on the next line, and a separate line for the closing brace. Closures must have a space after the function keyword. Never use the var keyword, this is used with JavaScript and would cause some confusion. Control structures, like IF, WHICH, FOR, and FOREACH must have one space before the condition parenthesis. The case keywords should be indented from the switch keyword. Keywords, like true, false, and null show be in lower case. See examples.\n","permalink":"http://uly.me/posts/psr-2-coding-style-guide/","summary":"\u003cp\u003eLaravel recently started using the PSR-2 style guide. PSR-2 is a coding style agreed upon by many PHP framework developers. It’s an extension of the original PSR-1, which basically has 3 main conventions.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eClasses are upper Camel case.\u003c/li\u003e\n\u003cli\u003eMethods are lower Camel case.\u003c/li\u003e\n\u003cli\u003eConstants are written in caps like VERSION_NUMBER.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003ePSR-2 expands this by using these standards\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eIndents are 4 spaces instead of tabs.\u003c/li\u003e\n\u003cli\u003eKeep line lengths at 80 characters. Soft limit of 120 characters.\u003c/li\u003e\n\u003cli\u003eUse one blank line after a namespace declaration. Use a blank line after a group of declarations.\u003c/li\u003e\n\u003cli\u003eOpening braces for classes MUST go on the next line. Closing brace must be on its own line.\u003c/li\u003e\n\u003cli\u003eOpening braces for methods must go on the next line, and a separate line for the closing brace.\u003c/li\u003e\n\u003cli\u003eClosures must have a space after the function keyword.\u003c/li\u003e\n\u003cli\u003eNever use the var keyword, this is used with JavaScript and would cause some confusion.\u003c/li\u003e\n\u003cli\u003eControl structures, like IF, WHICH, FOR, and FOREACH must have one space before the condition parenthesis.\u003c/li\u003e\n\u003cli\u003eThe case keywords should be indented from the switch keyword.\u003c/li\u003e\n\u003cli\u003eKeywords, like true, false, and null show be in lower case.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eSee \u003ca href=\"http://www.geekgumbo.com/2013/05/19/psr-2-coding-style-guide/\"\u003eexamples\u003c/a\u003e.\u003c/p\u003e","title":"psr-2 coding style guide"},{"content":"Laravel 5.1 was released in June 9, 2015. So, I updated my development environment with version 5.1 and updated it to GitHub. From there, I spun a server via Forge at Digital Ocean. Then, I deployed my development repository via GitHub.\nHowever, I faced two issues:\nI was getting an error saying that there is not enough memory. The simple fix is to do a composer update in your dev environment and then upload your changes to GitHub. If you have automatic deploy turned on, then the changes will be updated on the server. The other error was a missing app key. You can fix this by simply running artisan key:generate on the server. You must have a .env file on the Laravel directory. I believe it’s under /home/forge/default. You can create one or copy the .env.example. Hopefully, I save you some time with troubleshooting if you run into these issues.\n","permalink":"http://uly.me/posts/laravel-5-1-with-forge/","summary":"\u003cp\u003eLaravel 5.1 was released in June 9, 2015. So, I updated my development environment with version 5.1 and updated it to GitHub. From there, I spun a server via Forge at Digital Ocean. Then, I deployed my development repository via GitHub.\u003c/p\u003e\n\u003cp\u003eHowever, I faced two issues:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eI was getting an error saying that there is not enough memory. The simple fix is to do a \u003cstrong\u003ecomposer update\u003c/strong\u003e in your dev environment and then upload your changes to GitHub. If you have automatic deploy turned on, then the changes will be updated on the server.\u003c/li\u003e\n\u003cli\u003eThe other error was a missing app key. You can fix this by simply running \u003cstrong\u003eartisan key:generate\u003c/strong\u003e on the server. You must have a .env file on the Laravel directory. I believe it’s under /home/forge/default. You can create one or copy the .env.example.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eHopefully, I save you some time with troubleshooting if you run into these issues.\u003c/p\u003e","title":"laravel 5.1 with forge"},{"content":"After another downtime with my service provider, I wasn’t really happy with my backup strategy. Although, I have a backup plan in place, it’s not to the level of detail that I wanted. Back to the drawing board I went. I realized that what I really needed, was to back up my databases and keep copies of the last few days. Prior to that I was just relying on full file system backup and restore. Thankfully, backing up MySQL databases is not that difficult. The following pieces of code is the backup script I have put together to backup each MySQL database, as well rotate the backups and keep 5 days of copies of each database.\n#! /bin/bash # where sql files are stored cd /home/user/mysql # list all databases and assign to variable # exclude 3 MySQL default databases (information_schema,performance_schema,mysql) DATABASES=`mysql -e \u0026#34;SHOW DATABASES;\u0026#34; | grep -Ev \u0026#34;(Database|information_schema|performance_schema|mysql)\u0026#34;` # loop through all databases # remove db that\u0026#39;s 5 days old # rotate dbs. rename 1 day older # perform backup today for db in $DATABASES; do rm -rf $db-4.sql mv $db-3.sql $db-4.sql mv $db-2.sql $db-3.sql mv $db-1.sql $db-2.sql mv $db-0.sql $db-1.sql mysqldump $db \u0026gt; \u0026#34;$db-0.sql\u0026#34; done The for loop will execute everything inside it. The backup rotation gives me 5 days of backups of each database. You can schedule the script to run daily with cron. Just a side note. You need to create .my.cnf file in your home directory with your database credentials, so you don’t have to enter your username and password when running it from cron. Also script needs to be executable. A simple chmod +x will do the trick.\n","permalink":"http://uly.me/posts/backup-rotation/","summary":"\u003cp\u003eAfter another downtime with my service provider, I wasn’t really happy with my backup strategy. Although, I have a backup plan in place, it’s not to the level of detail that I wanted. Back to the drawing board I went. I realized that what I really needed, was to back up my databases and keep copies of the last few days. Prior to that I was just relying on full file system backup and restore. Thankfully, backing up MySQL databases is not that difficult. The following pieces of code is the backup script I have put together to backup each MySQL database, as well rotate the backups and keep 5 days of copies of each database.\u003c/p\u003e","title":"backup rotation"},{"content":"Laravel comes with several generators by way of Artisan CLI or Command Line Interface. To generate a controller, you simply run the following command from the Terminal. This is assuming you’re in the Laravel project folder.\n// generate a standard Controller $ php artisan make:controller HomeController // generate a plain Controller with no methods $ php artisan make:controller HomeController --plain The first example is the standard way of generating a controller with resourceful routing in mind.\nThe second example is plain way of generating a controller. It does not contain any method.\n","permalink":"http://uly.me/posts/generate-a-controller-in-laravel/","summary":"\u003cp\u003eLaravel comes with several generators by way of Artisan CLI or Command Line Interface. To generate a controller, you simply run the following command from the Terminal. This is assuming you’re in the Laravel project folder.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// generate a standard Controller\n$ php artisan make:controller HomeController\n\n// generate a plain Controller with no methods\n$ php artisan make:controller HomeController --plain\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe first example is the standard way of generating a controller with resourceful routing in mind.\u003c/p\u003e","title":"generate a controller in laravel"},{"content":"Eloquent ORM is a simple and yet powerful Active Record implementation included in Laravel, a PHP framework. This video at Laracasts is a great introduction to Eloquent. However, this article is everything you ever needed to know about Eloquent. If you’re new to Laravel, read the article. Get to know how to use Eloquent effectively.\n","permalink":"http://uly.me/posts/laravel-eloquent-orm/","summary":"\u003cp\u003eEloquent ORM is a simple and yet powerful Active Record implementation included in Laravel, a PHP framework. This \u003ca href=\"https://laracasts.com/series/laravel-5-fundamentals/episodes/8\"\u003evideo\u003c/a\u003e at Laracasts is a great introduction to Eloquent. However, this \u003ca href=\"https://scotch.io/tutorials/a-guide-to-using-eloquent-orm-in-laravel\"\u003earticle\u003c/a\u003e is everything you ever needed to know about Eloquent. If you’re new to Laravel, read the article. Get to know how to use Eloquent effectively.\u003c/p\u003e","title":"laravel eloquent orm"},{"content":"I made a mistake by publishing my database password to an environment file that’s visible. Rookie mistake. Replacing the database password entry with something else and submitting kinda takes care of the problem, but anyone can still view the history of the file and see your password. One way of getting rid of this, if you don’t really care about the history of your submits, is to reinitialize the project back to the initial commit. Here’s how.\n// Clone the project to your local computer $ git clone https://github.com/name/myproject.git // go to your project directory $ cd myproject // delete the .git folder where all the history is kept $ rm -rf .git // reinitialize your repository $ git init // add Github url $ git remote add origin https://github.com/name/myproject.git // verify remote $ git remote -v // Add all files and commit the changes $ git add --all $ git commit -am \u0026#39;initial commit\u0026#39; // Finally, push to the origin server which is Github $ git push -f origin master Your sensitive data is now gone from history. Just be careful next time.\n","permalink":"http://uly.me/posts/remove-sensitive-info-from-github/","summary":"\u003cp\u003eI made a mistake by publishing my database password to an environment file that’s visible. Rookie mistake. Replacing the database password entry with something else and submitting kinda takes care of the problem, but anyone can still view the history of the file and see your password. One way of getting rid of this, if you don’t really care about the history of your submits, is to reinitialize the project back to the initial commit. Here’s how.\u003c/p\u003e","title":"remove sensitive info from github"},{"content":"Here’s a snippet of code to display all WordPress posts alphabetically. Typically, you would list archives using the date they were posted, but there might be a need to list the posts alphabetically. You would normally place this code in your Archives Template page.\n","permalink":"http://uly.me/posts/display-posts-alphabetically/","summary":"\u003cp\u003eHere’s a snippet of code to display all WordPress posts alphabetically. Typically, you would list archives using the date they were posted, but there might be a need to list the posts alphabetically. You would normally place this code in your Archives Template page.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u003c/code\u003e\u003c/pre\u003e","title":"display posts alphabetically"},{"content":"If you’re new to WordPress and you want to learn more, I recommend you dig into the WordPress Codex, which is the online manual and living repository for WordPress information and documentation. As a newbie, you can start learning how to use WordPress, then work with Themes, and maybe even write a Plugin or two. If that’s not your forte, then maybe you can contribute to the WordPress community by becoming a tester by reporting bugs, or work on the online documentation. See link below.\nWordPress Codex\n","permalink":"http://uly.me/posts/wordpress-codex/","summary":"\u003cp\u003eIf you’re new to WordPress and you want to learn more, I recommend you dig into the WordPress Codex, which is the online manual and living repository for WordPress information and documentation. As a newbie, you can start learning how to use WordPress, then work with Themes, and maybe even write a Plugin or two. If that’s not your forte, then maybe you can contribute to the WordPress community by becoming a tester by reporting bugs, or work on the online documentation. See link below.\u003c/p\u003e","title":"wordpress codex"},{"content":"The following instructions will create a new repository on GitHub. These instructions will assume that you’re logged in to GitHub.com. You can create a new repository by clicking on the link called “create a new repository” found on several pages on GitHub. You can also go directly to this URL: https://github.com/new.\nYou need to provide a repository name that’s hopefully short and memorable. Click the “Create Repository” button to start the initiation process. Once the repository is created, you can create a new local repository on your computer and sync it to GitHub repository.\nOn your computer:\necho \u0026#34;# RepositoryName\u0026#34; \u0026gt;\u0026gt; README.md git init git add README.md git commit -m \u0026#34;first commit\u0026#34; git remote add origin https://github.com/ulyssesr/RepositoryName.git git push -u origin master If you have an existing local repository, you can push it to GitHub.\ngit remote add origin https://github.com/ulyssesr/RepositoryName.git git push -u origin master ","permalink":"http://uly.me/posts/setup-new-repository-on-github/","summary":"\u003cp\u003eThe following instructions will create a new repository on GitHub. These instructions will assume that you’re logged in to GitHub.com. You can create a new repository by clicking on the link called “create a new repository” found on several pages on GitHub. You can also go directly to this URL: \u003ca href=\"https://github.com/new\"\u003ehttps://github.com/new\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eYou need to provide a repository name that’s hopefully short and memorable. Click the “Create Repository” button to start the initiation process. Once the repository is created, you can create a new local repository on your computer and sync it to GitHub repository.\u003c/p\u003e","title":"setup new repository on github"},{"content":"YouTube now defaults to HTML5 video player instead of Flash. The new player takes advantage of MediaSource extensions for its Adaptive Bitrate streaming allowing viewers to quickly and seamlessly switch resolutions. The new player also uses a new video codec called VP9 which gives you higher resolution with low bandwidth. YouTube will also start using WebRTC for recording videos and for live streaming capabilities. Read more.\n","permalink":"http://uly.me/posts/youtube-html5-video-player/","summary":"\u003cp\u003eYouTube now defaults to HTML5 video player instead of Flash. The new player takes advantage of MediaSource extensions for its Adaptive Bitrate streaming allowing viewers to quickly and seamlessly switch resolutions. The new player also uses a new video codec called VP9 which gives you higher resolution with low bandwidth. YouTube will also start using WebRTC for recording videos and for live streaming capabilities. \u003ca href=\"http://www.iclarified.com/46799/youtube-now-defaults-to-html5-video-player-instead-of-flash\"\u003eRead more\u003c/a\u003e.\u003c/p\u003e","title":"youtube html5 video player"},{"content":"It looks like Laravel 5 will be released sometime next week. Laravel is a PHP framework which uses simple RESTful routing, Eloquent ORM and Blade templating. It’s built on top of Symfony and Composer. It comes with PHPUnit for testing, and of course, it has migrations built in the package. If you’re curious about what Laravel 5 can do and some of its features, there are several free videos available at Laracasts about Laravel 5.\n","permalink":"http://uly.me/posts/laravel-5/","summary":"\u003cp\u003eIt looks like Laravel 5 will be released sometime next week. \u003ca href=\"http://laravel.com\"\u003eLaravel\u003c/a\u003e is a PHP framework which uses simple RESTful routing, Eloquent ORM and Blade templating. It’s built on top of Symfony and Composer. It comes with PHPUnit for testing, and of course, it has migrations built in the package. If you’re curious about what Laravel 5 can do and some of its features, there are several \u003ca href=\"https://laracasts.com/series/whats-new-in-laravel-5\"\u003efree videos\u003c/a\u003e available at Laracasts about Laravel 5.\u003c/p\u003e","title":"laravel 5"},{"content":"If you need to run some code at certain times of the week, a weekly sale for example, PHP gives you that flexibility. In the example below, we will display an image on our website every Wednesday afternoon between 1pm and 5pm to display a sale.\nLet’s create a new function called wednesday_afternoon(). We can use this function to check the date and time. The function checks for the current time and compares it if it’s Wednesday afternoon. It returns a true if it is, and a false if it falls outside those times.\nfunction wednesday_afternoon() { date_default_timezone_set(\u0026#39;America/Los_Angeles\u0026#39;); $start_time = strtotime(\u0026#39;Wednesday 1pm\u0026#39;); $stop_time = strtotime(\u0026#39;Wednesday 5pm\u0026#39;); $current_time = strtotime(\u0026#39;now\u0026#39;); // return true if between start and stop times if ( $current_time \u0026gt; $start_time \u0026amp;\u0026amp; $current_time A simple if statement decides what image to display based if it\u0026rsquo;s Wednesday afternoon.\nif (wednesday_afternoon()) { \u0026lt;div class=\u0026#34;wednesday_sale\u0026#34;\u0026gt; \u0026lt;img decoding=\u0026#34;async\u0026#34; src=\u0026#34;/path/to/our/image.png\u0026#34;\u0026gt;\u0026lt;/img\u0026gt; \u0026lt;/div\u0026gt; } else { \u0026lt;div class=\u0026#34;no_sale\u0026#34;\u0026gt; \u0026lt;img decoding=\u0026#34;async\u0026#34; src=\u0026#34;/path/to/our/no/sale/image.png\u0026#34;\u0026gt;\u0026lt;/img\u0026gt; \u0026lt;/div\u0026gt; } I have posted a similar code GitHubGist.\n","permalink":"http://uly.me/posts/run-code-at-specific-times/","summary":"\u003cp\u003eIf you need to run some code at certain times of the week, a weekly sale for example, PHP gives you that flexibility. In the example below, we will display an image on our website every Wednesday afternoon between 1pm and 5pm to display a sale.\u003c/p\u003e\n\u003cp\u003eLet’s create a new function called wednesday_afternoon(). We can use this function to check the date and time. The function checks for the current time and compares it if it’s Wednesday afternoon. It returns a true if it is, and a false if it falls outside those times.\u003c/p\u003e","title":"run code at specific times"},{"content":"\nCharging the laptop at night. I’m trying to get back into photography. This photo shows how a responsive design render images differently in various screen sizes using CSS max-width at 100%. In addition, the height is set to auto to keep the scale correct.\nimg { height: auto; /* Make sure images are scaled correctly. */ max-width: 100%; /* Adhere to container width. */ } Now regarding the Mac, there’s a rumor that Apple is planning to release a 12-inch MacBook Air as detailed here by Forbes.\n","permalink":"http://uly.me/posts/charging-at-night/","summary":"\u003cp\u003e\u003cimg alt=\"charging\" loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2015/01/charging.jpg\"\u003e\u003c/p\u003e\n\u003cp\u003eCharging the laptop at night. I’m trying to get back into photography. This photo shows how a responsive design render images differently in various screen sizes using CSS max-width at 100%. In addition, the height is set to auto to keep the scale correct.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eimg {\n height: auto; /* Make sure images are scaled correctly. */\n max-width: 100%; /* Adhere to container width. */\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNow regarding the Mac, there’s a rumor that Apple is planning to release a 12-inch MacBook Air as detailed here by \u003ca href=\"http://www.forbes.com/sites/brookecrothers/2015/01/11/rumored-12-inch-macbook-9to5macs-mark-gurman-talks-new-connector/\"\u003eForbes\u003c/a\u003e.\u003c/p\u003e","title":"charging at night"},{"content":"Many web designers use Copyright followed by the current year on the bottom of their websites. It’s usually placed in the footer section of the page. If your site has been around for a while, spanning over several years, you’ll have to update your footer every time a new year comes along. If your site runs on PHP, you can make your footer a little bit more dynamic by using the PHP date function.\nFor example, you have a footer similar to this.\nCopyright © 2010 - 2014. All rights reserved. yourdomain.com. The result is:\nCopyright © 2010 – 2014. All rights reserved. yourdomain.com.\nYou can make the current year dynamic by using the PHP date function as displayed below.\nCopyright © 2010 - \u0026lt;?php echo date(\u0026#39;Y\u0026#39;); ??\u0026gt;. All rights reserved. yourdomain.com. Most web hosting services have PHP turned on by default. Even if your website runs only in HTML, you can probably use the PHP date function. If you decide to do it, just make sure to change the file extension from .html to .php. And you’re good to go.\n","permalink":"http://uly.me/posts/dynamic-footer/","summary":"\u003cp\u003eMany web designers use Copyright followed by the current year on the bottom of their websites. It’s usually placed in the footer section of the page. If your site has been around for a while, spanning over several years, you’ll have to update your footer every time a new year comes along. If your site runs on PHP, you can make your footer a little bit more dynamic by using the PHP date function.\u003c/p\u003e","title":"dynamic footer"},{"content":"HTML redirect is one of the oldest tricks in the books for web designers. If multiple links share the same information or page for example, you can simply redirect your visitors to a good-known page. Redirect is accomplished using HTML meta redirect. Here’s an example below.\n\u0026lt;title\u0026gt;\u0026lt;/title\u0026gt; \u0026lt;meta content=\u0026#34;0; url=http://yahoo.com\u0026#34; http-equiv=\u0026#34;refresh\u0026#34;\u0026gt;\u0026lt;/meta\u0026gt; The url is the website or page you want visitors to be redirected. Content is the number of delay in seconds. The value of 0 means that you want visitors to be redirected immediately. A value of 5 means visitors will be redirected after 5 seconds.\n","permalink":"http://uly.me/posts/html-redirect/","summary":"\u003cp\u003eHTML redirect is one of the oldest tricks in the books for web designers. If multiple links share the same information or page for example, you can simply redirect your visitors to a good-known page. Redirect is accomplished using HTML meta redirect. Here’s an example below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;title\u0026gt;\u0026lt;/title\u0026gt;\n\u0026lt;meta content=\u0026#34;0; url=http://yahoo.com\u0026#34; http-equiv=\u0026#34;refresh\u0026#34;\u0026gt;\u0026lt;/meta\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe url is the website or page you want visitors to be redirected. Content is the number of delay in seconds. The value of 0 means that you want visitors to be redirected immediately. A value of 5 means visitors will be redirected after 5 seconds.\u003c/p\u003e","title":"html redirect"},{"content":"Take a look at this piece of code from Codepen. It’s just a simple ordering list, but the list is broken up into several sections. The numerical order continuous as it spills over to other sections. It even changes to Roman numbering in the last section. How is this possible?\nJust HTML and CSS. No Javascript. The key is adding the appropriate CSS to the ol markup.\nJust look at the examples below.\n// Start the list at number 6 \u0026lt;ol start=\u0026#34;6\u0026#34;\u0026gt; \u0026lt;/ol\u0026gt; // Start the list at number 11. Assign \u0026#34;roman\u0026#34; class to it. \u0026lt;ol class=\u0026#34;roman\u0026#34; start=\u0026#34;11\u0026#34;\u0026gt; \u0026lt;/ol\u0026gt; The CSS for “roman” is:\n.roman { list-style-type:upper-roman; } Pretty neat.\n","permalink":"http://uly.me/posts/continuous-order-list/","summary":"\u003cp\u003eTake a look at this \u003ca href=\"http://codepen.io/xmark/pen/ZYpvEv\"\u003epiece of code\u003c/a\u003e from Codepen. It’s just a simple ordering list, but the list is broken up into several sections. The numerical order continuous as it spills over to other sections. It even changes to Roman numbering in the last section. How is this possible?\u003c/p\u003e\n\u003cp\u003eJust HTML and CSS. No Javascript. The key is adding the appropriate CSS to the \u003cstrong\u003eol\u003c/strong\u003e markup.\u003c/p\u003e\n\u003cp\u003eJust look at the examples below.\u003c/p\u003e","title":"continuous order list"},{"content":"You can do a lot with having a responsive design. If you’re using page widths on your designs, you can tailor your page layout based on the viewer’s screen size. The following CSS code will make your web page responsive by offering different page widths to your layout.\n@media screen and (min-width:480px) { #page {width:90%;} } @media screen and (min-width:720px) { #page {width:75%;} } @media screen and (min-width:1440px) { #page {width:60%;} } In the example above, any screen size that’s bigger than 1440px will have page width of 60%. A screen size of between 720px and 1440px will display a page width of 75%. Any screen size smaller than 480px will display a page width of 90%.\n","permalink":"http://uly.me/posts/responsive-page-width/","summary":"\u003cp\u003eYou can do a lot with having a responsive design. If you’re using page widths on your designs, you can tailor your page layout based on the viewer’s screen size. The following CSS code will make your web page responsive by offering different page widths to your layout.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e@media screen and (min-width:480px) {\n#page {width:90%;}\n}\n@media screen and (min-width:720px) {\n#page {width:75%;}\n}\n@media screen and (min-width:1440px) {\n#page {width:60%;}\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn the example above, any screen size that’s bigger than 1440px will have page width of 60%. A screen size of between 720px and 1440px will display a page width of 75%. Any screen size smaller than 480px will display a page width of 90%.\u003c/p\u003e","title":"responsive page width"},{"content":"Adding background images to your designs is quite simple. All you need to do is assign CSS background-image to the body of your design. In addition, you can also assign a background color, just in case the background image is not rendered.\nbody { background-image: url(\u0026#34;path/to/the/background/image.gif\u0026#34;); background-color: #cccccc; } The code above may have worked in the past, but with 4k and 5k monitors becoming popular nowadays, you need to make sure your background images are big enough to cover the large monitors as well.\nTo make your background image cover all monitor sizes, you need to use “background-cover.”\nbody { background-size: cover; } Here’s the entire code.\nbody { background-image: url(\u0026#34;path/to/the/background/image.gif\u0026#34;); background-color: #cccccc; background-size: cover; } ","permalink":"http://uly.me/posts/background-cover/","summary":"\u003cp\u003eAdding background images to your designs is quite simple. All you need to do is assign CSS background-image to the body of your design. In addition, you can also assign a background color, just in case the background image is not rendered.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ebody {\n    background-image: url(\u0026#34;path/to/the/background/image.gif\u0026#34;);\n    background-color: #cccccc;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe code above may have worked in the past, but with 4k and 5k monitors becoming popular nowadays, you need to make sure your background images are big enough to cover the large monitors as well.\u003c/p\u003e","title":"background cover"},{"content":"If you want to backup your Linux server to Amazon S3 (Simple Storage Service), you need to install a utility called S3cmd which allows you to interact with Amazon’s cloud storage service. You’ll be able to create s3 buckets, upload and retrieve files from your Linux server to the S3.\nYou can install S3cmd from Ubuntu.\nsudo apt-get install s3cmd Next, you need to configure S3cmd using your S3 credentials. You’ll need an Access key and a Secret key from Amazon’s Security Credentials page which you can access from Amazon’s IAM Management Console.\nsudo s3cmd --configure For details on how to fully implement S3cmd, please take a look at this article.\n","permalink":"http://uly.me/posts/install-s3cmd-on-ubuntu/","summary":"\u003cp\u003eIf you want to backup your Linux server to Amazon S3 (Simple Storage Service), you need to install a utility called S3cmd which allows you to interact with Amazon’s cloud storage service. You’ll be able to create s3 buckets, upload and retrieve files from your Linux server to the S3.\u003c/p\u003e\n\u003cp\u003eYou can install S3cmd from Ubuntu.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install s3cmd\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eNext, you need to configure S3cmd using your S3 credentials. You’ll need an Access key and a Secret key from Amazon’s Security Credentials page which you can access from Amazon’s IAM Management Console.\u003c/p\u003e","title":"install s3cmd on ubuntu"},{"content":"I’m currently testing NetBeans IDE for PHP development. You can download Netbeans IDE directly from NetBean’s website. Netbeans IDE is a free and open source IDE or integrated development environment. IDE’s are essentially glorified editors with a bunch tools to make development easier. Tools can vary from built-in functions, code completion, debugger, version control to FTP access. Netbeans has plugins for multiple programming languages such Java, Javascript, PHP, HTML, Ruby in Rails, etc. Java 7 or newer is a prerequisite to make NetBeans work on your computer. You can download Java from here.\n","permalink":"http://uly.me/posts/netbeans-ide/","summary":"\u003cp\u003eI’m currently testing NetBeans IDE for PHP development. You can download Netbeans IDE directly from NetBean’s \u003ca href=\"https://netbeans.org/\"\u003ewebsite\u003c/a\u003e. Netbeans IDE is a free and open source IDE or integrated development environment. IDE’s are essentially glorified editors with a bunch tools to make development easier. Tools can vary from built-in functions, code completion, debugger, version control to FTP access. Netbeans has plugins for multiple programming languages such Java, Javascript, PHP, HTML, Ruby in Rails, etc. Java 7 or newer is a prerequisite to make NetBeans work on your computer. You can download Java from \u003ca href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\"\u003ehere\u003c/a\u003e.\u003c/p\u003e","title":"netbeans ide"},{"content":"To find out what version of Apache running on your server, type the following.\nUbuntu-based distros\napache2 -V Debian-based distros\napachectl -V Redhat-based distros\nhttpd -V ","permalink":"http://uly.me/posts/get-apache-version/","summary":"\u003cp\u003eTo find out what version of Apache running on your server, type the following.\u003c/p\u003e\n\u003cp\u003eUbuntu-based distros\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapache2 -V\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eDebian-based distros\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eapachectl -V\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRedhat-based distros\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ehttpd -V\n\u003c/code\u003e\u003c/pre\u003e","title":"get apache version"},{"content":"I ran into several issues with the Roundcube installation on Ubuntu. Roundcube is a browser-based IMAP client that you can install on your server. It’s available from the Ubuntu repository to install. You run this command from the Terminal to install.\nRoundcube Install\nsudo apt-get install roundcube roundcube-mysql However, I ran into some issues. The two Roundcube configuration files are main.inc.php and debian.db.php. Both are located in the /etc/roundcube directory. If you have problems receiving or sending mails, it’s worth to take a look at your IMAP and SMTP settings on your /etc/roundcube/main.inc.php file.\nEdit the /etc/roundcube/main.inc.php file. Use your own server settings.\nsudo nano /etc/roundcube/main.inc.php IMAP and SMTP Settings\n// IMAP server $rcmail_config[\u0026#39;default_host\u0026#39;] = array(\u0026#34;ssl://imap.yourmailserver.com\u0026#34;); // TCP port used for IMAP connections $rcmail_config[\u0026#39;default_port\u0026#39;] = 993; // SMTP server $rcmail_config[\u0026#39;smtp_server\u0026#39;] = \u0026#39;ssl://smtp.yourmailserver.com\u0026#39;; // SMTP port $rcmail_config[\u0026#39;smtp_port\u0026#39;] = 465; // SMTP username (if required) use %u as the username $rcmail_config[\u0026#39;smtp_user\u0026#39;] = \u0026#39;%u\u0026#39;; // SMTP password (if required) use %p as the password $rcmail_config[\u0026#39;smtp_pass\u0026#39;] = \u0026#39;%p\u0026#39;; Use %u and %p if you have multiple accounts.\nDatabase Settings\nMake sure your database credentials are correct.\n$dbuser=\u0026#39;your_username\u0026#39;; $dbpass=\u0026#39;your_password\u0026#39;; $basepath=\u0026#39;\u0026#39;; $dbname=\u0026#39;roundcube\u0026#39;; $dbserver=\u0026#39;\u0026#39;; $dbport=\u0026#39;\u0026#39;; $dbtype=\u0026#39;mysql\u0026#39;; Finally, reboot the Apache server for good measure.\nsudo service apache2 restart ","permalink":"http://uly.me/posts/roundcube-install-errors/","summary":"\u003cp\u003eI ran into several issues with the Roundcube installation on Ubuntu. Roundcube is a browser-based IMAP client that you can install on your server. It’s available from the Ubuntu repository to install. You run this command from the Terminal to install.\u003c/p\u003e\n\u003cp\u003eRoundcube Install\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install roundcube roundcube-mysql\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHowever, I ran into some issues. The two Roundcube configuration files are main.inc.php and debian.db.php. Both are located in the /etc/roundcube directory. If you have problems receiving or sending mails, it’s worth to take a look at your IMAP and SMTP settings on your /etc/roundcube/main.inc.php file.\u003c/p\u003e","title":"roundcube install errors"},{"content":"If you’re a PHP developer, Laravel is all the rage. If you’re new to Laravel and you want to learn how to code, I recommend that you check out Laracasts, a video tutorial website about Laravel. You’ll find a number of free lessons, as well as some paid content.\nSince it’s Thanksgiving Day, Laracasts currently has a fire sale. Well, a Black Friday sale to be exact. Laracasts is offering 40% off any type of subscription. You can apply it to a yearly subscription. What a bargain!\nBetter act soon. The offer will expire November 28 at 11:59pm EST.\nLaracasts Black Friday Sale – 40% off any subscription\n","permalink":"http://uly.me/posts/laracasts-black-friday-sale/","summary":"\u003cp\u003eIf you’re a PHP developer, \u003ca href=\"http://laravel.com\"\u003eLaravel\u003c/a\u003e is all the rage. If you’re new to Laravel and you want to learn how to code, I recommend that you check out \u003ca href=\"http://laracasts.com\"\u003eLaracasts\u003c/a\u003e, a video tutorial website about Laravel. You’ll find a number of free lessons, as well as some paid content.\u003c/p\u003e\n\u003cp\u003eSince it’s Thanksgiving Day, Laracasts currently has a fire sale. Well, a Black Friday sale to be exact. Laracasts is offering 40% off any type of subscription. You can apply it to a yearly subscription. What a bargain!\u003c/p\u003e","title":"laracasts black friday sale"},{"content":"One way to speed up the Linux package updates is to use a package mirror made available by Linode. They are hosted in all six of their data centers. Just pick a data center where your data is Linode server is located by doing the following.\nEdit your sources list\nsudo nano /etc/apt/sources.list Search and replace\n# Replace this address http://us.archive.ubuntu.com/ubuntu/ # with the new address http://fremont.mirrors.linode.com/ubuntu/ # you can also use this - returns round robin of all locations http://mirrors.linode.com/ubuntu/ The next time you run a Linux update, it will be significantly faster.\nsudo apt-get update sudo apt-get upgrade ","permalink":"http://uly.me/posts/linode-linux-package-mirrors/","summary":"\u003cp\u003eOne way to speed up the Linux package updates is to use a package mirror made available by Linode. They are hosted in all six of their data centers. Just pick a data center where your data is Linode server is located by doing the following.\u003c/p\u003e\n\u003cp\u003eEdit your sources list\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo nano /etc/apt/sources.list\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSearch and replace\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Replace this address \nhttp://us.archive.ubuntu.com/ubuntu/ \n\n# with the new address \nhttp://fremont.mirrors.linode.com/ubuntu/\n\n# you can also use this - returns round robin of all locations\nhttp://mirrors.linode.com/ubuntu/\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe next time you run a Linux update, it will be significantly faster.\u003c/p\u003e","title":"linode linux package mirrors"},{"content":"You’ve abandoned Apache for a faster, newer and sleeker Nginx. Installation was a breeze. WordPress is just humming along until you start clicking links within WordPress. You realized the permalinks are broken, which is a biggie. So, here’s how you fix WordPress permalinks on Nginx.\nWordPress on root directory\n# Edit nginx config sudo nano /etc/nginx/sites-available/default # Add the following lines to the file. location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?args; } WordPress in a subdirectory under root\nlocation /wordpress/ { try_files $uri $uri/ /wordpress/index.php?args; } Restart Nginx\n# must restart nginx for the changes to take effect sudo nano service nginx restart ","permalink":"http://uly.me/posts/wordpress-permalinks-on-nginx/","summary":"\u003cp\u003eYou’ve abandoned Apache for a faster, newer and sleeker Nginx. Installation was a breeze. WordPress is just humming along until you start clicking links within WordPress. You realized the permalinks are broken, which is a biggie. So, here’s how you fix WordPress permalinks on Nginx.\u003c/p\u003e\n\u003cp\u003eWordPress on root directory\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Edit nginx config\nsudo nano /etc/nginx/sites-available/default\n\u003c/code\u003e\u003c/pre\u003e\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e# Add the following lines to the file.\nlocation / {\nindex index.php index.html index.htm;\ntry_files $uri $uri/ /index.php?args;\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWordPress in a subdirectory under root\u003c/p\u003e","title":"wordpress permalinks on nginx"},{"content":"MariaDB is a drop-in replacement for MySQL database. On most cases, you can just uninstall MySQL and install MariaDB and you are good to go. To keep up the two databases compatible, the MariaDB team are doing monthly merges with the MySQL code base making sure new features and fixes are kept up.\nUninstall MySQL\nsudo apt-get purge mysql* sudo apt-get autoremove Install MariaDB\nsudo apt-get install mariadb-server mariadb-client -y Verify if MariaDB is running\nsudo service mysql status ","permalink":"http://uly.me/posts/install-mariadb-on-ubuntu/","summary":"\u003cp\u003eMariaDB is a drop-in replacement for MySQL database. On most cases, you can just uninstall MySQL and install MariaDB and you are good to go. To keep up the two databases compatible, the MariaDB team are doing monthly merges with the MySQL code base making sure new features and fixes are kept up.\u003c/p\u003e\n\u003cp\u003eUninstall MySQL\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get purge mysql*\nsudo apt-get autoremove\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eInstall MariaDB\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install mariadb-server mariadb-client -y\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eVerify if MariaDB is running\u003c/p\u003e","title":"install mariadb on ubuntu"},{"content":"In the Unix world, a symbolic is special type of file that references to another file or directory. Symbolic links are also known to others as symlink or softlink. To create a symbolic link, the ln -s command is used to reference a file to another like below.\nsudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin To delete a symbolic link\nsudo rm /var/www/phpmyadmin # or sudo unlink /var/www/phpmyadmin ","permalink":"http://uly.me/posts/delete-a-symbolic-link/","summary":"\u003cp\u003eIn the Unix world, a symbolic is special type of file that references to another file or directory. Symbolic links are also known to others as symlink or softlink. To create a symbolic link, the ln -s command is used to reference a file to another like below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eTo delete a symbolic link\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo rm /var/www/phpmyadmin\n# or\nsudo unlink /var/www/phpmyadmin\n\u003c/code\u003e\u003c/pre\u003e","title":"delete a symbolic link"},{"content":"nginx (pronounced engine x) is an HTTP and reverse proxy server written by Igor Sysoev. nginx is gaining traction over the years due to its exceptional speed. The latest Netcraft web survey indicate that 14.42 percent of the Internet of websites runs on Nginx.\nIf you looking to replace your Apache web server or just want to play around with nginx, here are the really simple instructions on how to install nginx on any Ubuntu Server.\n# run update sudo apt-get update sudo apt-get upgrade # install nginx sudo apt-get install nginx # start nginx sudo service nginx start Open your browser and point it to the IP address of your Ubuntu Server.\nYou’ll see this if your installation was successful.\n","permalink":"http://uly.me/posts/install-nginx-on-ubuntu-server/","summary":"\u003cp\u003enginx (pronounced engine x) is an HTTP and reverse proxy server written by Igor Sysoev. nginx is gaining traction over the years due to its exceptional speed. The latest Netcraft web survey indicate that 14.42 percent of the Internet of websites runs on Nginx.\u003c/p\u003e\n\u003cp\u003eIf you looking to replace your Apache web server or just want to play around with nginx, here are the really simple instructions on how to install nginx on any Ubuntu Server.\u003c/p\u003e","title":"install nginx on ubuntu server"},{"content":"If you’re looking for a S3 client, check out Cyberduck. It’s a free FTP, SFTP, WebDAV, S3 \u0026amp; OpenStack Swift browser for both Mac and Windows. I started using it primarily to access an Amazon S3 account. Just download the client and select Amazon S3 to access your account.\nYou will need an Access Key ID and your Secret Access Key for your S3 account. You can get that from the AWS Dashboard under IAM (Identity Access Management). Once you’re authenticated, you can access your files from within Cyberduck. Drag and drop to download and upload. Very simple and intuitive.\n","permalink":"http://uly.me/posts/cyberduck/","summary":"\u003cp\u003eIf you’re looking for a S3 client, check out \u003ca href=\"https://cyberduck.io\"\u003eCyberduck\u003c/a\u003e. It’s a free FTP, SFTP, WebDAV, S3 \u0026amp; OpenStack Swift browser for both Mac and Windows. I started using it primarily to access an Amazon S3 account. Just download the client and select Amazon S3 to access your account.\u003c/p\u003e\n\u003cp\u003eYou will need an Access Key ID and your Secret Access Key for your S3 account. You can get that from the AWS Dashboard under IAM (Identity Access Management). Once you’re authenticated, you can access your files from within Cyberduck. Drag and drop to download and upload. Very simple and intuitive.\u003c/p\u003e","title":"cyberduck"},{"content":"I tried starting a new Laravel project from my Mac’s Terminal and came across this message saying, “Warning: This development build of composer is over 30 days old. It is recommended to update it by running “/usr/local/bin/composer self-update” to get the latest version.” So I ran this command to get the latest composer.\nsudo /usr/local/bin/composer self-update You’ll be prompted to enter the Admin password.\nAnd that’s the way you get the latest update of Composer.\nNow, back to the new project.\n","permalink":"http://uly.me/posts/update-composer/","summary":"\u003cp\u003eI tried starting a new Laravel project from my Mac’s Terminal and came across this message saying, “Warning: This development build of composer is over 30 days old. It is recommended to update it by running “/usr/local/bin/composer self-update” to get the latest version.” So I ran this command to get the latest composer.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo /usr/local/bin/composer self-update\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eYou’ll be prompted to enter the Admin password.\u003c/p\u003e\n\u003cp\u003eAnd that’s the way you get the latest update of Composer.\u003c/p\u003e","title":"update composer"},{"content":"I was working on PHPMyAdmin today trying to create a copy of a database. The SQL file was bigger than 8MB. Before I uploaded, I saw a message on the page of PHPMyAdmin saying the upload limit is 8MB. All indication points to increasing the upload size in the PHP configuration.\nSince my server runs on Ubuntu, the php.ini file is located in /etc/php/apache2/php.ini. You’ll need to change the following settings:\nsudo nano /etc/php/apache2/php.ini # Edit the following entries to file size you want upload_max_filesize = 32M post_max_size = 32M It makes sense to match the two values because they go hand-in-hand.\nThe changes won’t take effect until you restart Apache.\nsudo service apache2 restart ","permalink":"http://uly.me/posts/php-upload-limit/","summary":"\u003cp\u003eI was working on PHPMyAdmin today trying to create a copy of a database. The SQL file was bigger than 8MB. Before I uploaded, I saw a message on the page of PHPMyAdmin saying the upload limit is 8MB. All indication points to increasing the upload size in the PHP configuration.\u003c/p\u003e\n\u003cp\u003eSince my server runs on Ubuntu, the php.ini file is located in /etc/php/apache2/php.ini. You’ll need to change the following settings:\u003c/p\u003e","title":"php upload limit"},{"content":"There’s a new way to load WordPress stylesheets from within your templates. In the older versions of WordPress, the stylesheets were hard coded on the theme’s header file. The proper way to load your stylesheets is via the functions.php file. Here are the differences.\nThe old way was:\n\u0026lt;link href=\u0026#34;\u0026lt;?php bloginfo(\u0026#39;stylesheet_url\u0026#39;); ?\u0026gt;\u0026#34; media=\u0026#34;screen\u0026#34; rel=\u0026#34;stylesheet\u0026#34; type=\u0026#34;text/css\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; The new way uses wp_enqueue_scripts and the code is placed in functions.php.\nfunction sample_theme_scripts() { wp_enqueue_style( \u0026#39;style\u0026#39;, get_stylesheet_uri() ); } add_action( \u0026#39;wp_enqueue_scripts\u0026#39;, \u0026#39;sample_theme_scripts\u0026#39; ); Both codes work, but the latter will give you less headache.\nIf you use multiple stylesheets and JQuery at the same time, then you can use wp_enqueue_scripts to load them all at once. Using wp_enqueue_scripts will help you avoid conflicts from loading multiple copies of the same script. For example, you can deregister the standard WordPress JQuery and use your own JQuery version. This method is particularly helpful when you are writing your own plugins, much more so than using it on themes. Nevertheless, it’s good practice to use wp_enqueue_scripts to load stylesheets.\n","permalink":"http://uly.me/posts/wp_enqueue_scripts/","summary":"\u003cp\u003eThere’s a new way to load WordPress stylesheets from within your templates. In the older versions of WordPress, the stylesheets were hard coded on the theme’s header file. The proper way to load your stylesheets is via the functions.php file. Here are the differences.\u003c/p\u003e\n\u003cp\u003eThe old way was:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;link href=\u0026#34;\u0026lt;?php bloginfo(\u0026#39;stylesheet_url\u0026#39;); ?\u0026gt;\u0026#34; media=\u0026#34;screen\u0026#34; rel=\u0026#34;stylesheet\u0026#34; type=\u0026#34;text/css\u0026#34;\u0026gt;\u0026lt;/link\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe new way uses wp_enqueue_scripts and the code is placed in functions.php.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction sample_theme_scripts() {\n\twp_enqueue_style( \u0026#39;style\u0026#39;, get_stylesheet_uri() );\n}\nadd_action( \u0026#39;wp_enqueue_scripts\u0026#39;, \u0026#39;sample_theme_scripts\u0026#39; );\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eBoth codes work, but the latter will give you less headache.\u003c/p\u003e","title":"wp_enqueue_scripts"},{"content":"Here’s a really easy way on how to remove paragraphs or \u0026lt;p\u0026gt;\u0026lt;/p\u0026gt; from the WordPress content.\nIn the WordPress loop, look for the code ‘the_content().’ Add this command just before it:\nremove_filter (\u0026#39;the_content\u0026#39;, \u0026#39;wpautop\u0026#39;); the_content(); That essentially removes all the paragraphs from the WordPress content.\n","permalink":"http://uly.me/posts/remove-paragraphs-from-content/","summary":"\u003cp\u003eHere’s a really easy way on how to remove paragraphs or \u0026lt;p\u0026gt;\u0026lt;/p\u0026gt; from the WordPress content.\u003c/p\u003e\n\u003cp\u003eIn the WordPress loop, look for the code ‘the_content().’ Add this command just before it:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eremove_filter (\u0026#39;the_content\u0026#39;, \u0026#39;wpautop\u0026#39;);\nthe_content();\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThat essentially removes all the paragraphs from the WordPress content.\u003c/p\u003e","title":"remove paragraphs from content"},{"content":"Another issue when installing Laravel on the Ubuntu server is to make sure you have the mod_rewrite module enabled. You can turn it on by invoking the following command.\nsudo a2enmod rewrite sudo service apache2 reload Once you’ve enabled mod_rewrite, you need to restart Apache. That should fix any of the route issues that you may have. If mod_rewrite is disabled, you usually get 404 errors or file not found. The Laravel routes simply doesn’t work.\n","permalink":"http://uly.me/posts/enable-mod-rewrite-in-ubuntu/","summary":"\u003cp\u003eAnother issue when installing Laravel on the Ubuntu server is to make sure you have the mod_rewrite module enabled. You can turn it on by invoking the following command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo a2enmod rewrite\nsudo service apache2 reload\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eOnce you’ve enabled mod_rewrite, you need to restart Apache. That should fix any of the route issues that you may have. If mod_rewrite is disabled, you usually get 404 errors or file not found. The Laravel routes simply doesn’t work.\u003c/p\u003e","title":"enable mod rewrite in ubuntu"},{"content":"I’ve installed Laravel at least a dozen times. Each time, there’s always something new that goes awry during the installation. If it’s not curl, it’s mcrypt, or maybe the app/storage permissions. I think it’s just the fact that I’m experimenting where to put the Laravel files each time I install. It’s either /var/www or /home/user/. I’m using the Ubuntu standard PHP5 install. You have to specifically install php5-curl in addition to the standard PHP package. I think mcrypt is already in the PHP5 package, but to be sure I added it to the install. Here’s the command.\nPHP\nsudo apt-get install php5 php5-curl php5-mcrypt App/storage\ncd /home/user/laravel/app/ chmod -R o+x storage These two things seem to solve most of the Laravel installation issues.\n","permalink":"http://uly.me/posts/laravel-curl-and-mycrypt/","summary":"\u003cp\u003eI’ve installed Laravel at least a dozen times. Each time, there’s always something new that goes awry during the installation. If it’s not curl, it’s mcrypt, or maybe the app/storage permissions. I think it’s just the fact that I’m experimenting where to put the Laravel files each time I install. It’s either /var/www or /home/user/. I’m using the Ubuntu standard PHP5 install. You have to specifically install php5-curl in addition to the standard PHP package. I think mcrypt is already in the PHP5 package, but to be sure I added it to the install. Here’s the command.\u003c/p\u003e","title":"laravel: curl and mycrypt"},{"content":"If you work on servers via Terminal using SSH (secure shell), one of the more annoying things that happens quite regularly are timeouts. If there’s no activity between your SSH client and the server, your terminal is closed because your session has timed out. You’ll need to login again. If you do this at least 6 times a day, then you can see how taxing this whole exercise can be.\nTo avoid Terminal timeouts, you can set the SSH client, your terminal, to keep the connection alive by sending a null signal to the server every few seconds. I’ve set mine to 2 minutes. Since I’m on Mac OS, I’ll need to configure my SSH client. The configuration file is located in your home directory under .ssh/config. If the file doesn’t exist, just create one.\ncd nano .ssh/config Now add the following lines to it.\nHost * ServerAliveInterval 120 I’ve set mine to 120 seconds or 2 minutes. This value works for me while connected to an Ubuntu Server. You may have to play around with this value on other Linux systems. I think this is a better approach as opposed to configuring the SSH server on every server you are connected to. You may not have root access to some servers. Changing the settings on your SSH client is the better approach.\n","permalink":"http://uly.me/posts/keep-your-ssh-sessions-alive/","summary":"\u003cp\u003eIf you work on servers via Terminal using SSH (secure shell), one of the more annoying things that happens quite regularly are timeouts. If there’s no activity between your SSH client and the server, your terminal is closed because your session has timed out. You’ll need to login again. If you do this at least 6 times a day, then you can see how taxing this whole exercise can be.\u003c/p\u003e","title":"keep your ssh sessions alive"},{"content":"By the default, the Genesis child theme called Outreach Pro displays categories posts as excerpts. If you want to display the full content on just one category, Sridhar Katakam talks about it in his blog post. I changed the function names to fit my own, so here’s my own version of the code:\n// display full content on blog category add_action( \u0026#39;genesis_before_loop\u0026#39;, \u0026#39;urr_full_content_specific_category\u0026#39; ); function urr_full_content_specific_category() { if (is_category(\u0026#39;blog\u0026#39;)) { remove_action( \u0026#39;genesis_entry_content\u0026#39;, \u0026#39;genesis_do_post_content\u0026#39; ); add_action( \u0026#39;genesis_entry_content\u0026#39;, \u0026#39;urr_do_post_content\u0026#39; ); } } function urr_do_post_content() { the_content(); } ","permalink":"http://uly.me/posts/display-full-content-per-category/","summary":"\u003cp\u003eBy the default, the Genesis child theme called Outreach Pro displays categories posts as excerpts. If you want to display the full content on just one category, \u003ca href=\"http://sridharkatakam.com/author/sridhar/\"\u003eSridhar Katakam\u003c/a\u003e talks about it in his blog post. I changed the function names to fit my own, so here’s my own version of the code:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// display full content on blog category\nadd_action( \u0026#39;genesis_before_loop\u0026#39;, \u0026#39;urr_full_content_specific_category\u0026#39; );\n \nfunction urr_full_content_specific_category() {\n  if (is_category(\u0026#39;blog\u0026#39;)) {\n\t\tremove_action( \u0026#39;genesis_entry_content\u0026#39;, \u0026#39;genesis_do_post_content\u0026#39; );\n\t\tadd_action( \u0026#39;genesis_entry_content\u0026#39;, \u0026#39;urr_do_post_content\u0026#39; );\n\t}\n}\nfunction urr_do_post_content() {\n\tthe_content();\n}\n\u003c/code\u003e\u003c/pre\u003e","title":"display full content per category"},{"content":"Here’s a cool little WordPress script to display a post from a year ago. You can display your old content to entice your readers to view older articles. You can display your old posts on your theme’s sidebar, after your post content, or just anywhere on your theme. Here’s the code.\n// current day of the month without leading zeros, e.g. 1-31. $current_day = date(\u0026#39;j\u0026#39;); // last year $last_year = date(\u0026#39;Y\u0026#39;)-1; // perform a query based on today\u0026#39;s date last year query_posts(\u0026#39;day=\u0026#39;.$current_day.\u0026#39;\u0026amp;year=\u0026#39;.$last_year); if (have_posts()): while (have_posts()) : the_post(); the_title(); the_excerpt(); endwhile; endif; The result will depend if you have a post last year on the exact date as today, otherwise you’ll get a blank result. I suppose to be on the safe side, you can query all posts of the current month last year. Your chances of getting results is much better. You can use the date(‘n’) function to extract the current month. Your query would look something like this:\n$current_month = date(\u0026#39;n\u0026#39;); query_posts(\u0026#39;month=\u0026#39;.$current_month.\u0026#39;\u0026amp;year=\u0026#39;.$last_year); ","permalink":"http://uly.me/posts/display-post-from-a-year-ago/","summary":"\u003cp\u003eHere’s a cool little WordPress script to display a post from a year ago. You can display your old content to entice your readers to view older articles. You can display your old posts on your theme’s sidebar, after your post content, or just anywhere on your theme. Here’s the code.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// current day of the month without leading zeros, e.g. 1-31.\n$current_day = date(\u0026#39;j\u0026#39;);\n// last year\n$last_year = date(\u0026#39;Y\u0026#39;)-1;\n// perform a query based on today\u0026#39;s date last year\nquery_posts(\u0026#39;day=\u0026#39;.$current_day.\u0026#39;\u0026amp;year=\u0026#39;.$last_year);\nif (have_posts()):\n    while (have_posts()) : the_post();\n       the_title();\n       the_excerpt();\n    endwhile;\nendif;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe result will depend if you have a post last year on the exact date as today, otherwise you’ll get a blank result. I suppose to be on the safe side, you can query all posts of the current month last year. Your chances of getting results is much better. You can use the date(‘n’) function to extract the current month. Your query would look something like this:\u003c/p\u003e","title":"display post from a year ago"},{"content":"There are reasons why you want to hide the Admin Bar from your users. If users don’t have edit rights, then there’s really no use for an Admin bar. Another reason is if the account is shared with others, you don’t want users to reset the password. There are ample reasons why you want to hide the Admin bar.\nHere’s the code:\nif (!current_user_can(‘edit_posts’)) { show_admin_bar(false); } Here’s another:\nfunction my_function_admin_bar(){ return false; } add_filter( \u0026#39;show_admin_bar\u0026#39; , \u0026#39;my_function_admin_bar\u0026#39;); Here’s another for users that can’t manage options:\nif ( ! current_user_can( \u0026#39;manage_options\u0026#39; ) ) { show_admin_bar( false ); } And one more for good measure:\nadd_action(\u0026#39;set_current_user\u0026#39;, \u0026#39;csstricks_hide_admin_bar\u0026#39;); function csstricks_hide_admin_bar() { if (current_user_can(\u0026#39;edit_posts\u0026#39;)) { show_admin_bar(false); } } ","permalink":"http://uly.me/posts/hide-wordpress-admin-bar/","summary":"\u003cp\u003eThere are reasons why you want to hide the Admin Bar from your users. If users don’t have edit rights, then there’s really no use for an Admin bar. Another reason is if the account is shared with others, you don’t want users to reset the password. There are ample reasons why you want to hide the Admin bar.\u003c/p\u003e\n\u003cp\u003eHere’s the code:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eif (!current_user_can(‘edit_posts’)) {\n  show_admin_bar(false);\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s another:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction my_function_admin_bar(){ return false; }\nadd_filter( \u0026#39;show_admin_bar\u0026#39; , \u0026#39;my_function_admin_bar\u0026#39;);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s another for users that can’t manage options:\u003c/p\u003e","title":"hide wordpress admin bar"},{"content":"I noticed several websites using a fullscreen background videos on their home pages. A good example is Paypal.com. The videos are typically short, between 10-15 seconds, with the sound turned off. The video falls back to a still background image for visitors whose browsers do not support HTML5 videos.\nIn addition, Paypal is using what looks like a playlist of several short videos that are displayed in a loop. If you’re interested in how you can implement background videos on your web pages, demothenes.info has a tutorial on how to add video background videos on your website.\n","permalink":"http://uly.me/posts/html5-fullscreen-background-videos/","summary":"\u003cp\u003eI noticed several websites using a fullscreen background videos on their home pages. A good example is \u003ca href=\"http://paypal.com\"\u003ePaypal.com\u003c/a\u003e. The videos are typically short, between 10-15 seconds, with the sound turned off. The video falls back to a still background image for visitors whose browsers do not support HTML5 videos.\u003c/p\u003e\n\u003cp\u003eIn addition, Paypal is using what looks like a playlist of several short videos that are displayed in a loop. If you’re interested in how you can implement background videos on your web pages, \u003ca href=\"http://demothenes.info\"\u003edemothenes.info\u003c/a\u003e has a tutorial on \u003ca href=\"http://demosthenes.info/blog/777/Create-Fullscreen-HTML5-Page-Background-Video\"\u003ehow to add video background videos\u003c/a\u003e on your website.\u003c/p\u003e","title":"html5 fullscreen background videos"},{"content":"Part of creating web design involves working with shades of color. At times, using a color for a HTML link may look good indeed, but the same Hex color code may not necessarily work as a background color. As a designer, you may have to work with different shades of the same color.\nThis article, the code side of color, explains the science behind hexadecimal code, but if you need to figure out colors quickly on your website, Colllor is a great resource that I have been using for several years. Check it out.\n","permalink":"http://uly.me/posts/shades-of-color/","summary":"\u003cp\u003ePart of creating web design involves working with shades of color. At times, using a color for a HTML link may look good indeed, but the same Hex color code may not necessarily work as a background color. As a designer, you may have to work with different shades of the same color.\u003c/p\u003e\n\u003cp\u003eThis article, \u003ca href=\"http://www.smashingmagazine.com/2012/10/04/the-code-side-of-color/\"\u003ethe code side of color\u003c/a\u003e, explains the science behind hexadecimal code, but if you need to figure out colors quickly on your website, \u003ca href=\"http://colllor.com\"\u003eColllor\u003c/a\u003e is a great resource that I have been using for several years. Check it out.\u003c/p\u003e","title":"shades of color"},{"content":"Github released yesterday a new editor called Atom. It’s built on HTML, CSS, Javascript and Node.js. It’s designed to be extensible via add-on packages so it can be used for a number of things, but it’s mainly used as a text editor. The Atom core, Package Manager and Shell are open-source available via the MIT license. Currently is available only on Mac OS, but will be available soon for Windows and Linux.\nThere are over 800 add-on packages already available from the project’s homepage. If you’re a PHP developer, be sure to add language-php, php-twig and php-beautifier. Based on the initial review, it seems to be well-received by a number of reviewers. Is there enough here to get developers to move from Text-Mate and Sublime Text Editor? We will see. I happen to like it a lot. I plan to use it for the next two weeks.\n","permalink":"http://uly.me/posts/atom-editor/","summary":"\u003cp\u003e\u003ca href=\"http://github.com\"\u003eGithub\u003c/a\u003e released yesterday a new editor called \u003ca href=\"https://atom.io/\"\u003eAtom\u003c/a\u003e. It’s built on HTML, CSS, Javascript and \u003ca href=\"http://nodejs.org/\"\u003eNode.js\u003c/a\u003e. It’s designed to be extensible via add-on packages so it can be used for a number of things, but it’s mainly used as a text editor. The Atom core, Package Manager and Shell are open-source available via the \u003ca href=\"http://opensource.org/licenses/MIT\"\u003eMIT license\u003c/a\u003e. Currently is available only on Mac OS, but will be available soon for Windows and Linux.\u003c/p\u003e\n\u003cp\u003eThere are over 800 add-on packages already available from the project’s homepage. If you’re a PHP developer, be sure to add \u003ca href=\"https://atom.io/packages/search?q=php\"\u003elanguage-php\u003c/a\u003e, \u003ca href=\"https://atom.io/packages/search?q=php\"\u003ephp-twig\u003c/a\u003e and \u003ca href=\"https://atom.io/packages/search?q=php\"\u003ephp-beautifier\u003c/a\u003e. Based on the initial review, it seems to be well-received by a number of \u003ca href=\"http://techcrunch.com/2014/05/06/github-open-sources-its-atom-text-editor/\"\u003ereviewers\u003c/a\u003e. Is there enough here to get developers to move from \u003ca href=\"http://macromates.com/\"\u003eText-Mate\u003c/a\u003e and \u003ca href=\"http://www.sublimetext.com/\"\u003eSublime Text Editor\u003c/a\u003e? We will see. I happen to like it a lot. I plan to use it for the next two weeks.\u003c/p\u003e","title":"atom editor"},{"content":"If you’re looking for a way to check if your PHP code is correct without ever loading your script to the web server, then try writecodeonline.com. The service is no longer available. Just paste your PHP code on the online form and click the ‘Run Code’ button and see if your code validates. The online interpreter defaults to PHP 5, but you can choose PHP 4 if you prefer.\nI’ve used it several times to check if my logic makes sense. It’s a great tool to have. It’s very handy tool to have if you want to do a quick check if your code works or not. It does throw out errors so you’ll be able to correct your script if it has a syntax error or if your logic is incorrect.\nBeginning with PHP 5.4, PHP comes with a built-in server. It’s meant to aid application development or for testing in controlled environments. It’s not meant to be a production server or placed in a public network.\n","permalink":"http://uly.me/posts/write-php-code-online/","summary":"\u003cp\u003eIf you’re looking for a way to check if your PHP code is correct without ever loading your script to the web server, then try \u003cdel\u003ewritecodeonline.com\u003c/del\u003e. The service is no longer available. Just paste your PHP code on the online form and click the ‘Run Code’ button and see if your code validates. The online interpreter defaults to PHP 5, but you can choose PHP 4 if you prefer.\u003c/p\u003e\n\u003cp\u003eI’ve used it several times to check if my logic makes sense. It’s a great tool to have. It’s very handy tool to have if you want to do a quick check if your code works or not. It does throw out errors so you’ll be able to correct your script if it has a syntax error or if your logic is incorrect.\u003c/p\u003e","title":"write php code online"},{"content":"I modified an existing Icecast PHP class that I found online. I’ve added a couple of extra fields particularly the ‘status’ field where you’ll be able to determine if your Icecast server is streaming or not. I’ve initially set the status variable to ‘On Air’ and ‘Off Air.’ To use the class, take a look at the code below:\n// include the class file include( \u0026#39;icecast.php\u0026#39; ); // instantiate class $stream = new IceCast(); // set server and mount $server = \u0026#39;http://yourdomain.com:8001\u0026#39;; $file = \u0026#39;/status.xsl?mount=/yourmount.ogg\u0026#39;; // set the url $stream-\u0026gt;setUrl($server,$file); // get status info $radio = $stream-\u0026gt;getStatus(); // assign array to variables extract($radio); // echo the status echo $status.\u0026#39;\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;; // display more stats if ON AIR if ($status==\u0026#39;ON AIR\u0026#39;) : echo $listeners.\u0026#39; listeners\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;; echo $most_listeners.\u0026#39; max listeners\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;; endif; Here’s the Icecast class.\nclass IceCast { var $server = \u0026#34;http://yourdomain.com:8001\u0026#34;; var $stats_file = \u0026#34;/status.xsl?mount=/yourmount.ogg\u0026#34;; var $radio_info=array(); function __construct() { // build array to store our Icecast stats $this-\u0026gt;radio_info[\u0026#39;server\u0026#39;] = $this-\u0026gt;server; $this-\u0026gt;radio_info[\u0026#39;title\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;description\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;content_type\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;mount_start\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;bit_rate\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;listeners\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;most_listeners\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;genre\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;url\u0026#39;] = \u0026#39;\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;now_playing\u0026#39;] = array(); $this-\u0026gt;radio_info[\u0026#39;now_playing\u0026#39;][\u0026#39;artist\u0026#39;] = \u0026#39;Unknown\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;now_playing\u0026#39;][\u0026#39;track\u0026#39;] = \u0026#39;Unknown\u0026#39;; $this-\u0026gt;radio_info[\u0026#39;status\u0026#39;] = \u0026#39;OFF AIR\u0026#39;; } function setUrl($url,$file) { $this-\u0026gt;server=$url; $this-\u0026gt;stats_file=$file; $this-\u0026gt;radio_info[\u0026#39;server\u0026#39;] = $this-\u0026gt;server; } private function fetch() { // create a new curl resource $ch = curl_init(); // set the url curl_setopt($ch,CURLOPT_URL,$this-\u0026gt;server.$this-\u0026gt;stats_file); // return as a string curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // $output = the status.xsl file $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); return $output; } function getStatus() { $output=$this-\u0026gt;fetch(); // loop through $output and sort arrays $temp_array = array(); $search_for = \u0026#34;\u0026lt;td\u0026gt;]*class=\\\u0026#34;streamdata\\\u0026#34;\u0026gt;(.*)\u0026#34;; $search_td = array(\u0026#39;\u0026lt;/td\u0026gt;\u0026lt;td class=\u0026#34;streamdata\u0026#34;\u0026gt;\u0026#39;,\u0026#39;\u0026lt;/td\u0026gt;\u0026#39;); if(preg_match_all(\u0026#34;/$search_for/siU\u0026#34;,$output,$matches)) { foreach($matches[0] as $match) { $to_push = str_replace($search_td,\u0026#39;\u0026#39;,$match); $to_push = trim($to_push); array_push($temp_array,$to_push); } } if(count($temp_array)) { //sort our temp array into our ral array $this-\u0026gt;radio_info[\u0026#39;title\u0026#39;] = $temp_array[0]; $this-\u0026gt;radio_info[\u0026#39;description\u0026#39;] = $temp_array[1]; $this-\u0026gt;radio_info[\u0026#39;content_type\u0026#39;] = $temp_array[2]; $this-\u0026gt;radio_info[\u0026#39;mount_start\u0026#39;] = $temp_array[3]; $this-\u0026gt;radio_info[\u0026#39;bit_rate\u0026#39;] = $temp_array[4]; $this-\u0026gt;radio_info[\u0026#39;listeners\u0026#39;] = $temp_array[5]; $this-\u0026gt;radio_info[\u0026#39;most_listeners\u0026#39;] = $temp_array[6]; $this-\u0026gt;radio_info[\u0026#39;genre\u0026#39;] = $temp_array[7]; $this-\u0026gt;radio_info[\u0026#39;url\u0026#39;] = $temp_array[8]; if(isset($temp_array[9])) { $x = explode(\u0026#34; - \u0026#34;,$temp_array[9]); $this-\u0026gt;radio_info[\u0026#39;now_playing\u0026#39;][\u0026#39;artist\u0026#39;] = $x[0]; $this-\u0026gt;radio_info[\u0026#39;now_playing\u0026#39;][\u0026#39;track\u0026#39;] = $x[1]; } $this-\u0026gt;radio_info[\u0026#39;status\u0026#39;] = \u0026#39;ON AIR\u0026#39;; } return $this-\u0026gt;radio_info; } } ","permalink":"http://uly.me/posts/icecast-php-class/","summary":"\u003cp\u003eI modified an existing Icecast PHP class that I found online. I’ve added a couple of extra fields particularly the ‘status’ field where you’ll be able to determine if your Icecast server is streaming or not. I’ve initially set the status variable to ‘On Air’ and ‘Off Air.’ To use the class, take a look at the code below:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// include the class file\ninclude( \u0026#39;icecast.php\u0026#39; );\n\n// instantiate class\n$stream = new IceCast();\n\n// set server and mount\n$server = \u0026#39;http://yourdomain.com:8001\u0026#39;;\n$file   = \u0026#39;/status.xsl?mount=/yourmount.ogg\u0026#39;;\n\n// set the url\n$stream-\u0026gt;setUrl($server,$file);\n\n// get status info\n$radio = $stream-\u0026gt;getStatus();\n\n// assign array to variables\nextract($radio);\n\n// echo the status\necho $status.\u0026#39;\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;;\n\n// display more stats if ON AIR\nif ($status==\u0026#39;ON AIR\u0026#39;) :\necho $listeners.\u0026#39; listeners\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;;\necho $most_listeners.\u0026#39; max listeners\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#39;;\nendif;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eHere’s the Icecast class.\u003c/p\u003e","title":"icecast php class"},{"content":"I wrote a custom blog in CodeIgniter two years ago. I revisited the code to change the content format a bit. I’ve noticed that there were several pieces of code that were commented out. At the time, I was playing around with what I could potentially do with the content. I thought I would share it here, because it will show you how you could drastically change the content of a blog by manipulating the content.\nLet’s say the content of your blog is assigned to a variable called $item-\u0026gt;content. We can alter the content by passing PHP functions to it. Let’s say we want to limit the content to just the first 330 characters. We can use a PHP function called substr. Substr returns a portion of the string from a specified start and length.\nThe Excerpt\n$item-\u0026gt;content = substr($item-\u0026gt;content,0,330); echo $item-\u0026gt;content; In this example, we are limiting content to the first 330 characters.\nRemove page breaks and new lines\n$item-\u0026gt;content = str_replace(array(\u0026#39;\\r\u0026#39;, \u0026#39;\\n\u0026#39;), \u0026#39;\u0026#39;, $item-\u0026gt;content); echo $item-\u0026gt;content; In this example, str_replace replace page breaks and new lines with ” or nothing.\nRemove two spaces\n$item-\u0026gt;content = str_replace(\u0026#39; \u0026#39;, \u0026#39;\u0026#39;, $item-\u0026gt;content); echo $item-\u0026gt;content; Finally, adding Read More […]\n$item-\u0026gt;content = $item-\u0026gt;content . \u0026#39;\u0026lt;a href=\u0026#34;#\u0026#34;\u0026gt;Read [...]\u0026lt;/a\u0026gt;\u0026#39;; echo $item-\u0026gt;content; I appended to content a link with the anchor of ‘Read […].’\n","permalink":"http://uly.me/posts/modifying-the-content-of-your-blog/","summary":"\u003cp\u003eI wrote a custom blog in CodeIgniter two years ago. I revisited the code to change the content format a bit. I’ve noticed that there were several pieces of code that were commented out. At the time, I was playing around with what I could potentially do with the content. I thought I would share it here, because it will show you how you could drastically change the content of a blog by manipulating the content.\u003c/p\u003e","title":"modifying the content of your blog"},{"content":"If you like to deliver specific content to a certain device type, you can use PHP’s server environment settings to know what type of device, operating systems, and browser type is being used. The server environment setting we are interested in is ‘HTTP_USER_AGENT.’ This index contains a string that is given off by the user agent, the browser in this case. All devices pass down pieces of information identifying themselves, including the type of device, operating system, and browser that is being used.\nIf we were to look for an iPad for example, we need to perform the following commands:\n$iPad = stripos($_SERVER[\u0026#39;HTTP_USER_AGENT\u0026#39;],\u0026#34;iPad\u0026#34;); if ($iPad) { echo \u0026#39;This is an iPad\u0026#39;; } else { echo \u0026#39;This is not\u0026#39;; } Other Devices\n$user_agent = $_SERVER[\u0026#39;HTTP_USER_AGENT\u0026#39;]; $iPad = stripos($user_agent,\u0026#34;iPad\u0026#34;); $iPod = stripos($user_agent,\u0026#34;iPod\u0026#34;); $iPhone = stripos($user_agent,\u0026#34;iPhone\u0026#34;); $webOS = stripos($user_agent,\u0026#34;webOS\u0026#34;); $BlackBerry = stripos($user_agent,\u0026#34;BlackBerry\u0026#34;); $RimTablet= stripos($user_agent,\u0026#34;RIM Tablet\u0026#34;); if (stripos($user_agent,\u0026#34;Android\u0026#34;) \u0026amp;\u0026amp; stripos($user_agent,\u0026#34;mobile\u0026#34;)) { $Android = true; } elseif(stripos($user_agent,\u0026#34;Android\u0026#34;)){ $AndroidTablet = true; } if ($AndroidTablet) { echo \u0026#39;This is an Android Tablet\u0026#39;; } else { echo \u0026#39;This is not an Android Tablet\u0026#39;; } Detect OS Type\n$user_agent = $_SERVER[\u0026#39;HTTP_USER_AGENT\u0026#39;]; if (preg_match(\u0026#39;/linux/i\u0026#39;, $user_agent)) { $platform = \u0026#39;linux\u0026#39;; } if (preg_match(\u0026#39;/macintosh|mac os x/i\u0026#39;, $user_agent)) { $platform = \u0026#39;mac\u0026#39;; } if (preg_match(\u0026#39;/windows|win32/i\u0026#39;, $user_agent)) { $platform = \u0026#39;windows\u0026#39;; } if ($platform == \u0026#39;windows\u0026#39;) { // do something } Detect Browser Type\n$user_agent = $_SERVER[\u0026#39;HTTP_USER_AGENT\u0026#39;]; if (preg_match(\u0026#39;/MSIE/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Internet Explorer\u0026#39;; } if (preg_match(\u0026#39;/Firefox/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Mozilla Firefox\u0026#39;; } if (preg_match(\u0026#39;/Chrome/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Google Chrome\u0026#39;; } if (preg_match(\u0026#39;/Safari/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Apple Safari\u0026#39;; } if (preg_match(\u0026#39;/Opera/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Opera\u0026#39;; } if (preg_match(\u0026#39;/Netscape/i\u0026#39;,$user_agent)) { $browser = \u0026#39;Netscape\u0026#39;; } if ($browser == \u0026#39;Google Chrome\u0026#39;) { // do something } With the sample code above, you can pretty much single out any device and deliver specific content to it.\n","permalink":"http://uly.me/posts/detect-device-os-browser/","summary":"\u003cp\u003eIf you like to deliver specific content to a certain device type, you can use PHP’s server environment settings to know what type of device, operating systems, and browser type is being used. The server environment setting we are interested in is ‘HTTP_USER_AGENT.’ This index contains a string that is given off by the user agent, the browser in this case. All devices pass down pieces of information identifying themselves, including the type of device, operating system, and browser that is being used.\u003c/p\u003e","title":"detect device, os, browser"},{"content":"You’ve heard of the famous 5-minute WordPress installation. You might be able to shave off some considerable time if you try installing WordPress from the command line using a Bash script. So, here’s my stab at how to install WordPress from the Linux shell. To be able to do this, you need access to server’s command line or shell as it’s commonly known in the Linux world. Some hosting companies allows you to have access to shell, some don’t. So, your mileage may vary. In this exercise, you need access to it, if you want to perform these functions.\n#!/bin/bash sudo wget http://wordpress.org/latest.tar.gz sudo tar -xzvf latest.tar.gz sudo mv wordpress/* ./ rm -rf wordpress rm -f latest.tar.gz echo \u0026#34;done!\u0026#34; The sequence\nThe first line tells the system it’s a Bash script.\nThe second line downloads the latest WordPress.\nThe third line untags or unzips the compressed file.\nThe fourth line moves wordpress to the current directory.\nThe fifth line deletes the wordpress folder.\nThe sixth removes the compressed file.\nThe seventh, you echo “done” to the shell.\nThe fourth line needs a little bit of explaining. By default, when you decompress the WordPress zipped file, it dumps all the files in the “wordpress” directory. It might be your intention to create a sub-folder called “wordpress”, but if that is not what you want to do, then you will need to move all the contents out of the ‘wordpress’ folder and place them in the current directory. That’s what I’m doing here. I’m just moving the WordPress files up one level. After the moving the files, I just delete the now empty ‘wordpress’ folder.\nThe echo ‘done’ to the screen is just to tell the user that the installation has completed. All you need to do from this point on is to go to your browser and complete the now famous 5-minute installation. Except that you’ll do it at least half the time. Maybe a quarter off the time.\n","permalink":"http://uly.me/posts/wordpress-bash-script/","summary":"\u003cp\u003eYou’ve heard of the famous 5-minute WordPress installation. You might be able to shave off some considerable time if you try installing WordPress from the command line using a Bash script. So, here’s my stab at how to install WordPress from the Linux shell. To be able to do this, you need access to server’s command line or shell as it’s commonly known in the Linux world. Some hosting companies allows you to have access to shell, some don’t. So, your mileage may vary. In this exercise, you need access to it, if you want to perform these functions.\u003c/p\u003e","title":"wordpress bash script"},{"content":"Heredoc is a way of displaying simplified code in many programming languages. Heredoc is available in PHP and other major languages such as Python, Ruby, and others. If you were to display a HTML form within PHP, you could go in and out of PHP, or use the echo or printf functions within PHP. Any quotes found inside the main quotes would need to be escaped with a backlash or \\. Another trick is to alternatively use single and double quotes. If the string is long, I imagine it can get confusing. Wouldn’t be nice if there was simpler way of doing it. So, here is heredoc coming to the rescue. The following code shows the different ways of presenting HTML within PHP.\nWeaving in and out of PHP\n\u0026lt;?php // some PHP code here ?\u0026gt; \u0026lt;form\u0026gt; First name: \u0026lt;input name=\u0026#34;firstname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; Last name: \u0026lt;input name=\u0026#34;lastname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt; \u0026lt;?php // some more PHP code?\u0026gt; Staying within PHP and using the echo function. Quotes are escaped.\n\u0026lt;?php // some PHP code here echo \u0026#34;\u0026lt;form?\u0026gt;\u0026#34;; echo \u0026#34;First name: \u0026lt;input name=\u0026#34;\\\u0026#34;firstname\\\u0026#34;\u0026#34; type=\u0026#34;\\\u0026#34;text\\\u0026#34;\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\u0026#34;; echo \u0026#34;Last name: \u0026lt;input name=\u0026#34;\\\u0026#34;lastname\\\u0026#34;\u0026#34; type=\u0026#34;\\\u0026#34;text\\\u0026#34;\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\u0026#34;; echo \u0026#34;\u0026#34;; // some more PHP code ?\u0026gt; Using single quotes and double quotes.\n\u0026lt;?php // some PHP code here echo \u0026#39;\u0026lt;form\u0026gt;\u0026#39;; echo \u0026#39;First name: \u0026lt;input name=\u0026#34;firstname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\u0026#39;; echo \u0026#39;Last name: \u0026lt;input name=\u0026#34;lastname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\u0026#39;; echo \u0026#39;\u0026lt;/form\u0026gt;\u0026#39;; ?\u0026gt; \u0026lt;?php // some more PHP code ?\u0026gt; Using heredoc\n\u0026lt;?php // some PHP code here echo = \u0026lt;\u0026lt;\u0026lt;HERE_DOC \u0026lt;form?\u0026gt; First name: \u0026lt;input name=\u0026#34;firstname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt; Last name: \u0026lt;input name=\u0026#34;lastname\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; HERE_DOC; As you can see, Heredoc looks a lot cleaner especially if the form is quite lengthy. You can see the potential advantage as to why one should use Heredoc. To use Heredoc, there are certain rules worth mentioning. The ‘\n","permalink":"http://uly.me/posts/heredoc-in-php/","summary":"\u003cp\u003eHeredoc is a way of displaying simplified code in many programming languages. Heredoc is available in PHP and other major languages such as Python, Ruby, and others. If you were to display a HTML form within PHP, you could go in and out of PHP, or use the echo or printf functions within PHP. Any quotes found inside the main quotes would need to be escaped with a backlash or \\. Another trick is to alternatively use single and double quotes. If the string is long, I imagine it can get confusing. Wouldn’t be nice if there was simpler way of doing it. So, here is heredoc coming to the rescue. The following code shows the different ways of presenting HTML within PHP.\u003c/p\u003e","title":"heredoc in php"},{"content":"If you’re thinking about adding syndication to your website, consider using SimplePie, a super fast and easy-to-use feed parser written in PHP. With SimplePie, adding a RSS feed to your site couldn’t be more easier. In this article, I will show you how to create a RSS page that will display a feed. It will display my blog’s RSS feed as default when nothing is clicked. I’ve included a couple of links that are clickable. When the links are clicked, the RSS feed for that link will be displayed.\nFirst, download SimplePie.\nNext, we need to create a file and copy the code below. The code is pretty much self-explanatory.\n\u0026lt;?php // include SimplePie require_once(\u0026#39;php/autoloader.php\u0026#39;); // Create a new object called $feed $feed = new SimplePie(); // Set the default to my blog\u0026#39;s RSS at first run if ($_GET[feed] == \u0026#34;\u0026#34;) { $_GET[feed]=\u0026#34;http://uly.me/feed/\u0026#34;; } $feed-?\u0026gt;set_feed_url($_GET[feed]); // Run SimplePie. $feed-\u0026gt;init(); // Send the result to show up on the browser $feed-\u0026gt;handle_content_type(); ?\u0026gt; \u0026lt;a href=\u0026#34;rssfeed.php?feed=http://news.yahoo.com/rss\u0026#34;\u0026gt;Yahoo News\u0026lt;/a\u0026gt; | \u0026lt;a href=\u0026#34;rssfeed.php?feed=http://feeds.reuters.com/reuters/topNews\u0026#34;\u0026gt;Reuter News\u0026lt;/a\u0026gt; \u0026lt;div class=\u0026#34;header\u0026#34;\u0026gt; \u0026lt;h1\u0026gt;\u0026lt;a href=\u0026#34;\u0026lt;?php echo $feed-\u0026gt;get_permalink(); ?\u0026gt;\u0026#34;\u0026gt;\u0026lt;?php echo $feed-?\u0026gt;get_title(); ?\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/h1\u0026gt; \u0026lt;p\u0026gt;\u0026lt;?php echo $feed-?\u0026gt;get_description(); ?\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php // Display the feed inside a loop foreach ($feed-?\u0026gt;get_items() as $item): ?\u0026gt; \u0026lt;div class=\u0026#34;item\u0026#34;\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a href=\u0026#34;\u0026lt;?php echo $item-\u0026gt;get_permalink(); ?\u0026gt;\u0026#34; target=\u0026#34;_blank\u0026#34;\u0026gt;\u0026lt;?php echo $item-?\u0026gt;get_title(); ?\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;p\u0026gt;\u0026lt;?php echo $item-?\u0026gt;get_description(); ?\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;p\u0026gt;\u0026lt;small\u0026gt;Posted on \u0026lt;?php echo $item-?\u0026gt;get_date(\u0026#39;j F Y | g:i a\u0026#39;); ?\u0026gt;\u0026lt;/small\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php endforeach; /* end of file */ See the demo. Just add your own CSS stylesheet and you\u0026rsquo;re ready to go.\n","permalink":"http://uly.me/posts/simplepie-rss-reader/","summary":"\u003cp\u003eIf you’re thinking about adding syndication to your website, consider using SimplePie, a super fast and easy-to-use feed parser written in PHP. With SimplePie, adding a RSS feed to your site couldn’t be more easier. In this article, I will show you how to create a RSS page that will display a feed. It will display my blog’s RSS feed as default when nothing is clicked. I’ve included a couple of links that are clickable. When the links are clicked, the RSS feed for that link will be displayed.\u003c/p\u003e","title":"simplepie rss reader"},{"content":"Calculating and formatting dates is an important function when writing software applications. You might be needing to perform a database search of all transactions a month ago, six months ago, etc. To make this all possible, you need to be able to figure out how to calculate dates based from today’s date. PHP has a couple of date functions called date() and mktime(). I use the date() function primarily for formatting dates, and mktime() function for calculating dates since mktime() is the actual Unix timestamp. With these two functions, you can do some pretty amazing date calculations.\nLet’s get started.\n// Today\u0026#39;s date $day = date(\u0026#34;d\u0026#34;); $month = date(\u0026#34;m\u0026#34;); $year = date(\u0026#34;Y\u0026#34;); // Using mktime calculate past dates $start_of_three_months_ago = mktime(0, 0, 0, date(\u0026#34;m\u0026#34;)-2, 1, date(\u0026#34;Y\u0026#34;)); $end_of_three_months_ago = mktime(23, 59, 59, date(\u0026#34;m\u0026#34;)-1, 0, date(\u0026#34;Y\u0026#34;)); // Using mktime to calculate future dates $start_of_three_months_from_now = mktime(0, 0, 0, date(\u0026#34;m\u0026#34;)+3, 1, date(\u0026#34;Y\u0026#34;)); $end_of_three_months_from_now = mktime(23, 59, 59, date(\u0026#34;m\u0026#34;)+4, 0, date(\u0026#34;Y\u0026#34;)); // Formatting dates to \u0026#39;month day, year\u0026#39; format. $a = date(\u0026#34;M j, Y\u0026#34;, $start_of_three_months_ago); $b = date(\u0026#34;M j, Y\u0026#34;, $end_of_three_months_ago); $c = date(\u0026#34;M j, Y\u0026#34;, $start_of_three_months_from_now); $d = date(\u0026#34;M j, Y\u0026#34;, $end_of_three_months_from_now); // results are based on today\u0026#39;s date echo $day; // results in 26 echo $month; // results in 02 echo $year; // results in 2014 echo $a; // results in Dec 1, 2013 echo $b; // results in Dec 31, 2014 echo $c; // results in May 1, 2014 echo $d; // results in May 31, 2014 You can then use any set of dates to calculate transactions on the database. For example.\nSELECT price FROM product WHERE purchase_date BETWEEN $a AND $b; Read more about PHP’s date and mktime functions. See demo. Results are based on today’s date.\n","permalink":"http://uly.me/posts/calculating-dates-in-php/","summary":"\u003cp\u003eCalculating and formatting dates is an important function when writing software applications. You might be needing to perform a database search of all transactions a month ago, six months ago, etc. To make this all possible, you need to be able to figure out how to calculate dates based from today’s date. PHP has a couple of date functions called date() and mktime(). I use the date() function primarily for formatting dates, and mktime() function for calculating dates since mktime() is the actual Unix timestamp. With these two functions, you can do some pretty amazing date calculations.\u003c/p\u003e","title":"calculating dates in php"},{"content":"I recently switched to Comcast for my Internet services. It has been several years since I have left and abandoned Comcast. I was curious more than anything as to what kind of download speeds I’ll be getting now that I’m back to using broadband cable. The result is pretty impressive. It has been a while since I’ve seen this kind of speeds at home. It’s about 4-5 times faster than what I previously had. I ran 3 different speed tests from 3 different sources. I’m a little surprised the results were similar. All fell within the same range of one another. So, without much further ado, here are the results of the speed tests.\nComcast Speed Test\nSpeakeasy\nSpeedtest\n","permalink":"http://uly.me/posts/the-latest-speed-test/","summary":"\u003cp\u003eI recently switched to Comcast for my Internet services. It has been several years since I have left and abandoned Comcast. I was curious more than anything as to what kind of download speeds I’ll be getting now that I’m back to using broadband cable. The result is pretty impressive. It has been a while since I’ve seen this kind of speeds at home. It’s about 4-5 times faster than what I previously had. I ran 3 different speed tests from 3 different sources. I’m a little surprised the results were similar. All fell within the same range of one another. So, without much further ado, here are the results of the speed tests.\u003c/p\u003e","title":"the latest speed test"},{"content":"I ran into some issues with a piece of code I wrote several years ago in CodeIgniter. I’m using names of people as part of the URL. When someone enters a name with spaces on the database, the spaces are converted to %20 in the resulting URL. The URL doesn’t look pretty and definitely not SEO friendly. It needs to be cleaned up by replacing spaces with either a dash or an underscore.\nThe other issue is when performing a search, the database doesn’t really know that ‘John Doe’ is essentially the same as ‘John%20Doe.’ So, I ended up using a CodeIgniter function called url_title. The function strips the spaces and replaces it with a dash or a hyphen. In the case of ‘John%20Doe’, it now displays as ‘John-Doe.’ You can also use an underscore. See example below.\nReplace %20 with dash or hypen\n$name = \u0026#39;John Doe\u0026#39;; $url = url_title($name); // produces \u0026#39;John-Doe\u0026#39; $name = \u0026#39;John Doe\u0026#39;; $url = url_title($name, \u0026#39;_\u0026#39;); // produces \u0026#39;John_Doe\u0026#39; Put the space before the search\nBefore performing a search, I use str_replace to remove the dash and put back the space so it matches the database entry. It’s essentially the reverse of what I did to display a friendly URL.\n$url = \u0026#39;John-Doe\u0026#39;; $name = str_replace(\u0026#39;-\u0026#39;, \u0026#39; \u0026#39;, $url); // perform your search function here If you’re not familiar with CodeIgniter, check how URI routing and url_title are handled.\n","permalink":"http://uly.me/posts/url-spaces-in-codeigniter/","summary":"\u003cp\u003eI ran into some issues with a piece of code I wrote several years ago in CodeIgniter. I’m using names of people as part of the URL. When someone enters a name with spaces on the database, the spaces are converted to %20 in the resulting URL. The URL doesn’t look pretty and definitely not SEO friendly. It needs to be cleaned up by replacing spaces with either a dash or an underscore.\u003c/p\u003e","title":"url spaces in codeigniter"},{"content":"If you have a problem importing SQL files into phpMyAdmin, the issue could be that the upload limit in PHP is set too low. By default, PHP sets the upload file limit to 2MB, which is too low for most people. You can increase the limit to something more realistic such as 16MB, if you’re working mostly with medium-sized SQL databases.\nIf you have access to the Terminal and have root access, you can edit your PHP.ini settings. First, you need to find out where your default PHP.ini is located. There might be several PHP.ini files in your system, but there’s only one bound to Apache. To determine to which one is being used, I suggest you create a file that contains the PHP function called phpinfo(). Place this file your web server and run it.\nCreate a file called phpinfo.php. Enter the code below. Save. Upload to server.\n\u0026lt;?php phpinfo(); ??\u0026gt; Now, open your browser and point the URL where your phpinfo.php is stored on your web server. The phpinfo.php file will run the phpinfo() function and will display the environment variables being used by Apache. Near the top of the page, you’ll see the path of the php.ini. Now that you know where your php.ini file is exactly located, you’ll need to edit that file and look for the Upload Limits.\nIn Ubuntu, my php.ini is located in /etc/php5/apache2/php.ini.\nsudo nano /etc/php5/apache2/php.ini Look for the File Uploads text as displayed below. Change from 2M to 16M. Save file.\n;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; upload_max_filesize = 16M Finally, you need to reboot Apache for your changes take effect.\nsudo /etc/init.d/apache restart ","permalink":"http://uly.me/posts/importing-sql-in-phpmyadmin/","summary":"\u003cp\u003eIf you have a problem importing SQL files into phpMyAdmin, the issue could be that the upload limit in PHP is set too low. By default, PHP sets the upload file limit to 2MB, which is too low for most people. You can increase the limit to something more realistic such as 16MB, if you’re working mostly with medium-sized SQL databases.\u003c/p\u003e\n\u003cp\u003eIf you have access to the Terminal and have root access, you can edit your PHP.ini settings. First, you need to find out where your default PHP.ini is located. There might be several PHP.ini files in your system, but there’s only one bound to Apache. To determine to which one is being used, I suggest you create a file that contains the PHP function called phpinfo(). Place this file your web server and run it.\u003c/p\u003e","title":"importing sql in phpmyadmin"},{"content":"If there’s a need for you to list directories on the server, there’s a PHP function called Glob which will find pathnames to match a certain pattern. To make glob read only directories on the server, we can specify in the glob function with the GLOB_ONLYDIR option which will return only directories and ignore files. The asterisk means it will accept any pattern.\nglob(\u0026#39;*\u0026#39;, GLOB_ONLYDIR); In the example below, we will specify any directory by assigning an empty or a blank to the $dir variable. We will then use the foreach loop to display all directories found. If we have WordPress installed, we can ignore the WordPress directories by searching for them in the if statement. We will finally echo and print to the screen each individual directory found by our glob function.\nHere’s the entire script with HTML included.\n\u0026lt;title\u0026gt;Glob - list directories\u0026lt;/title\u0026gt; \u0026lt;style\u0026gt; li { list-style-type:none; margin-left:-15px; } \u0026lt;/style\u0026gt; \u0026lt;h1\u0026gt;List directories using Glob\u0026lt;/h1\u0026gt; \u0026lt;?php // set to current directory $dir = \u0026#39;\u0026#39;; // directories only. ignore files, etc. foreach(glob($dir.\u0026#39;*\u0026#39;, GLOB_ONLYDIR) as $folder){ // do not include wordpress directories if (($folder != \u0026#39;wp-admin\u0026#39;) \u0026amp;\u0026amp; ($folder != \u0026#39;wp-content\u0026#39;) \u0026amp;\u0026amp; ($folder != \u0026#39;wp-includes\u0026#39;)) { // list directories and their links ?\u0026gt; - [\u0026#34;\u0026amp;gt;\u0026lt;?php echo $folder;??\u0026gt;](\u0026lt;\u0026lt;?php echo $dir.\u0026gt;) \u0026lt;?php } } ?\u0026gt; ","permalink":"http://uly.me/posts/list-directories-using-glob/","summary":"\u003cp\u003eIf there’s a need for you to list directories on the server, there’s a PHP function called \u003ca href=\"http://us2.php.net/glob\"\u003eGlob\u003c/a\u003e which will find pathnames to match a certain pattern. To make glob read only directories on the server, we can specify in the glob function with the GLOB_ONLYDIR option which will return only directories and ignore files. The asterisk means it will accept any pattern.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eglob(\u0026#39;*\u0026#39;, GLOB_ONLYDIR);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn the example below, we will specify any directory by assigning an empty or a blank to the $dir variable. We will then use the foreach loop to display all directories found. If we have WordPress installed, we can ignore the WordPress directories by searching for them in the if statement. We will finally echo and print to the screen each individual directory found by our glob function.\u003c/p\u003e","title":"list directories using glob"},{"content":"Akismet is a web service that detects spam. Akismet was originally created by Automattic, the company behind WordPress, to filter out spam comments on its own blogs. The use of Akismet has spread to other blogs and CMS engines. Akismet can also be implemented on other websites. There are a number of plugins and libraries available. Akismit also has an API.\nAkismet is open-source and free for personal use. Akismet offers professional and enterprise plans for a modest fee. To start using Akismet on your website, you first need an Akismet key which you can get from WordPress.com. Just register. A key will be automatically generated for you. In addition, you also need to download the Akismet class library which you’ll need to include in your web projects.\nHow to use Akismet\nIn this example, we will use Akismet’s PHP class library. Download. So, let’s assume you have a comment form or a contact page on your website. When your form is submitted, Akismet will check if the comment is spam or not. The API accesses the Akismet servers and it will return either a yes or a no. Simple enough. How Akismet filters out the spam is not known. They say it’s in the “secret sauce.”\nOur HTML Form\nWe will keep our form simple. We will use the post method. Our form will call itself after submission. We are taking the proper precautions to avoid cross-site scripting attacks, etc. by using the htmlspecialchars function and the $_SERVER[“PHP_SELF”] variable itself.\n\u0026lt;form action=\u0026#34;\u0026lt;?php echo htmlspecialchars($_SERVER[\u0026#34; method=\u0026#34;post\u0026#34; php_self=\u0026#34;\u0026#34;\u0026gt; Name: \u0026lt;input name=\u0026#34;name\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; Email: \u0026lt;input name=\u0026#34;email\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; URL: \u0026lt;input name=\u0026#34;url\u0026#34; type=\u0026#34;text\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; Comment: \u0026lt;textarea cols=\u0026#34;80\u0026#34; name=\u0026#34;comment\u0026#34; rows=\u0026#34;5\u0026#34;\u0026gt;\u0026lt;/textarea\u0026gt; \u0026lt;input name=\u0026#34;submit\u0026#34; type=\u0026#34;submit\u0026#34; value=\u0026#34;Submit\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt; Our PHP Code\nThis is the PHP code that we can place at top of our page. The code will start a new session. It will check if the form is submitted. We will then create a new Akismet object and check if our comment data is spam or not. The Akismet class will contact the Akismet servers. It will determine if our comment is spam or not. If it is, it will mark it as spam. We can either ignore it or save it to the database. If it’s a good comment, we definitely need to keep it and mark it as good comment.\n\u0026lt;?php // start a new session session_start(); // our submitted values are sanitized $author = addslashes(htmlspecialchars(strip_tags(trim($_POST[\u0026#39;name\u0026#39;])))); $email = addslashes(htmlspecialchars(strip_tags(trim($_POST[\u0026#39;email\u0026#39;])))); $url = addslashes(htmlspecialchars(strip_tags(trim($_POST[\u0026#39;url\u0026#39;])))); $comment = addslashes(htmlspecialchars(strip_tags(trim($_POST[\u0026#39;comment\u0026#39;])))); // Load array with comment data. $data = array( \u0026#39;author\u0026#39; =?\u0026gt; $author, \u0026#39;email\u0026#39; =\u0026gt; $email, \u0026#39;website\u0026#39; =\u0026gt; \u0026#39;http://www.yourdomain.com/\u0026#39;, \u0026#39;body\u0026#39; =\u0026gt; $comment, \u0026#39;permalink\u0026#39; =\u0026gt; \u0026#39;http://www.yourdomain.com/path-to-your-comment-page\u0026#39;, ); // include Akismet class include \u0026#34;akismet.class.php\u0026#34;; // check if the form was submitted if(isset($_POST[\u0026#39;submit\u0026#39;])) { // submitted // create a new object $akismet = new Akismet(\u0026#39;http://www.yourdomain.com/\u0026#39;, \u0026#39;YOUR_WORDPRESS_API_KEY\u0026#39;, $data); if($akismet-\u0026gt;errorsExist()) { echo \u0026#34;Oops! Problem connecting to the Akismet server!\u0026#34;; } else { if($akismet-\u0026gt;isSpam()) { echo \u0026#34;This is spam!\u0026#34;; // mark comment as spam // option to either save to database or ignore } else { echo \u0026#34;This is good ham! Let\u0026#39;s keep it!\u0026#34;; // mark comment as good ham // definitely save the good comment to the database } } } ?\u0026gt; Making a Correction\nOccasionally, not very often, Akismet screws up, and marks a good comment as spam, and vice versa. We can tell Akismet, “Hey, what’s the matter! Please correct these comments!” We can correct Akismet by running these two methods.\n// Submit as Ham $akismet-\u0026gt;submitHam(); // Submit as Spam $akismet-\u0026gt;submitSpam(); That’s how how Akismet is implemented in a nutshell.\n","permalink":"http://uly.me/posts/fighting-spam-with-akismet/","summary":"\u003cp\u003eAkismet is a web service that detects spam. Akismet was originally created by Automattic, the company behind WordPress, to filter out spam comments on its own blogs. The use of Akismet has spread to other blogs and CMS engines. Akismet can also be implemented on other websites. There are a number of plugins and libraries available. Akismit also has an API.\u003c/p\u003e\n\u003cp\u003eAkismet is open-source and free for personal use. Akismet offers professional and enterprise plans for a modest fee. To start using Akismet on your website, you first need an Akismet key which you can get from WordPress.com. Just register. A key will be automatically generated for you. In addition, you also need to download the Akismet class library which you’ll need to include in your web projects.\u003c/p\u003e","title":"fighting spam with akismet"},{"content":"I just signed up for an all-day conference called Responsive Web Trends Conference in San Francisco. It’s a day-long event and it’s free as in beer. The event is on Wednesday, February 12, 2014 starting at 9am. Register.\nResponsive Web Trends is a completely free, day-long conference for those who are passionate about creating websites that look great and work well on any device—even those that haven’t been invented yet.\nThe conference brings together forward-thinking industry influencers, designers and developers for a day of deep discussions and workshops. Presented by Moboom, the conference explores trends in responsive web design and adaptive technologies with the goal of creating an open dialogue about how designers and developers can work more efficiently and think beyond just mobile.\nThe speakers include Jason Grigsby, Greg Nudelman, and Ben Callahan.\nThe topics planned are:\nA Developer’s Next Big Challenge Dissecting Responsive Design Lean Mobile-First UX Scale Big with Docker Multi-Lingual Coding And more… The event is sponsored by Moboom.\n","permalink":"http://uly.me/posts/responsive-web-trends-conference/","summary":"\u003cp\u003eI just signed up for an all-day conference called Responsive Web Trends Conference in San Francisco. It’s a day-long event and it’s free as in beer. The event is on Wednesday, February 12, 2014 starting at 9am. \u003ca href=\"http://www.meetup.com/sfhtml5/events/164549162/\"\u003eRegister\u003c/a\u003e.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eResponsive Web Trends is a completely free, day-long conference for those who are passionate about creating websites that look great and work well on any device—even those that haven’t been invented yet.\u003c/p\u003e\n\u003cp\u003eThe conference brings together forward-thinking industry influencers, designers and developers for a day of deep discussions and workshops. Presented by Moboom, the conference explores trends in responsive web design and adaptive technologies with the goal of creating an open dialogue about how designers and developers can work more efficiently and think beyond just mobile.\u003c/p\u003e","title":"responsive web trends conference"},{"content":"We’ve all seen the default WordPress login page. It’s dull, bland, and boring. Typically, the login page is not part of the WordPress theme setup. Most theme designers don’t bother to change the login screen because it’s not really necessary. The cool thing is, it’s entirely feasible to customize the login page. This article will show you how to change your WordPress login page to something like below.\nChanging the WordPress Logo\nWe can replace the WordPress logo located on top of the login form by calling a WordPress hook called ‘login_enqueue_scripts.’ This hook is responsible for enqueuing items to the login page. In this example, we are assigning an image to ‘body.login div#login h1 a.’\nPlace the following code in your theme’s ‘functions.php’ file.\nfunction urr_login_logo() { } The ‘logo.png’ file is located in your theme’s ‘images’ folder. Why can’t I see the logo image? Believe me, it’s there. You can’t see it because I made it transparent. It would be visible if it were non-transparent. So, it’s possible to replace the WordPress logo or display nothing at all, like I just did just now, using a transparent image.\nBy the way, the image needs to be 80×80 pixels in size.\nAdding a Background Image\nHow do we add a background image to the login page? Well, one thing worth noting, WordPress does not load your theme’s stylesheet when the login page is loaded. To style to the login page, we need to add our own custom stylesheet. It will be loaded when the login page is displayed.\nNow, place the following code in your theme’s ‘functions.php’ file.\nfunction urr_custom_login_css() { echo \u0026#39;\u0026#39;; } add_action(\u0026#39;login_head\u0026#39;, \u0026#39;urr_custom_login_css\u0026#39;); This code above loads a stylesheet when the login page is loaded. It’s using the ‘login_head’ hook.\nOur Stylesheet\nCreate a file called login-style.css and place it inside our theme’s directory under the ‘css’ folder. We can now style our login page. The code below will apply a background image ‘darkwood.jpg’ to the login page. The form and its inputs are darkened, except for the submit button which remains unchanged. In addition, we also rounded the corners of the form.\nbody.login { background: #000 url(\u0026#39;http://uly.me/wp-content/themes/minimum/images/darkwood.jpg\u0026#39;) no-repeat fixed center; } div#login form { background-color:#111; border-radius: 10px; } div#login form input#user_pass, div#login form input#user_login, div#login form input#rememberme { color: #aaa; background-color:#333; border: 1px solid #000; border-radius: 3px; } div#login form input#user_pass, div#login form input#user_login, div#login form input#rememberme { color: #aaa; background-color:#333; } Finally, upload your functions.php, login-styles.css and images files to your server. Enjoy your custom login page.\n","permalink":"http://uly.me/posts/wordpress-custom-login-page/","summary":"\u003cp\u003eWe’ve all seen the default WordPress login page. It’s dull, bland, and boring. Typically, the login page is not part of the WordPress theme setup. Most theme designers don’t bother to change the login screen because it’s not really necessary. The cool thing is, it’s entirely feasible to customize the login page. This article will show you how to change your WordPress login page to something like below.\u003c/p\u003e\n\u003cp\u003e\u003cimg alt=\"wp-login\" loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2014/02/wp-login.png\"\u003e\u003c/p\u003e\n\u003cp\u003eChanging the WordPress Logo\u003c/p\u003e","title":"wordpress custom login page"},{"content":"Yahoo got hacked again. Based on what I read, not everyone was affected. Yahoo has over 273 million users using their mail service. If you haven’t received an email from Yahoo asking you to reset your password, you are probably ok. But, you could never be so sure. Better reset your password.\nLike most users, we probably use the same password across many sites. It’s doesn’t sound like a good idea now. If one website gets hacked, all your other accounts are possibly compromised as well. As a good security practice, it’s probably a good idea to use different passwords for different accounts.\nComing up with a difficult password is not always easy. There are numerous sites that auto-generate passwords for you. You can specify the level of difficulty. You can make it 6, 7, or 8 characters. You can include numbers, special characters and use capitalization.\nInstead of going to websites and auto-generating passwords for you, you could do it yourself. You can learn how to randomly create passwords. In this article, I will share with you how you can auto-generate passwords using the PHP language, and in particular using PHP function called mt_rand().\nFirst, let’s specify what characters we want to include in our password. We will use both uppercase and lowercase. No vowels. Numbers 1 to 9. Finally, we will include some specials characters to spice things up. We will assign all the characters that we want included to a variable called $characters.\nThe Characters\n// list of random characters $characters = array( \u0026#34;B\u0026#34;,\u0026#34;C\u0026#34;,\u0026#34;D\u0026#34;,\u0026#34;F\u0026#34;,\u0026#34;G\u0026#34;,\u0026#34;H\u0026#34;,\u0026#34;J\u0026#34;,\u0026#34;K\u0026#34;,\u0026#34;L\u0026#34;,\u0026#34;M\u0026#34;,\u0026#34;N\u0026#34;,\u0026#34;P\u0026#34;,\u0026#34;Q\u0026#34;,\u0026#34;R\u0026#34;,\u0026#34;S\u0026#34;,\u0026#34;T\u0026#34;,\u0026#34;V\u0026#34;,\u0026#34;W\u0026#34;,\u0026#34;X\u0026#34;,\u0026#34;Y\u0026#34;,\u0026#34;Z\u0026#34;, \u0026#34;b\u0026#34;,\u0026#34;c\u0026#34;,\u0026#34;d\u0026#34;,\u0026#34;f\u0026#34;,\u0026#34;g\u0026#34;,\u0026#34;h\u0026#34;,\u0026#34;j\u0026#34;,\u0026#34;k\u0026#34;,\u0026#34;l\u0026#34;,\u0026#34;m\u0026#34;,\u0026#34;n\u0026#34;,\u0026#34;p\u0026#34;,\u0026#34;q\u0026#34;,\u0026#34;r\u0026#34;,\u0026#34;s\u0026#34;,\u0026#34;t\u0026#34;,\u0026#34;v\u0026#34;,\u0026#34;w\u0026#34;,\u0026#34;x\u0026#34;,\u0026#34;y\u0026#34;,\u0026#34;z\u0026#34;, \u0026#34;1\u0026#34;,\u0026#34;2\u0026#34;,\u0026#34;3\u0026#34;,\u0026#34;4\u0026#34;,\u0026#34;5\u0026#34;,\u0026#34;6\u0026#34;,\u0026#34;7\u0026#34;,\u0026#34;8\u0026#34;,\u0026#34;9\u0026#34;, \u0026#34;!\u0026#34;,\u0026#34;@\u0026#34;,\u0026#34;#\u0026#34;,\u0026#34;$\u0026#34;,\u0026#34;%\u0026#34;,\u0026#34;^\u0026#34;,\u0026#34;*\u0026#34;,\u0026#34;(\u0026#34;,\u0026#34;)\u0026#34;,\u0026#34;+\u0026#34;,\u0026#34;=\u0026#34;,\u0026#34;{\u0026#34;,\u0026#34;}\u0026#34;,\u0026#34;[\u0026#34;,\u0026#34;]\u0026#34;,\u0026#34;~\u0026#34; ); In this example, we will use a 7 character password. We will create a loop that will be executed 7 times. It will randomly pick a character from the $characters array. It will check to see if the character was already picked. It will pick another if it is. It will then store the characters in an array called $keys until all 7 characters are picked.\nThe while loop checks how many characters are in the array and will stop until all 7 characters are picked. The mt_rand() function randomly picks the characters. The in_array() function checks to see if the character was already picked in the array.\nThe Random Keys\n// Assign an array for our random key $keys = array(); // generate random key 7 times while(count($keys) Now that we have our 7 character key, let\u0026rsquo;s display it on the screen. Since it\u0026rsquo;s in an array, we will extract it one by one using the while loop and assign the keys to a variable called $random_chars. Finally, we will echo the variable $random_chars to display our auto-generated password to the screen.\nDisplay the Keys foreach($keys as $key) : $random_chars .= $characters[$key]; endforeach; // display random key echo $random_chars; If you like to see how it works, check out the demo. Click refresh to view a different result.\n","permalink":"http://uly.me/posts/password-generator/","summary":"\u003cp\u003eYahoo got hacked again. Based on what I read, not everyone was affected. Yahoo has over 273 million users using their mail service. If you haven’t received an email from Yahoo asking you to reset your password, you are probably ok. But, you could never be so sure. Better reset your password.\u003c/p\u003e\n\u003cp\u003eLike most users, we probably use the same password across many sites. It’s doesn’t sound like a good idea now. If one website gets hacked, all your other accounts are possibly compromised as well. As a good security practice, it’s probably a good idea to use different passwords for different accounts.\u003c/p\u003e","title":"password generator"},{"content":"If you have a form that accepts IP addresses, you might want to validate it to make sure it really is a valid IP address. I’m talking about IPv4 since IPv6 is not yet universally implemented. A valid IPv4 IP addresses should fall between the numbers 0.0.0.0 and 255.255.255.255. In this example, we will use a regular expression and a pattern matching function in PHP to see if it’s a real IP address.\nFirst things first, we need to sanitize the input. We can use the following PHP functions. We will assign the sanitized input to a variable.\n// sanitize input from form $ip_address = addslashes(htmlspecialchars(strip_tags(trim($_POST[\u0026#39;ip_address\u0026#39;])))); This is the regular expression that we will use that accepts valid IP addresses.\n// the regular expression for valid ip addresses $reg_ex = \u0026#39;/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$/\u0026#39;; We will now compare the two variables: $reg_ex and $ip_address to see if IP address passes the test.\n// test input against the regular expression if (preg_match($reg_ex, $ip_address)) { return TRUE; // it\u0026#39;s a valid ip address } We will now place everything in a tidy function so we can use it anytime we want.\nfunction validate_ip_address($ip_address) { // sanitized ip address $clean_ip_address = addslashes(htmlspecialchars(strip_tags(trim($ip_address)))); // the regular expression for valid ip addresses $reg_ex = \u0026#39;/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$/\u0026#39;; // test input against the regular expression if (preg_match($reg_ex, $clean_ip_address)) { return TRUE; // it\u0026#39;s a valid ip address } } Finally, it’s time to call our function.\n$ip_address = $_POST[\u0026#39;ip_address\u0026#39;]; if (validate_ip_address($ip_address)) { echo \u0026#34;It\u0026#39;s a valid IP address!\u0026#34;; } ","permalink":"http://uly.me/posts/validating-ip-addresses/","summary":"\u003cp\u003eIf you have a form that accepts IP addresses, you might want to validate it to make sure it really is a valid IP address. I’m talking about IPv4 since IPv6 is not yet universally implemented. A valid IPv4 IP addresses should fall between the numbers 0.0.0.0 and 255.255.255.255. In this example, we will use a regular expression and a pattern matching function in PHP to see if it’s a real IP address.\u003c/p\u003e","title":"validating ip addresses"},{"content":"The title of an article is one of the most important factors for SEO. It’s second only to the content itself. The title has to be catchy, concise and relevant to the content. If you look at Google search results, they show roughly 70 characters of the title on the results page. If the title is too long, you’ll see 3 dots or ellipses as they’re appropriately called. There’s really no ideal length for titles, as long as they best describe the content of the page. They can be short or long and must contain certain keywords.\nIf the title is too long, it can sometimes wreak havoc to the layout of the theme. There are times that you may have to trim the title so it doesn’t become such an eyesore. If you need to truncate the title, there is a function in PHP called ‘substr’ which returns parts of a string. In WordPress, page titles can be retrieved using a function called the_title(). We can truncate this string, by creating a new function called truncate().\n\u0026lt;?php // lets create truncate function function truncate($the_title) { $the_new_title = substr($the_title, 0, 70); if (strlen($the_title) ?\u0026gt; 70) $the_new_title .= \u0026#39; ...\u0026#39;; return $the_new_title; } // assign the title to a variable $the_title = the_title(); // we call the truncate function echo truncate($the_title); In this example above, we created a new function called truncate(). We passed a variable containing the title to the function. Substr will trim the title string starting at location 0, and will preserve it for the next 70 characters. The strlen function counts the string, and adds ellipses at the end if the string is longer than 70 characters. The truncated value is then returned. It can be echoed for display if we want. We can place this new function anywhere in our theme files. We can insert it in the main WordPress loop or on single pages.\n","permalink":"http://uly.me/posts/truncating-page-titles/","summary":"\u003cp\u003eThe title of an article is one of the most important factors for SEO. It’s second only to the content itself. The title has to be catchy, concise and relevant to the content. If you look at Google search results, they show roughly 70 characters of the title on the results page. If the title is too long, you’ll see 3 dots or ellipses as they’re appropriately called. There’s really no ideal length for titles, as long as they best describe the content of the page. They can be short or long and must contain certain keywords.\u003c/p\u003e","title":"truncating page titles"},{"content":"There are some instances where you might need to alter or customize the content of a WordPress post. You could be working on a custom post type with a few extra meta box fields, and you simply want to display them on a template. So, instead of editing the WordPress theme files, you can simply customize the WordPress content if it’s a certain post type. Otherwise, the content remains the same if it’s a regular post or page.\nShow me! In this example, we will filter the WordPress content called the_content by passing a custom function to it. The custom function will pass the content and checks to see if the post type is equal to ‘books.’ If the post type is equal to ‘books’, it will prepend a paragraph saying, ‘Hello Bookworms!!!’ before the content. If the post type is not equal to ‘books’, it will simply return the original content.\nHere’s the Code\nfunction urr_filter_content($content) { $format = get_post_type( get_the_ID() ); if ( $format == \u0026#39;books\u0026#39; ) : // your custom post-type $new_content = \u0026#39;\u0026lt;p\u0026gt;Hello Bookworms!!!\u0026lt;/p\u0026gt;\u0026#39;; // add your custom post type meta $new_content .= \u0026#39;\u0026lt;p\u0026gt;Writer: \u0026#39; . get_post_meta( get_the_ID(), \u0026#39;books_writer\u0026#39;, true) . \u0026#39;\u0026lt;/p\u0026gt;\u0026#39;; endif; $content = $new_content . $content; return $content; } add_filter(\u0026#39;the_content\u0026#39;, \u0026#39;urr_filter_content\u0026#39;); There could be numerous reasons why you want to filter the content. Here’s just a few.\nCustom format based on ‘post type’ or ‘post format’ Adding image, audio and video embeds to your content Adding special divs to your content Drop Caps An author byline Adding a widget area In most cases, content remains undisturbed. But, there might be some crazy instance where you may have to alter it. The function above shows you how you can filter and alter your WordPress content. If you have questions, just leave me a comment!\n","permalink":"http://uly.me/posts/custom-content-in-wordpress/","summary":"\u003cp\u003eThere are some instances where you might need to alter or customize the content of a WordPress post. You could be working on a custom post type with a few extra meta box fields, and you simply want to display them on a template. So, instead of editing the WordPress theme files, you can simply customize the WordPress content if it’s a certain post type. Otherwise, the content remains the same if it’s a regular post or page.\u003c/p\u003e","title":"custom content in wordpress"},{"content":"You can ignore specific files in Git by placing a .gitignore file at the root of your local repository. The files listed in .gitignore will not be tracked by Git. Why would you do this? Well, there are certain OS generated files placed in system folders such as .DS_Store or Thumbs.db that are not really part of your code.\nCreate a .gitignore file\ntouch .gitignore Edit the .gitignore file\nsudo nano .gitignore Add the files you want excluded. You can use wildcards.\n.DS_Store Thumbs.db *.log Commit and Push\ngit commit -m \u0026#34;adding .gitignore file\u0026#34; -a git push That should do it!\n","permalink":"http://uly.me/posts/gitignore/","summary":"\u003cp\u003eYou can ignore specific files in Git by placing a .gitignore file at the root of your local repository. The files listed in .gitignore will not be tracked by Git. Why would you do this? Well, there are certain OS generated files placed in system folders such as .DS_Store or Thumbs.db that are not really part of your code.\u003c/p\u003e\n\u003cp\u003eCreate a .gitignore file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003etouch .gitignore\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEdit the .gitignore file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo nano .gitignore\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd the files you want excluded. You can use wildcards.\u003c/p\u003e","title":"gitignore"},{"content":"If you have a long list of words laid out on a page (see list below), it might be better to place them in a multi-column page format. CSS3 makes this entirely possible without using tables or multiple divs. All we need is a single div for the entire list. In this example, we will work with a list of animals. We will use a div class called “animals.”\naardvark beetle camel dog elephant fox goat hen iguana jackal kangaroo lionTo use multi-columns, we simply style the div with: .animals {-moz-column-count:3; -webkit-column-count:3; column-count:3;} Multi-column divs is supported on Firefox, Safari, Chrome and IE browsers.\nMulti-Column Example\n\u0026lt;div style=\u0026#34;-moz-column-count: 3; -webkit-column-count: 3; column-count: 3;\u0026#34;\u0026gt; aardvark beetle camel dog elephant fox goat hen iguana jackal kangaroo lion \u0026lt;/div\u0026gt; Just change the numbers to make multiple columns.\n","permalink":"http://uly.me/posts/multi-column-css/","summary":"\u003cp\u003eIf you have a long list of words laid out on a page (see list below), it might be better to place them in a multi-column page format. CSS3 makes this entirely possible without using tables or multiple divs. All we need is a single div for the entire list. In this example, we will work with a list of animals. We will use a div class called “animals.”\u003c/p\u003e\n\u003cdiv class=\"animals\"\u003eaardvark beetle camel dog elephant fox goat hen iguana jackal kangaroo lion\u003c/div\u003eTo use multi-columns, we simply style the div with:\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e.animals {-moz-column-count:3; -webkit-column-count:3; column-count:3;}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMulti-column divs is supported on Firefox, Safari, Chrome and IE browsers.\u003c/p\u003e","title":"multi-column css"},{"content":"The Genesis framework has a feature where you choose the post navigation technique. You can select either “previous / next” or the “numeric” option. This feature is found under the main Genesis Theme settings about halfway down. Selecting the “numeric” option, in this example, will display the numeric post navigation at the bottom of the home page after the main content.\nUnfortunately, it didn’t always look like this, when I first enabled it. It lacks margin and some padding. The link colors falls back to the default colors. I had to style the post navigation technique to make it look better. So, I just wanted to share with you the following CSS styles that will make this Genesis numeric post navigation technique look much better.\n/* Page Navigation */ .navigation li { font-size:14px; } .navigation li a { padding:10px; margin:0; color: #fff; background-color: #777;border-radius:5px; } .navigation li.active a { padding:10px; margin:0; color:#000; background-color:#aaa; border-radius:5px; } .navigation li a:hover { color:#000 } First, I increased the font size to make it more legible. I added some padding and margins, gave it some link color, background color, and added a border radius to make it less boxy. Finally, I also changed the hover color to show a mouse rollover. It’s nothing fancy, but it looks much better with a little bit of window dressing.\n","permalink":"http://uly.me/posts/styling-genesis-post-navigation/","summary":"\u003cp\u003eThe Genesis framework has a feature where you choose the post navigation technique. You can select either “previous / next” or the “numeric” option. This feature is found under the main Genesis Theme settings about halfway down. Selecting the “numeric” option, in this example, will display the numeric post navigation at the bottom of the home page after the main content.\u003c/p\u003e\n\u003cp\u003e\u003cimg alt=\"pagination\" loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2014/01/pagination.png\"\u003e\u003c/p\u003e\n\u003cp\u003eUnfortunately, it didn’t always look like this, when I first enabled it. It lacks margin and some padding. The link colors falls back to the default colors. I had to style the post navigation technique to make it look better. So, I just wanted to share with you the following CSS styles that will make this Genesis numeric post navigation technique look much better.\u003c/p\u003e","title":"styling genesis post navigation"},{"content":"Customizing your WordPress theme gives you total control of the look and feel of your website. One of the ways of customizing your theme is to add a “widget area” that you can place anywhere on your theme’s template. The first step in adding a widget area is to edit your theme’s functions.php file. In this example, we are going to add a widget area just underneath the header and before the main post loop.\nOpen your theme’s functions.php and add the following lines.\nif (function_exists(\u0026#39;register_sidebar\u0026#39;)) { register_sidebar(array( \u0026#39;name\u0026#39; =\u0026gt; \u0026#39;Below Header Widgets\u0026#39;, \u0026#39;id\u0026#39; =\u0026gt; \u0026#39;below-header-widgets\u0026#39;, \u0026#39;description\u0026#39; =\u0026gt; \u0026#39;The below the header widgets of your website.\u0026#39;, \u0026#39;before_widget\u0026#39; =\u0026gt; \u0026#39;\u0026lt;div class=\u0026#34;widget %2$s\u0026#34; id=\u0026#34;%1$s\u0026#34;\u0026gt;\u0026#39;, \u0026#39;after_widget\u0026#39; =\u0026gt; \u0026#39;\u0026lt;/div\u0026gt;\u0026#39;, \u0026#39;before_title\u0026#39; =\u0026gt; \u0026#39;\u0026lt;h2\u0026gt;\u0026#39;, \u0026#39;after_title\u0026#39; =\u0026gt; \u0026#39;\u0026lt;/h2\u0026gt;\u0026#39; )); } Save the file. Now that we added a new widget area to the functions.php file, we can now add this bit of code to our template. In this example, we will add the new widget area to our template’s header.php file. Notice the name ‘Below Header Widgets’ matches the ‘name’ in the code above.\n\u0026lt;div class=\u0026#34;below-header\u0026#34;\u0026gt; \u0026lt;ul\u0026gt; \u0026lt;?php if (!function_exists(\u0026#39;dynamic_sidebar\u0026#39;) || !dynamic_sidebar(\u0026#39;Below Header Widgets\u0026#39;)) : endif; ??\u0026gt; \u0026lt;/ul\u0026gt; \u0026lt;/div\u0026gt; Now go to your Admin Dashboard \u0026gt; Appearance \u0026gt; Widgets menu. You should now see the new widget area in your theme. The last thing you’ll need to do is style your new widget area. If you want the text to display in inline, we can add the following CSS styles.\n.below-header ul li { float:left; display:inline; padding-right:10px; } The CSS above floats and displays each widget and its content inline, as well as add a 10px right padding.\n","permalink":"http://uly.me/posts/add-a-widget-area-in-wordpress/","summary":"\u003cp\u003eCustomizing your WordPress theme gives you total control of the look and feel of your website. One of the ways of customizing your theme is to add a “widget area” that you can place anywhere on your theme’s template. The first step in adding a widget area is to edit your theme’s functions.php file. In this example, we are going to add a widget area just underneath the header and before the main post loop.\u003c/p\u003e","title":"add a widget area in wordpress"},{"content":"I stopped by Starbucks to hang out, sip coffee, and perform some housecleaning on my website. I fired up my MacBook Air and tried to access my website. Chrome barked at me saying, “This webpage is not available.” What! So, I opened up Terminal to see if I’m really connected to the WiFi network. Yes, I am. I can ping everything else, but my domain.\nSo, what’s happening? Is my site down? I logged into my VPS. The server is doing just fine. I did some more investigating. I realized that I can ping my IP address, but not the domain. That’s interesting. AT\u0026amp;T is currently the provider for the WiFI for Starbucks.\nA few weeks ago, I saw a blurb on the news that Google will provide WiFi for Starbucks. As far as I know, that hasn’t happened yet, at least not at this Starbucks location. Google plans to roll out its WiFi services to Starbucks in the next few months. So, we are still months away from that coming into fruition.\nIs AT\u0026amp;T blocking my domain? I have AT\u0026amp;T DSL at home. I can access my domain just fine. So, whoever is managing the AT\u0026amp;T WiFi, must be applying some kind of filtering to block certain domains from working.\nSince I can still ping my IP Address, I decided to just edit my hosts file.\nFor Macs, the hosts file is located in /private/etc/hosts.\n$ sudo nano /private/etc/hosts I added a host a new entry to resolve my domain to my server’s IP address.\n127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 173.255.251.194 uly.me I saved the new entry, and pinged my domain! It works! I opened up the browser to access my website. It works!\nI’m glad I was able to find a workaround! However, I’m still perplexed as to why my domain is being blocked.\n","permalink":"http://uly.me/posts/this-webpage-is-not-available/","summary":"\u003cp\u003eI stopped by Starbucks to hang out, sip coffee, and perform some housecleaning on my website. I fired up my MacBook Air and tried to access my website. Chrome barked at me saying, “This webpage is not available.” What! So, I opened up Terminal to see if I’m really connected to the WiFi network. Yes, I am. I can ping everything else, but my domain.\u003c/p\u003e\n\u003cp\u003eSo, what’s happening? Is my site down? I logged into my VPS. The server is doing just fine. I did some more investigating. I realized that I can ping my IP address, but not the domain. That’s interesting. AT\u0026amp;T is currently the provider for the WiFI for Starbucks.\u003c/p\u003e","title":"this webpage is not available"},{"content":"Have you ever tried to open a file, but the wrong application opens it? It happened to me at least a couple of times on the Mac. But, don’t fret. There’s actually a simple one-minute fix to make files to associate with the correct application.\nTo correctly associate a file:\nRight click on the file. Select Get Info. Select “Open With.” Select the correct Application. Click “Change All.” Click “Continue” to apply to all similar files. That should do it. You can test the file if the association is correct by running it. The file should open up with the application that you’ve selected.\n","permalink":"http://uly.me/posts/file-association-on-the-mac/","summary":"\u003cp\u003eHave you ever tried to open a file, but the wrong application opens it? It happened to me at least a couple of times on the Mac. But, don’t fret. There’s actually a simple one-minute fix to make files to associate with the correct application.\u003c/p\u003e\n\u003cp\u003eTo correctly associate a file:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eRight click on the file.\u003c/li\u003e\n\u003cli\u003eSelect Get Info.\u003c/li\u003e\n\u003cli\u003eSelect “Open With.”\u003c/li\u003e\n\u003cli\u003eSelect the correct Application.\u003c/li\u003e\n\u003cli\u003eClick “Change All.”\u003c/li\u003e\n\u003cli\u003eClick “Continue” to apply to all similar files.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThat should do it. You can test the file if the association is correct by running it. The file should open up with the application that you’ve selected.\u003c/p\u003e","title":"file association on the mac"},{"content":"GitHub has a native for the Mac OS called “Github Mac.” You can download the app directly from GitHub. With this native app, you can clone, and fork a repository. You can commit your changes to the local or remote repository. Github for Mac is fairly intuitive. I didn’t need to read the manual to perform version control tasks.\nIn addition, you can also browse history, switch branches and synchronize your changes to the master repository. The application was designed using Chameleon, a port of Apple’s UIKit for iOS. The interface is well-designed and integrates well with the GitHub repositories. Synchronization seems to be snappy and quite fast. Overall, it’s a fast and snappy application. Most of all, it’s free.\n","permalink":"http://uly.me/posts/github-for-mac/","summary":"\u003cp\u003eGitHub has a native for the Mac OS called “Github Mac.” You can download the app directly from \u003ca href=\"http://mac.github.com/\"\u003eGitHub\u003c/a\u003e. With this native app, you can clone, and fork a repository. You can commit your changes to the local or remote repository. Github for Mac is fairly intuitive. I didn’t need to read the manual to perform version control tasks.\u003c/p\u003e\n\u003cp\u003e\u003cimg alt=\"github\" loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2014/01/github.png\"\u003e\u003c/p\u003e\n\u003cp\u003eIn addition, you can also browse history, switch branches and synchronize your changes to the master repository. The application was designed using Chameleon, a port of Apple’s UIKit for iOS. The interface is well-designed and integrates well with the GitHub repositories. Synchronization seems to be snappy and quite fast. Overall, it’s a fast and snappy application. Most of all, it’s free.\u003c/p\u003e","title":"github for mac"},{"content":"I’m releasing a new WordPress plugin called Custom Stylesheet. This plugin creates a safe haven for some custom CSS styles that you want preserved, even if you switch from one theme to another. In addition, this plugin also prevent theme updates from overwriting your custom styles. Lastly, this plugin also serves as a quick test environment for applying your custom CSS styles.\nInstall and Configure Upload the “stylesheet” folder to the WordPress plugins folder. Activate the “Custom Stylesheet” plugin from the “Plugins \u0026gt; Installed Plugins.” Custom Stylesheet is available from “Appearance \u0026gt; Stylesheet.” Add your custom CSS styles. Click “Save Custom Stylesheet” to save. Download\n","permalink":"http://uly.me/posts/wordpress-custom-css-stylesheet/","summary":"\u003cp\u003eI’m releasing a new WordPress plugin called Custom Stylesheet. This plugin creates a safe haven for some custom CSS styles that you want preserved, even if you switch from one theme to another. In addition, this plugin also prevent theme updates from overwriting your custom styles. Lastly, this plugin also serves as a quick test environment for applying your custom CSS styles.\u003c/p\u003e\n\u003ch4 id=\"install-and-configure\"\u003eInstall and Configure\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003eUpload the “stylesheet” folder to the WordPress plugins folder.\u003c/li\u003e\n\u003cli\u003eActivate the “Custom Stylesheet” plugin from the “Plugins \u0026gt; Installed Plugins.”\u003c/li\u003e\n\u003cli\u003eCustom Stylesheet is available from “Appearance \u0026gt; Stylesheet.”\u003c/li\u003e\n\u003cli\u003eAdd your custom CSS styles.\u003c/li\u003e\n\u003cli\u003eClick “Save Custom Stylesheet” to save.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003e\u003ca href=\"https://uly.me/wp-content/uploads/2019/12/stylesheet.zip\"\u003eDownload\u003c/a\u003e\u003c/p\u003e","title":"wordpress custom css stylesheet"},{"content":"Dual boot desktops makes sense. Most techies prefer it. There’s no need for an extra computer. It’s also less clutter on the desk. If you had to install two or more OS on a bare system, I suggest that you install Windows first, followed by Linux. Doing it the other way around, in installing Linux first and then Windows, is certainly doable, but you have to perform an extra step to fix Grub. Grub is the boot loader for Linux systems. Windows removes the Linux Grub entry from the MBR (Master Boot Record) after Windows is installed. This is a case of Microsoft not playing nice. Running a Linux recovery CD, to reinstate Grub in the MBR, does the trick.\nSo, here are the major steps in installing Windows after Linux.\nCreate a Windows partition in Linux using either a Disk Utility or GParted. Install Windows on the new Windows partition. Run the Recovery CD to restore Grub in the MBR. The other option is to run Windows inside a Linux virtual machine. You will have lots of flexibility with this setup. You can have as many virtual machines running different OS. You can also have multiple OS running at the same time, as opposed to just one OS running on the system. There’s also another thing to consider. Systems that run in a virtual machine, tend to be not as fast as systems that run natively. It’s because virtual machines have to share resources with the host OS and other virtual machines that are running at the same time.\nSo, those are the tough choices when considering a dual boot OS. You have to figure out which OS to install first? Windows or Linux? Chances are, you may not have that luxury, since you already have an OS installed on your system. The other major option is to whether to run Windows in a virtual machine or using dual boot. Tough choices, but all very doable. It’s just a matter of preference.\n","permalink":"http://uly.me/posts/installing-windows-after-linux/","summary":"\u003cp\u003eDual boot desktops makes sense. Most techies prefer it. There’s no need for an extra computer. It’s also less clutter on the desk. If you had to install two or more OS on a bare system, I suggest that you install Windows first, followed by Linux. Doing it the other way around, in installing Linux first and then Windows, is certainly doable, but you have to perform an extra step to fix Grub. Grub is the boot loader for Linux systems. Windows removes the Linux Grub entry from the MBR (Master Boot Record) after Windows is installed. This is a case of Microsoft not playing nice. Running a Linux recovery CD, to reinstate Grub in the MBR, does the trick.\u003c/p\u003e","title":"installing windows after linux"},{"content":"HTML Kickstart is an ultra-lean website framework built on top of HTML5, CSS3, Javascript and JQuery. HTML Kickstart is a good alternative to the widely-popular Twitter’s Bootstrap. The download is quite small. It’s less than 1MB, but it’s quite powerful in terms of what you can do with it. All you have to do is add 3 lines into your existing HTML page to enable HTML Kickstart.\n\u0026lt;script src=\u0026#34;https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script src=\u0026#34;js/kickstart.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;link href=\u0026#34;css/kickstart.css\u0026#34; media=\u0026#34;all\u0026#34; rel=\u0026#34;stylesheet\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; The framework is well documented and quite easy to follow and implement. Some of the framework features are the ability to render: buttons, lists, menus, tables, tooltips, menus, horizontal rules, icons, code, tabs, breadcrumbs, responsive and flexible grid/ columns, images, slideshow, forms, labels, and extra helpers.\nIf you’re looking for a great alternative to Bootstrap, give HTML Kickstart a try.\n","permalink":"http://uly.me/posts/html-kickstart/","summary":"\u003cp\u003e\u003ca href=\"http://www.99lime.com/elements/\"\u003eHTML Kickstart\u003c/a\u003e is an ultra-lean website framework built on top of HTML5, CSS3, Javascript and JQuery. HTML Kickstart is a good alternative to the widely-popular \u003ca href=\"http://getbootstrap.com\"\u003eTwitter’s Bootstrap\u003c/a\u003e. The download is quite small. It’s less than 1MB, but it’s quite powerful in terms of what you can do with it. All you have to do is add 3 lines into your existing HTML page to enable HTML Kickstart.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;script src=\u0026#34;https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt;\n\u0026lt;script src=\u0026#34;js/kickstart.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \n\u0026lt;link href=\u0026#34;css/kickstart.css\u0026#34; media=\u0026#34;all\u0026#34; rel=\u0026#34;stylesheet\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; \n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe framework is well documented and quite easy to follow and implement. Some of the framework features are the ability to render: buttons, lists, menus, tables, tooltips, menus, horizontal rules, icons, code, tabs, breadcrumbs, responsive and flexible grid/ columns, images, slideshow, forms, labels, and extra helpers.\u003c/p\u003e","title":"html kickstart"},{"content":"This article shows you how to install MySQL on the Mac OS X. MySQL is an open-source relational database management system used in majority of websites on the Internet. MySQL works on many platforms including Windows, Mac and many flavors of the Linux OS.\nThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\nHow to Install MySQL on Mac OS X First, download the MySQL dmg archive for the Mac OS.\nInstall the following 3 items:\nMySQL package MySQL Startup Item package MySQL Preferences Pane Add the MySQL path to your existing path so you can invoke MySQL commands from anywhere.\n$ export PATH=/usr/local/mysql/bin:$PATH Secure the database. You’ll be prompted to provide a new MySQL password.\n$ sudo mysql_secure_installation Make sure MySQL is connected to Apache and PHP.\ncd /var sudo mkdir mysql cd mysql sudo ln -s /tmp/mysql.sock mysql.sock Access MySQL from the Terminal. Provide your password when prompted.\n$ mysql -u root -p Once logged in, you can check the databases just to be sure you’re connected.\nmysql\u0026gt; show databases; exit; ","permalink":"http://uly.me/posts/install-mysql-on-mac/","summary":"\u003cp\u003eThis article shows you how to install MySQL on the Mac OS X. MySQL is an open-source relational database management system used in majority of websites on the Internet. MySQL works on many platforms including Windows, Mac and many flavors of the Linux OS.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\u003c/p\u003e","title":"install mysql on mac"},{"content":"This article will show you how to install PHP on the Mac. By default, Apache and PHP are already installed on the Mac, although both are not activated. We must first enable Apache. Once you’ve Apache is enabled, you can then proceed in activating PHP.\nThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\nHow to Install PHP on Mac OS X PHP is already installed. We just have to enable it. Edit the ‘/etc/apache2/httpd.conf‘ file.\n$ sudo nano /etc/apache2/httpd.conf Uncomment or delete the ‘#’ sign for the line that contains the text below.\nLoadModule php5_module libexec/apache2/libphp5.so Restart Apache\n$ sudo apachectl restart Place a index.php file that contains the following in your web server root.\n\u0026lt;?php phpinfo(); ??\u0026gt; If you see PHP info and stats, that means PHP is working! If you see the code, it means PHP is not working.\n","permalink":"http://uly.me/posts/install-php-on-mac/","summary":"\u003cp\u003eThis article will show you how to install PHP on the Mac. By default, Apache and PHP are already installed on the Mac, although both are not activated. We must first enable Apache. Once you’ve Apache is enabled, you can then proceed in activating PHP.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\u003c/p\u003e","title":"install php on mac"},{"content":"This article covers how to install PhpMyAdmin on Mac OS X. PhpMyAdmin is a software tool written in PHP to manage and administer MySQL databases. It supports not only MySQL, but also MariaDB and Drizzle databases. PhpMyAdmin supports a variety of database operations such as managing databases, tables, columns, relations, indexes, users, and permissions.\nThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\nHow to Install PhpMyAdmin on Mac OS X To install PhpMyAdmin, download the latest version.\nUnzip the file and rename the folder to ‘phpmyadmin.’\nMove the ‘phpmyadmin’ folder to ‘/usr/local/phpmyadmin.’\n$ sudo mv phpmyadmin /usr/local/phpmyadmin Copy the config.sample.inc.php to config.inc.php.\n$ cd /usr/local/phpmyadmin $ sudo cp config.sample.inc.php config.inc.php Create a config file in ‘/etc/apache2/other.’\n$ sudo touch /etc/apache2/other/phpmyadmin.conf Edit the config file.\n$ sudo nano /etc/apache2/other/phpmyadmin.conf Add the following:\nAlias /phpmyadmin /usr/local/phpmyadmin \u0026lt;directory\u0026gt; Options Indexes Order allow,deny Allow from all \u0026lt;/directory\u0026gt; Restart Apache\n$ sudo apachectl restart Finally, access PhpMyAdmin from your browser. Example: http://localhost/phpmyadmin\n","permalink":"http://uly.me/posts/install-phpmyadmin-on-mac/","summary":"\u003cp\u003eThis article covers how to install PhpMyAdmin on Mac OS X. PhpMyAdmin is a software tool written in PHP to manage and administer MySQL databases. It supports not only MySQL, but also MariaDB and Drizzle databases. PhpMyAdmin supports a variety of database operations such as managing databases, tables, columns, relations, indexes, users, and permissions.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\u003c/p\u003e","title":"install phpmyadmin on mac"},{"content":"Creating an Apache virtual host on your Mac is quite easy. Assuming you already have Apache installed and running on your Mac, you will now have to decide whether to serve your pages from the default web root, or create your own virtual host, and serve your pages from an alternate location.\nThis article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\nCreate an Apache Virtual Host on Mac OS X Edit the /etc/apache2/httpd.conf file using the nano editor.\n$ sudo nano /etc/apache2/httpd.conf Look for the text ‘# Virtual hosts’ located at the end of the file. Uncomment by removing # from the line that says:\nInclude /private/etc/apache2/extra/httpd-vhosts.conf Save file and exit. If your not familiar with nano, it’s Ctrl-O for save, and Ctrl-X for exit.\nNow edit the https-vhosts.conf file.\n$ sudo nano /private/etc/apache2/extra/httpd-vhosts.conf Append the following at the end of the file:\n\u0026lt;virtualhost\u0026gt; DocumentRoot \u0026#34;/Users/Ulysses/Sites/\u0026#34; ServerName ulysses.dev ErrorLog \u0026#34;/private/var/log/apache2/ulysses.dev.local-error_log\u0026#34; CustomLog \u0026#34;/private/var/log/apache2/ulysses.dev.local-access_log\u0026#34; common \u0026lt;directory\u0026gt; AllowOverride All Order allow,deny Allow from all \u0026lt;/directory\u0026gt; \u0026lt;/virtualhost\u0026gt; In this example, I am using an alternate web root located at ‘/Users/Ulysses/Sites/.’ In addition, I’m also using a made-up domain called ‘ulysses.dev.’ I used .dev because it’s not a real top level domain or TLD. There won’t be a conflict with a real existing domain on the Internet. You can use any domain or TLD that you like.\nThe final step. Edit your hosts file to add your domain. This step is very important since we are using a made-up domain that doesn’t exist. By editing our hosts file, we are spoofing our system that a host does exist.\n$ nano /private/etc/hosts Add the following domain at the end of the line. 127.0.0.1 is the loopback address of your system.\n127.0.0.1 ulysses.dev Save file and exit.\nRestart Apache\n$ sudo apachectl restart From the terminal ping your domain.\n$ ping ulysses.dev Write permissions\nThe Apache user on the Mac is _www and is part of the staff group. To make the Sites folder writeable to the Apache _www user, perform the following commands from the Terminal.\ncd /Users/Ulysses $ sudo chown -R _www:staff Sites $ sudo chmod -R 755 Sites Finally, open up your browser and access your domain. In this example, http://ulysses.dev.\n","permalink":"http://uly.me/posts/apache-virtual-host-on-mac/","summary":"\u003cp\u003eCreating an Apache virtual host on your Mac is quite easy. Assuming you already have Apache installed and running on your Mac, you will now have to decide whether to serve your pages from the default web root, or create your own virtual host, and serve your pages from an alternate location.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\u003c/p\u003e","title":"apache virtual host on mac"},{"content":"This article will show you how to install Apache on the Mac OS. This is ideal if you want to use your Mac desktop or laptop as your development environment, a place where you can test code, scripts, themes, plugins without affecting your production environment.\nThis article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\nApache is the widely popular web server that runs on multiple platforms including Linux, Mac OS and Windows. Some people might be surprised to know that Apache is already installed and included on the latest Mac OS X Mavericks. All you need to do is turn it on. You can do so by accessing the Terminal and typing the following:\nHow to Install Apache on Mac OS X Start Apache $ sudo apachectl start You should be able to see ‘It works!‘ if you access ‘http://localhost‘ from your Safari, Chrome or Firefox browser.\nIn addition, you can also stop and restart Apache using the commands below.\nStop Apache $ sudo apachectl stop Restart Apache $ sudo apachectl restart By default, the web root for the Apache web server is located at ‘/Library/WebServer/Documents/.’ In the directory, you’ll find a document called ‘index.html.en‘ which contains the code that displays ‘It works!‘\n\u0026lt;h1\u0026gt;It works!\u0026lt;/h1\u0026gt; It works! Finally, you can now move your HTML pages to the ‘/Library/WebServer/Documents/‘ folder to serve pages. The other option is to create a virtual host within Apache which I will cover in my next article.\n","permalink":"http://uly.me/posts/install-apache-on-mac/","summary":"\u003cp\u003eThis article will show you how to install Apache on the Mac OS. This is ideal if you want to use your Mac desktop or laptop as your development environment, a place where you can test code, scripts, themes, plugins without affecting your production environment.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.\u003c/p\u003e","title":"install apache on mac"},{"content":"Linode Manager is the official Android mobile application for Linode. With this application, you’ll be able to manage and administer your Linodes from anywhere in the world. Here’s a list of things that you can do with this smart phone application:\nCreate, remove, boot, and reboot Linodes Access Linodes via SSH and Lish Resize Linodes on the fly Keep tabs on your Linodes performance with CPU, network, and IO utilization graphs Create and manage NodeBalancers and domain zones Access the complete Linode Library Manage your Linode account and make payments Linode Shell or Lish for short, works primarily with a web browser console in this app. I prefer Chrome with Lish. SSH seems to look for an app called Connectbot. Unfortunately, I couldn’t get SSH to work because it defaults to port 22. I use a different port for SSH, an added security to my Linode.\nHaving access to the shell terminal from a smartphone is a nice feature to have. Perhaps, you can do perform a couple of updates or simple maintenance functions. However, I prefer to use my desktop if I were to do anything drastic to my Linode.\n","permalink":"http://uly.me/posts/linode-manager-on-android/","summary":"\u003cp\u003e\u003ca href=\"https://blog.linode.com/2013/12/10/linode-mobile-2-0/\"\u003eLinode Manager\u003c/a\u003e is the official Android mobile application for Linode. With this application, you’ll be able to manage and administer your Linodes from anywhere in the world. Here’s a list of things that you can do with this smart phone application:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCreate, remove, boot, and reboot Linodes\u003c/li\u003e\n\u003cli\u003eAccess Linodes via SSH and Lish\u003c/li\u003e\n\u003cli\u003eResize Linodes on the fly\u003c/li\u003e\n\u003cli\u003eKeep tabs on your Linodes performance with CPU, network, and IO utilization graphs\u003c/li\u003e\n\u003cli\u003eCreate and manage NodeBalancers and domain zones\u003c/li\u003e\n\u003cli\u003eAccess the complete Linode Library\u003c/li\u003e\n\u003cli\u003eManage your Linode account and make payments\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eLinode Shell or Lish for short, works primarily with a web browser console in this app. I prefer Chrome with Lish. SSH seems to look for an app called Connectbot. Unfortunately, I couldn’t get SSH to work because it defaults to port 22. I use a different port for SSH, an added security to my Linode.\u003c/p\u003e","title":"linode manager on android"},{"content":"I experienced a “nano” editor error this morning. It displayed this:\nError reading /home/ulysses/.nano_history: Permission denied Press Enter to continue starting nano. The error doesn’t prevent you from using the nano editor, but it displays an annoying message. You have to press the Enter key each time you want to use the editor. I’m not sure how I manage to make the nano editor behave this way. I probably edited a file in my home directory while I was root. It’s a common mistake.\nSo, when accessed as a regular user, I simply didn’t have permissions to the nano history. A simple fix for this is to delete the .nano_history file while logged in as root. Switch back as a regular user and run nano again. Nano will re-create the history file the next time you use it.\n$ sudo rm /home/ulysses/.nano_history That should take care of it.\n","permalink":"http://uly.me/posts/nano-history-error/","summary":"\u003cp\u003eI experienced a “nano” editor error this morning. It displayed this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eError reading /home/ulysses/.nano_history: Permission denied\nPress Enter to continue starting nano.\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe error doesn’t prevent you from using the nano editor, but it displays an annoying message. You have to press the Enter key each time you want to use the editor. I’m not sure how I manage to make the nano editor behave this way. I probably edited a file in my home directory while I was root. It’s a common mistake.\u003c/p\u003e","title":"nano history error"},{"content":"Gimp is the GNU image manipulation program that I use exclusively for editing and creating image files. It’s open-source and it’s free. Gimp on the Mac OS X has come a long way. Last year, Gimp went native on OS X, meaning it no longer required XQuartz or Apple’s X11 to run on the Mac OS.\nWhen Apple released Mac OS X Mavericks a couple of months ago, Gimp followed with its own release supporting Mavericks. However, there are some serious bugs that need fixing, particularly with the keyboard focus. When Gimp is prompted with a text box, the keyboard focus remains in the background.\nTyping something in text box results in either nothing or some odd behavior in the background. Fortunately, there’s a temporary workaround with the keyboard focus issue. You must disable the keyboard shortcuts. You can do that by accessing Preferences \u0026gt; Interface \u0026gt; Remove All Keyboard Shortcuts.\nThe problem disappears once the keyboard shortcuts are disabled. I don’t really use keyboard shortcuts, so it doesn’t affect me. However, there are others that may be dependent on them. Hopefully, there will be a fix soon.\n","permalink":"http://uly.me/posts/gimp-on-mac-os-x/","summary":"\u003cp\u003e\u003ca href=\"http://www.gimp.org\"\u003eGimp\u003c/a\u003e is the GNU image manipulation program that I use exclusively for editing and creating image files. It’s open-source and it’s free. Gimp on the Mac OS X has come a long way. Last year, Gimp went native on OS X, meaning it no longer required XQuartz or Apple’s X11 to run on the Mac OS.\u003c/p\u003e\n\u003cp\u003eWhen Apple released Mac OS X \u003ca href=\"http://www.apple.com/osx/\"\u003eMavericks\u003c/a\u003e a couple of months ago, Gimp followed with its own release supporting Mavericks. However, there are some serious bugs that need fixing, particularly with the keyboard focus. When Gimp is prompted with a text box, the keyboard focus remains in the background.\u003c/p\u003e","title":"gimp on mac os x"},{"content":"My DSL router/modem is failing miserably. My Internet connection slows down to a crawl. Pinging a host online takes twice as long. Resetting the router/modem fixes the problem temporarily, but only for a couple of hours, then it’s back to its slow crawl.\nRummaging through my stash of electronics, I found an old DSL modem that I put away years ago. There’s a reason why it’s in the electronic pile. It has problems with overheating as I recall. Desperate for a fix. I pried off the heatsink from an old motherboard, and placed it on top of the overheating chip on the modem.\nWell, after 12 hours of operation, so far, so good. Surprisingly, the heatsink is still quite warm to the touch. I don’t know how Motorola failed see the heating issues with this particular model. Anyways, I can’t replace the modem cover because the heatsink is way too big. Suffice to say, the modem cover looks nicely as a stand.\nHeatsink and modem, just like the horse and carriage.\n","permalink":"http://uly.me/posts/heatsink-and-modem/","summary":"\u003cp\u003eMy DSL router/modem is failing miserably. My Internet connection slows down to a crawl. Pinging a host online takes twice as long. Resetting the router/modem fixes the problem temporarily, but only for a couple of hours, then it’s back to its slow crawl.\u003c/p\u003e\n\u003cp\u003eRummaging through my stash of electronics, I found an old DSL modem that I put away years ago. There’s a reason why it’s in the electronic pile. It has problems with overheating as I recall. Desperate for a fix. I pried off the heatsink from an old motherboard, and placed it on top of the overheating chip on the modem.\u003c/p\u003e","title":"heatsink and modem"},{"content":"Apple Mac Pro will go on sale tomorrow. The cylindrical high-end desktop is made and assembled in the USA and priced somewhere between $3000 to $4000. The lower end unit features a 3.7 Ghz quad-core Intel Xeon E5 processor, 12 GB of RAM, two FirePro D500 graphics processing units and 256 GB of flash storage.\nThe high-end unit will have upgrade to faster processors, more memory and 1 TB of SSD flash storage. The Mac Pro is geared towards movie editors that need lots of processing power. The Mac Pro is available at Apple.com, Apple stores and select resellers.\nThe Mac Pro can support up to three 4K Ultra HD video displays at once. It also has six thunderbolt ports which support up to six displays as well.\n","permalink":"http://uly.me/posts/mac-pro/","summary":"\u003cp\u003eApple Mac Pro will go on sale tomorrow. The cylindrical high-end desktop is made and assembled in the USA and priced somewhere between $3000 to $4000. The lower end unit features a 3.7 Ghz quad-core Intel Xeon E5 processor, 12 GB of RAM, two FirePro D500 graphics processing units and 256 GB of flash storage.\u003c/p\u003e\n\u003cp\u003eThe high-end unit will have upgrade to faster processors, more memory and 1 TB of SSD flash storage. The Mac Pro is geared towards movie editors that need lots of processing power. The Mac Pro is available at Apple.com, Apple stores and select resellers.\u003c/p\u003e","title":"mac pro"},{"content":"Laravel version 4.1 was released just a couple of days ago. With the latest release of Laravel, the installation and setup couldn’t be any easier. In this article, I will show you how easy it is to install Laravel on Ubuntu. You can quickly adapt these commands to other Linux flavors using either the ‘yum’ or ‘rpm’ commands.\nThe preferred way of installing Laravel is by using Composer, which is a dependency manager for PHP. In this article, I will be using Composer because it’s by far the easiest way to install Laravel.\nFirst things first, update Ubuntu to the latest and greatest patches.\n$ sudo apt-get update $ sudo apt-get upgrade You can skip the following command if you’ve already installed Apache, MySQL and PHP.\n$ sudo apt-get install apache2 mysql-server mysql-client php5 libapache2-mod-php5 In addition, we also want to make sure PHP5 mcrypt and Json is also installed.\n$ sudo apt-get install php5-mcrypt php5-common We will now install Composer first using the curl command from the Terminal. Once the install is finished, we will now rename ‘composer.phar’ to ‘composer’ and move it to the ‘/usr/local/bin’ directory so it’s accessible from anywhere on the system.\n$ curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer Now that we have Composer installed, we will now install Laravel using Composer. The only variable that we need to modify is ‘test.’ This is the target directory where Laravel will be installed from the current directory.\n$ composer create-project laravel/laravel test --prefer-dist Relax and grab a cup of coffee. This process will take approximately 2-3 minutes to complete. Composer will be installing Laravel and all its dependencies.\nAfter Laravel install is complete, we need to give read and write permissions to the app/storage directory.\n$ sudo chmod 777 app/storage You can now access Laravel from the browser. To make it simpler, you can setup a virtual host if you like. I recently wrote an article on how to create a new virtual host. Check it out.\n","permalink":"http://uly.me/posts/installing-laravel-4-1/","summary":"\u003cp\u003e\u003ca href=\"http://laravel.com\"\u003eLaravel\u003c/a\u003e version 4.1 was released just a couple of days ago. With the latest release of Laravel, the installation and setup couldn’t be any easier. In this article, I will show you how easy it is to install Laravel on \u003ca href=\"http://ubuntu.com\"\u003eUbuntu\u003c/a\u003e. You can quickly adapt these commands to other Linux flavors using either the ‘yum’ or ‘rpm’ commands.\u003c/p\u003e\n\u003cp\u003eThe preferred way of installing Laravel is by using \u003ca href=\"http://getcomposer.org/\"\u003eComposer\u003c/a\u003e, which is a dependency manager for PHP. In this article, I will be using Composer because it’s by far the easiest way to install Laravel.\u003c/p\u003e","title":"installing laravel 4.1"},{"content":"Sublime Text 2 is a sophisticated text editor built for writing code, markup and prose. It has a slick user interface with extraordinary features and amazing performance. Sublime Text 2 is available multiple platforms including Windows, Mac OS and Linux OS. After 4 months of heavy use, I now use Sublime Text 2 exclusively. I stopped using other text editors altogether.\nSince I work mostly from the Terminal, I wanted to be able to launch Sublime Text 2 directly from the command line. In order to make this possible, I needed to create a symbolic link for easier access. The reason for this is because the Sublime Text 2 command is located in a directory that is hard to remember. So, here’s the command to create a symbolic link called ‘/bin/subl‘ for Sublime Text 2.\nsudo ln -s \u0026#34;/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl\u0026#34; /bin/subl From this point on, every time I needed to edit a file, I simply type the following in the commands from the Terminal:\n$ subl archives.php $ subl /etc/hosts $ subl archives.php footer.php I gave 3 examples above.\nIn the first example, Sublime Text 2 will launch and open a file from the current directory. The second example will open a file from its full path. The third will open multiple files separated by spaces.\n","permalink":"http://uly.me/posts/sublime-text-2/","summary":"\u003cp\u003e\u003ca href=\"http://www.sublimetext.com/2\"\u003eSublime Text 2\u003c/a\u003e is a sophisticated text editor built for writing code, markup and prose. It has a slick user interface with extraordinary features and amazing performance. Sublime Text 2 is available multiple platforms including Windows, Mac OS and Linux OS. After 4 months of heavy use, I now use Sublime Text 2 exclusively. I stopped using other text editors altogether.\u003c/p\u003e\n\u003cp\u003eSince I work mostly from the Terminal, I wanted to be able to launch Sublime Text 2 directly from the command line. In order to make this possible, I needed to create a symbolic link for easier access. The reason for this is because the Sublime Text 2 command is located in a directory that is hard to remember. So, here’s the command to create a symbolic link called ‘\u003cstrong\u003e/bin/subl\u003c/strong\u003e‘ for Sublime Text 2.\u003c/p\u003e","title":"sublime text 2"},{"content":"Creating a virtual host in Apache allows for multiple domains to be hosted on a single IP address. This is extremely useful in terms of hosting multiple domains on a single host or VPS. As far as I know, you can have an unlimited number of virtual hosts. The only limitation is the system resources in terms of CPU usage, memory and storage. This article will show you how to add Apache virtual hosts in Ubuntu.\nTypically, the web root for Apache in Ubuntu is located in /var/www. Instead, we will use a directory under the /home/username directory. So, let’s now create a directory in /home/username/fakedomain.com/. We can achieve this by typing the following:\n$ mkdir /home/username/fakedomain.com We will give it read and write permissions.\n$ chmod 755 -R /home/username/fakedomain.com Now, let’s create a new virtual host file.\n$ sudo touch /etc/apache2/sites-available/fakedomain.com We will add the following configuration.\n\u0026lt;virtualhost\u0026gt; ServerAdmin webmaster@localhost Servername fakedomain.com ServerAlias www.fakedomain.com DocumentRoot /home/username/fakedomain.com \u0026lt;/virtualhost\u0026gt; Save the file by pressing Control-O followed by Control-X.\nActivate our new host.\n$ sudo a2ensite fakedomain.com Restart Apache.\n$ sudo service apache2 restart Edit your hosts file. The first line is for Ubuntu, the second for Mac OS.\n$ sudo nano /etc/hosts $ sudo nano /private/etc/hosts Add the fakedomain.com to your hosts file. Substitute the IP address of your host.\n192.168.0.5 fakedomain.com Save the file by pressing Control-O followed by Control-X.\nYou can now access fakedomain.com from your browser by typing ‘http://fakedomain.com’ on the address bar.\n","permalink":"http://uly.me/posts/virtual-apache-host/","summary":"\u003cp\u003eCreating a virtual host in \u003ca href=\"http://httpd.apache.org/\"\u003eApache\u003c/a\u003e allows for multiple domains to be hosted on a single IP address. This is extremely useful in terms of hosting multiple domains on a single host or VPS. As far as I know, you can have an unlimited number of virtual hosts. The only limitation is the system resources in terms of CPU usage, memory and storage. This article will show you how to add Apache virtual hosts in Ubuntu.\u003c/p\u003e","title":"virtual apache host"},{"content":"WordPress 3.8 was released today. It’s named “Parker” after the jazz saxophonist Charlie “Bird” Parker. WordPress 3.8 has a new modern, clean, aesthetic Admin Dashboard. The clean design makes it easier to navigate and read the Admin Dashboard. It comes in 8 stunning color themes. My favorite is “Midnight.”\nIn addition, WordPress now uses the “Open Sans” typeface which is friendly for desktop and mobile viewing. WordPress 3.8 now uses vector-based icons that scales to every device. To top it all off, WordPress 3.8 comes with a new sleek magazine-styled default theme called “Twenty Fourteen.”\nIf you are new to CMS, blogging or just want to start a website, consider using WordPress. It’s open and it’s free. Not only that, it also now powers 20% of the Internet worldwide.\n","permalink":"http://uly.me/posts/wordpress-3-8/","summary":"\u003cp\u003e\u003ca href=\"http://wordpress.org\"\u003eWordPress 3.8\u003c/a\u003e was released today. It’s named “Parker” after the jazz saxophonist Charlie “Bird” Parker. WordPress 3.8 has a new modern, clean, aesthetic \u003ca href=\"http://wordpress.org/news/2013/12/parker/\"\u003eAdmin Dashboard\u003c/a\u003e. The clean design makes it easier to navigate and read the Admin Dashboard. It comes in 8 stunning color themes. My favorite is “Midnight.”\u003c/p\u003e\n\u003cp\u003eIn addition, WordPress now uses the “Open Sans” typeface which is friendly for desktop and mobile viewing. WordPress 3.8 now uses vector-based icons that scales to every device. To top it all off, WordPress 3.8 comes with a new sleek magazine-styled default theme called “Twenty Fourteen.”\u003c/p\u003e","title":"wordpress 3.8"},{"content":"Mumble is a voice over IP or VOIP application designed primarily for gamers. The Mumble application is similar to Ventrilo and Teamspeak. Mumble uses a client-server architecture letting users talk to each other while connected to the Mumble server called Murmur. Mumble contains a simple admin interface and features a high quality audio codec with low latency. All communication is encrypted to ensure user privacy.\nLogging in to Mumble servers provide users with a root channel and a hierarchical tree underneath it. Mumble uses Speex audio codec for voice, noise reduction and automatic gain control. The CELT audio codec was added starting with Mumble version 1.2. Mumble is optimized for low latency resulting in faster communication. Mumble has positional audio which modifies audio based on a player’s position within a video game.\nMumble is open-source and therefore is free. There are no user limits. You can have as many users as you like as long as your web server can handle it, in terms of CPU usage, memory, and monthly transfer rate. Similar to Ventrilo and Teamspeak, you cab sign up with several hosting companies that offer Mumble. If you’re adventurous enough, you can install Mumble on a Linux server or a VPS server, which gives you complete freedom.\n","permalink":"http://uly.me/posts/mumble/","summary":"\u003cp\u003e\u003ca href=\"http://mumble.sourceforge.net/\"\u003eMumble\u003c/a\u003e is a voice over IP or VOIP application designed primarily for gamers. The Mumble application is similar to Ventrilo and Teamspeak. Mumble uses a client-server architecture letting users talk to each other while connected to the Mumble server called Murmur. Mumble contains a simple admin interface and features a high quality audio codec with low latency. All communication is encrypted to ensure user privacy.\u003c/p\u003e\n\u003cp\u003eLogging in to Mumble servers provide users with a root channel and a hierarchical tree underneath it. Mumble uses \u003ca href=\"http://www.speex.org/\"\u003eSpeex\u003c/a\u003e audio codec for voice, noise reduction and automatic gain control. The \u003ca href=\"http://celt-codec.org/\"\u003eCELT\u003c/a\u003e audio codec was added starting with Mumble version 1.2. Mumble is optimized for low latency resulting in faster communication. Mumble has positional audio which modifies audio based on a player’s position within a video game.\u003c/p\u003e","title":"mumble"},{"content":"Running your own mail server has its own benefits and drawbacks. If you want full control, then running your own is the ideal option. You will be able to personalize your own email, have access to your server logs, and access to the raw email files. The are a few drawbacks such as, configuration is complicated, troubleshooting problems is a pain, downtime can result in lost emails, and the need to run your own spam and virus filtering. Your system can also be exploited if not properly secured.\nThe other option is to have a hosting company run it for you. You can use your own domain as well to personalize email addresses. Zoho is an email hosting company that offers free email accounts. The free version is limited to 5 email users, 5GB of disk storage, and one domain. Zoho also offers other paid options. There are two business plans starting at $2.50 and $3.50 per month. The setup is easy and straightforward. It’s definitely much more easier than setting up your own email server.\n","permalink":"http://uly.me/posts/zoho-mail/","summary":"\u003cp\u003eRunning your own mail server has its own benefits and drawbacks. If you want full control, then running your own is the ideal option. You will be able to personalize your own email, have access to your server logs, and access to the raw email files. The are a few drawbacks such as, configuration is complicated, troubleshooting problems is a pain, downtime can result in lost emails, and the need to run your own spam and virus filtering. Your system can also be exploited if not properly secured.\u003c/p\u003e","title":"zoho mail"},{"content":"Google announced today that it can now stream HBO Go to Chromecast from both iOS and Android devices. Google is slowly adding the pieces together in making Chromecast a formidable streaming option. Priced at just $35, it’s an attractive buy considering the competition from Roku, Apple TV and others.\nAt this moment, Chromecast can now stream from Pandora, Hulu Plus, Netflix, and YouTube. In time, more and more services will be added in the future. In a year or two, we will see a much longer list of streaming services. Google should add sports programming next. NFL, NBA, MLB, NHL and MLS would be nice.\nMy only gripe about Chromecast is streaming local files. Technically, it’s possible by dropping them into the Google Chrome browser, but it’s not optimized for streaming. Video quality and delays are common issues. Chromecast initially supported access to local files, but Google removed it, but they did promise to put it back.\n","permalink":"http://uly.me/posts/chromecast-adds-hbo-go/","summary":"\u003cp\u003eGoogle announced today that it can now stream \u003ca href=\"http://news.yahoo.com/hbo-ios-android-now-stream-chromecast-135941702.html\"\u003eHBO Go to Chromecast\u003c/a\u003e from both iOS and Android devices. Google is slowly adding the pieces together in making Chromecast a formidable streaming option. Priced at just $35, it’s an attractive buy considering the competition from Roku, Apple TV and others.\u003c/p\u003e\n\u003cp\u003eAt this moment, Chromecast can now stream from Pandora, Hulu Plus, Netflix, and YouTube. In time, more and more services will be added in the future. In a year or two, we will see a much longer list of streaming services. Google should add sports programming next. NFL, NBA, MLB, NHL and MLS would be nice.\u003c/p\u003e","title":"chromecast adds hbo go"},{"content":"If you want to learn how to develop websites, visit CodeAcademy.com. In about several dozen exercises or so, you can quickly learn how to write code in different languages that empower the web. Courses in HTML/CSS, PHP, Javascript, Python, Ruby, and APIs are being offered. The program is geared towards people with no programming experience, but challenging enough for those with some programming experience.\nThe programs are designed to get you started, and to get your feet wet. It’s by no means a be all exhaustive programming experience. The CodeAcademy exercises are designed to get you introduced to the basics of each language. If you’re looking for a programming experience that is exhaustive, extensive and covers intermediate and advanced levels, CodeAcademy is not this program. There are other certification programs offered for a handsome fee.\nCodeAcademy programs are free.\n","permalink":"http://uly.me/posts/codeacademy/","summary":"\u003cp\u003eIf you want to learn how to develop websites, visit \u003ca href=\"http://codeacademy.com\"\u003eCodeAcademy.com\u003c/a\u003e. In about several dozen exercises or so, you can quickly learn how to write code in different languages that empower the web. Courses in HTML/CSS, PHP, Javascript, Python, Ruby, and APIs are being offered. The program is geared towards people with no programming experience, but challenging enough for those with some programming experience.\u003c/p\u003e\n\u003cp\u003eThe programs are designed to get you started, and to get your feet wet. It’s by no means a be all exhaustive programming experience. The CodeAcademy exercises are designed to get you introduced to the basics of each language. If you’re looking for a programming experience that is exhaustive, extensive and covers intermediate and advanced levels, CodeAcademy is not this program. There are other certification programs offered for a handsome fee.\u003c/p\u003e","title":"codeacademy"},{"content":"PHP.net revealed its brand new website design today. PHP.net is the official website of PHP. The redesign is based on HTML5, Google Fonts, and Bootstrap. The website’s layout is a typical Bootstrap-centered layout with a top menu level. It’s both simple and elegant. The website color scheme remains purple, but the colors have been lightened a bit according to the PHP.net designers. The font of choice is “Source Sans Pro” making the website’s font much more smoother and softer to read. The PHP code examples are more readable.\nIn addition, the PHP documentation has also been redesigned. It’s a drastic improvement over the previous design. It’s easier to navigate and read, making the reading documentation fun again. The new design has been a long time coming. The older design was showing its age. The website seemed stuck in time ten years ago. So, kudos to the PHP Group and to those who were involved for making the bold move. There’s no doubting now, PHP is truly the most popular language of the web.\n","permalink":"http://uly.me/posts/php-net-new-design/","summary":"\u003cp\u003ePHP.net revealed its brand new website design today. \u003ca href=\"http://php.net\"\u003ePHP.net\u003c/a\u003e is the official website of PHP. The redesign is based on \u003ca href=\"http://www.w3.org/html/wg/drafts/html/master/\"\u003eHTML5\u003c/a\u003e, \u003ca href=\"http://google.com/fonts/\"\u003eGoogle Fonts\u003c/a\u003e, and \u003ca href=\"http://getbootstrap.com/\"\u003eBootstrap\u003c/a\u003e. The website’s layout is a typical Bootstrap-centered layout with a top menu level. It’s both simple and elegant. The website color scheme remains purple, but the colors have been lightened a bit according to the PHP.net designers. The font of choice is “Source Sans Pro” making the website’s font much more smoother and softer to read. The PHP code examples are more readable.\u003c/p\u003e","title":"php.net new design"},{"content":"Sales of the popular and highly successful Raspberry Pi have hit the two million units last week. The creators of the $35 credit-card sized computer initially planned to sell a 1000 units. It took a year to sell the first million and 8 months to sell the second. I bought two units myself last year. Raspberry Pi have been introduced to schools to teach kids how to program. There are many uses for Raspberry Pi. The Linux-based units are used in variety of ways from running websites, mail servers, print servers, media servers, DNS servers, as well as automation. Raspberry Pi users have found different uses for the open-sourced units from running bars, as a translator, for ordering pizzas, etc.\nFollowing the success of the Pi, there are other projects worth checking into in 2014.\n","permalink":"http://uly.me/posts/2-million-raspberry-pi/","summary":"\u003cp\u003eSales of the popular and highly successful \u003ca href=\"http://www.raspberrypi.org/\"\u003eRaspberry Pi\u003c/a\u003e have hit the two million units last week. The creators of the $35 credit-card sized computer initially planned to sell a 1000 units. It took a year to sell the first million and 8 months to sell the second. I bought two units myself last year. Raspberry Pi have been introduced to schools to teach kids how to program. There are many uses for Raspberry Pi. The Linux-based units are used in variety of ways from running websites, mail servers, print servers, media servers, DNS servers, as well as automation. Raspberry Pi users have found different uses for the open-sourced units from \u003ca href=\"http://www.wired.co.uk/news/archive/2013-11/07/raspberry-pi-powered-bar\"\u003erunning bars\u003c/a\u003e, as a \u003ca href=\"http://lifehacker.com/transform-your-raspberry-pi-into-a-universal-translator-1458394765\"\u003etranslator\u003c/a\u003e, for \u003ca href=\"http://wnmufm.org/post/device-lets-you-order-pizza-push-button\"\u003eordering pizzas\u003c/a\u003e, etc.\u003c/p\u003e","title":"2 million raspberry pi"},{"content":"I’ve been using Mac OS 10.9 Mavericks for a couple of weeks now. So far, so good. No issues whatsoever. There were several updates that followed the OS upgrade. Updates to iTunes, iMovie, iPhoto were the obvious ones, plus a couple of other small applications that were also updated as a result of the OS upgrade.\nI happen to use Git for version control for my software projects. One thing I noticed after upgrading to Mavericks, Git stopped working completely. I tried to do a git pull, and I was met with this error, “xcode-select: note: no developer tools were found at ‘/Applications/Xcode.app’, requesting install. Choose an option in the dialog to download the command line developer tools.”\nThe cool part about all this is, Mavericks immediately recognized the problem and offered to correct it by asking the user to proceed with Xcode installation. I gladly clicked Update/Install. The update took less than 5 minutes to complete. After the install, I issued git pull command again, and sure enough the my git repository updated nicely.\nI’m glad to report that after two weeks running on Mac OS Mavericks, I haven’t had any major problems, except for this relatively minor inconvenience of reinstalling Xcode.\n","permalink":"http://uly.me/posts/xcode-reinstall-on-mavericks/","summary":"\u003cp\u003eI’ve been using Mac OS 10.9 Mavericks for a couple of weeks now. So far, so good. No issues whatsoever. There were several updates that followed the OS upgrade. Updates to iTunes, iMovie, iPhoto were the obvious ones, plus a couple of other small applications that were also updated as a result of the OS upgrade.\u003c/p\u003e\n\u003cp\u003eI happen to use Git for version control for my software projects. One thing I noticed after upgrading to Mavericks, Git stopped working completely. I tried to do a git pull, and I was met with this error, “xcode-select: note: no developer tools were found at ‘/Applications/Xcode.app’, requesting install. Choose an option in the dialog to download the command line developer tools.”\u003c/p\u003e","title":"xcode reinstall on mavericks"},{"content":"HTML5 has a little-known attribute called download. The download attribute is often used in conjunction with the link or the \u0026lt;a\u0026gt; tag. Check the correct markup for the link tag below. Clicking on a HTML link will typically result in the browser opening up a new page, image, or a document.\nIn some cases, depending on your browser settings, clicking on a link will download a document, file or an image. For consistency, we can alter the behavior of the link tag by adding the download attribute. Let’s say, we want our readers to download an image, pdf, or a web page. We simply add the download attribute in the link tag.\nA typical link looks like this:\n\u0026lt;a href=\u0026#34;page.html\u0026#34;\u0026gt;link\u0026lt;/a\u0026gt; A link with the download tag would look something like this:\n\u0026lt;a download=\u0026#34;test.jpg\u0026#34; href=\u0026#34;random-xxx.jpg\u0026#34;\u0026gt;link\u0026lt;/a\u0026gt; By adding a filename in the download tag, we are specifying that we want the downloaded file to be renamed to test.png. The download attribute is currently supported on Chrome and Firefox. Safari and IE have not adapted it yet. Click on the Sample link below to see the download tag in action.\nDemo\n","permalink":"http://uly.me/posts/html5-download-attribute/","summary":"\u003cp\u003eHTML5 has a little-known attribute called download. The download attribute is often used in conjunction with the link or the \u0026lt;a\u0026gt; tag. Check the correct markup for the link tag below. Clicking on a HTML link will typically result in the browser opening up a new page, image, or a document.\u003c/p\u003e\n\u003cp\u003eIn some cases, depending on your browser settings, clicking on a link will download a document, file or an image. For consistency, we can alter the behavior of the link tag by adding the download attribute. Let’s say, we want our readers to download an image, pdf, or a web page. We simply add the download attribute in the link tag.\u003c/p\u003e","title":"html5 download attribute"},{"content":"RSS or Really Simple Syndication enable publishers to syndicate their data automatically. Readers can subscribe to the feed and content will be delivered automatically. Most websites, news feeds, blogs, forums, etc. nowadays run some kind of content management system or CMS. And most CMS, if not all, have built-in RSS feed generators.\nBut, why is it so hard to find the RSS feed for some websites? Why do readers have to go for a bunny hunt each time, just to find the RSS feed. If it’s not on the top of the page, it must be at the bottom. If it’s not on the front page, then clearly, it must be somewhere else on the site. Maybe, it’s searchable on the website. Well, try again. In some instances, there is no RSS at all. What a shame at this day and age.\nIf you do find it, will it work at all? You’ll be surprise, some RSS feeds don’t work at all. I’m not sure why publishers can’t adhere to the standard RSS format of either RSS 2.0 or Atom 1.0. Clearly, there must be a way to simplify the entire RSS hunt process. Maybe, modern browsers like Chrome, Firefox, Safari and IE can help out a bit in locating the RSS feeds of each website.\nBrowsers should be able to direct users to the RSS feed of each website, and make them accessible to minimize the hunt. There are several browser plugins or extensions that simplify the process. I use RSS Feed Reader for Chrome. Acquiring feeds for each website is not always automatic. I still have to type the domain, but it does simplify the process a bit.\nClearly, there has to be a better way. I hope Chrome, Firefox, or other browsers can help out.\n","permalink":"http://uly.me/posts/where-is-your-rss-feed/","summary":"\u003cp\u003eRSS or Really Simple Syndication enable publishers to syndicate their data automatically. Readers can subscribe to the feed and content will be delivered automatically. Most websites, news feeds, blogs, forums, etc. nowadays run some kind of content management system or CMS. And most CMS, if not all, have built-in RSS feed generators.\u003c/p\u003e\n\u003cp\u003eBut, why is it so hard to find the RSS feed for some websites? Why do readers have to go for a bunny hunt each time, just to find the RSS feed. If it’s not on the top of the page, it must be at the bottom. If it’s not on the front page, then clearly, it must be somewhere else on the site. Maybe, it’s searchable on the website. Well, try again. In some instances, there is no RSS at all. What a shame at this day and age.\u003c/p\u003e","title":"where is your rss feed?"},{"content":"Starting with WordPress 3.7, you don’t have to lift a finger to perform a WordPress update. Most WordPress-powered websites will be able to perform automatic updates without any intervention. The only prerequisite is that your website is capable of carrying updates without entering your FTP credentials. In the future, WordPress may require users to click “Update Now” for major feature releases.\nThe good news is, several of my WordPress-powered websites were able to perform auto updates automatically without a hitch. WordPress, as a courtesy, does send out an email notifications to WordPress administrators after each upgrade is completed. This new feature will be a tremendous help for many administrators who manage dozens of websites, knowing WordPress updates are going to be done automatically.\n","permalink":"http://uly.me/posts/wordpress-3-7-auto-updates/","summary":"\u003cp\u003eStarting with WordPress 3.7, you don’t have to lift a finger to perform a WordPress update. Most WordPress-powered websites will be able to perform automatic updates without any intervention. The only prerequisite is that your website is capable of carrying updates without entering your FTP credentials. In the future, WordPress may require users to click “Update Now” for major feature releases.\u003c/p\u003e\n\u003cp\u003eThe good news is, several of my WordPress-powered websites were able to perform auto updates automatically without a hitch. WordPress, as a courtesy, does send out an email notifications to WordPress administrators after each upgrade is completed. This new feature will be a tremendous help for many administrators who manage dozens of websites, knowing WordPress updates are going to be done automatically.\u003c/p\u003e","title":"wordpress 3.7 auto updates"},{"content":"If you’re a Mac user, you can open up a file by right-clicking on it, and choosing “Open With,” and selecting an application. If you see duplicates, you can remove multiple entries by running the following script. The script restarts the Launch Register called lsregister and removes the duplicates.\n/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user Right click the file again. The duplicates should be gone.\n","permalink":"http://uly.me/posts/open-with-application-duplicate/","summary":"\u003cp\u003eIf you’re a Mac user, you can open up a file by right-clicking on it, and choosing “Open With,” and selecting an application. If you see duplicates, you can remove multiple entries by running the following script. The script restarts the Launch Register called lsregister and removes the duplicates.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eRight click the file again. The duplicates should be gone.\u003c/p\u003e","title":"open with application duplicate"},{"content":"Although PHP comes with its own email() function, it lack features. There’s an alternative called PHPMailer that’s easy to implement. PHPMailer is a library class used by many popular PHP projects. In this article, I’ll show how PHPMailer is used to send out notification emails via GMail’s STMP server. Using GMail SMTP server requires an account as well as the need to authenticate. So, here’s the code using PHPMailer and GMail SMTP server.\n// email class require_once(\u0026#39;class.phpmailer.php\u0026#39;); $mail = new PHPMailer(); $mail-\u0026gt;IsSMTP(); // telling the class to use SMTP $mail-\u0026gt;Host = \u0026#34;domain.tld\u0026#34;; // SMTP server $mail-\u0026gt;SMTPAuth = true; // enable SMTP authentication $mail-\u0026gt;SMTPSecure = \u0026#34;tls\u0026#34;; // sets the prefix to the servier $mail-\u0026gt;Host = \u0026#34;smtp.gmail.com\u0026#34;; // sets GMAIL as the SMTP server $mail-\u0026gt;Port = 587; // set the SMTP port for the GMAIL server $mail-\u0026gt;Username = \u0026#34;name@gmail.com\u0026#34;; // GMAIL username $mail-\u0026gt;Password = \u0026#34;password\u0026#34;; // GMAIL password $mail-\u0026gt;Subject = \u0026#34;Your Subject\u0026#34;; $mail-\u0026gt;Body = \u0026#34;Your message.\u0026#34;; // recipient $address = \u0026#34;name@domain.tld\u0026#34;; $mail-\u0026gt;AddAddress($address, \u0026#34;Your Friend\u0026#34;); // sender $mail-\u0026gt;SetFrom(\u0026#39;name@gmail.com\u0026#39;, \u0026#39;Your Name\u0026#39;); $mail-\u0026gt;AddReplyTo(\u0026#34;name@gmail.com\u0026#34;,\u0026#34;Your Name\u0026#34;); // send out email if(!$mail-\u0026gt;Send()) { echo \u0026#34;Mailer Error: \u0026#34; . $mail-\u0026gt;ErrorInfo; } else { echo \u0026#34;Message sent!\u0026#34;; } Include the code in your projects. You can also create a function and call the function each time you need to send out an email notification. Off course, you’ll need to pass variables such as recipients, body message, etc to complete your function.\n","permalink":"http://uly.me/posts/phpmailer-and-gmail-smtp/","summary":"\u003cp\u003eAlthough PHP comes with its own email() function, it lack features. There’s an alternative called PHPMailer that’s easy to implement. PHPMailer is a library class used by many popular PHP projects. In this article, I’ll show how PHPMailer is used to send out notification emails via GMail’s STMP server. Using GMail SMTP server requires an account as well as the need to authenticate. So, here’s the code using PHPMailer and GMail SMTP server.\u003c/p\u003e","title":"phpmailer and gmail smtp"},{"content":"I installed a FTP server called vsftpd on my Ubuntu Server recently. After the install, I’ve been unable to login at all. It turned out to be a bug within the vsftpd program. I found a fix here. Essentially, the fix was removing the vsftpd program first, deleting the /etc/pam.d/vsftpd file and forcing the application to recreate the file. The third step is to reinstall the vstfpd once again.\nFrom the Terminal, type the following commands.\nsudo apt-get remove vsftpd sudo rm /etc/pam.d/vsftpd sudo apt-get install vsftpd After making the changes, I was able to log in successfully using the Filezilla client. Success.\n","permalink":"http://uly.me/posts/530-incorrect-login-error-on-vsftpd/","summary":"\u003cp\u003eI installed a FTP server called vsftpd on my Ubuntu Server recently. After the install, I’ve been unable to login at all. It turned out to be a bug within the vsftpd program. I found a fix \u003ca href=\"http://www.jackenhack.com/vsftpd-ubuntu-server-530-login-incorrect-error-fixed/\"\u003ehere\u003c/a\u003e. Essentially, the fix was removing the vsftpd program first, deleting the /etc/pam.d/vsftpd file and forcing the application to recreate the file. The third step is to reinstall the vstfpd once again.\u003c/p\u003e\n\u003cp\u003eFrom the Terminal, type the following commands.\u003c/p\u003e","title":"530 incorrect login error on vsftpd"},{"content":"What’s not to like with Samba. If you’re not familiar with Samba, it’s an open-source file and printer services which allows disparate clients to share files via SMB/CIFS standard, meaning there’s interoperability between Linux/Unix servers and Windows-based clients. This article will show you how to install a Samba shared drive on an Ubuntu Server.\nInstall Samba Server\nsudo apt-get install samba Configure Samba by editing /usr/samba/smb.conf. Uncomment and add the following.\nsecurity = user [share] comment = Ubuntu File Server Share path = /home/ulysses/share browsable = yes guest ok = yes read only = no create mask = 0755 Create the shared drive.\nsudo mkdir /home/ulysses/share sudo chown nobody.nogroup /home/ulysses/share sudo chmod -R 0777 /home/ulysses/share Restart Samba Server\nsudo restart smbd sudo restart nmbd Test the shared drive by accessing it from another computer or from another OS like a Mac or Windows.\n","permalink":"http://uly.me/posts/install-samba-shared-drive/","summary":"\u003cp\u003eWhat’s not to like with Samba. If you’re not familiar with Samba, it’s an open-source file and printer services which allows disparate clients to share files via SMB/CIFS standard, meaning there’s interoperability between Linux/Unix servers and Windows-based clients. This article will show you how to install a Samba shared drive on an Ubuntu Server.\u003c/p\u003e\n\u003cp\u003eInstall Samba Server\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo apt-get install samba\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eConfigure Samba by editing /usr/samba/smb.conf. Uncomment and add the following.\u003c/p\u003e","title":"install samba shared drive"},{"content":"A week ago, Linode doubled the storage for all its VPS plans. It now boasts 48GB of disk storage. This came at the heels of a RAM upgrade back in May. A month before that, Linode doubled its CPU from 4 to 8 cores. All of these upgrade are for the same monthly price of just $20 per month. Not bad at all. So overall, here are the details.\nLinode 1 GB\n8 cores 1 GB RAM 48 GB disk 2 TB transfer $20 per month I’m loving all these upgrades. I’m glad I switched to Linode more than a year ago. It’s the best thing I ever did.\nIn addition, you also get full ssh and root access. That means you can install any software or application that you want on your Linode. You also get a dedicated IP address and a choice of where to host your server from any of the 6 data centers around the world. The only complaint I have is the backup. I wished it was included with the plan instead of the extra $5 per month. Otherwise, I’m one happy Linode customer.\n","permalink":"http://uly.me/posts/linode-doubled-its-disk-storage/","summary":"\u003cp\u003eA week ago, Linode doubled the storage for all its VPS plans. It now boasts 48GB of disk storage. This came at the heels of a RAM upgrade back in May. A month before that, Linode doubled its CPU from 4 to 8 cores. All of these upgrade are for the same monthly price of just $20 per month. Not bad at all. So overall, here are the details.\u003c/p\u003e\n\u003cp\u003eLinode 1 GB\u003c/p\u003e","title":"linode doubled its disk storage"},{"content":"Adding host entries in your desktop can be beneficial if you run several servers or hosts on your internal network. Instead of typing and remembering long IP addresses, you simply type the name of each host to make things easier for you. Let’s say you have several servers named “one”, “two” and “three” in your internal network. Each hosts will have their own assigned static IP address. By editing your hosts file and adding host entries to it, you can then use the hostnames instead of IP addresses.\nIn the end, you can ping each hostname like this:\n$ ping one $ ping two $ ping three In addition, you can also use the hosts “one”, “two” or “three” on your browser URL if your host has a web interface. If there are no host entries, the ping command, as well as you browser will simply timeout. To make this all possible in your Mac OS, you’ll need to edit the /private/etc/hosts file, by opening the Terminal and typing:\n$ sudo nano /private/etc/hosts You need to add each host to the file in this format: ip_address hostname. See below:\n192.168.1.22 one 192.168.5.56 two 192.168.1.33 three Save file and exit. Ctrl-o and Ctrl-x.\nFlush the DNS by typing:\n$ dscacheutil -flushcache You can now ping and use the hostname anyway you want.\nThe only limitation with this approach is, you’ll have to edit the hosts file for each desktop or laptop that is on your network. You can avoid this by take the next step, by running your own internal DNS server.\n","permalink":"http://uly.me/posts/mac-os-hosts-file/","summary":"\u003cp\u003eAdding host entries in your desktop can be beneficial if you run several servers or hosts on your internal network. Instead of typing and remembering long IP addresses, you simply type the name of each host to make things easier for you. Let’s say you have several servers named “one”, “two” and “three” in your internal network. Each hosts will have their own assigned static IP address. By editing your hosts file and adding host entries to it, you can then use the hostnames instead of IP addresses.\u003c/p\u003e","title":"mac os hosts file"},{"content":"HTML buttons are dull and boring. If you like to make your HTML buttons stand out in the crowd, you’ll need to style them using CSS. This article will show you how to spice up your HTML buttons, therefore giving them life and color.\nTo begin, here’s the syntax for the HTML button:\n\u0026lt;input type=\u0026#34;submit\u0026#34; value=\u0026#34;Click here\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; Starting HTML4 and now with HTML5, button tags were made available. Instead of using input, you can simply use the button tags instead of the input tags. The button syntax is like this:\n\u0026lt;button\u0026gt;Click here\u0026lt;/button\u0026gt; The following CSS styles will work for both input and button tags. In this article and for the sake of simplicity, I will use the input tag primarily, but it can substituted by button tags, and the same CSS can be applied with the same effect.\nFirst, lets add an id called “submitbutton” to our button. This will identify our button from other buttons on the same page.\n\u0026lt;input id=\u0026#34;submitbutton\u0026#34; type=\u0026#34;submit\u0026#34; value=\u0026#34;Click here\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; Now that we have an ID, we can now style our button.\nHere’s the CSS styles that I will be adding.\ninput#submitbutton { border:1px solid #007aa7; /*border color dark blue */ background:#00aeef; /*the color of the button is blue */ padding:5px 15px; /*add padding inside of the button*/ -moz-border-radius: 5px; /* add rounded corners */ -webkit-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 0 4px rgba(0,0,0, .75); /* add drop shadows */ -moz-box-shadow: 0 0 4px rgba(0,0,0, .75); box-shadow: 0 0 4px rgba(0,0,0, .75); color:#f3f3f3; /* text color is white */ font-size:1em; /* font size is 1em */ cursor:pointer; /* change cursor when hover */ } input#submitbutton:hover, input#submitbutton:focus { background-color :#0090c6; /* the background a little darker*/ -webkit-box-shadow: 0 0 1px rgba(0,0,0, .75); /* drop shadow is narrower to give a pushed effect */ -moz-box-shadow: 0 0 1px rgba(0,0,0, .75); box-shadow: 0 0 1px rgba(0,0,0, .75); The border is set to solid and dark blue. Setting the border is important, otherwise the button remains the same. The background color is blue which will be the color of the button itself. Padding is added to the inside of the button to create more space. Rounded corners were added to make the button corners less edgy. Shadow effects were added to give it more depth. The text color is white. Font size is set to 1em. A slightly darker background is added for the hover effect. The shadow is narrower in hover mode to give it a pushed effect. See the demo.\n","permalink":"http://uly.me/posts/a-custom-html-button/","summary":"\u003cp\u003eHTML buttons are dull and boring. If you like to make your HTML buttons stand out in the crowd, you’ll need to style them using CSS. This article will show you how to spice up your HTML buttons, therefore giving them life and color.\u003c/p\u003e\n\u003cp\u003eTo begin, here’s the syntax for the HTML button:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e\u0026lt;input type=\u0026#34;submit\u0026#34; value=\u0026#34;Click here\u0026#34;\u0026gt;\u0026lt;/input\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eStarting HTML4 and now with HTML5, button tags were made available. Instead of using input, you can simply use the button tags instead of the input tags. The button syntax is like this:\u003c/p\u003e","title":"a custom html button"},{"content":"I recently had a problem with an Ubuntu server that was running MySQL. None of my applications were connecting to the database. After poking around in the server, I realized the database doesn’t seem to be running at all. I tried restarting it from the Terminal, but I ran into this error message.\nERROR 2003 (HY000): Can\u0026#39;t connect to MySQL server on \u0026#39;10.10.10.110\u0026#39; (111) As it turns out, the Ubuntu server picked up a new IP address of 10.10.10.113 from the last reboot. I went ahead and assigned a static IP address to the server of 10.10.10.200. I should have done it initially when I setup the server. If you need help setting up a static IP address on the Ubuntu server, here are the instructions on how to set Ubuntu server to static IP address.\nI looked at the MySQL configuration file called /etc/mysql/my.cnf, the bind-address was manually set to the old IP address of 10.10.10.110. So, edited the file and entered the new IP address of 10.10.10.200.\nbind-address = 10.10.10.200 Finally, I restarted the network as well as started the MySQL server.\nsudo /etc/init.d/networking restart sudo /etc/init.d/mysql start Everything is hunky dory again.\n","permalink":"http://uly.me/posts/cant-connect-to-mysql-server/","summary":"\u003cp\u003eI recently had a problem with an Ubuntu server that was running MySQL. None of my applications were connecting to the database. After poking around in the server, I realized the database doesn’t seem to be running at all. I tried restarting it from the Terminal, but I ran into this error message.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eERROR 2003 (HY000): Can\u0026#39;t connect to MySQL server on \u0026#39;10.10.10.110\u0026#39; (111)\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAs it turns out, the Ubuntu server picked up a new IP address of 10.10.10.113 from the last reboot. I went ahead and assigned a static IP address to the server of 10.10.10.200. I should have done it initially when I setup the server. If you need help setting up a static IP address on the Ubuntu server, here are the instructions on \u003ca href=\"http://ulyssesonline.com/ubuntu/2007/06/28/change-ip-address/\"\u003ehow to set Ubuntu server to static IP address\u003c/a\u003e.\u003c/p\u003e","title":"cant connect to mysql server"},{"content":"Every once in a while (it doesn’t happen very often) DNS servers would stop resolving certain domains causing intermittent issues when accessing the Internet. To solve the DNS issues, I often switch DNS servers on my main router. Changing DNS servers may require rebooting your router.\nSo, here’s a list of DNS servers you could use on your router, in case the current DNS servers you are using is having problems. I primarily use OpenDNS and Google DNS servers, but others DNS servers are reliable as well.\nOpenDNS\n208.67.222.222 Primary 208.67.220.220 Secondary Google\n8.8.8.8 Primary 8.8.4.4 Secondary Comcast\n75.75.75.75 Primary 75.75.76.76 Secondary AT\u0026amp;T DSL\n68.94.156.1 Primary 68.94.157.1 Secondary UltraDNS\n156.154.70.1 Primary 156.154.71.1 Secondary ScrubIt\n67.138.54.100 Primary 207.225.209.66 Secondary DNSResolvers\n205.210.42.205 Primary 64.68.200.200 Secondary ","permalink":"http://uly.me/posts/choosing-dns-servers/","summary":"\u003cp\u003eEvery once in a while (it doesn’t happen very often) DNS servers would stop resolving certain domains causing intermittent issues when accessing the Internet. To solve the DNS issues, I often switch DNS servers on my main router. Changing DNS servers may require rebooting your router.\u003c/p\u003e\n\u003cp\u003eSo, here’s a list of DNS servers you could use on your router, in case the current DNS servers you are using is having problems. I primarily use OpenDNS and Google DNS servers, but others DNS servers are reliable as well.\u003c/p\u003e","title":"choosing dns servers"},{"content":"A client of mine had a request to connect Microsoft Access to MySQL via an ODBC connector. The MySQL ODBC setup is not very common, but is entirely possible. MySQL does provide an ODBC connector for other database clients. The setup is a bit tricky. Unfortunately, there’s not a lot of information and documentation online for this type of setup. After some trial and error, I got it to work.\nFirst of all, here are some details. The MySQL server runs on Ubuntu 12.04. The ODBC client, MS Access 2010, runs on a Windows 7 machine. Assuming MySQL is already installed, we just need to make sure the MySQL server ODBC library is installed first.\nsudo apt-get install libmyodbc Now, let’s create an ODBC Data Source. Not sure if this step is required or optional. I did it anyways.\nsudo nano /etc/odbc.ini Add the following entries:\n[ODBC Data Sources] testodbc = MyODBC 5.2.5 Driver DSN [testodbc] Driver = MySQL Description = MySQL ODBC 5.2.5 Driver DSN Server = localhost Port = User = user Password = password Database = test Option = 3 Socket = Let’s secure your MySQL database by answering the following questions.\nsudo mysql_secure_installation Answer the following questions:\nEnter current password for root. Enter password. Change root password? [Y/n] n Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] n Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y Allow remote login on MySQL\n# Edit mysql configuration sudo nano /etc/mysql/my.cnf # Comment out \u0026#34;skip-networking\u0026#34; # Add \u0026#34;bind-address = 192.168.0.10\u0026#34; # Enter your own IP address $ bind-address = 192.168.0.10 # Save file and exit. # Login to MySQL $ sudo mysql -u root -p # Grant privileges mysql\u0026gt; grant all privileges on *.* to \u0026#39;root\u0026#39;@\u0026#39;%\u0026#39; identified by \u0026#39;password\u0026#39; with grant option; mysql\u0026gt; flush privileges; mysql\u0026gt; exit; # Restart MySQL $ sudo /etc/init.d/mysql restart # Test connection $ telnet 192.168.0.10 3306 Download the latest MySQL ODBC Connector and install.\nhttp://dev.mysql.com/downloads/connector/odbc/\nOpen Microsoft Access\nCreate “new blank database.” Select “External Data” and click on “ODBC Database.” Select “Link to the data source by creating a link table.” Create a new DSN Choose “MySQL 5.2 ODBC Driver.” Enter IP, Port 3306, Username, Password, and Database. Save DNS for later use. You should have connected to the MySQL by now.\n","permalink":"http://uly.me/posts/mysql-and-access-via-odbc/","summary":"\u003cp\u003eA client of mine had a request to connect Microsoft Access to MySQL via an ODBC connector. The MySQL ODBC setup is not very common, but is entirely possible. MySQL does provide an ODBC connector for other database clients. The setup is a bit tricky. Unfortunately, there’s not a lot of information and documentation online for this type of setup. After some trial and error, I got it to work.\u003c/p\u003e","title":"mysql and access via odbc"},{"content":"When setting up your Ubuntu server, you can allow regular Linux accounts to access your web root directory via FTP or secure shell. In this case, you want users to access /var/www directory. One of the first things you’ll need to do is give permissions to the Apache user www-data.\nChange the group name to /var/www.\nsudo chgrp www-data /var/www Make it writeable.\nsudo chmod 775 /var/www Set the GID for www-data for all sub-folders.\nsudo chmod g+s /var/www Finally, add your user to www-data group.\nsudo usermod -a -G www-data username This will now allow you to use a regular user account via FTP or SSH with write permissions to the /var/www directory. This is much more secure way than using the www-data user account.\n","permalink":"http://uly.me/posts/user-access-to-web-root/","summary":"\u003cp\u003eWhen setting up your Ubuntu server, you can allow regular Linux accounts to access your web root directory via FTP or secure shell. In this case, you want users to access /var/www directory. One of the first things you’ll need to do is give permissions to the Apache user www-data.\u003c/p\u003e\n\u003cp\u003eChange the group name to /var/www.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo chgrp www-data /var/www\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eMake it writeable.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo chmod 775 /var/www\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eSet the GID for www-data for all sub-folders.\u003c/p\u003e","title":"user access to web root"},{"content":"If you’re working on Ubuntu and running Apache, you probably have seen this error when rebooting Apache. It says “could not reliably determine the server’s fully qualified domain name.” There’s a simple fix to this configuration issue.\nYou’ll need to edit the /etc/apache2/httpd.conf config file:\nsudo nano /etc/apache2/httpd.conf and add this entry:\nServerName localhost Reboot Apache\nsudo /etc/init.d/apache2 restart The error is now gone.\n","permalink":"http://uly.me/posts/fix-apache-fdq-error/","summary":"\u003cp\u003eIf you’re working on Ubuntu and running Apache, you probably have seen this error when rebooting Apache. It says “could not reliably determine the server’s fully qualified domain name.” There’s a simple fix to this configuration issue.\u003c/p\u003e\n\u003cp\u003eYou’ll need to edit the /etc/apache2/httpd.conf config file:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo nano /etc/apache2/httpd.conf\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eand add this entry:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eServerName localhost\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eReboot Apache\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esudo /etc/init.d/apache2 restart\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe error is now gone.\u003c/p\u003e","title":"fix apache fdq error"},{"content":"CodeIgniter comes with a URL helper that assist you with managing URLs. One function worth examining is called anchor, which creates standard HTML links. Instead of the standard HTML \u0026lt;a href=””\u0026gt;anchor\u0026lt;/a\u0026gt; tag most people are familiar with, CodeIgniter coders can take advantage of the simpler anchor function.\nTo create a standard link, all you have to do is code this:\n=anchor(\u0026#39;blog /index\u0026#39;, \u0026#39;Home\u0026#39;);?\u0026gt; // Output is \u0026lt;a href=\u0026#34;http://yourdomain.com/blog/index.php\u0026#34;\u0026gt;Home\u0026lt;/a\u0026gt; If you want to add a Javascript popup that will ask you “Are you sure?” before proceeding to the link, then all you have to do is add a third option in the anchor function like this:\n\u0026lt;?php $onclick = array(\u0026#39;onclick\u0026#39;=?\u0026gt;\u0026#34;return confirm(\u0026#39;Are you sure?\u0026#39;)\u0026#34;);?\u0026gt; =anchor(\u0026#39;blog /index\u0026#39;, \u0026#39;Home\u0026#39;, $onclick);?\u0026gt; // Output is \u0026lt;a href=\u0026#34;http://yourdomain.com/blog/index.php\u0026#34; onclick=\u0026#34;return confirm(\u0026#39;Are you sure?\u0026#39;)\u0026#34;\u0026gt;Home\u0026lt;/a\u0026gt; This function works great especially if you add it to code that delete records. You like to be able to ask the user first if that’s what they really want to do before proceeding.\n","permalink":"http://uly.me/posts/codeigniter-anchor-with-onclick/","summary":"\u003cp\u003eCodeIgniter comes with a \u003ca href=\"http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html\"\u003eURL helper\u003c/a\u003e that assist you with managing URLs. One function worth examining is called anchor, which creates standard HTML links. Instead of the standard HTML \u0026lt;a href=””\u0026gt;anchor\u0026lt;/a\u0026gt; tag most people are familiar with, CodeIgniter coders can take advantage of the simpler anchor function.\u003c/p\u003e\n\u003cp\u003eTo create a standard link, all you have to do is code this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e=anchor(\u0026#39;blog /index\u0026#39;, \u0026#39;Home\u0026#39;);?\u0026gt;\n\n// Output is\n\u0026lt;a href=\u0026#34;http://yourdomain.com/blog/index.php\u0026#34;\u0026gt;Home\u0026lt;/a\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIf you want to add a Javascript popup that will ask you “Are you sure?” before proceeding to the link, then all you have to do is add a third option in the anchor function like this:\u003c/p\u003e","title":"codeigniter anchor with onclick"},{"content":"If you work with MacOS and you FTP files to a Linux server, you probably have seen this pesky and ubiquitous hidden files named .DS_Store. They seem to be in every folder known to man. The .DS_Store files are hidden MacOS files used to store the attributes of a folder such as position of icons and choice of background images, etc. Although they are not harmful, they probably don’t belong on the web server. Instead of deleting them one by one, there’s a faster way of deleting them recursively. You can invoke this command from the Linux terminal on your webroot folder.\ncd /var/www/ find . \u0026#34;-name\u0026#34; \u0026#34;.DS_Store\u0026#34; -exec rm {} \\; The .DS_Store files will be deleted recursively.\n","permalink":"http://uly.me/posts/delete-ds_store-files-recursively/","summary":"\u003cp\u003eIf you work with MacOS and you FTP files to a Linux server, you probably have seen this pesky and ubiquitous hidden files named .DS_Store. They seem to be in every folder known to man. The .DS_Store files are hidden MacOS files used to store the attributes of a folder such as position of icons and choice of background images, etc. Although they are not harmful, they probably don’t belong on the web server. Instead of deleting them one by one, there’s a faster way of deleting them recursively. You can invoke this command from the Linux terminal on your webroot folder.\u003c/p\u003e","title":"delete .ds_store files recursively"},{"content":"If you’re a system administrator or web developer with root privileges, chances are, you probably have complete control of your web server, including root privileges. That’s a good thing. You can setup the server anyway you want. If you’re starting out to build out a new web server, some of the questions that you may have is, what’s the proper or correct way of creating a web directory structure on your web server.\nThe answer is, there is really no correct way. There’s no magic bullet configuration. You do have complete freedom to setup your server anyway you want. But, if you want to make it easy for yourself, you should probably look for a well-established standard, or some proven way in structuring web directories.\nThe following is my “suggestion” after my extensive experience with countless web servers over the years. I called it “suggestion” because it’s by no means the holy grail, but the concept has served me well over the years. You may not necessarily agree with my format, or you may have something similar, or something completely different than mine. Nevertheless, my setup is simple and it works.\nMost web servers nowadays can host multiple domains. I will make an assumption that you will be running multiple domains on your web server. A typical structure would be something similar to the one below. Each domain has its own subdirectory.\n/var/www/domain1.com/ /var/www/domain2.com/ /var/www/domain3.com/ If you have a static website, the file structure would be something like this.\n/var/wwww/domain.com/index.html If you have a dynamic website, you have something similar to this.\n/var/www/domain.com/index.php /var/www/domain.com/wp-content/ By the way, “wp-content” is a WordPress folder where templates and plugins reside. The above structure is serviceable, but if you ever find yourself working with PHP Frameworks such as CodeIgniter, Zend Frameworks, or even Ruby on Rails, there are some additional directories and programs that you would want to hide from the public for security reasons. Here are some directories using the CodeIgniter example.\n/var/www/domain.com/index.php /var/www/domain.com/application/ /var/www/domain.com/system/ To make your application secure, we need to move the “application” and the “system” folders above the web root folder. With the current setup, this is where you begin to have some issues. Where exactly do we put your “application” and “system” folders if multiple domains need them. So, here’s my suggestion. We need to create a “www” folder under each domain. We will make the “www” folder the web root folder. The setup would look something like this.\n/var/www/domain1.com/www/ /var/www/domain2.com/www/ Now, that we have the “www” folder created, we can then place the “application” and “system” folders on their own directory above the web root. The setup would look something like this.\n/var/www/domain1.com/www/index.php /var/www/domain1.com/application/ /var/www/domain1.com/system/ /var/www/domain2.com/www/index.php /var/www/domain2.com/application/ /var/www/domain2.com/system/ So, the setup above is ideal for placing folders above the web root folder if you want a more secure application. At the same time, these folders are still under each domain. So, this is the web structure that I have implemented over the years. If there’s a better way of doing this, I would like to hear about it.\n","permalink":"http://uly.me/posts/web-directory-structure/","summary":"\u003cp\u003eIf you’re a system administrator or web developer with root privileges, chances are, you probably have complete control of your web server, including root privileges. That’s a good thing. You can setup the server anyway you want. If you’re starting out to build out a new web server, some of the questions that you may have is, what’s the proper or correct way of creating a web directory structure on your web server.\u003c/p\u003e","title":"web directory structure"},{"content":"One of the first things you should do once you have your Raspberry Pi is setup a wireless network adapter. This will allow you to be cable free. To configure, you will need one of several approved USB wireless adapters. I’m using an Airlink 101 Wireless N 150 Ultra Mini-USB Adapter that I purchased at Amazon for just $14. I chose the Airline 101 because it was affordable, and it works very well with the Raspberry Pi.\n10 steps to setup wireless on Raspberry Pi:\nPlug in the Airlink 101 adapter. Power up the the Raspberry Pi. To see if the wireless device is recognized, type lsusb. To see if the kernel driver is installed, type lsmod. Edit the /etc/network/interfaces file. Edit the /etc/wpa_supplicant/wpa_supplicant.conf file. Reboot. Check with ifconfig. Check with ping. All done. Here are the commands, instructions and their respected screen outputs.\n$ lsusb Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter $ lsmod 8192cu 485042 0 $ sudo nano /etc/network/interfaces # Add the following lines: auto wlan0 allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf # Add the following lines: network={ ssid=\u0026#34;The_SSID\u0026#34; proto=RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk=\u0026#34;The_WPA_SHARED_KEY_\u0026#34; } $ sudo reboot $ sudo ifconfig wlan0 $ ping yahoo.com ","permalink":"http://uly.me/posts/setup-wireless-on-raspberry-pi/","summary":"\u003cp\u003eOne of the first things you should do once you have your Raspberry Pi is setup a wireless network adapter. This will allow you to be cable free. To configure, you will need one of several approved USB wireless adapters. I’m using an Airlink 101 Wireless N 150 Ultra Mini-USB Adapter that I \u003ca href=\"http://www.amazon.com/exec/obidos/ASIN/B006ZZUK5Y/savagehomeaut-20\"\u003epurchased\u003c/a\u003e at Amazon for just $14. I chose the Airline 101 because it was affordable, and it works very well with the Raspberry Pi.\u003c/p\u003e","title":"setup wireless on raspberry pi"},{"content":"I had a little trouble with CodeIgniter pagination today. The pagination function is working fine, but Page 1 is always selected regardless which page I select. The data seems to be correct as I go from one page to another, but the page number doesn’t move at all. Well, after trial and error, the problem turned out to be a configuration issue.\nCodeIgniter typically uses the following URI format:\nhttp://domain.com/class/function/id.\nThe third segment is normally used by the pagination function for navigating from one page to another. By default, CodeIgniter pagination only uses 3 URI segments. If you are using more than 3 segments, then you will need to specify the location of the URI segment in your configuration. In my case, I’m using the fourth segment, I needed to include this setting.\n$config [‘uri_segment’] = ‘4’;\nIf you need help with pagination, please refer to the Pagination class from the CodeIgniter User Guide.\n","permalink":"http://uly.me/posts/first-page-is-always-selected/","summary":"\u003cp\u003eI had a little trouble with CodeIgniter pagination today. The pagination function is working fine, but Page 1 is always selected regardless which page I select. The data seems to be correct as I go from one page to another, but the page number doesn’t move at all. Well, after trial and error, the problem turned out to be a configuration issue.\u003c/p\u003e\n\u003cp\u003eCodeIgniter typically uses the following URI format:\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"http://domain.com/class/function/id\"\u003ehttp://domain.com/class/function/id\u003c/a\u003e.\u003c/p\u003e","title":"first page is always selected"},{"content":"When performing a database query, we normally use a loop to output the database result. This is a common exercise for programmers when displaying results to the screen. To make the output readable, commas are typically used to separate data. Consider a loop below that prints a list of names. We added a string ‘, ‘ after each name to make it readable.\nforeach($query as $item) : echo $item-\u0026gt;name.\u0026#39;, \u0026#39;; endforeach; The output would be something like this:\nJohn, Mary, Steve, Mark,\nThe output works as intended, but there is a trailing comma at the end that we don’t want. We either need to get rid of it, or replace it with a period. So, how do we do that? Here’s how.\nWe will use the trim() function to remove the last comma. But before we can do that, we should probably hold off on echoing to the screen until the loop is finished. So, we will store the results in a variable called $result as we go through the loop. To avoid a PHP undefined variable error, we need to initialize the $result variable before the loop begins. After the loop, we will use the rtrim function to remove the last comma. Finally, we echo the trimmed results and add a period.\n$result=\u0026#34;\u0026#34;; foreach($query as $item) : $result.=$item-\u0026gt;name.\u0026#39;, \u0026#39;; endforeach; $trimmed=rtrim($result, \u0026#39;, \u0026#39;); echo $trimmed; echo \u0026#39;.\u0026#39;; The output is now:\nJohn, Mary, Steve, Mark.\n","permalink":"http://uly.me/posts/remove-last-comma-in-loop/","summary":"\u003cp\u003eWhen performing a database query, we normally use a loop to output the database result. This is a common exercise for programmers when displaying results to the screen. To make the output readable, commas are typically used to separate data. Consider a loop below that prints a list of names. We added a string \u003cstrong\u003e‘, ‘\u003c/strong\u003e after each name to make it readable.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eforeach($query as $item) :\necho $item-\u0026gt;name.\u0026#39;, \u0026#39;; \nendforeach;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe output would be something like this:\u003cbr\u003e\nJohn, Mary, Steve, Mark,\u003c/p\u003e","title":"remove last comma in loop"},{"content":"Jumpstart your website by adding Bootstrap, a front-end CSS framework started by a couple of Twitter developers. If you are starting on a new web project, why not dress it with Bootstrap. You can quickly transform your website, by just adding a couple of markups. Bootstrap uses some HTML markup, LESS CSS, and Javascript plugins to create the framework.\nTo get started, Download Bootstrap first.\nThen, use this HTML Bootstrap template\n\u0026lt;title\u0026gt;Bootstrap 101 Template\u0026lt;/title\u0026gt; \u0026lt;link href=\u0026#34;css/bootstrap.min.css\u0026#34; media=\u0026#34;screen\u0026#34; rel=\u0026#34;stylesheet\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; \u0026lt;div class=\u0026#34;container-fluid\u0026#34;\u0026gt; \u0026lt;h1\u0026gt;Hello, world!\u0026lt;/h1\u0026gt; \u0026lt;script src=\u0026#34;http://code.jquery.com/jquery-latest.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script src=\u0026#34;js/bootstrap.min.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;/div\u0026gt; To learn more about Bootstrap, just play around with all the different aspects of the framework. Add some navigation buttons, forms, tables, alerts, and some Javascript features. Finally, you can learn a lot more by studying the rest of the documentation.\n","permalink":"http://uly.me/posts/bootstrap-your-website/","summary":"\u003cp\u003eJumpstart your website by adding Bootstrap, a front-end CSS framework started by a couple of Twitter developers. If you are starting on a new web project, why not dress it with Bootstrap. You can quickly transform your website, by just adding a couple of markups. Bootstrap uses some HTML markup, LESS CSS, and Javascript plugins to create the framework.\u003c/p\u003e\n\u003cp\u003eTo get started, \u003ca href=\"http://twitter.github.com/bootstrap/index.html\"\u003eDownload Bootstrap\u003c/a\u003e first.\u003c/p\u003e\n\u003cp\u003eThen, use this HTML Bootstrap template\u003c/p\u003e","title":"bootstrap your website"},{"content":"One of many clever ways you can do with Dropbox is to make it the web root of your development server. There’s an advantage to doing this, as I’ll explain in this post. Currently, I have Dropbox installed on my Linux Mint desktop. I also use the desktop as my web development server. I have Apache, PHP, MySQL, etc. installed. Typically the web root of the Apache web server, is located in the /var/www directory. I’ve changed mine to a Dropbox folder at /home/ulysses/Dropbox/web/.\nThere’s an advantage to making Dropbox the web root. I normally use multiple computers to code. I have a Linux desktop, Macbook Air, and a Windows machine. I installed Dropbox on all of them, and placed my code in a Dropbox folder to share files. My code is always synched on all computers. Each time I move to another computer, I can always access the same code, because Dropbox does a fantastic job of synching files on all my computers.\nIn addition, I made Dropbox the web root of my development server, so every time I make a file change, the development web server is also updated. So, there is no more need for me to FTP or copy files to my development server. One more thing, if my desktop is turned on at home, any changes I make away from home, are reflected on my development server instantaneously.\nTo change Apache’s web root, edit the /etc/apache2/sites-available/default config file. Change the default directory from /var/www to /home/ulysses/Dropbox/web/, the location of my Dropbox folder.\nDocumentRoot /home/ulysses/Dropbox/web \u0026lt;directory\u0026gt;\u0026lt;/directory\u0026gt; Options FollowSymLinks AllowOverride None \u0026lt;directory\u0026gt;\u0026lt;/directory\u0026gt; Options Indexes FollowSymLinks Multiviews AllowOverride All Order allow,deny allow from all Do the same for the /etc/apache2/sites-enabled/default config file.\nFinally, restart Apache.\n$ sudo /etc/init.d/apache2 restart ","permalink":"http://uly.me/posts/dropbox-folder-as-web-root/","summary":"\u003cp\u003eOne of many clever ways you can do with Dropbox is to make it the web root of your development server. There’s an advantage to doing this, as I’ll explain in this post. Currently, I have Dropbox installed on my Linux Mint desktop. I also use the desktop as my web development server. I have Apache, PHP, MySQL, etc. installed. Typically the web root of the Apache web server, is located in the /var/www directory. I’ve changed mine to a Dropbox folder at /home/ulysses/Dropbox/web/.\u003c/p\u003e","title":"dropbox folder as web root"},{"content":"I was working with PHP forms the other day which contained an email address. Validating email addresses is important. Occasionally, email addresses are used for activating accounts or resetting passwords. We can’t always guarantee that the email address provided is going to be valid, but at least, we can validate it’s going to be in the correct format. For pattern matching, I’m using a regex I found online. I like it because it’s very strict. I’m using the regex pattern with the preg_match function to determine a valid email address.\nfunction check_email($email) { $pattern = \u0026#34;/^([a-zA-Z0-9])+([a-zA-Z0-9\\._+-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\\._-]+)+$/\u0026#34;; if (!preg_match($pattern, stripslashes(trim($email)))) : return false; else : return true; endif; } To use the function, we can do this.\n$email = \u0026#34;name@domain.com\u0026#34;; echo $message = (check_email($email) ? \u0026#34;Valid.\u0026#34; : \u0026#34;Wrong format.\u0026#34;); In this example above, I’m using a ternary operator to display the result. It echoes out “Valid” because the email address we provided is in a valid format. You can use the regular “if else” conditional, if you prefer, instead of the ternary operator. By the way, I set $email variable manually. It this was an actual application, the email address cloud have come from a form.\n","permalink":"http://uly.me/posts/validate-email-address/","summary":"\u003cp\u003eI was working with PHP forms the other day which contained an email address. Validating email addresses is important. Occasionally, email addresses are used for activating accounts or resetting passwords. We can’t always guarantee that the email address provided is going to be valid, but at least, we can validate it’s going to be in the correct format. For pattern matching, I’m using a regex I found online. I like it because it’s very strict. I’m using the regex pattern with the preg_match function to determine a valid email address.\u003c/p\u003e","title":"validate email address"},{"content":"Here’s a simple way to validate forms with empty fields. When working with forms, we want users to submit required fields. We can easily check by using the PHP empty() function. In this example, I will use a simple form, and check if “username” is empty. Since the action for the form is blank, the form will submit to itself. The the code you see for “value” is a shorthand PHP code to echo the field entry after a submit.\n\u0026lt;form action=\u0026#34;\u0026#34; method=\u0026#34;post\u0026#34; name=\u0026#34;\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;username\u0026#34; type=\u0026#34;text\u0026#34; value=\u0026#34;\u0026lt;?=$username;?\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;input name=\u0026#34;submit\u0026#34; type=\u0026#34;submit\u0026#34; value=\u0026#34;Submit\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt; Here’s the PHP code. First, we need to check if the form was submitted. We do this by checking $_POST[‘submit’]. Next, we will check if “username” is empty by using the empty() PHP function. If it’s empty, then we assign an error message to $errors. Finally, we will check if $errors is empty. If it is, then we can proceed with whatever we want to do. Otherwise, we echo the error messages.\n$errors = array(); if (isset($_POST[\u0026#39;submit\u0026#39;])) : $username = $_POST[\u0026#39;username\u0026#39;]; if (empty($username)) $errors[] = \u0026#34;Empty username.\u0026#34;; if (empty($errors)) : // do something special here, like saving to a database. else: // otherwise print the error messages. foreach ($errors as $msg) : echo \u0026#34;$msg\u0026lt;br\u0026gt;\u0026lt;/br\u0026gt;\\n\u0026#34;; endforeach; endif; endif; And one more thing. Place this PHP code above your form. The reason for this is, we want to redisplay the form just below the error messages. Users will be able to see the error messages right away, and the form is right there in front of the user ready for editing again.\n","permalink":"http://uly.me/posts/validate-empty-fields/","summary":"\u003cp\u003eHere’s a simple way to validate forms with empty fields. When working with forms, we want users to submit required fields. We can easily check by using the PHP empty() function. In this example, I will use a simple form, and check if “username” is empty. Since the action for the form is blank, the form will submit to itself. The the code you see for “value” is a shorthand PHP code to echo the field entry after a submit.\u003c/p\u003e","title":"validate empty fields"},{"content":"My Raspberry Pi finally arrived yesterday, after what seemed like an eternity of waiting. I ordered it October 24. It was shipped November 20 and arrived on my doorstep November 29. That’s over a month! I had a few hours to play around with it. The first thing I did was placed the Raspberry Pi inside an Adafruit Rainbow Pibow enclosure that I’ve ordered several weeks back. It looks amazing. Here’s it is.\nOnce it was inside the Pibow enclosure, I downloaded the Raspberry image called Raspbian Wheezy. I loaded it to an old 4GB SD card that originally came with my Nikon D90 camera. Once the image was loaded, I inserted the SD card, connected a USB keyboard, a USB mouse, and a HDMI cable.\nOn a side note, I’m currently using a 5v 750ma USB adapter, which I know is sufficient, but the Raspberry Pi needs more ooomp with multiple USB devices connected to it. They recommend that you have at least a 5v 1amp power adapter.\nFinally, I powered the Raspberry Pi. A blank screen! Not good. It turned out to be just a resolution issue. I ended up plugging my Raspberry Pi to my old TV, via a RCA composite cable. It worked, although a good portion of the screen was clipped. I started the GUI, then accessed the Terminal and changed the screen resolution from there.\nI found this page with instructions how to change Raspberry Pi to 1680×1050 resolution.\nEdit the /boot/config.txt file.\nsudo nano /boot/config.txt Add the following code to the end of the file. 58 is for screens with a 1680×1050 resolution.\nhdmi_group=2 hdmi_mode=58 Reboot.\nsudo reboot My monitor works! All 1680×1050 pixels. I ran an update next by issuing the following commands.\nsudo apt-get update sudo apt-get upgrade This process takes a good 20 minutes. Finally, I installed Apache.\nsudo apt-get install apache2 Once installed. I checked if the web server works. It does.\n","permalink":"http://uly.me/posts/the-raspberry-pi-works/","summary":"\u003cp\u003eMy \u003ca href=\"http://www.raspberrypi.org\"\u003eRaspberry Pi\u003c/a\u003e finally arrived yesterday, after what seemed like an eternity of waiting. I ordered it October 24. It was shipped November 20 and arrived on my doorstep November 29. That’s over a month! I had a few hours to play around with it. The first thing I did was placed the Raspberry Pi inside an \u003ca href=\"http://www.adafruit.com/products/975\"\u003eAdafruit Rainbow Pibow\u003c/a\u003e enclosure that I’ve ordered several weeks back. It looks amazing. Here’s it is.\u003c/p\u003e","title":"the raspberry pi works"},{"content":"This article will show you how to generate random characters in PHP. Random characters are useful in a variety of ways, such as generating random passwords or filenames. The command that we are going to use to generate random characters is a function called mt_rand(). In addition, we will specify which characters we want to include in our random key.\nI’ve decided to omit vowels, as well as the number zero, to make the random characters much more unpredictable. I’ve added some special characters in the mix, just for the fun of it. If you don’t want the special characters, you can just take them out. Here’s our list.\n// List of random characters $characters = array( \u0026#34;B\u0026#34;,\u0026#34;C\u0026#34;,\u0026#34;D\u0026#34;,\u0026#34;F\u0026#34;,\u0026#34;G\u0026#34;,\u0026#34;H\u0026#34;,\u0026#34;J\u0026#34;,\u0026#34;K\u0026#34;,\u0026#34;L\u0026#34;, \u0026#34;M\u0026#34;,\u0026#34;N\u0026#34;,\u0026#34;P\u0026#34;,\u0026#34;Q\u0026#34;,\u0026#34;R\u0026#34;,\u0026#34;S\u0026#34;,\u0026#34;T\u0026#34;,\u0026#34;V\u0026#34;,\u0026#34;W\u0026#34;, \u0026#34;X\u0026#34;,\u0026#34;Y\u0026#34;,\u0026#34;Z\u0026#34;,\u0026#34;b\u0026#34;,\u0026#34;c\u0026#34;,\u0026#34;d\u0026#34;,\u0026#34;f\u0026#34;,\u0026#34;g\u0026#34;,\u0026#34;h\u0026#34;, \u0026#34;j\u0026#34;,\u0026#34;k\u0026#34;,\u0026#34;l\u0026#34;,\u0026#34;m\u0026#34;,\u0026#34;n\u0026#34;,\u0026#34;p\u0026#34;,\u0026#34;q\u0026#34;,\u0026#34;r\u0026#34;,\u0026#34;s\u0026#34;, \u0026#34;t\u0026#34;,\u0026#34;v\u0026#34;,\u0026#34;w\u0026#34;,\u0026#34;x\u0026#34;,\u0026#34;y\u0026#34;,\u0026#34;z\u0026#34;, \u0026#34;1\u0026#34;,\u0026#34;2\u0026#34;,\u0026#34;3\u0026#34;,\u0026#34;4\u0026#34;,\u0026#34;5\u0026#34;,\u0026#34;6\u0026#34;,\u0026#34;7\u0026#34;,\u0026#34;8\u0026#34;,\u0026#34;9\u0026#34;, \u0026#34;!\u0026#34;,\u0026#34;@\u0026#34;,\u0026#34;#\u0026#34;,\u0026#34;$\u0026#34;,\u0026#34;%\u0026#34;,\u0026#34;^\u0026#34;,\u0026#34;*\u0026#34;,\u0026#34;(\u0026#34;,\u0026#34;)\u0026#34;, \u0026#34;+\u0026#34;,\u0026#34;=\u0026#34;,\u0026#34;{\u0026#34;,\u0026#34;}\u0026#34;,\u0026#34;[\u0026#34;,\u0026#34;]\u0026#34;,\u0026#34;~\u0026#34; ); Next, we will create a variable array to store our random key. We will run a loop 7 times, to generate a key that is 7 characters long. Inside the loop, we count the number of characters on our list, and generate a key, one by one, until the loop is done. Finally, we reveal our random key on the screen using the echo command. Just reload the page to generate a different key.\n// Assign an array for our random key $keys = array(); // generate random key 7 times while(count($keys) Demo\n","permalink":"http://uly.me/posts/generate-random-characters/","summary":"\u003cp\u003eThis article will show you how to generate random characters in PHP. Random characters are useful in a variety of ways, such as generating random passwords or filenames. The command that we are going to use to generate random characters is a function called mt_rand(). In addition, we will specify which characters we want to include in our random key.\u003c/p\u003e\n\u003cp\u003eI’ve decided to omit vowels, as well as the number zero, to make the random characters much more unpredictable. I’ve added some special characters in the mix, just for the fun of it. If you don’t want the special characters, you can just take them out. Here’s our list.\u003c/p\u003e","title":"generate random characters"},{"content":"About a month ago, I bought a Mac Mini at the Apple store in San Francisco. I remember it very well, because it was October 31, which happens to be Halloween. If that wasn’t enough, it was also the day of the victory parade of the World Champions San Francisco Giants. So, I headed out to the Apple store, at the corner of Ellis and Stockton after watching the last motorcade. I picked up the new 2012 Mac Mini, and carried it home, inside an Apple plastic bag.\nThe new Mac Mini is twice as fast versus its predecessor. It’s powered by a 2.3GHz quad-core Intel Core i7 (Turbo Boost up to 3.3GHz) processor with 6MB L3 cache. It comes with a 1TB (5400-rpm) hard drive, and 4GB RAM. I upgraded the memory to 8GB, which I thought was a good decision at the time. The Mac Mini also comes with a Thunderbolt port, four USB 3.0 ports, a Firewire 800 port, a Gigabit Ethernet port, and a 802.11n Wi-Fi wireless adapter.\nThe only gripe I have with the Mac Mini is, my widescreen monitor, a HP w2207h HDMI flat screen, doesn’t quite work quite well with the Mac Mini. When connected using a straight HDMI to HDMI cable, the screen would blink or flash every second. I think it’s a display driver issue with this HP monitor. In the end, I had to get a Mini DisplayPort to DVI Adapter, a DVI to HDMI cable, to connect my Mac Mini to the HP monitor. It’s quite a convoluted way to connect to a monitor, if you ask me, but it works. I tried using a Mini DisplayPort to VGA connection, but it’s not quite as sharp.\nAfter a month, I can honestly say, I love my Mac Mini equally as much as my Linux desktop.\n","permalink":"http://uly.me/posts/2012-mac-mini/","summary":"\u003cp\u003eAbout a month ago, I bought a Mac Mini at the Apple store in San Francisco. I remember it very well, because it was October 31, which happens to be Halloween. If that wasn’t enough, it was also the day of the victory parade of the World Champions San Francisco Giants. So, I headed out to the Apple store, at the corner of Ellis and Stockton after watching the last motorcade. I picked up the new 2012 Mac Mini, and carried it home, inside an Apple plastic bag.\u003c/p\u003e","title":"2012 mac mini"},{"content":"I was working on a client project last night. I had to sort a multidimensional array. I came across a neat PHP function called asort. In the end, I had to use arsort instead of asort to get a reverse sort order. This short article will show you how to sort arrays in normal and reverse order. Here’s our array.\n$animals = array(\u0026#34;a\u0026#34; =\u0026gt; \u0026#34;Giraffe\u0026#34;, \u0026#34;b\u0026#34; =\u0026gt; \u0026#34;Elephant\u0026#34;, \u0026#34;c\u0026#34; =\u0026gt; \u0026#34;Lion\u0026#34;); We will sort the array using the asort function. We print the array to view the results.\nasort($animals); print_r($animals); The asort output is:\nArray ( [b] =\u0026gt; Elephant [a] =\u0026gt; Giraffe [c] =\u0026gt; Lion ) The arsort (reverse order) output is:\nArray ( [c] =\u0026gt; Lion [a] =\u0026gt; Giraffe [b] =\u0026gt; Elephant ) ","permalink":"http://uly.me/posts/sorting-arrays/","summary":"\u003cp\u003eI was working on a client project last night. I had to sort a multidimensional array. I came across a neat PHP function called asort. In the end, I had to use arsort instead of asort to get a reverse sort order. This short article will show you how to sort arrays in normal and reverse order. Here’s our array.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e$animals = array(\u0026#34;a\u0026#34; =\u0026gt; \u0026#34;Giraffe\u0026#34;, \u0026#34;b\u0026#34; =\u0026gt; \u0026#34;Elephant\u0026#34;, \u0026#34;c\u0026#34; =\u0026gt; \u0026#34;Lion\u0026#34;);\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWe will sort the array using the asort function. We print the array to view the results.\u003c/p\u003e","title":"sorting arrays"},{"content":"I’m releasing a WordPress plugin called “Web Fonts.” This plugin takes advantage of the free and open-source Google Web Fonts. If you’re not familiar with Google Web Fonts, it’s a group of fonts that allows designers to customize the looks of their blogs or websites using hundreds of exotic fonts. With a gaggle of external fonts available for use, “Web Fonts” can transform the overall design of a website.\nInstall and Configure Upload the “webfonts” folder to the WordPress plugins folder. Activate the “Web Fonts” plugin from the “Dashboard \u0026gt; Plugins \u0026gt; Installed Plugins.” Configure stylesheet link and CSS from the “Dashboard \u0026gt; Settings \u0026gt; Web Fonts.” If you want multiple fonts, just add a second stylesheet link and additional CSS. “Update Options” to save. Screenshot Version 1.1 Moved to “Appearance \u0026gt; Web Fonts” Added some documentation Download\n","permalink":"http://uly.me/posts/google-web-fonts-plugin/","summary":"\u003cp\u003eI’m releasing a WordPress plugin called “Web Fonts.” This plugin takes advantage of the free and open-source \u003ca href=\"http://google.com/webfonts/\"\u003eGoogle Web Fonts\u003c/a\u003e. If you’re not familiar with Google Web Fonts, it’s a group of fonts that allows designers to customize the looks of their blogs or websites using hundreds of exotic fonts. With a gaggle of external fonts available for use, “Web Fonts” can transform the overall design of a website.\u003c/p\u003e\n\u003ch4 id=\"install-and-configure\"\u003eInstall and Configure\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003eUpload the “webfonts” folder to the WordPress plugins folder.\u003c/li\u003e\n\u003cli\u003eActivate the “Web Fonts” plugin from the “Dashboard \u0026gt; Plugins \u0026gt; Installed Plugins.”\u003c/li\u003e\n\u003cli\u003eConfigure stylesheet link and CSS from the “Dashboard \u0026gt; Settings \u0026gt; Web Fonts.”\u003c/li\u003e\n\u003cli\u003eIf you want multiple fonts, just add a second stylesheet link and additional CSS.\u003c/li\u003e\n\u003cli\u003e“Update Options” to save.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch4 id=\"screenshot\"\u003eScreenshot\u003c/h4\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2012/11/Screen-Shot-2012-11-26-at-3.48.42-PM-e1353973916434.png\" title=\"Screen Shot 2012-11-26 at 3.48.42 PM\"\u003e\u003c/p\u003e","title":"google web fonts plugin"},{"content":"This article will show you how to limit currency and numbers only in a form. There are essentially two different approaches when validating data. One way is to validate before submitting the form. The other is to validate after submitting the form. Obviously, validating before submit has its own merits. Incorrect data can be corrected before hitting the submit button. In this article, we will validate a field to allow numbers and currency only. We will allow up two decimal places to reflect currency values. The HTML markup is detailed below.\nHTML Form We have a simple form with one input and a submit button. There are two Javascript functions in the input field. The blockNonNumbers function allow numbers only to be typed on the input field. Non-number characters are ignored. The extractNumber function formats the input to two decimal places.\n\u0026lt;form action=\u0026#34;\u0026#34; id=\u0026#34;login\u0026#34; method=\u0026#34;post\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;username\u0026#34; onblur=\u0026#34;extractNumber(this,2,false);\u0026#34; onkeypress=\u0026#34;return blockNonNumbers(this, event, true, false);\u0026#34; onkeyup=\u0026#34;extractNumber(this,2,false);\u0026#34; type=\u0026#34;text\u0026#34; value=\u0026#34;\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt;#### Javascript I’ve included the validate.js Javascript code, which you can download. The code contains two functions: blockNonNumbers and extractNumber. In the markup, we can link to the Javascript file in the head section of the page using the following markup.\n\u0026lt;script language=\u0026#34;javascript\u0026#34; src=\u0026#34;validate.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; All Together Now Here’s the entire markup.\n\u0026lt;script language=\u0026#34;javascript\u0026#34; src=\u0026#34;validate.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;form action=\u0026#34;\u0026#34; id=\u0026#34;login\u0026#34; method=\u0026#34;post\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;username\u0026#34; onblur=\u0026#34;extractNumber(this,2,false);\u0026#34; onkeypress=\u0026#34;return blockNonNumbers(this, event, true, false);\u0026#34; onkeyup=\u0026#34;extractNumber(this,2,false);\u0026#34; type=\u0026#34;text\u0026#34; value=\u0026#34;\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt; Demo\n","permalink":"http://uly.me/posts/numbers-and-currency-on-forms/","summary":"\u003cp\u003eThis article will show you how to limit currency and numbers only in a form. There are essentially two different approaches when validating data. One way is to validate before submitting the form. The other is to validate after submitting the form. Obviously, validating before submit has its own merits. Incorrect data can be corrected before hitting the submit button. In this article, we will validate a field to allow numbers and currency only. We will allow up two decimal places to reflect currency values. The HTML markup is detailed below.\u003c/p\u003e","title":"numbers and currency on forms"},{"content":"One of the basic things you can do with Javascript is to open up a small popup window. You can set the resulting window to any size you want. You can make the window scrollable, fixed and resizable. To create a popup window, we will use a simple link to trigger the event. Here are details of our page with some embedded Javascript code.\nIn this example, we are using a regular link to trigger an event. Instead of the standard URL on the link, we will use the “javascript:open_window()” function. The “open_window” function opens the contents of my home page, which is http://uly.me. We can point it to any file or page that we want. The new window is called “abc.”\nThe popup window is sized accordingly to a width of 700 and height of 500, and it contains a scrollbar, and it’s resizeable.\nCheck the demo below.\n\u0026lt;a href=\u0026#34;javascript:open_window()\u0026#34;\u0026gt;Link\u0026lt;/a\u0026gt; \u0026lt;script\u0026gt; function open_window() { window.open(\u0026#39;http://uly.me\u0026#39;,\u0026#39;abc\u0026#39;,\u0026#39;width=700,height=500,resizable=yes,scrollbars=yes\u0026#39;); } \u0026lt;/script\u0026gt; Demo\n","permalink":"http://uly.me/posts/open-new-window/","summary":"\u003cp\u003eOne of the basic things you can do with Javascript is to open up a small popup window. You can set the resulting window to any size you want. You can make the window scrollable, fixed and resizable. To create a popup window, we will use a simple link to trigger the event. Here are details of our page with some embedded Javascript code.\u003c/p\u003e\n\u003cp\u003eIn this example, we are using a regular link to trigger an event. Instead of the standard URL on the link, we will use the “javascript:open_window()” function. The “open_window” function opens the contents of my home page, which is \u003ca href=\"http://uly.me\"\u003ehttp://uly.me\u003c/a\u003e. We can point it to any file or page that we want. The new window is called “abc.”\u003c/p\u003e","title":"open new window"},{"content":"If you try to abandon a form, you’ll be reminded that you’ve made changes. In addition, a pop up message will come up, asking you whether to stay on the page or to abandon it. This feature is made possible using a Javascript function. This short article will show how to alert users if they made changes to a form, prior to canceling or going to another link.\nThe Form In this example, I created a simple form with one input called “username.” I’ve added “onchange=’needToConfirm=True\u0026rsquo;” to monitor the input field. I also added a save and cancel button, as well as an internal link for testing the form later. The save button calls the “needToConfirm” function when the save button is clicked. The cancel button simply reloads the same page when the cancel button is clicked. Here’s the HTML markup.\n\u0026lt;form action=\u0026#34;\u0026#34; id=\u0026#34;login\u0026#34; method=\u0026#34;post\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;username\u0026#34; onchange=\u0026#34;needToConfirm=true\u0026#34; size=\u0026#34;40\u0026#34; type=\u0026#34;text\u0026#34; value=\u0026#34;\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;input name=\u0026#34;save\u0026#34; onclick=\u0026#34;needToConfirm=false;\u0026#34; type=\u0026#34;Submit\u0026#34; value=\u0026#34;Save\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;input onclick=\u0026#34;window.location=\u0026#39;confirm.html\u0026#39;\u0026#34; type=\u0026#34;button\u0026#34; value=\u0026#34;Cancel\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; [Link](confirm.html)#### Javascript \u0026lt;/form\u0026gt; The unsaved changes feature is made possible using Javascript. The function starts out setting needToConfirm to false. A pop up window comes up notifying the user that they have unsaved changes on the form. The user is prompted whether to stay on the page or to leave the page. Add the following Javascript code at the end of the form. Go ahead, test the demo below.\n\u0026lt;script\u0026gt; needToConfirm = false; window.onbeforeunload = askConfirm; function askConfirm() { if (needToConfirm) { return \u0026#34;You have unsaved changes.\u0026#34;; } } \u0026lt;/script\u0026gt; Demo\n","permalink":"http://uly.me/posts/unsaved-changes-on-forms/","summary":"\u003cp\u003eIf you try to abandon a form, you’ll be reminded that you’ve made changes. In addition, a pop up message will come up, asking you whether to stay on the page or to abandon it. This feature is made possible using a Javascript function. This short article will show how to alert users if they made changes to a form, prior to canceling or going to another link.\u003c/p\u003e\n\u003ch4 id=\"the-form\"\u003eThe Form\u003c/h4\u003e\n\u003cp\u003eIn this example, I created a simple form with one input called “username.” I’ve added “onchange=’needToConfirm=True\u0026rsquo;” to monitor the input field. I also added a save and cancel button, as well as an internal link for testing the form later. The save button calls the “needToConfirm” function when the save button is clicked. The cancel button simply reloads the same page when the cancel button is clicked. Here’s the HTML markup.\u003c/p\u003e","title":"unsaved changes on forms"},{"content":"When designing web applications, it’s important to sanitize data before storing them into the database. I use several PHP built-in functions namely trim, strip_tags, htmlspecialchars, and addslashes to sanitize my forms. This function has become a staple for all my web projects. So, here it is.\nfunction sanitize($in) { return addslashes(htmlspecialchars(strip_tags(trim($in)))); } Whenever I need to sanitize a form input, I simply use the sanitize function before storing the data to the database.\n$_POST[\u0026#39;firstname\u0026#39;] = sanitize($_POST[\u0026#39;firstname\u0026#39;]); ","permalink":"http://uly.me/posts/sanitize-input/","summary":"\u003cp\u003eWhen designing web applications, it’s important to sanitize data before storing them into the database. I use several PHP built-in functions namely trim, strip_tags, htmlspecialchars, and addslashes to sanitize my forms. This function has become a staple for all my web projects. So, here it is.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efunction sanitize($in) {\n  return addslashes(htmlspecialchars(strip_tags(trim($in))));\n}\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eWhenever I need to sanitize a form input, I simply use the sanitize function before storing the data to the database.\u003c/p\u003e","title":"sanitize input"},{"content":"This article will show you how to remove commas, semicolons, or any character, from a form. This tidy PHP script is quite useful when filtering out unwanted characters submitted in a form. This is important when the data is collected and exported later to a CSV (comma-delimited values) file. CSV files use commas and semicolons to separate data values. Having commas and semicolons in your data creates confusion and unwanted results. This neat PHP script removes commas and semicolons, and replaces them with a blank value.\nHTML Form First, the HTML form. This is just a HTML form with one field and a submit button. The form calls itself when submitted since the “action” field is left blank.\n\u0026lt;form action=\u0026#34;\u0026#34; method=\u0026#34;post\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;field\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;input name=\u0026#34;submit\u0026#34; type=\u0026#34;submit\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt;#### PHP Now, the fun part. I came up with a list of characters that I want filtered out. In this example, I want to filter out commas and semicolons only. The unwanted characters are placed in an array. I cleaned up the input data using a PHP function called str_replace(). This PHP function replaces commas and semicolons with blanks. Finally, the results are assigned to a variable called $clean and echoed to the screen.\n$list = array(\u0026#34;,\u0026#34;, \u0026#34;;\u0026#34;); $clean = str_replace($list, \u0026#34;\u0026#34;, $_POST[\u0026#39;field\u0026#39;]); echo $clean; PHP Function Taking one more step. I made the code modular by creating a function called clean_input(). I can then invoke the function numerous times on my script without repeating code. I simply call the clean_input() function when I need it. The function uses the same code above with some slight modification. We are passing the $in variable to the function. This is going to be in input field on our form. The clean_input function replaces it, and the results are returned.\nfunction clean_input($in) { $list = array(\u0026#34;,\u0026#34;, \u0026#34;;\u0026#34;); $clean = str_replace($list, \u0026#34;\u0026#34;, $in); return $clean; } $output = clean_input($_POST[\u0026#39;field\u0026#39;]); echo $output; All Together Now Finally, we can put all the pieces together in a single file called form.php. The input value in the form will be echoed after submission. Commas and semicolons are filtered out by our PHP function. We can test the function in the demo below. Just type any value to our input field. If you type a comma or semicolon, the input is replaced with a blank.\n\u0026lt;form action=\u0026#34;\u0026#34; method=\u0026#34;post\u0026#34;\u0026gt; \u0026lt;input name=\u0026#34;field\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;input name=\u0026#34;submit\u0026#34; type=\u0026#34;submit\u0026#34;\u0026gt;\u0026lt;/input\u0026gt; \u0026lt;/form\u0026gt; \u0026lt;?php function clean_input($in) { $list = array(\u0026#34;,\u0026#34;, \u0026#34;;\u0026#34;); $clean = str_replace($list, \u0026#34;\u0026#34;, $in); return $clean; } $output = clean_input($_POST[\u0026#39;field\u0026#39;]); echo $output; /* end of file */ Demo\n","permalink":"http://uly.me/posts/remove-commas-from-forms/","summary":"\u003cp\u003eThis article will show you how to remove commas, semicolons, or any character, from a form. This tidy PHP script is quite useful when filtering out unwanted characters submitted in a form. This is important when the data is collected and exported later to a CSV (comma-delimited values) file. CSV files use commas and semicolons to separate data values. Having commas and semicolons in your data creates confusion and unwanted results. This neat PHP script removes commas and semicolons, and replaces them with a blank value.\u003c/p\u003e","title":"remove commas from forms"},{"content":"I have several old computers with perfectly working power supplies. I decided to convert one of them into into a bench power supply. Typically, a bench power supply can cost anywhere from $100-200 dollars or more, depending on brand and quality of equipment. With this modified ATX bench power supply, it cost me only $20 and about 3 hours of project work.\nThis ATX bench power supply gives me 3 different voltages at 3.3, 5 and 12 volts. The voltages are rated at 18, 12 and 21 amps respectively. I didn’t bother using the -5 and -12 volts since the amperage on these two voltages are very low. The only downside to this power supply is the voltages are fixed. It would have been nice to have an adjustable voltages.\nIt was a fun little project. I won’t bother posting the instructions since many people have already covered this topic. Here are two good sources worth checking: JumperOneTV and GeoNoJRJ.\nParts total at around $20\nBinding Posts Power switch Lamp assembly 10 ohm 10 watt load resistor Heat shrink Cable ties Rubber feet ","permalink":"http://uly.me/posts/atx-bench-power-supply/","summary":"\u003cp\u003eI have several old computers with perfectly working power supplies. I decided to convert one of them into into a bench power supply. Typically, a bench power supply can cost anywhere from $100-200 dollars or more, depending on brand and quality of equipment. With this modified ATX bench power supply, it cost me only $20 and about 3 hours of project work.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2012/11/DSC_0843.jpg\" title=\"DSC_0843\"\u003e\u003c/p\u003e\n\u003cp\u003eThis ATX bench power supply gives me 3 different voltages at 3.3, 5 and 12 volts. The voltages are rated at 18, 12 and 21 amps respectively. I didn’t bother using the -5 and -12 volts since the amperage on these two voltages are very low. The only downside to this power supply is the voltages are fixed. It would have been nice to have an adjustable voltages.\u003c/p\u003e","title":"atx bench power supply"},{"content":"Git Commit is a command for committing files to the local repository. Once satisfied with the changes in the local repository, the files will need to be committed. This command does not update the master repository in Github. Just the local repository. You commit files to the local repository by issuing this command in the Terminal.\ngit commit -m “your comments go here” -a ","permalink":"http://uly.me/posts/git-commit/","summary":"\u003cp\u003eGit Commit is a command for committing files to the local repository. Once satisfied with the changes in the local repository, the files will need to be committed. This command does not update the master repository in Github. Just the local repository. You commit files to the local repository by issuing this command in the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit commit -m “your comments go here” -a\n\u003c/code\u003e\u003c/pre\u003e","title":"git commit"},{"content":"Subversion has an export command when you want a copy of the repository without the .svn directories and files. Git Export is similar to Subversion’s Export command. To export a project in Git, you will need to go to the root of your Git project and issue the following commands.\ncd git/project Create a gzip file or a zip file.\ngit archive master | gzip \u0026gt; project.tgz or\ngit archive master | zip \u0026gt; project.zip ","permalink":"http://uly.me/posts/git-export/","summary":"\u003cp\u003eSubversion has an export command when you want a copy of the repository without the .svn directories and files. Git Export is similar to Subversion’s Export command. To export a project in Git, you will need to go to the root of your Git project and issue the following commands.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003ecd git/project\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eCreate a gzip file or a zip file.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit archive master | gzip \u0026gt; project.tgz\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eor\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit archive master | zip \u0026gt; project.zip\n\u003c/code\u003e\u003c/pre\u003e","title":"git export"},{"content":"I ordered a couple of Raspberry Pis from Newark Element 14 two weeks ago. I’m ecstatic to say the least. I can’t wait to get my hands on the Raspberry Pi. The estimated shipment date is November 19. It will probably take 4-5 days for the shipment to arrive home.\nI’m not sure yet what I plan to do with the Raspberry Pi yet. I will probably start with a media center for streaming music, videos, movies, and radio stations. The other Raspberry Pi, I will most likely use it for other projects. November 19 can’t get here soon enough.\nDebian will probably be my OS of choice. What kind of services do I plan to install? Maybe, a web server, FTP server, PHP and MySQL database. I could install TeamSpeak or Ventrilo server as well. Who knows. There are tons of possibilities. X10 home automation also is another possibility.\n","permalink":"http://uly.me/posts/raspberry-pi/","summary":"\u003cp\u003eI ordered a couple of Raspberry Pis from Newark Element 14 two weeks ago. I’m ecstatic to say the least. I can’t wait to get my hands on the Raspberry Pi. The estimated shipment date is November 19. It will probably take 4-5 days for the shipment to arrive home.\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2012/11/raspberrypi.jpg\"\u003e\u003c/p\u003e\n\u003cp\u003eI’m not sure yet what I plan to do with the Raspberry Pi yet. I will probably start with a media center for streaming music, videos, movies, and radio stations. The other Raspberry Pi, I will most likely use it for other projects. November 19 can’t get here soon enough.\u003c/p\u003e","title":"raspberry pi"},{"content":"Subversion Branch creates a new branch in the local working directory. In the example below, a copy of the project directory is forked and given a new name. The new branch will be treated as a separate branch.\nsvn copy http://repository/project/trunk \\ http://repository/project/branch/newbranch \\ -m \u0026#34;Place comments here.\u0026#34; ","permalink":"http://uly.me/posts/subversion-branch/","summary":"\u003cp\u003eSubversion Branch creates a new branch in the local working directory. In the example below, a copy of the project directory is forked and given a new name. The new branch will be treated as a separate branch.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn copy http://repository/project/trunk \\ \n         http://repository/project/branch/newbranch \n         \\ -m \u0026#34;Place comments here.\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion branch"},{"content":"The Subversion Delete command will delete a file in the local working directory. While it removes file in the working copy, it doesn’t remove the same file in the repository until after a commit.\nsvn delete foo.c ","permalink":"http://uly.me/posts/subversion-delete/","summary":"\u003cp\u003eThe Subversion Delete command will delete a file in the local working directory. While it removes file in the working copy, it doesn’t remove the same file in the repository until after a commit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn delete foo.c\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion delete"},{"content":"Subversion Diff will display differences between a file in the local working directory versus the same file that’s located in the repository. It will display on the screen what has been edited, modified or deleted. You invoke the Diff command from the Terminal as displayed below.\nsvn diff ","permalink":"http://uly.me/posts/subversion-diff/","summary":"\u003cp\u003eSubversion Diff will display differences between a file in the local working directory versus the same file that’s located in the repository. It will display on the screen what has been edited, modified or deleted. You invoke the Diff command from the Terminal as displayed below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn diff\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion diff"},{"content":"Subversion Move is a command that renames a file in either in the local working directory or directly in the repository. You can invoke the move command from Terminal like this example below.\nsvn move foo.c bar.c svn move http://repository/project/trunk/foo.c \\ http://repository/project/trunk/bar.c -m \u0026#34;Place comment here.\u0026#34; ","permalink":"http://uly.me/posts/subversion-move/","summary":"\u003cp\u003eSubversion Move is a command that renames a file in either in the local working directory or directly in the repository. You can invoke the move command from Terminal like this example below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn move foo.c bar.c\nsvn move http://repository/project/trunk/foo.c \\ \n    http://repository/project/trunk/bar.c \n    -m \u0026#34;Place comment here.\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion move"},{"content":"Subversion Revert undoes the recent changes in the local working directory. Revert can also undo changes recursively. Here’s a couple of examples displayed below.\nsvn revert foo.c svn revert --recursive . ","permalink":"http://uly.me/posts/subversion-revert/","summary":"\u003cp\u003eSubversion Revert undoes the recent changes in the local working directory. Revert can also undo changes recursively. Here’s a couple of examples displayed below.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn revert foo.c\nsvn revert --recursive .\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion revert"},{"content":"Subversion Export creates a clean working copy of a project without the .svn folders and files. In this example, the command creates a folder named project and places a clean working copy in it.\nsvn export http://repository/project/trunk project ","permalink":"http://uly.me/posts/subversion-export/","summary":"\u003cp\u003eSubversion Export creates a clean working copy of a project without the .svn folders and files. In this example, the command creates a folder named \u003ccode\u003eproject\u003c/code\u003e and places a clean working copy in it.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn export http://repository/project/trunk project\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion export"},{"content":"Subversion Display shows information of the local working copy of the repository. The information displayed will contain the versioned number, the recent commits made, user-level locks held on a object, local scheduling information such as (added, deleted and copied), and any local convict information. To display the info, type in the Terminal this command.\nsvn info ","permalink":"http://uly.me/posts/subversion-info/","summary":"\u003cp\u003eSubversion Display shows information of the local working copy of the repository. The information displayed will contain the versioned number, the recent commits made, user-level locks held on a object, local scheduling information such as (added, deleted and copied), and any local convict information. To display the info, type in the Terminal this command.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn info\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion info"},{"content":"Subversion Update is used to synch the working copy with repository. You can use any of the two commands below. Any changes done by you since the last update will not be overwritten. Your changes will be reflected on the repository once you perform a commit to the repository.\nsvn update svn up ","permalink":"http://uly.me/posts/subversion-update/","summary":"\u003cp\u003eSubversion Update is used to synch the working copy with repository. You can use any of the two commands below. Any changes done by you since the last update will not be overwritten. Your changes will be reflected on the repository once you perform a commit to the repository.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn update\nsvn up\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion update"},{"content":"The Git Push command sends all commits found in the local repository to the remote or master repository on the web such as Github or Unfuddle, as an example. You can invoke the Git Push command from the Terminal by typing the following:\ngit push In addition, you can be more specific by typing the following:\ngit push origin master ","permalink":"http://uly.me/posts/git-push/","summary":"\u003cp\u003eThe Git Push command sends all commits found in the local repository to the remote or master repository on the web such as Github or Unfuddle, as an example. You can invoke the Git Push command from the Terminal by typing the following:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit push\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eIn addition, you can be more specific by typing the following:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit push origin master\n\u003c/code\u003e\u003c/pre\u003e","title":"git push"},{"content":"Git Status is a command to display the status of files in the local working repository. It displays differences of files whether if updated or if it needs to committed to the repository. The Git Status command is typed in Terminal of the local working directory.\ngit status ","permalink":"http://uly.me/posts/git-status/","summary":"\u003cp\u003eGit Status is a command to display the status of files in the local working repository. It displays differences of files whether if updated or if it needs to committed to the repository. The Git Status command is typed in Terminal of the local working directory.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit status\n\u003c/code\u003e\u003c/pre\u003e","title":"git status"},{"content":"The Subversion Status command give you the status of the local working directory. Type this command in the Terminal to display the status.\nsvn status ","permalink":"http://uly.me/posts/subversion-status/","summary":"\u003cp\u003eThe Subversion Status command give you the status of the local working directory. Type this command in the Terminal to display the status.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn status\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion status"},{"content":"The Git Add command will add files to the current local working repository. This is how files are officially added to the local repository. You can specify one file or multiple files by using wildcards.\nAdd one file\ngit add sample.php Add all files\ngit add . Add all PHP files\ngit add *.php ","permalink":"http://uly.me/posts/git-add/","summary":"\u003cp\u003eThe Git Add command will add files to the current local working repository. This is how files are officially added to the local repository. You can specify one file or multiple files by using wildcards.\u003c/p\u003e\n\u003cp\u003eAdd one file\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit add sample.php\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd all files\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit add .\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eAdd all PHP files\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit add *.php\n\u003c/code\u003e\u003c/pre\u003e","title":"git add"},{"content":"Git Clone is a command used to make a copy of a Git repository to your local drive. It creates a new directory and creates a clone of the repository on the local drive. In the example below, a clone of an existing repository from Github is placed on the local computer. You initiate a clone by typing the following command on the Terminal.\n// old way. does not work anymore. git clone git@github.com:username/Project.git // new way. use this from this point on. git clone https://github.com/username/Project ","permalink":"http://uly.me/posts/git-clone/","summary":"\u003cp\u003eGit Clone is a command used to make a copy of a Git repository to your local drive. It creates a new directory and creates a clone of the repository on the local drive. In the example below, a clone of an existing repository from Github is placed on the local computer. You initiate a clone by typing the following command on the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003e// old way. does not work anymore.\ngit clone git@github.com:username/Project.git\n\n// new way. use this from this point on.\ngit clone https://github.com/username/Project\n\u003c/code\u003e\u003c/pre\u003e","title":"git clone"},{"content":"Git init is a command to start a new repository or reinitialize an existing one. You will need to type this command in the Terminal in the desired directory of your choice to start new repository.\ngit init There are options or switches you can add. See the manual.\n","permalink":"http://uly.me/posts/git-init/","summary":"\u003cp\u003eGit init is a command to start a new repository or reinitialize an existing one. You will need to type this command in the Terminal in the desired directory of your choice to start new repository.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003egit init\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere are options or switches you can add. See the \u003ca href=\"http://www.kernel.org/pub/software/scm/git/docs/git-init.html\"\u003emanual\u003c/a\u003e.\u003c/p\u003e","title":"git init"},{"content":"Once you are done editing, and are through with making file changes in the local working directory, you have the option to commit the changes to the Subversion repository. You simply type the following command from the Terminal to initiate a commit.\nsvn commit -m \u0026#34;Place your comment here\u0026#34; I encourage that you add comments, so you’ll know exactly what changes you’ve applied. Going forward, it will be easier to keep track of changes as you apply hundreds of commits to a project.\n","permalink":"http://uly.me/posts/subversion-commit/","summary":"\u003cp\u003eOnce you are done editing, and are through with making file changes in the local working directory, you have the option to commit the changes to the Subversion repository. You simply type the following command from the Terminal to initiate a commit.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn commit -m \u0026#34;Place your comment here\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eI encourage that you add comments, so you’ll know exactly what changes you’ve applied. Going forward, it will be easier to keep track of changes as you apply hundreds of commits to a project.\u003c/p\u003e","title":"subversion commit"},{"content":"Typically, you use the Subversion Import command to start or add a new project to a remote repository. Subversion recommends that you setup three directories called trunk, tags and branches under each project in a repository. Trunk will be the current version you are working on. Tags are for releases. Branches are when you fork projects based on one particular release. The following directory format under each project is recommended.\nrepository/project/trunk /tags /branches Once the directories are setup, you can then perform the import command to upload a new project to the repository. Just the following command in the Terminal.\nsvn import project http://repository -m \u0026#34;Place comments here.\u0026#34; ","permalink":"http://uly.me/posts/subversion-import/","summary":"\u003cp\u003eTypically, you use the Subversion Import command to start or add a new project to a remote repository. Subversion recommends that you setup three directories called trunk, tags and branches under each project in a repository. Trunk will be the current version you are working on. Tags are for releases. Branches are when you fork projects based on one particular release. The following directory format under each project is recommended.\u003c/p\u003e","title":"subversion import"},{"content":"Subversion Tags are snapshots of a project at a certain time. Tags are ideal for version releases. To create a tag, you will need to type the following command in the Terminal. It’s a good idea when creating a project that you create a tag directory under the project directory. The tag directory will be the place where you can store all your tag releases in an organized way.\nsvn copy http://repository/project/trunk \\ http://repository/project/tags/1.0 \\ -m \u0026#34;Place comments here.\u0026#34; ","permalink":"http://uly.me/posts/subversion-tag/","summary":"\u003cp\u003eSubversion Tags are snapshots of a project at a certain time. Tags are ideal for version releases. To create a tag, you will need to type the following command in the Terminal. It’s a good idea when creating a project that you create a tag directory under the project directory. The tag directory will be the place where you can store all your tag releases in an organized way.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn copy http://repository/project/trunk \\ \n         http://repository/project/tags/1.0 \\ \n         -m \u0026#34;Place comments here.\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e","title":"subversion tag"},{"content":"Years ago, I implemented an alternative style switcher I found at A List Apart. But, that solution is quite old now. It was published eleven years ago, back in 2001. Now, I’m looking for something a little bit more modern, perhaps a solution that uses JQuery. The idea is to let the readers choose a CSS stylesheet of their liking by simply clicking on a link. So, here’s the finished product. Demo.\nThe Stylesheet\nI’m using two very simple stylesheets. The default stylsheet is called style.css. The alternate stylesheet is called black.css. This code belongs in the head section of the HTML page.\n\u0026lt;link href=\u0026#34;style.css\u0026#34; rel=\u0026#34;stylesheet\u0026#34; title=\u0026#34;style\u0026#34; type=\u0026#34;text/css\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; \u0026lt;link href=\u0026#34;black.css\u0026#34; rel=\u0026#34;alternate stylesheet\u0026#34; title=\u0026#34;black\u0026#34; type=\u0026#34;text/css\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; JQuery\nWe are using Google’s JQuery CDN by also linking it from within the head section of the HTML page. The second line is the Javascript code that actually performs the stylesheet switching. You can download the styleswitcher.js code directly from my website.\n\u0026lt;script src=\u0026#34;//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script src=\u0026#34;styleswitcher.js\u0026#34; type=\u0026#34;text/javascript\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; CSS Switch\nWe will provide two links where readers can switch stylesheets from default to black and vice versa. The links are standard HTML links and using Javascript’s onclick event.\n\u0026lt;a href=\u0026#34;#\u0026#34; onclick=\u0026#34;setActiveStyleSheet(\u0026#39;style\u0026#39;);return false;\u0026#34;\u0026gt;Default\u0026lt;/a\u0026gt; | \u0026lt;a href=\u0026#34;#\u0026#34; onclick=\u0026#34;setActiveStyleSheet(\u0026#39;black\u0026#39;);return false;\u0026#34;\u0026gt;Black\u0026lt;/a\u0026gt; Putting It All Together\nHere’s the final code.\n\u0026lt;title\u0026gt;CSS Switcher\u0026lt;/title\u0026gt; \u0026lt;link href=\u0026#34;”style.css”\u0026#34; rel=\u0026#34;”stylesheet”\u0026#34; title=\u0026#34;”style”\u0026#34; type=\u0026#34;”text/css”\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; \u0026lt;link href=\u0026#34;”black.css”\u0026#34; rel=\u0026#34;”alternate\u0026#34; stylesheet=\u0026#34;\u0026#34; title=\u0026#34;”black”\u0026#34; type=\u0026#34;”text/css”\u0026#34;\u0026gt;\u0026lt;/link\u0026gt; \u0026lt;script src=\u0026#34;”//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;script src=\u0026#34;”styleswitcher.js”\u0026#34; type=\u0026#34;”text/javascript”\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;a false=\u0026#34;\u0026#34; href=\u0026#34;”#”\u0026#34; onclick=\u0026#34;”setActiveStyleSheet(‘style’);return\u0026#34;\u0026gt;Default\u0026lt;/a\u0026gt; | \u0026lt;a false=\u0026#34;\u0026#34; href=\u0026#34;”#”\u0026#34; onclick=\u0026#34;”setActiveStyleSheet(‘black’);return\u0026#34;\u0026gt;Black\u0026lt;/a\u0026gt; Demo\nHappy switching!\n","permalink":"http://uly.me/posts/css-style-switcher/","summary":"\u003cp\u003eYears ago, I implemented an \u003ca href=\"http://www.alistapart.com/articles/alternate/\"\u003ealternative style switcher\u003c/a\u003e I found at \u003ca href=\"http://alistapart.com\"\u003eA List Apart\u003c/a\u003e. But, that solution is quite old now. It was published eleven years ago, back in 2001. Now, I’m looking for something a little bit more modern, perhaps a solution that uses JQuery. The idea is to let the readers choose a CSS stylesheet of their liking by simply clicking on a link. So, here’s the finished product. \u003ca href=\"http://uly.me/demo/styleswitcher/\"\u003eDemo\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eThe Stylesheet\u003c/p\u003e","title":"css style switcher"},{"content":"Adding a file or directory to Subversion is quite easy. The following commands will add a file and a directory to the current Subversion working directory. The added file or directory is only added to the local working directory, and not to the Subversion repository. For that to happen, you’ll need to issue a Subversion commit to synch the files to the repository. The following commands simply add files and directories in the local working directory.\nAdd a file\nsvn add foo.c Add a directory\nsvn add directory ","permalink":"http://uly.me/posts/subversion-add/","summary":"\u003cp\u003eAdding a file or directory to Subversion is quite easy. The following commands will add a file and a directory to the current Subversion working directory. The added file or directory is only added to the local working directory, and not to the Subversion repository. For that to happen, you’ll need to issue a Subversion commit to synch the files to the repository. The following commands simply add files and directories in the local working directory.\u003c/p\u003e","title":"subversion add"},{"content":"The Subversion Checkout command is used to pull out a working copy of a project from the main Subversion repository. The Checkout command signals the start of using version control. This command is usually performed once at the beginning, but sometimes, it can also be performed whenever there are major changes to a project structure. To perform a checkout, type the following command in the Terminal.\nsvn co http://repository/project/trunk . The period at the end is very important.\nIt tells Subversion that you want a copy of “trunk” in the current directory.\n","permalink":"http://uly.me/posts/subversion-checkout/","summary":"\u003cp\u003eThe Subversion Checkout command is used to pull out a working copy of a project from the main Subversion repository. The Checkout command signals the start of using version control. This command is usually performed once at the beginning, but sometimes, it can also be performed whenever there are major changes to a project structure. To perform a checkout, type the following command in the Terminal.\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003esvn co http://repository/project/trunk .\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThe period at the end is very important.\u003c/p\u003e","title":"subversion checkout"},{"content":"Here are a few things I learned as a cloud engineer. Hope you find this website helpful. :)\n","permalink":"http://uly.me/posts/cloud-journal/","summary":"\u003cp\u003eHere are a few things I learned as a cloud engineer. Hope you find this website helpful. :)\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"http://uly.me/wp-content/uploads/2012/01/blog.jpg\" title=\"blog.jpg\"\u003e\u003c/p\u003e","title":"cloud journal"}]