Skip to content

Instantly share code, notes, and snippets.

View mitake's full-sized avatar
💭
I may be slow to respond.

Hitoshi Mitake mitake

💭
I may be slow to respond.
  • 19:42 (UTC +09:00)
View GitHub Profile
@mitake
mitake / gist:3924195
Created October 20, 2012 17:51
easy string format without runtime memory allocation, example of IP address
#include <stdio.h>
#include <string.h>
#define BUF_NUM 32
#define BUF_LEN 16
static char *format(int val)
{
static char buf[BUF_NUM][BUF_LEN];
static int buf_i;
@mitake
mitake / evhttp-multh-thread-httpd.cpp
Created November 5, 2012 07:10 — forked from kzk/evhttp-multh-thread-httpd.cpp
Multi-Threaded HTTPServer using evhttp
// g++ evhttp-multh-thread-httpd.cpp -levent
#include <event.h>
#include <evhttp.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
@mitake
mitake / party-accounting.pl
Created December 8, 2012 06:22
Party accounting
% usage:
% $ swipl -o party-accounting -c party-accounting.pl
% $ ./party-accounting
% ?- main.
:- use_module(library('clp/bounds')).
party_accounting(Nr_manager, Manager_yen, Nr_principle, Principle_yen, Nr_director, Director_yen, Nr_hira, Hira_yen, Total_yen) :-
Manager_yen in 0..Total_yen,
@mitake
mitake / replace.py
Last active December 11, 2015 12:49
string replace in python
#! /usr/bin/env python
import sys, re
def conf_file(path):
f = open(path, 'r')
res = []
for line in f.readlines():
line = line.replace('vprintf', 'sd_printf')
line = line.replace('eprintf', 'sd_eprintf')
@mitake
mitake / CMakeLists.txt
Created March 6, 2013 14:09
sample of DynamoRIO client
cmake_minimum_required(VERSION 2.8)
SET(DynamoRIO_DIR "/home/mitake/dynamorio/exports/cmake")
find_package(DynamoRIO)
add_library(sample SHARED sample.c)
configure_DynamoRIO_client(sample)
[2015/08/20-16:10:36.847511] xio_tcp_datapath.c:1753 [ERROR] - partial completion of request due to missing, response buffer
[2015/08/20-16:10:36.847559] xio_tcp_datapath.c:1812 [ERROR] - xio_tcp_send_msg failed
[2015/08/20-16:10:36.847580] xio_nexus.c:2200 [ERROR] - transport send failed err:1247689306
@mitake
mitake / idea
Last active September 4, 2015 02:24 — forked from chrisdarroch/idea
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=/opt/intellij-idea-ce/bin/idea.sh
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@mitake
mitake / patch-3.5.0-bvt1
Created March 7, 2016 05:54 — forked from leverich/patch-3.5.0-bvt1
Borrowed Virtual Time patch against Linux 3.5.0
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4a1f493..ef258ef 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1179,6 +1179,10 @@ struct sched_entity {
u64 exec_start;
u64 sum_exec_runtime;
u64 vruntime;
+#ifdef CONFIG_CFS_BVT
+ u64 effective_vruntime;
#! /bin/bash
export ETCDCTL_API=3
ETCDCTL=bin/etcdctl
echo p | $ETCDCTL user add root --interactive=false
echo p | $ETCDCTL user add u1 --interactive=false
$ETCDCTL role add root
$ETCDCTL role add r1
(pprof) top 295
1.54s of 1.54s total ( 100%)
flat flat% sum% cum cum%
0.18s 11.69% 11.69% 0.19s 12.34% syscall.Syscall
0.13s 8.44% 20.13% 0.13s 8.44% github.com/coreos/etcd/cmd/vendor/golang.org/x/crypto/blowfish.encryptBlock
0.05s 3.25% 23.38% 0.05s 3.25% math/big.addMulVVW
0.05s 3.25% 26.62% 0.05s 3.25% math/big.divWW
0.05s 3.25% 29.87% 0.05s 3.25% math/big.mulAddVWW
0.05s 3.25% 33.12% 0.05s 3.25% runtime.futex
0.05s 3.25% 36.36% 0.05s 3.25% runtime.heapBitsSetType