Skip to content

Instantly share code, notes, and snippets.

@farhany
farhany / .bash_profile
Created March 16, 2016 05:19
VirtualBox Command Line Aliases
alias startvm="VBoxManage startvm --type headless "
alias listrunningvms="VBoxManage list runningvms"
alias stopvm='function _stopvm(){ VBoxManage controlvm $1 acpipowerbutton; }; _stopvm'

Keybase proof

I hereby claim:

  • I am farhany on github.
  • I am farhany (https://keybase.io/farhany) on keybase.
  • I have a public key whose fingerprint is 073A 2F2A 74EF E043 EF18 88B8 089C 50BB 6283 5215

To claim this, I am signing this object:

@farhany
farhany / sierra-virtualbox-install.md
Created April 17, 2017 18:37 — forked from arobb/sierra-virtualbox-install.md
Install macOS Sierra in VirtualBox on macOS host

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
@farhany
farhany / ansible-summary.md
Created October 17, 2017 16:43 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

brew cask install osxfuse
brew install sshfs
sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa user@host:/remotefolder/ /localfolder
mount
umount user@host:/remotefolder/
pgrep -lf sshfs
kill -9 <pid_of_sshfs_process>
sudo umount -f <mounted_dir>
# Source: https://susanqq.github.io/jekyll/pixyll/2017/09/05/remotefiles/
@farhany
farhany / log_request.go
Created February 26, 2018 05:41 — forked from hoitomt/log_request.go
Golang: Log HTTP Requests in Go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
@farhany
farhany / readCookie.go
Created March 2, 2018 03:14
golang - read cookie
func ReadCookie(w http.ResponseWriter, req *http.Request) {
// read cookie
var cookie, err = req.Cookie("cookie")
if err == nil {
var cookieValue = cookie.Value
log.Printf("Cookie is %s\n", cookieValue)
}
}
@farhany
farhany / favicon.rice.go
Last active March 3, 2018 07:51
favicon.ico from golang's rice
func FavIcon(w http.ResponseWriter, r *http.Request) {
StaticBox := rice.MustFindBox("static")
faviconContent, _ := StaticBox.HTTPBox().Open(r.URL.Path)
http.ServeContent(w, r, r.URL.Path, time.Now(), faviconContent)
}
@farhany
farhany / brew_installs.sh
Created March 4, 2018 01:21
brew packages on my Mac
brew install rclone
brew install fzf
brew install fasd
brew install sshfs
# https://superuser.com/questions/665030/is-it-possible-to-format-ps-rss-memory-output-to-be-more-human-friendly
# credit to https://superuser.com/users/261502/pono who write this script
# get terminal width
WIDTH=`tput cols`
# pipe stdin to awk
cat | \
awk '\
BEGIN {
# set output format