Skip to content

Instantly share code, notes, and snippets.

View ryuheechul's full-sized avatar
💻
hacking on projects!

Heechul Ryu ryuheechul

💻
hacking on projects!
View GitHub Profile
@ryuheechul
ryuheechul / autoUnmountify.js
Created November 22, 2016 05:07
When you need to unmount child element whenever parent element refreshed
var flag = 0;
autoUnmountify = (ele) => {
const wrap = <span>{ele}</span>;
const unmountify = flag ? wrap : ele;
flag = !flag;
return unmountify;
}
@ryuheechul
ryuheechul / encode-env-via-base64.rb
Last active December 26, 2016 08:34
base64 encode for env values
#!/usr/bin/env ruby
filename = ARGV.first
file = File.new(filename, "r")
while (line = file.gets)
k, v = line.split('=', 2)
ev = `echo "#{v}" | base64`.gsub("\n",'')
puts " #{k}: #{ev}"
end
file.close
@ryuheechul
ryuheechul / env-strip.sh
Created December 29, 2016 03:32
Run command with removing newlines in values of ENV
#!/usr/bin/env bash
## strip newlines of envs
# used some code from http://stackoverflow.com/a/11746174
string=`printenv`
arr=()
while read -r line; do
arr+=("$line")
@ryuheechul
ryuheechul / 0-papercliper-fog-gcs.md
Created May 7, 2017 01:29
Paperclip + fog + Google Cloud Storage

An example code to use GCS instead of S3

@ryuheechul
ryuheechul / install-docker-ce-on-loki.sh
Created June 13, 2017 12:03
Installation steps to install docker-ce on Elemantary OS Loki
#!/usr/bin/env bash
# based on https://store.docker.com/editions/community/docker-ce-server-ubuntu
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt update
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER
@ryuheechul
ryuheechul / Echo.elm
Created January 20, 2018 13:20
Elm (0.18) program ports example
port module Echo exposing (..)
import Platform exposing (program, Program)
import Json.Decode
-- importing Json.Decode is necessary for now because of https://github.com/elm-lang/elm-make/issues/127
---- MODEL ----
type alias Model =
{ crap : String }
@ryuheechul
ryuheechul / example.js
Created February 7, 2018 11:48
Concept for scene-stealer-request
const { hss, scene, storage, market } = require('hire-scene-stealer')
hss
.scene(scene
.url('https://google.com')
.selector('img#hplogo')
.domIndex(0) // you can skip if it's 0
.viewport(900, 700)
)
.storage(storage
@ryuheechul
ryuheechul / simple-healthcheck.sh
Last active July 28, 2022 22:23
Useful commands
#!/usr/bin/env bash
url='https://github.com' # or whatever url you want to check
sec=3
while true; do
date -u +%H:%M:%S # or date +%H:%M:%S
echo "${url}"
# https://unix.stackexchange.com/a/84820/396504
curl -Is "${url}" | head -n 1 && sleep "${sec}"
@ryuheechul
ryuheechul / no-concurrency-promise.js
Created February 21, 2018 08:22
an example of no concurrency in JS Promise
function printTo100(n) {
for (i in [...Array(100).keys()]){
console.log(`${n}-${i}`)
}
return Promise.resolve()
}
Promise.all(
printTo100('a'),
printTo100('b'),
@ryuheechul
ryuheechul / ttl.jsx
Created March 7, 2018 07:39
An example code that implements how to reuse Tagged template literals
const ttl = (strings, ...variables) => [strings, ...variables]
// or const ttl = (...args) => [...args]
// we are using www.styled-components.com as an example
const Adder = ({className, x, y}) => {
return (
<span className={className}> {x+y} </span>
)
}