Skip to content

Instantly share code, notes, and snippets.

@sugy
sugy / nginx_error_log_rate_limit_to_ltsv.py
Created June 25, 2021 08:51
Convert nginx's Rate Limiting log to LTSV Format.
#!/usr/bin/python
import fileinput
import datetime
import sys
for line in fileinput.input():
try:
d = {}
l = line.rstrip().split(',')
@sugy
sugy / gist_edit_height.js
Last active August 13, 2020 18:45
make gist edit pages full height with the touch of a button
// ==UserScript==
// @name gist edit height
// @namespace https://gist.github.com/sugy/1016a3c2d1c9638c5938bf5284efa46d
// @version 0.2
// @description make gist edit pages full height with the touch of a button
// @author sugy
// @grant none
// @include https://gist.github.com/*/edit
// ==/UserScript==
package main
import "fmt"
func main() {
count := 10
for i := 0; i < count; i++ {
fmt.Println("increment iterate")
}
@sugy
sugy / 0_reuse_code.js
Created January 18, 2016 07:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sugy
sugy / mysql_
Last active November 17, 2015 01:29
munin でサクッと mysql の table size のグラフが作成したい。
#!/usr/bin/perl
# -*- perl -*-
=encoding utf8
=head1 NAME
mysql_ - Munin plugin to display misc MySQL server status
=head1 APPLICABLE SYSTEMS
@sugy
sugy / slack.format.js
Created July 28, 2015 08:16
CopyHook の .copyhook/slack.format.js の replace の正規表現を変更した。日付の部分がマッチしなかったみたい。
//#!node
function formatSlack(text) {
return text.replace(/^(.+)\s(\[\d+:\d+ .+\])\s*\n(.+)\n*/gm, function (_, name, time, text) {
return time + ' ' + name + ': ' + text + "\n";
});
}
if (typeof module != "undefined") {
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Updated: 2013-11-13 Yuichiro Saito
# Updated: 2015-07-21 Kazutoshi Sugiyama
function get_swap_used {
DIR=$1
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
/*
queue-fix 1.4
by Eric Huss
e-huss@netmeridian.com
reconstructs qmail's queue
*/
#include <stdio.h>
#include <sys/stat.h>
#include <pwd.h>
@sugy
sugy / virt-addr.pl
Created October 15, 2014 06:22
virt-addr | Tip: Find the IP address of a virtual machine
#!/usr/bin/perl -w
## http://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
use strict;
use warnings;
use Data::Dumper;
use XML::XPath;
use XML::XPath::XMLParser;
@sugy
sugy / mysql_version.c
Created September 30, 2014 10:11
MySQL C API を使ってみる 2
#include <my_global.h>
#include <mysql.h>
int main(int argc, char **argv)
{
if (argc != 2){
printf("Input mysqld host.\n");
exit(1);
}