Skip to content

Instantly share code, notes, and snippets.

View bungoume's full-sized avatar

ume bungoume

View GitHub Profile
@bungoume
bungoume / parser.py
Last active March 25, 2019 16:22
S3 log parser
from datetime import datetime
import os
import re
from urllib.parse import unquote_plus
import boto3
RE_TEXT = r"""
^(?P<bucket_owner>\S+)\u0020
@bungoume
bungoume / aws-iam.json
Last active August 29, 2015 14:24
AWS ELB付け直しのスクリプト (MIT LIcense)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:DescribeInstanceHealth",
"elasticloadbalancing:DescribeLoadBalancerAttributes",
"elasticloadbalancing:DescribeLoadBalancers"
],
@bungoume
bungoume / bench.py
Last active August 29, 2015 14:17
python replace benchmark
import timeit
import re
def a(w):
w = w.replace('g', 'k')
w = w.replace('z', 's')
w = w.replace('d', 't')
w = re.sub(r'[bp]', 'h', w)
return w
@bungoume
bungoume / uniq.py
Created January 15, 2015 10:14
python unique function
def uniq(array, callback=None):
seen = []
result = []
for obj in array:
if callback:
key = callback(obj)
else:
key = obj
if key not in seen:
seen.append(key)
@bungoume
bungoume / USAGE.txt
Last active April 5, 2024 11:04
早稲田大学 学籍番号CD(チェックデジット)計算
print(calc_cd('1W130000'))
-> 3
print(faculty('1W130000'))
-> '基幹理工学部'
Webで実行
https://dl.dropboxusercontent.com/u/2390414/test/student_id.html
@bungoume
bungoume / ddns.sh
Last active July 24, 2022 13:08
cli53を使ってダイナミックDNSをするスクリプトファイル
#!/bin/bash
DOMAIN="example.com"
IPADDR=`wget -q -O - "http://checkip.dyndns.org" |sed -e 's/[^0-9]*\([0-9\.]*\).*/\1/'`
DOMAINIP=`cli53 rrlist $DOMAIN|grep $'\tA\t'|cut -f5`
if [ $IPADDR != $DOMAINIP ]; then
cli53 rrdelete $DOMAIN @ A
cli53 rrcreate $DOMAIN @ A $IPADDR
echo "$DOMAINIP to $IPADDR"
else
@bungoume
bungoume / findObject.js
Created February 22, 2013 09:53
Search a JavaScript Object
function findKey(obj, searchValue){
for (var key in obj){
if (_.has(obj, key) && obj[key]==searchValue){
return key;
}
}
}
findKey({a:1,b:2,c:3},3);//-->'c'
@bungoume
bungoume / gist:3031457
Created July 2, 2012 06:33 — forked from tmd45/gist:1369167
MITライセンス表示文章の雛形(英語+日本語)
The MIT License
Copyright (c) {year} {copyright holders}
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH T
@bungoume
bungoume / gist:2818041
Created May 28, 2012 08:54
print ieee754(double) data
#include <stdio.h>
#include <tchar.h>
#include <iostream>
typedef struct {
unsigned int fraction1: 32;
unsigned int fraction2: 20;
unsigned int exponent: 11;
unsigned int sign: 1;
}field;