Skip to content

Instantly share code, notes, and snippets.

@sunfuze
sunfuze / cgroup_memory_stat.sh
Created January 21, 2022 02:47
show human readable cgroup memory stat
cat /sys/fs/cgroup/memory/memory.stat | awk 'BEGIN{suffixes_len=split("B KB MB GB",suffixes)} {n_suffix=1; while($2 > 1000 &&
n_suffix < suffixes_len) {$2 /= 1024; n_suffix++;}; printf "%20s %7.2f %2s\n",$1,$2,suffixes[n_suffix]}'
@sunfuze
sunfuze / trx.sql
Created February 28, 2019 09:37
数据库事务查询
# 事务隔离级别,
# READ-UNCOMMITTED 读未提交
# READ-COMMITTED 读提交
# REPEATABLE-READ 可重复读
# SERIALIZABLE 串行化
show variables like 'transaction_isolation';
# 事务事件执行事件大于 60 秒的操作
select * from information_schema.innodb_trx where TIME_TO_SEC(timediff(now(),trx_started))>60;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sunfuze
sunfuze / dbg.h
Last active August 29, 2015 14:24
zed's debug macros
//copy: http://c.learncodethehardway.org/book/ex20.html
#ifndef __dbg_h
#define __dbg_h
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifndef NDEBUG
@sunfuze
sunfuze / installOpencv.sh
Last active August 29, 2015 14:01
install opencv in ubuntu 14.04
#! /bin/bash
# install dependencies
sudo apt-get install gcc cmake build-essential libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy
# get source
git clone https://github.com/Itseez/opencv.git
cd opencv
mkdir build
function hex2ascii(hex) {
var str = '';
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
return str;
};
function ascii2hex(ascii) {
/*
* Copyright 2010 Georgios Migdos .
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sunfuze
sunfuze / tags.sh
Created January 7, 2014 10:42
ctag 使用
#!/bin/bash
#for c lang
find . -type f -iname "*.[chS]" | xargs etags -a
@sunfuze
sunfuze / gist:6087494
Created July 26, 2013 09:19
将redis加入到service中
#!/bin/bash
#
# redis Startup script for redis processes
#
# author: snowolf
#
# processname: redis
redis_path="/usr/local/bin/redis-server"
redis_conf="/etc/redis/redis.conf"
@sunfuze
sunfuze / CharacterUtil
Created July 19, 2013 10:56
去掉标点和空字符,转MD5
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CharacterUtil {
public static String removeSymbol(String chs) {