This file contains hidden or 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
# frozen_string_literal: true | |
class Apple | |
def one | |
loop do | |
'kaboom' | |
.map { |char| char.upcase.downacase } | |
.filter { |char| char != '0' } | |
.drop { |char| char == 7 } | |
end | |
end |
This file contains hidden or 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 ( | |
"fmt" | |
"net" | |
"net/http" | |
"strconv" | |
"strings" | |
"time" |
This file contains hidden or 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
FROM ruby:2.2.3 | |
ENV APP_HOME=/consumer | |
RUN mkdir $APP_HOME | |
WORKDIR $APP_HOME | |
COPY Gemfile* $APP_HOME/ | |
RUN bundle install |
This file contains hidden or 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 ( | |
"flag" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"os" |
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
def parse_arglist(args): | |
arglist = [] | |
for arg in args: | |
if not arg.startswith('-'): | |
arglist.append(arg) |
This file contains hidden or 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
import os | |
import time | |
def open_unless_older_than(age_s, path): | |
meta = os.stat(path) # will throw IOError if path does not exist | |
if time.time() - meta.st_mtime > age_s: | |
raise IOError('File older than %d seconds' % age_s) | |
return open(path, r) |
This file contains hidden or 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
// Wagner–Fischer a dynamic programming algorithm that computes the edit distance between | |
// two strings of characters. | |
// | |
// Source: | |
// http://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm | |
package main | |
import ( | |
"fmt" | |
) |
This file contains hidden or 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 chunked_reader | |
import "io" | |
// ChunkedReader implements io.Reader interface while allowing the source to be | |
// read in set increments and running a callback function after each increment. | |
type ChunkedReader struct { | |
readSoFar int64 | |
Reader io.Reader // The underlying io.Reader. | |
ChunkSize int // Maximum bytes to read on each Read call. |
This file contains hidden or 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 trie | |
const ( | |
// Number of possible values represented by a single byte. | |
byteValues = 1 << 8 | |
) | |
type Trie struct { | |
culDeSac bool | |
children []*Trie |
This file contains hidden or 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
// Original idea: | |
// http://commandcenter.blogspot.nl/2014/01/self-referential-functions-and-design.html | |
package main | |
import "fmt" | |
type Cat struct { | |
Name string | |
} |
NewerOlder