This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
b2dstatus=$(boot2docker status) | |
b2dip="$(boot2docker ip 2>/dev/null)" | |
if [ "$?" -ne 0 ]; then | |
message="" | |
else | |
message="on $b2dip" | |
fi | |
echo boot2docker is $b2dstatus $message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://tour.golang.org/concurrency/8 | |
package main | |
import ( | |
"fmt" | |
"golang.org/x/tour/tree" | |
) | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"fmt" | |
"net/http" | |
) | |
const staticDir = "static" | |
const port = "3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [1991,1,2,4,5,0,18,90,90,90,10,1973,42,8,34,2015,102,3] | |
bubbleSort = (source) -> #0(n^2) | |
copy = source.slice() | |
moved = true | |
until !moved | |
moved = false | |
for index in [0...copy.length - 1] | |
if copy[index] > copy[index+1] | |
swap = copy[index] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove duplicate characters in a given string keeping only the first occurrences. For example, if the input is ‘tree traversal’ the output will be ‘tre avsl’. - See more at: http://www.ardendertat.com/2012/01/09/programming-interview-questions/#sthash.H0JW5qet.dpuf | |
removeDuplicate = (source) -> | |
chars = [] | |
result = "" | |
for char in source | |
unless chars[char]? | |
chars[char] = 1 | |
result += char | |
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There is an array of non-negative integers. A second array is formed by shuffling the elements of the first array and deleting a random element. Given these two arrays, find which element is missing in the second array. - See more at: http://www.ardendertat.com/2012/01/09/programming-interview-questions/#sthash.O5ROTbyu.dpuf | |
findMissing = (longArray, shortArray) -> #O(n^2x) | |
# does not work with duplicates | |
for char in longArray | |
for target in shortArray | |
found = char == target | |
break if found | |
return char unless found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Find the first non-repeated (unique) character in a given string. - See more at: http://www.ardendertat.com/2011/11/14/programming-interview-questions-15-first-non-repeated-character-in-string/#sthash.rnXPFFOK.dpuf | |
find = (string) -> #O(n^2) | |
for index in [0...string.length] | |
for targetIndex in [0...string.length] | |
unless index == targetIndex | |
unique = string[index] != string[targetIndex] | |
console.log "#{string[index]}(#{index}) vs #{string[targetIndex]}(#{targetIndex}) -> #{unique}" | |
break unless unique | |
return string[index] if unique |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
euler1 = -> #O(n) | |
multiples = [] | |
for i in [1...1000] | |
if (i % 3 == 0) | |
multiples.push i | |
else if (i % 5 == 0) | |
multiples.push i | |
multiples.reduce(((n,n1) -> n+n1),0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.serpodile.shop.version; | |
import com.google.common.collect.SortedSetMultimap; | |
import com.google.common.collect.TreeMultimap; | |
import lombok.EqualsAndHashCode; | |
import org.junit.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class MultiMapWoesTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.serpodile.shop.tech; | |
import com.squareup.okhttp.*; | |
import lombok.extern.slf4j.Slf4j; | |
import java.io.IOException; | |
@Slf4j | |
public class Slack { | |
private String slackUrl; |