Skip to content

Instantly share code, notes, and snippets.

View minsooshin's full-sized avatar

Ted Shin minsooshin

  • Lunit Inc.
  • Seoul, Korea
View GitHub Profile
@minsooshin
minsooshin / 0_reuse_code.js
Created December 16, 2013 06:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@minsooshin
minsooshin / js_sorting.js
Last active August 29, 2015 14:21
Javascript Sortings (bubble, insert, and quick)
/**
* Simple Javascript sorting implementation
* bubble, insert, quick
* @author Mason Shin
*/
var Sortings = (function() {
/**
* privates
*/
// Bonfire: Sum All Numbers in a Range
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-numbers-in-a-range
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumAll(arr) {
var newArr = [],
min = Math.min(arr[0], arr[1]),
max = Math.max(arr[0], arr[1]);
// Bonfire: Diff Two Arrays
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function diff(arr1, arr2) {
var newArr = [];
function check(a1, a2) {
var obj = {};
// Bonfire: Roman Numeral Converter
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-roman-numeral-converter
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function convert(num) {
var romanMap = {
"M": 1000,
"CM": 900,
"D": 500,
@minsooshin
minsooshin / bonfire-where-art-thou.js
Created November 20, 2015 06:17
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Where art thou
// Bonfire: Where art thou
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-art-thou
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(collection, source) {
var arr = [];
function check(val) {
var obj = {};
@minsooshin
minsooshin / bonfire-search-and-replace.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Search and Replace
// Bonfire: Search and Replace
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-search-and-replace
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function myReplace(str, before, after) {
if ((/^[A-Z]/).test(before)) after = after.charAt(0).toUpperCase() + after.slice(1);
str = str.replace(new RegExp(before, 'gi'), after);
return str;
}
@minsooshin
minsooshin / bonfire-pig-latin.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Pig Latin
// Bonfire: Pig Latin
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-pig-latin
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function translate(str) {
var vowelReg = /^[aeiou]/i,
index = [];
if ((vowelReg).test(str)) {
@minsooshin
minsooshin / bonfire-dna-pairing.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: DNA Pairing
// Bonfire: DNA Pairing
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function pair(str) {
var pairing = {
"A": "T",
"T": "A",
"C": "G",
@minsooshin
minsooshin / bonfire-sorted-union.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sorted Union
// Bonfire: Sorted Union
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sorted-union
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function unite(arr1, arr2, arr3) {
var args = Array.prototype.slice.call(arguments);
arr1 = args.reduce(function(old, cur) {
var obj = {}, diff;
for (var i = 0; i < old.length; i++) {