Skip to content

Instantly share code, notes, and snippets.

View qmaillogparser.pl
#!/usr/bin/env perl
use warnings;
use strict;
my $msg = {};
my $delivery = {};
while (<>) {
if ($_ =~ /^([^\s]+) info msg ([\d]+): bytes [\d]+ from ([^\s]+)/) {
View dht22.py
#!/usr/bin/env python
import sys
from datetime import datetime
import Adafruit_DHT as DHT
SENSOR_TYPE = DHT.DHT22
DHT_GPIO = 18
print(datetime.now().strftime('%Y/%m/%d %H:%M:%S') + "\t"),
View add_exif_datetime.py
#!/usr/bin/env python
import sys
import os
import stat
import datetime
import pyexiv2
argvs = sys.argv
argc = len(argvs)
@akagisho
akagisho / apalogconvert.py
Created Jun 6, 2018
Apache のログの日時を Excel が認識できる形式に変換
View apalogconvert.py
#!/usr/bin/env python
import sys
import re
from datetime import datetime
for line in sys.stdin:
m = re.search('\[(\d{2}/[A-Z][a-z]{2}/\d{4}:\d{2}:\d{2}:\d{2}) .{0,6}\]', line)
if m:
d = datetime.strptime(m.group(1), '%d/%b/%Y:%H:%M:%S')
View apalogcounting.py
#!/usr/bin/env python
import sys
import re
from datetime import datetime
ips = []
count = []
first = []
last = []
View Dockerfile
FROM ubuntu:xenial
MAINTAINER akagisho <akagisho@gmail.com>
RUN sed -i -e "s|http://archive.ubuntu.com/|http://jp.archive.ubuntu.com/|" /etc/apt/sources.list
RUN apt update \
&& apt install -y sudo curl git libfontconfig-dev fonts-takao* chromium-browser supervisor
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
View screenshot.js
const viewportWidth = 1200;
const viewportHeight = 900;
const argv = process.argv;
var path = require('path');
const puppeteer = require('puppeteer');
if (argv.length < 3) {
console.error('Usage: node ' + path.basename(argv[1]) + ' <path> <url>');
process.exit(1);
@akagisho
akagisho / import_templates.php
Created Sep 18, 2017
Import Zabbix's Templates
View import_templates.php
<?php
require_once 'vendor/autoload.php';
use ZabbixApi\ZabbixApi;
$url = $argv[1];
$user = $argv[2];
$pass = $argv[3];
$file = $argv[4];
@akagisho
akagisho / export_templates.php
Last active Sep 18, 2017
Export Zabbix's Templates
View export_templates.php
<?php
require_once 'vendor/autoload.php';
use ZabbixApi\ZabbixApi;
$url = $argv[1];
$user = $argv[2];
$pass = $argv[3];
$search = $argv[4];
View Dockerfile
FROM ubuntu:xenial
MAINTAINER akagisho <akagisho@gmail.com>
RUN sed -i -e "s|http://archive.ubuntu.com/|http://jp.archive.ubuntu.com/|" /etc/apt/sources.list
RUN apt update \
&& apt install -y curl git libfontconfig-dev fonts-takao* supervisor sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*