Skip to content

Instantly share code, notes, and snippets.

View namenu's full-sized avatar
🧑‍🌾

Hyunwoo Nam namenu

🧑‍🌾
View GitHub Profile
@namenu
namenu / mysql.autocommit.procedure.sh
Last active August 29, 2015 13:58
Commit DB scheme daily
#!/bin/bash
REPO=
BRANCH=Release
DB=bom_$(date +%Y%m%d)
set -x
cd /htdocs/dev/repo/release
@namenu
namenu / monitor.replication.sh
Last active June 22, 2017 13:14
MySQL crontab
#!/bin/bash
MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW GLOBAL STATUS LIKE 'Slave_running'" | grep 'Slave_running' | awk '{ print $2 }'`
res="$MYSQL"
if [ $res != "ON" ]; then
touch replication.broken
echo 'Replication was broken' | /usr/bin/mail -s 'echo 'Replication was broken' | /usr/bin/mail -s "[`hostname`] Replication was broken"' infradev.team@ridicorp.com
fi
#MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW SLAVE STATUS\G"`
@namenu
namenu / install.sh
Last active February 4, 2021 13:52
bootstrap
# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# desktop applications
brew install --cask firefox
brew install --cask chrome
brew install --cask dropbox
brew install --cask notion
brew install --cask 1password
@namenu
namenu / lambda_function.py
Created August 6, 2017 07:18
CloudFlare "colo" Monitor
from urllib.parse import urlencode
import json
import logging
import urllib.request as urlrequest
import re
import os
log = logging.getLogger()
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@namenu
namenu / fizzbuzz.clj
Last active May 26, 2021 01:52
FizzBuzz
(defn divisible? [divisor number]
(zero? (mod number divisor)))
(defn fizzbuzz [n]
(case [(divisible? 3 n) (divisible? 5 n)]
[true false] "Fizz"
[false true] "Buzz"
[true true] "FizzBuzz"
n))
@namenu
namenu / recaman.clj
Last active July 29, 2018 06:54
Recamán Sequence
(defn recaman
([]
(recaman 1 1 #{1}))
([n prev visited]
(lazy-seq
(cons prev
(let [n (inc n)
next (let [lookup (- prev n)]
(if (and (pos? lookup) (nil? (visited lookup)))
lookup
@namenu
namenu / ListReverse.js
Created September 6, 2018 17:14
Reverse a linked list
// Q. Reverse a linked list.
// What is linked list?
const cons = h => t => f => f(h)(t)
// What is boolean?
const T = a => b => a
const F = a => b => b
// What is integer?
@namenu
namenu / keybase.md
Created July 2, 2019 17:58
keybase.md

Keybase proof

I hereby claim:

  • I am namenu on github.
  • I am namenu (https://keybase.io/namenu) on keybase.
  • I have a public key whose fingerprint is 50BA 7CF6 A83C A23B 15B8 39CC EA0C 0066 44CC EE7C

To claim this, I am signing this object:

(ns interval-tree
(:require [clojure.spec.alpha :as s]))
;; augmented 1-D interval tree
(defrecord ^:private Node [interval highest left right])
(defn insert [{:keys [interval highest left right] :as tree} [vlow vhigh :as value]]
(if (nil? tree)
(Node. value vhigh nil nil)