Skip to content

Instantly share code, notes, and snippets.

View shufo's full-sized avatar

Shuhei Hayashibara shufo

View GitHub Profile
@shufo
shufo / skype
Created August 7, 2014 03:35
Skype-bot init script
#!/bin/bash
#
# Init file for daemonized Skype service
#
### BEGIN INIT INFO
# Provides: skype
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
@shufo
shufo / bot.py
Last active October 11, 2020 09:04
Skype-bot script
#!python2.6
#coding: utf-8
import Skype4Py
import os, sys, time, struct, re
reload(sys)
sys.setdefaultencoding('utf-8')
os.environ["DISPLAY"] = ":20"
@shufo
shufo / supervisord.conf
Created August 7, 2014 05:08
supervisord conf for skype bot
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
#!/usr/bin/env python
# (c) 2013, Greg Buehler
#
# This file is part of Ansible,
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
<source>
type tail
path /usr/local/WowzaStreamingEngine/logs/wowzastreamingengine_access.log
tag wowza
format tsv
keys date,time,tz,x-event,x-category,x-severity,x-status,x-ctx,x-comment,x-vhost,x-app,x-appinst,x-duration,s-ip,s-port,s-uri,c-ip,c-proto,c-referer,c-user-agent,client-id,cs-bytes,sc-bytes,x-stream-id,x-spos,cs-stream-bytes,sc-stream-bytes,x-sname,x-sname-query,x-file-name,x-file-ext,x-file-size,x-file-length,x-suri,x-suri-stem,x-suri-queri,cs-uri-stem,cs-uri-query
pos_file /tmp/fluentd--1466642855.pos
</source>
@shufo
shufo / keymap.cson
Created January 19, 2017 14:14
IntelliJ like keybinding for Atom
'.platform-win32, .platform-linux':
'alt-f1': 'tree-view:reveal-active-file'
'.platform-linux, .platform-linux .command-palette atom-text-editor':
'ctrl-shift-a': 'command-palette:toggle'
'.platform-linux':
'ctrl-shift-n': 'fuzzy-finder:toggle-file-finder'
'.platform-linux atom-text-editor':
@shufo
shufo / kinesis-firehose-process-cloudwatch-logs-record.py
Created October 17, 2017 11:33
processing cloudwatch logs to put kinesis firehose
from __future__ import print_function
import base64
import gzip
import StringIO
import json
def lambda_handler(event, context):
output = []
@shufo
shufo / websocket_handler_cowboy2.ex
Created November 14, 2018 14:54
Websocket handler for Cowboy 2
defmodule MyApp.WebSocketHandlerCowboy2 do
def init(req, state) do
opts = %{idle_timeout: 60000}
{:cowboy_websocket, req, state, opts}
end
def websocket_init(state) do
{:ok, state}
end
defmodule LogViewer.Server do
def start_link() do
dispatch = :cowboy_router.compile([
{:_,
[
{'/websocket', LogViewer.WebSocketHandler, []},
{"/", :cowboy_static, {:priv_file, :log_viewer, "index.html"}},
{"/_nuxt/[...]", :cowboy_static, {:priv_dir, :log_viewer, "_nuxt"}},
{"/[...]", :cowboy_static, {:priv_file, :log_viewer, "index.html"}}
]}
defmodule LogViewer do
use Application
require Logger
def start(_type, _args) do
import Supervisor.Spec, warn: false
children =
[