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
(* | |
See: http://beust.com/weblog/2008/06/27/ | |
--- | |
compile & run: | |
$ ocamlfind ocamlc -package batteries -linkpkg challenge.ml -o challenge | |
$ ./challenge | |
*) | |
open Batteries; | |
(* Test whether a number have repeating digits *) |
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
(* | |
See: http://thecodersbreakfast.net/index.php?post/2013/02/18/Coding-challenge-maman-les-petits-avions | |
--- | |
compile & run: | |
$ ocamlfind ocamlc -package batteries -linkpkg avions.ml -o avions | |
$ ./avions | |
*) | |
open Batteries;; | |
(* The syracuse suite *) |
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
/** See: http://zeroturnaround.com/fun/magical-java-puzzle-pat-the-unicorns/ */ | |
import java.util.*; | |
public class Unicorn { | |
static Set<Integer> lines = new HashSet<Integer>(); | |
public static boolean pat() { | |
int callerLine = Thread.currentThread().getStackTrace()[3].getLineNumber(); | |
return lines.add(callerLine); | |
} |
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
# This is a solution to a blog post I just found at https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
# I wrote it in Python because it shines for such challenges. | |
# It took me approximately 35 minutes (edit: added 5 minutes because of a bug in problem #4), so if I trust the internet, I'm definitely a Software Engineer. | |
# How cool is that? :-) | |
# Problem 1 | |
# --------- | |
# Write three functions that compute the sum of the numbers in a given list | |
# using a for-loop, a while-loop, and recursion. | |
def problem1_1(l): |
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 drum | |
import ( | |
"bytes" | |
"encoding/binary" | |
"encoding/hex" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" |
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
public class TimeTable { | |
List<String> week = new ArrayList<>(); | |
List<String> saturday = new ArrayList<>(); | |
List<String> sunday = new ArrayList<>(); | |
List<String> nextRides; | |
public List<String> collectMinutes(String line, String hour) { | |
return Arrays.asList(line.split(" ")).stream() | |
.filter(s -> !s.trim().isEmpty()).map(s -> hour + ":" + s.trim()).collect(Collectors.toList()); | |
} |
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
from __future__ import print_function | |
import uuid | |
sample = [] | |
for _ in xrange(1000000): | |
sample.append("SET %s %s" % (uuid.uuid4(), uuid.uuid4())) | |
print("\n".join(sample), file=open('sample.input', 'w+')) |
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
from __future__ import print_function | |
import uuid, sys | |
def redis_protocol(cmd): | |
proto = "*%d\r\n" % len(cmd.split(' ')) | |
for arg in cmd.split(' '): | |
proto += "$%d\r\n%s\r\n" % (len(arg), arg) | |
return proto | |
sample = "" |
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 me.grison.redis.foo; | |
import org.springframework.boot.*; | |
import org.springframework.boot.autoconfigure.*; | |
import org.springframework.context.annotation.*; | |
import redis.clients.jedis.*; | |
import java.util.UUID; | |
@ComponentScan |
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 me.grison.redis.foo; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import redis.clients.jedis.Jedis; |
OlderNewer