Skip to content

Instantly share code, notes, and snippets.

@koseki
koseki / README.md
Last active Jun 13, 2021
Dump RPM headers
View README.md
@koseki
koseki / dump-rpm-headers.py
Last active Jun 12, 2021
Dump RPM headers
View dump-rpm-headers.py
#! /usr/bin/env python
import struct
from ctypes import *
import io
import re
from enum import Enum
from sys import argv
@koseki
koseki / index.js
Last active Apr 11, 2021
Memoized Async Function
View index.js
import axios from 'axios'
class App {
constructor() {
this.cache = {}
}
/**
* 何もキャッシュしないバージョン
*/
@koseki
koseki / aioredis_reconnection.py
Last active Jan 4, 2021
aioredis Pub/Sub reconnection
View aioredis_reconnection.py
import asyncio
from typing import List
import aioredis
from aioredis import Redis
from aioredis.pubsub import Channel
from aioredis.connection import RedisConnection
class Sample:
@koseki
koseki / README.md
Last active Dec 14, 2020
日本の市外局番と都道府県の対応 Phone Number Area Code and Prefectures in Japan
View README.md
@koseki
koseki / MFARequiredForCurrentUsers.json
Last active Sep 16, 2020
MFA required IAM Policies
View MFARequiredForCurrentUsers.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowViewAccountInfo",
"Effect": "Allow",
"Action": [
"iam:GetAccountPasswordPolicy",
"iam:GetAccountSummary",
"iam:ListVirtualMFADevices"
@koseki
koseki / dst.md
Last active Apr 23, 2021
サマータイム終了時の挙動
View dst.md

タイムゾーン America/Los_Angeles では、サマータイム終了日 2018/11/04 の 01:00:00 〜 01:59:59 が2度繰り返される。

Ruby の Time は、午前1時台をサマータイム終了後として扱っている。

irb(main):001:0> ENV['TZ'] = 'America/Los_Angeles'
=> "America/Los_Angeles"
irb(main):002:0> Time.local(2018, 11, 4, 0, 59, 0)
=> 2018-11-04 00:59:00 -0700
irb(main):003:0> Time.local(2018, 11, 4, 0, 59, 0).dst?
@koseki
koseki / HTPasswd.php
Last active Aug 20, 2017
PHP - MD5 based htpasswd entry generator class
View HTPasswd.php
<?php
/**
* MD5 based htpasswd entry generator
*
* Original: https://stackoverflow.com/questions/2994637/how-to-edit-htpasswd-using-php/8786956#8786956
* Spec: https://httpd.apache.org/docs/2.4/misc/password_encryptions.html
*
*
* random_compat is required if you are using PHP < 7.0.
@koseki
koseki / DateTime.js
Last active Jun 19, 2017
Timezone / Daylight Saving Time aware JavaScript class
View DateTime.js
/**
* var d = new DateTime(2017, 3, 21, 19, 0, 0, 'JST');
* d.setTimezone('PST');
* console.log(d.format());
*/
var DateTime = (function () {
// Constructor
var DateTime = function(year, month, date, hour, min, sec, tz) {
month = month - 1;
@koseki
koseki / sat5000-google20k-plot.rb
Created Jul 17, 2016
Plot sat 5000 words frequency rank
View sat5000-google20k-plot.rb
#! /usr/bin/env ruby
require 'open-uri'
unless File.exist?('sat5000.html')
open('http://www.freevocabulary.com/') do |io|
open('sat5000.html', 'w') do |out|
out.puts(io.read)
end
end