Skip to content

Instantly share code, notes, and snippets.

View AlexYangYu's full-sized avatar

Alex Yang AlexYangYu

View GitHub Profile
@AlexYangYu
AlexYangYu / latency.txt
Created July 5, 2012 09:32 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@AlexYangYu
AlexYangYu / gist:5476137
Created April 28, 2013 06:52
Use asynchbase to get or create an id for key.
package me.alexyang.deferred;
import com.stumbleupon.async.Callback;
import com.stumbleupon.async.Deferred;
import java.util.ArrayList;
import org.hbase.async.Bytes;
import org.hbase.async.GetRequest;
import org.hbase.async.HBaseClient;
import org.hbase.async.KeyValue;
import org.hbase.async.PutRequest;
package me.alexyang.scanner;
import com.stumbleupon.async.Callback;
import com.stumbleupon.async.Deferred;
import java.nio.charset.Charset;
import java.util.ArrayList;
import org.hbase.async.HBaseClient;
import org.hbase.async.KeyValue;
import org.hbase.async.Scanner;
@AlexYangYu
AlexYangYu / fibonacci_closure.go
Created September 28, 2013 15:30
Exercise: Fibonacci closure
package main
import "fmt"
func fibonacci() func() int {
x, y := 0, 1
return func () int {
x, y = x + y, x
return x
}
@AlexYangYu
AlexYangYu / gist:7433490
Created November 12, 2013 16:07
Vagrantfile for OpenStack two nodes environment.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
@AlexYangYu
AlexYangYu / gist:9782496
Last active August 29, 2015 13:57
Neutron conf
/etc/neutron.conf
[DEFAULT]
debug = False
verbos = False
state_path = /var/lib/neutron
lock_path = $state_path/lock
#core_plugin = neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2
core_plugin = neutron.plugins.ml2.plugin.Ml2Plugin
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
notification_driver = neutron.openstack.common.notifier.rpc_notifier
@AlexYangYu
AlexYangYu / raid.py
Created October 8, 2014 08:27
Python code for zabbix low level discovery to monitor MegaRAID and physical disks.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Description:
# This application is used to discovery the pyhsical disk by using the MegaCLI tool.
#
# Author: Alex Yang <alex890714@gmail.com>
#
#include <stdio.h>
#include <string.h>
struct log {
char func_name[255];
char hour[2];
char minute[2];
char second[2];
bool action;
};
@AlexYangYu
AlexYangYu / gist:f498e871a6894f8c17ec
Last active August 29, 2015 14:26
BlockDeviceDriver Errors
# Cinder Multi Backend
[root@node-67 ~]# cinder service-list
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | node-67.domain.tld | nova | enabled | up | 2015-07-30T06:15:50.000000 | None |
| cinder-volume | node-67.domain.tld@iscsi | nova | enabled | up | 2015-07-30T06:15:50.000000 | None |
| cinder-volume | node-70.domain.tld@local-70 | nova | enabled | up | 2015-07-30T06:15:55.000000 | None |
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+
[root@node-67 ~]# cinder type-list