Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import os
top_dir = "/sys/devices/system/cpu"
cpu_pattern = r'cpu(\d+)'
nominal_perf = 'acpi_cppc/nominal_perf'
highest_perf = 'acpi_cppc/highest_perf'
@kien-truong
kien-truong / gist:02b5e9b33899805a2fda533d22455eac
Created August 5, 2019 03:30
my.cnf configuration templates
[mysql]
# CLIENT #
port = {{mysql_port}}
socket = {{home_dir}}/mysql.sock
host = 127.0.0.1
[mysqld]
# SERVER #
@kien-truong
kien-truong / input.txt
Created May 11, 2019 04:40
Sample data for Prometheus graphite_exporter bug#90
flink.jm.test.Status.JVM.ClassLoader.ClassesUnloaded 0 1557548814
flink.jm.test.Status.JVM.ClassLoader.ClassesLoaded 6831 1557548814
flink.jm.test.Status.JVM.Memory.Direct.Count 18 1557548814
flink.jm.test.Status.JVM.GarbageCollector.PS-Scavenge.Time 15 1557548814
flink.jm.test.Status.JVM.GarbageCollector.PS-MarkSweep.Count 2 1557548814
flink.jm.test.Status.JVM.GarbageCollector.PS-MarkSweep.Time 46 1557548814
flink.jm.test.Status.JVM.GarbageCollector.PS-Scavenge.Count 2 1557548814
flink.jm.test.Status.JVM.CPU.Load 0.00 1557548814
flink.jm.test.Status.JVM.Memory.Direct.MemoryUsed 573419 1557548814
flink.jm.test.Status.JVM.Memory.Heap.Committed 1029177344 1557548814
@kien-truong
kien-truong / mysql_partition_maintenace.sql
Last active January 17, 2019 03:29
Maintenace procedure to create & drop MySQL on a weekly basis
CREATE PROCEDURE CREATE_WEEKLY_PARTITION(tableName VARCHAR(200), refDate DATE)
BEGIN
SET @startOfWeek = SUBDATE(refDate, WEEKDAY(refDate));
SET @partName = DATE_FORMAT(@startOfWeek, 'part%Y%m%d');
SET @dbName = DATABASE();
SET @tName = tableName;
SET @checkQuery = 'SELECT PARTITION_NAME FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA = ? and TABLE_NAME = ? and PARTITION_NAME = ?';
PREPARE chkStmt FROM @checkQuery;
@kien-truong
kien-truong / smemcap.c
Created August 11, 2016 20:37
smemcap.c modify to return /proc/[pid]/* as string
/*
smem - a tool for meaningful memory reporting
Copyright 2008-2009 Matt Mackall <mpm@selenic.com>
Copyright 2016 Kien Truong <duckientruong@gmail.com>
This software may be used and distributed according to the terms of
the GNU General Public License version 2 or later, incorporated
herein by reference.
*/
ssh -t root@localhost << EOF
cd /tmp
mkdir abc
EOF
import java.util.Scanner;
public class Rectangle {
public static class Point {
public float x, y;
public Point(float x, float y) {
this.x = x;
@kien-truong
kien-truong / opengl_sample.c
Created October 6, 2012 06:24
Codeblock OpenGL project sample file
#include <windows.h>
#include <gl/gl.h>
LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
void EnableOpenGL(HWND hwnd, HDC*, HGLRC*);
void DisableOpenGL(HWND, HDC, HGLRC);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
@kien-truong
kien-truong / Dictconfig example
Last active August 9, 2023 20:18
Example log dictionary config in pure python
logconfig = {
"version": 1,
"disable_existing_loggers": 0,
"root": {
"level": "DEBUG",
"handlers": [
"console",
"file",
"debugfile"
]