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 ( | |
"fmt" | |
"bytes" | |
"os" | |
"log" | |
"time" | |
"io" | |
"http" |
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" | |
"io" | |
"os" | |
"crypto/tls" | |
"strings" | |
"net" | |
"flag" |
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
#!/usr/bin/env python | |
# coroutine equivalent of http://play.golang.org/p/lKBbS56f-n | |
def generate(s,even,odd): | |
for i,c in enumerate(s): | |
if i%2 == 0: | |
even.send(c) | |
else: | |
odd.send(c) |
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
/** | |
* Trying to recreate the "Holder" class publishing error from JCIP. | |
* See http://stackoverflow.com/a/6812936/55094 for the description of the problem. | |
*/ | |
public class Publishing { | |
static class Holder { | |
int h = 0; | |
int dummy = 0; | |
public Holder(int h) { | |
for (long i=0;i<1000*1000;i++) { |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
// weird exercise from a friend | |
// need to Implement this struct | |
typedef struct attrib_t { | |
struct attrib_t* bytes[256]; | |
const char *data; |
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
class BencodeWriter { | |
static class SizedInputStream { | |
public InputStream stream; | |
public int size; | |
public SizedInputStream(InputStream _stream,int _size) {stream = _stream;size = _size;} | |
} | |
public static class BencodeProducer { | |
private OutputStream out; | |
public BencodeProducer(OutputStream o) {out = o;} |
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 | |
// run this file with `go run clientDoGzip.go, and then file tmp.out to verify body is gzipped | |
import "net/http" | |
import "io/ioutil" | |
import "bytes" | |
import "fmt" | |
import "log" | |
import "compress/gzip" |
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 ("bufio" | |
"fmt" | |
"io" | |
"net/http" | |
"net" | |
"strings") | |
type readFirstCloseSecond 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 ( | |
"io" | |
"os" | |
"time" | |
) | |
func singLine(line string,w io.Writer) { | |
time.Sleep(time.Second) |
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 cp | |
import ( | |
"io" | |
"os" | |
) | |
func cp(dst, src string) error { | |
s, err := os.Open(src) | |
if err != nil { |
OlderNewer