Skip to content

Instantly share code, notes, and snippets.

View sajal's full-sized avatar
💭
What's happening?

Sajal Kayan sajal

💭
What's happening?
View GitHub Profile
@sajal
sajal / rbdinfo.go
Created March 27, 2017 11:21
rbd info
package main
import (
"log"
"github.com/ceph/go-ceph/rados"
"github.com/ceph/go-ceph/rbd"
)
func main() {
package main
import (
"context"
"flag"
"fmt"
"log"
"net"
"net/http"
"net/http/httptest"
@sajal
sajal / buggy-also.go
Created December 8, 2016 10:28
map booboo
package main
import (
"sync"
"time"
)
// cache allows manipulating cached data.
type cache struct {
// Concurrent access control to maps
Dec 8 09:56:00 pulse cnc[3886]: 2016/12/08 09:56:00 warning: libgeoip lookup failed for ip '10.1.9.1'
Dec 8 09:56:00 pulse cnc[3886]: 2016/12/08 09:56:00 warning: libgeoip lookup failed for ip '192.168.2.254'
Dec 8 09:56:00 pulse cnc[3886]: 2016/12/08 09:56:00 warning: libgeoip lookup failed for ip '192.168.1.1'
Dec 8 09:56:00 pulse cnc[3886]: 2016/12/08 09:56:00 warning: libgeoip lookup failed for ip '10.0.1.254'
Dec 8 09:56:00 pulse cnc[3886]: 2016/12/08 09:56:00 (geoipdb) cache miss for 58.221.26.69
Dec 8 09:56:00 pulse cnc[3886]: fatal error: 2016/12/08 09:56:00 (geoipdb) cache miss for 217.170.0.244
Dec 8 09:56:00 pulse cnc[3886]: concurrent map writes
Dec 8 09:56:00 pulse cnc[3886]: goroutine 1936 [running]:
Dec 8 09:56:00 pulse cnc[3886]: runtime.throw(0x8b944e, 0x15)
Dec 8 09:56:00 pulse cnc[3886]: #011/usr/local/go/src/runtime/panic.go:566 +0x95 fp=0xc4209e1b08 sp=0xc4209e1ae8
@sajal
sajal / 16808.go
Created September 16, 2016 18:55
reproduction for Go issue #16808
package main
import (
"log"
"net"
"net/http"
"os"
"os/exec"
"strconv"
"time"
@sajal
sajal / .config
Created February 25, 2015 16:46
gccgo on WT1520
#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_ppc40x is not set
# CONFIG_TARGET_realview is not set
# CONFIG_TARGET_arm64 is not set
# CONFIG_TARGET_sunxi is not set

Keybase proof

I hereby claim:

  • I am sajal on github.
  • I am sajal (https://keybase.io/sajal) on keybase.
  • I have a public key whose fingerprint is A668 BBFE 438C BEDA 7BB6 3925 3964 90AC BF15 828F

To claim this, I am signing this object:

@sajal
sajal / s3lineoutput.py
Created October 29, 2012 18:40
Output stream for S3
from disco.worker.classic.func import task_output_stream
class S3LineOutput(object):
"""
Output stream for S3.
key from each reduce becomes key name in S3
If gzip param is True, it gzips before uploading.
AWS_KEY, AWS_SECRET and BUCKET_NAME in params is required.
"""
def __init__(self,stream,params,partition, url):
@sajal
sajal / magiclist.py
Created October 23, 2012 22:02
Memory efficient list...
from collections import defaultdict
import math
class MagicList():
"""
An attempt to make a python object which could potentially hold
unlimited values with finite distinct values.
All items are not stored in memory, only the count of each distinct item is.
So if you want to hold say 1 million numbers where each number is between 1 to 5000,
this should be a better choice than a list.
@sajal
sajal / s3output.py
Created October 19, 2012 17:31
S3Output for storing disco reduce items directly to Amazon S3
from disco.worker.classic.func import task_output_stream
class S3Output(object):
"""
Output stream for S3.
key from each reduce becomes key name in S3
If gzip param is True, it gzips before uploading.
AWS_KEY, AWS_SECRET and BUCKET_NAME in params is required.
"""
def __init__(self,stream,params):