Skip to content

Instantly share code, notes, and snippets.

View rankun203's full-sized avatar
🔨
building things

Kun R rankun203

🔨
building things
View GitHub Profile
@rankun203
rankun203 / ensure-env.sh
Created January 18, 2018 02:04
Ensure environment is exist and empty
#!/usr/bin/env bash
# Functions --------
ensure_env () {
ENV_NAME="$1"
ENV_VAL=${!ENV_NAME}
if [[ -z "${ENV_VAL}" ]]; then
echo "${ENV_NAME} does not exists, exiting."
exit
else
@rankun203
rankun203 / download-file.sh
Last active December 26, 2017 09:37
Dump Rackspace Cloud Files Container
#!/usr/bin/env bash
# Usage:
# ./download-file.sh <CONTAINER_NAME> <FILE_PATH>
readonly CONTAINER="$1"
readonly FILE_PATH="$2"
readonly FILE_FOLDER=`dirname $FILE_PATH`
readonly IGNORED_FILES="lodestreams-docs/logs"
if [ "${FILE_PATH/$IGNORED_FILES}" = "$FILE_PATH" ] ; then
@rankun203
rankun203 / currencies.js
Last active November 29, 2017 03:39
Currencies helper
// Data is from http://www.xe.com/symbols.php
const currencies = {
ALL: { code: 'ALL', fontCode: 'Lek' },
AFN: { code: 'AFN', fontCode: '؋' },
ARS: { code: 'ARS', fontCode: '$' },
AWG: { code: 'AWG', fontCode: 'ƒ' },
AUD: { code: 'AUD', fontCode: '$' },
AZN: { code: 'AZN', fontCode: '₼' },
BSD: { code: 'BSD', fontCode: '$' },
BBD: { code: 'BBD', fontCode: '$' },

Keybase proof

I hereby claim:

  • I am rankun203 on github.
  • I am kun (https://keybase.io/kun) on keybase.
  • I have a public key ASCChicqQHhrP2jOFa7k8AQ-n8Kn01JNjJoMIds1y2FTqwo

To claim this, I am signing this object:

@rankun203
rankun203 / backup-docker.sh
Created April 4, 2017 01:44
Backup data to pwd/tar.gz from a container.
#!/usr/bin/env bash
#
# $1: backup filename.
# $2: backup target dir.
# $3: backup target volumes
if [[ "$1" = "-h" ]]
then
echo '$1: backup filename.'
echo '$2: backup target dir.'
@rankun203
rankun203 / index.html
Last active January 2, 2017 15:23
Use service worker to quickly fail non accessible URLs.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Service Worker test</title>
<script>
navigator.serviceWorker.getRegistration().then(function (registration) {
if (!registration || !navigator.serviceWorker.controller) {
navigator.serviceWorker.register('./sw.js').then(function () {
console.log('Service worker registered, reloading the page');
@rankun203
rankun203 / font-face-observer.html
Last active December 14, 2016 10:27
Professional Web Typography Notes
<!DOCTYPE html>
<!--#if expr="$HTTP_COOKIE=/fonts\-loaded\=true/" -->
<html lang="en" class="fonts-loaded">
<!--#else -->
<html lang="en">
<!--#endif -->
<head>
<meta charset="utf-8">
<title></title>
@rankun203
rankun203 / css-limit-lines.css
Last active December 14, 2016 10:20
css-limit-lines.css
/* mixin for multiline */
@mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 1, $bgColor: white){
overflow: hidden;
position: relative;
line-height: $lineHeight;
max-height: $lineHeight * $lineCount;
text-align: justify;
margin-right: -1em;
padding-right: 1em;
&:before {
@rankun203
rankun203 / docker-compose.yml
Last active January 9, 2017 03:19
Docker compose file for mysql web and update-db scripts. https://github.com/abh/ntppool/blob/master/docker-compose.yml
version: '2'
services:
mysql:
image: mariadb:10.0
volumes:
- "./.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ntppool
git config --global http.proxy 'http://localhost:8123'