Skip to content

Instantly share code, notes, and snippets.

@fumin
fumin / bashrc
Last active November 25, 2023 23:34
bashrc
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
export PATH=/usr/local/ffmpeg-6.1-amd64-static:$PATH
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
open() {
nautilus $1 &
}
@fumin
fumin / mat_pretty_printer.py
Created April 10, 2022 13:58
pretty printer for opencv Mat
numpy_code = """
# -*- coding: utf-8 -*-
# Copyright (c) 2014, Almar Klein and Wade Brainerd
# tinynumpy is distributed under the terms of the MIT License.
#
# Original code by Wade Brainerd (https://github.com/wadetb/tinyndarray)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@fumin
fumin / haproxy.cfg
Last active September 18, 2020 23:53
Haproxy config file for SSL and basic authentication
# Haproxy config file for SSL and basic authentication
#
# Since ssl is needed, we need to use
# `make TARGET=linux26 USE_OPENSSL=1 ADDLIB=-lz` to install haproxy.
# Also, haproxy version must be haproxy-1.5-dev19 or above.
#
# An example curl command that queryies pic-collage.com/api/collages/feed is
# `curl -k -v -u 'collages:password' 'https://ec2-ip.compute-1.amazonaws.com/api/collages/feed'`
userlist collages_dyno
@fumin
fumin / dynamodb_invalid_utf8.go
Created April 14, 2017 18:48
Demonstration that DynamoDB automatically collates String fields, which is undesirable.
package main
import (
"flag"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/pkg/errors"
@fumin
fumin / tcpdump
Created August 31, 2013 00:36
command for filtering only packets with length > 0
# Command for filtering only packets with length > 0
# Copied from http://www.wains.be/pub/networking/tcpdump_advanced_filters.txt
#
sudo tcpdump -i lo0 -A -q '(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) && port 55976'
@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.

@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 / 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 / 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 "$@" {} \;