Skip to content

Instantly share code, notes, and snippets.

View namenu's full-sized avatar
🧑‍🌾

Hyunwoo Nam namenu

🧑‍🌾
View GitHub Profile
@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 / 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))
# 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 / 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()
@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 / 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"' [email protected]
fi
#MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW SLAVE STATUS\G"`
@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