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
import java.util.Hashtable; | |
public class Bank { | |
public static class InsufficientFunds extends Exception {} | |
final public interface Account { | |
Integer balance(); | |
void increase (Integer amount); | |
void decrease (Integer amount); | |
} |
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
diff --git a/src/encoding/base64/base64.go b/src/encoding/base64/base64.go | |
index ad3abe6..bff443f 100644 | |
--- a/src/encoding/base64/base64.go | |
+++ b/src/encoding/base64/base64.go | |
@@ -22,7 +22,7 @@ import ( | |
// (RFC 1421). RFC 4648 also defines an alternate encoding, which is | |
// the standard encoding with - and _ substituted for + and /. | |
type Encoding struct { | |
- encode string | |
+ encode [64]byte |
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
// The latest implementation and stats are at | |
// | |
// https://github.com/egonelbre/exp/tree/master/physicscompress | |
// | |
// | |
// Response to Data Compression Challenge | |
// http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/ | |
// | |
// The main insight that this compression uses is |
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
#include <stdio.h> | |
#include <stdint.h> | |
#include <limits.h> | |
#define BLOCK (1<<16) | |
#define MASK (BLOCK - 1) | |
typedef struct wordcount { | |
int w0[BLOCK]; | |
int w1[BLOCK]; | |
int w2[BLOCK]; |
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 ( | |
"database/sql" | |
"encoding/json" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"net/http" | |
"time" |
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 egonelbre | |
import ( | |
"errors" | |
"io" | |
) | |
const ( | |
maxChunk = 16 << 10 | |
) |
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 egonelbre | |
import ( | |
"io" | |
"sync/atomic" | |
) | |
type process struct { | |
quit chan struct{} | |
sleep chan struct{} |
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 ( | |
"crypto/rand" | |
"fmt" | |
"time" | |
) | |
const ( | |
keysize = 35 // bytes |
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 foo | |
type Foo struct { | |
} | |
type DB interface { | |
Find(string) (Foo, error) | |
} |
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
// add here more values if more range is needed | |
#define ilog(x) x < 2 ? 1 : x < 4 ? 2 : x < 8 ? 3 : x < 16 ? 4 : x < 32 ? 8 : x < 64 ? 9 : x < 128 ? 10 : \ | |
x < 256 ? 11 : x < 512 ? 12 : 13 | |
// imprecision macro P4 ( 4 bytes for float ) | |
// (0.00 .. 1.99) | |
// avg err = 0.00375 | |
// max err = 0.0075 | |
// (2.00 .. 3.99) | |
// avg err = 0.0075 |