Skip to content

Instantly share code, notes, and snippets.

View colus001's full-sized avatar

Seokjun Kim colus001

View GitHub Profile
@colus001
colus001 / cryptokitties.sol
Created June 29, 2018 16:45
Cryptokitties smart contract in Solidity
pragma solidity ^0.4.11;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@colus001
colus001 / scenario.md
Last active June 29, 2018 16:37
How to reproduce javascript test failure

Steps to Reproduce

TheContract.sol

pragma solidity ^0.4.23;

contract TheContract {
  struct Object {
    address createdBy;
    uint balance;
@colus001
colus001 / anti-cancer.js
Created February 13, 2018 05:12
anti-cancer for ugly css site
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'
link.crossorigin = 'anonymous'
const head = document.getElementsByTagName('head')[0]
head.prepend(link)
const body = document.getElementsByTagName('body')[0]
body.className = 'container'
@colus001
colus001 / withLocalCache.js
Last active January 8, 2018 02:57
HOC to cache react component's state to local storage
import { omit, pick, isEmpty } from 'lodash'
import React from 'react'
import { isBrowser, get } from 'utils/misc'
const hasLocalStorage = isBrowser && !!localStorage
type Options = {
cacheKey: string,
whitelist: Array<string>,
Built-in Atom Packages (92)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
@colus001
colus001 / .zshrc
Created October 10, 2017 02:08
MY ZSHRC
# Path to your oh-my-zsh installation.
export ZSH=/Users/KimSeokjun/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="pygmalion"
# Uncomment the following line to use case-sensitive completion.
@colus001
colus001 / setup-pi.sh
Created July 24, 2017 04:59
Setup raspberry pi for mac terminal
#!/bin/bash
# Erase SD card
sudo diskutil eraseDisk FAT32 NAME MBRFormat /dev/disk2
# Unmount SD card to build image
sudo diskutil unmountDisk /dev/disk2
# Build boot image
sudo dd bs=1m if=2017-07-05-raspbian-jessie.img of=/dev/rdisk2
@colus001
colus001 / fibonacci-memoized.js
Last active July 3, 2017 11:30
Fibonacci number generator with memoization in Javascript
var fibonacci = (() => {
const memo = [0, 1]
return n => (
memo[n] >= 0
? memo[n]
: memo[n] = fibonacci(n - 1) + fibonacci(n - 2)
)
})()
@colus001
colus001 / dijkstra.js
Last active July 3, 2017 11:29
Dijkstra algorithm in Javascript
const _ = require('lodash')
const adjacency = (paths, start, end) => {
const visited = [], queues = [start], matrix = {}
let minPath = null
_.each(paths, (path, key) => { matrix[key] = {} })
matrix[start][start] = {
from: start,
cost: 0,
@colus001
colus001 / simple-extends.js
Created June 21, 2017 09:28
Simple prototype inheritance
function Person () {
this.race = 'human'
}
function Japanese () {
this.lang = 'Japanese'
}
Japanese.prototype = new Person()
var j = new Japanese()