Skip to content

Instantly share code, notes, and snippets.

@fumin
fumin / profile.rb
Last active August 29, 2015 13:56
redis key distribution profiling script
# profile.rb - A script that analyzes the memory usage of a redis instance from it's "dump.rdb"
#
# To run this script, edit the key_groups variable in the stats method, and then run
# `ruby profile.rb dump.rdb` in the command line.
# Running this script will:
# * Dump the contents of the input rdb file in CSV format to "/tmp/memory.csv"
# * Load the contents of "/tmp/memory.csv" to the table "mem" in the "redis_mem" database
# * Print the stats of each key group to STDOUT
#
# Dependencies:
@fumin
fumin / floating_point_experiment.m
Created February 24, 2014 16:15
OpenGL floating point texture experiment
void floatTextureExperiment
{
GLenum err = 0;
GLuint texture1;
glGenTextures(1, &texture1);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@fumin
fumin / selfreproducing.go
Created April 7, 2014 19:19
self-reproducing program in Go
package main
import "fmt"
func main() {
m := `package main
import "fmt"
@fumin
fumin / present.go
Created July 5, 2014 04:09
Example of using the present package
package main
import (
"bytes"
"html/template"
"net/http"
"code.google.com/p/go.tools/present"
)
@fumin
fumin / concat.go
Last active August 29, 2015 14:05
A command to truncate and then concatenate Google Cloud Storage files
package main
import (
"bytes"
"flag"
"fmt"
"os"
"os/exec"
"strings"
)
@fumin
fumin / use_rc_tumblr.rb
Created October 23, 2012 21:40
how to use RC::Tumblr
c = RC::Tumblr.new
c.authorize_url! # https://api.tumblr.com/oauth/authorize?oauth_token=I8QcLz0oqCTS47D9cHqjn9QfHkcmZzeMJNZEwkpCEwOdIctD2Y
# throw the above link into browser and login
# Eventually you'll end up in http://pic-collage.com/?oauth_token=I8QcLz0oqCTS47D9cHqjn9QfHkcmZzeMJNZEwkpCEwOdIctD2Y&oauth_verifier=nSAGgIsnwFoNChxIWAjYmFWKjMDWTG0UmOOr4VGpRcYsSDY7Z3
c.authorize! :oauth_verifier => 'nSAGgIsnwFoNChxIWAjYmFWKjMDWTG0UmOOr4VGpRcYsSDY7Z3'
# You are ready now :)
pp c.user_info
@fumin
fumin / findcode
Last active October 13, 2015 02:18
find code for use with vim
#!/bin/bash
cd `pwd`
find . ! \( -name ".git" -prune -o -name tmp -prune -o -name log -prune \) -type f -exec grep "$@" {} \;
@fumin
fumin / futures.rb
Created December 12, 2012 02:13
futures implementation
require 'fiber'
require 'eventmachine'
require 'rest-core'
class BlockingClient
def initialize *args
@client = RC::Universal.new(*args)
end
def get path, params={}, opts={}
@client.get(path, params, opts).tap{}
@fumin
fumin / background.sh
Created November 22, 2015 19:59
script to restart all background processes including dynamodb, sqs, redis, and elasticsearch
#!/bin/sh
function killport {
while true; do
PID=$(lsof -i TCP:$1 | grep LISTEN | awk '{print $2}')
exec 3>&2 # 3 is now a copy of 2
exec 2> /dev/null # 2 now points to /dev/null
kill $PID
kill -0 $PID
@fumin
fumin / english_club_self_intro.md
Last active December 14, 2015 00:59
self intro for english club

Awaw self intro for English Club

Basic info

I am fumin (awaw in most places on the web) who is mainly a developer focusing on web, iOS, and Android apps. I work at cardinalblue.com. You can find more about me at github/fumin, previous homepage, and future graphics.

Motivation

To practice the English language orally, and to get to know new friends

Expectations

I hope everyone participating find the gathering interesting, helpful, and rewarding. I believe I will feel the same if everyone feels so.