Skip to content

Instantly share code, notes, and snippets.

View alevy's full-sized avatar

Amit Levy alevy

View GitHub Profile
@alevy
alevy / largeobjects.rb
Created July 16, 2012 20:21
Storing large objects in memcache
require 'dalli'
require 'benchmark'
client = Dalli::Client.new
# As an example, generate a large random string
@mylargeobject = (0...5000).map{ ('a'..'z').to_a[rand(26)] }.join
@mykey = "mykey"
@alevy
alevy / checkdns.rb
Created December 8, 2012 00:36
Compare Route53 with Ground Truth DNS
require 'net/dns'
require 'route53'
def go(recs, type)
recs.each do |record|
rslv = Net::DNS::Resolver.start(record.name, type).answer
found = true
rslv.each do |answer|
@alevy
alevy / gist:5512907
Created May 3, 2013 19:05
Dalli store/get large value
require 'dalli'
module Dalli
class Client
def set_large(key, val, ttl = 0)
chunk_size = 1024 * 900
i = 0
start_idx = 0
next_chunk = val[start_idx..(start_idx + chunk_size - 1)]
start_idx += chunk_size

Keybase proof

I hereby claim:

  • I am alevy on github.
  • I am amit (https://keybase.io/amit) on keybase.
  • I have the public key with fingerprint 720B 97A3 E367 ACC3 45FC  A0FB 68CA AE74 BF7C 250A

To claim this, I am signing this object:

@alevy
alevy / server_net.go
Created April 13, 2014 23:40
Golang tls.Conn#Read vs net.Conn#Read discrepency
package main
import (
"net"
"log"
)
func main() {
listener, err := net.Listen("tcp", ":8080")
if err != nil {
@alevy
alevy / test.js
Created December 3, 2014 01:34
MemJS load test
var cp = require('child_process');
var children = [];
for (var i = 0; i < 500; i += 1) {
children.push(cp.fork(__dirname + '/test_child.js'));
}
setTimeout(function() {
for (var i = 0; i < children.length; i += 1) {
@alevy
alevy / pomodoro
Created March 23, 2015 21:28
Pomodoro for xmobar with libnotify notifications
#!/bin/bash
pomodoro_file=$HOME/.pomodoro
default_pomodoro_time=1500
pomodoro_time=$default_pomodoro_time
default_rest_time=300
rest_time=$default_rest_time
notify_cmd="notify-send --icon=$HOME/local/share/icons/pomodoro.png Pomodoro"
@alevy
alevy / _intro.md
Last active August 29, 2015 14:25
Syscall/Driver interface

Interface for/to Drivers

Drivers implement the Driver trait --- command and subscribe methods that correspond to command and subscribe system calls for that driver.

The subscribe system call comes with access to a Callback. Callbacks encode the process that invoked the syscall, and the function pointer passed as a callback. Callbacks also act as a capability to allocate memory from the application's heap space.

Questions

Keybase proof

I hereby claim:

  • I am alevy on github.
  • I am amit (https://keybase.io/amit) on keybase.
  • I have a public key ASD5IHMKpuZHvYE139uGlTYq52l0le2uA2jkXefh8ynbwgo

To claim this, I am signing this object:

@alevy
alevy / .gdbinit
Created August 17, 2016 13:05
Tock GDB
target remote :2331
file build/storm/kernel.elf
monitor reset