Skip to content

Instantly share code, notes, and snippets.

  1. 一般 Hash 情況是這樣:
hash = {}
hash[:foo][:bar] = :hello
=> NoMethodError: undefined method `[]=' for nil:NilClass

請建立一個 Hash 可以不管 key 值是否存在都可以自動設定 key 及 value

Keybase proof

I hereby claim:

  • I am gogojimmy on github.
  • I am gogojimmy (https://keybase.io/gogojimmy) on keybase.
  • I have a public key whose fingerprint is C0D6 893D 457D 006D 8477 C54A CE06 8843 E498 948F

To claim this, I am signing this object:

@gogojimmy
gogojimmy / elk.sh
Last active September 12, 2019 11:10
Install ELK stack for elk 7.x
#!/bin/bash
# Checking whether user has enough permission to run this script
sudo -n true
if [ $? -ne 0 ]
then
echo "This script requires user to have passwordless sudo access"
exit
fi

Keybase proof

I hereby claim:

  • I am gogojimmy on github.
  • I am gogojimmy (https://keybase.io/gogojimmy) on keybase.
  • I have a public key ASAMM3jBSqi6zARbdKQRGgUz71W22cGm4Noba0KNQ5b2mQo

To claim this, I am signing this object: