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 / 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-sum-all-primes.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sum All Primes
// Bonfire: Sum All Primes
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-primes
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumPrimes(num) {
var primes = [2];
function isPrime(n) {
for (var i = 2; i < n; i++) {
@minsooshin
minsooshin / bonfire-sum-all-odd-fibonacci-numbers.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Sum All Odd Fibonacci Numbers
// Bonfire: Sum All Odd Fibonacci Numbers
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-odd-fibonacci-numbers
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumFibs(num) {
var fibs = getFibs(num),
oddFibs = [];
@minsooshin
minsooshin / bonfire-spinal-tap-case.js
Last active November 22, 2015 04:00
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Spinal Tap Case
// Bonfire: Spinal Tap Case
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.replace(/([a-z])([A-Z])/g, '$1 $2')
.toLowerCase().replace(/\s/g, '-')
@minsooshin
minsooshin / bonfire-convert-html-entities.js
Last active November 22, 2015 04:01
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Convert HTML Entities
// Bonfire: Convert HTML Entities
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-convert-html-entities
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function convert(str) {
// &colon;&rpar;
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
@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++) {