Skip to content

Instantly share code, notes, and snippets.

View moriyoshi's full-sized avatar
😎
I do what to do.

Moriyoshi Koizumi moriyoshi

😎
I do what to do.
View GitHub Profile
@moriyoshi
moriyoshi / openssh-lpk.schema.ldif
Created February 4, 2018 05:08
Add SSH LDAP Public Key schema to Active Directory
dn: CN=sshPublicKey,CN=Schema,CN=Configuration,DC=testing,DC=example,DC=com
changetype: add
cn: sshPublicKey
name: sshPublicKey
lDAPDisplayName: sshPublicKey
adminDisplayName: sshPublicKey
objectClass: attributeSchema
attributeID: 1.3.6.1.4.1.24552.500.1.1.1.13
attributeSyntax: 2.5.5.10
schemaIDGUID:: +jduGq6aTj+LLL7JZhfWpw==

この記事はpyspa advent calendar 2020の18日目の記事です。前日は、flagboyの配られたカードで勝負するでした。主旨は異なりますが、徒然草百十段の「双六の名人」が思い出されました。明日はYutaka Matsubara a.k.a. mopemopeさんの記事となります。お楽しみに。

1ヶ月で10,000行くらいのコードを書いた話

行数を書くと「いやいや、私はもっと高い生産性を持っている」、という方は少なくないだろう。登大遊氏に至っては、ネットワークプログラミングという複雑な領域での実装でありながら「1日に少なくとも3,000行程度、多く書くときで10,000行」と述べており、凡才さを思い知らされる。

さて、この記事は、私のような動物でも高効率にコードを書くために何をしたのかを備忘として残しておく主旨である。

開発環境編

@moriyoshi
moriyoshi / xpproductkey.py
Created September 8, 2019 22:04
Recover a XP product key from the registry
import math
# HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId
# offset from 28 (0x1c) to 43 (0x2b)
b = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
digits = "BCDFGHJKMPQRTVWXY2346789"
def base24(b):
v = sum((256 ** i) * c for i, c in enumerate(b))
{
"argv": [
"spark-launch-ipykernel",
"-f",
"{connection_file}"
],
"display_name": "Python 3 (ipykernel)",
"language": "python",
"metadata": {
"debugger": true
console.log('%c ', unescape(escape('👤👩👳👰👬👡👹😺👩👮👬👩👮👥😭👢👬👯👣👫😻👢👡👣👫👧👲👯👵👮👤😺😣👦👦👦😠👵👲👬😨👤👡👴👡😺👩👭👡👧👥😯👳👶👧😫👸👭👬😻👢👡👳👥😶😴😬👐🙈🙎😲👚👹🙂😲👚👘🙊👺👡👗😹👵👐👓🙉👸🙌👪🙅👩🙉🙈👚👰👚👘👤🙃👢😳👧😹🙉👪👕👵🙎🙃🙁😱🙌👪👑👧🙍👔🙉😰🙉🙄🙍👷🙉👩🙂😴👢👗👸👵👣👺😰👩👡🙈👒😰👣🙄👯👶🙌😳👤😳👤👹😵😳🙍👹😵👶👣👭👣👶🙍👪🙁👷🙍🙃😹👺👤👭👣👩👐👪👸👷👙👘👒👯🙉🙇👑😹🙉👫😰👸🙎👹🙁😱🙌👪👒👪🙌👓😴👸🙎👩🙁👸🙌👓😴👺🙎👩🙁👹🙌👓😴😱🙏👓🙁👺👣👹😰👵🙎👓🙁👸🙌👪👧👴🙌👪👣😴🙉🙄🙉👵🙎👭👧👸🙎👘👙😱🙌👪👚👯🙌👔👕👵🙎👗🙅👹🙍👩🙁👹🙍👩🙁👷🙉🙄🙁👸🙌👔🙉👵🙎👓🙁😴🙌👪👕👧🙍👔👫👧🙍👔👫👧🙍🙃🙁👷🙍👓😰😰🙌👪🙍👧🙎👓😴😰🙉🙄🙉😲🙉🙄🙉😲🙉🙄🙁👧🙍🙄🙅👴🙎🙃😴😱🙉🙄🙍👧🙍👪🙅👧🙍👪🙅👧🙍🙃🙁👷🙍👓😰👺🙌👪👕👧🙍👓😴😱🙉🙄👫👵🙏🙃🙁😵🙌👪👧👧🙍🙃🙁👷🙍👓😰👸🙌👪👑👵🙍👺👤😲🙌👔👕👵🙎😲🙅😳🙌👪👙👧🙎👹😴😲🙉🙄🙁👧🙍🙄🙁👸🙌👪👑👴🙌👪👑😱🙉🙄🙅😱🙉🙄🙅😱🙉🙄🙁👧🙍🙄🙁😲🙌👪👫👴🙎👓😴😴🙉🙄🙅😳🙉🙄🙅😳🙉🙄🙁👧🙍🙄🙁👹🙌👪🙍👴🙎👩😴😵👡🙃😰😱🙌👪👬👨🙍👪🙅👧🙍👪🙅👧🙍🙃🙁👷🙍👓😰👺🙌👪👕👧🙎🙃😴😳🙉🙄🙉👷🙉🙄🙉👷🙉🙄🙁👧🙍🙄🙅👴🙍👹🙁👹🙌👪👕👧🙍👔🙅👧🙍👔🙅👧🙍🙃🙁👷🙍👓😰👸🙌👪🙉👵🙎👺👚😲🙌👔👙👵🙎🙇🙅😰🙉🙄👑👧🙍🙃🙁👷🙍🙃😴😳🙏🙃😰👵🙎👪👑👧🙏👓😴😵🙉🙄👫👵🙏👓🙁👷🙉🙄🙁👷🙍👓😴😲🙌👔🙉👵🙍👩🙁👺🙍🙃🙁👺🙍🙃🙁👷🙉🙄🙁👷🙍👓😴😵🙌👔🙍👵🙏👓🙁👹🙎👓🙁👹🙎👓🙁👷🙉🙄🙁👷🙍👓😴😲🙌👔👕👵🙏👘👯👧👔👔🙍😵🙉🙄👣👵🙎🙇🙅😱🙌👪👫👧🙎👓😴😵🙉🙄🙁👧🙍🙄🙁👴🙎👩🙁😱🙌👪👨👪🙍🙃🙁😰🙌👪🙍👧🙎👓😴😱🙉🙄👫👵🙎🙃🙁😱🙌👪👧👧🙏👓😴😲👙👓😴👺🙍👓😴👺🙍👓🙁👷🙉🙄🙁👷🙌👪🙉😱🙌👪🙁😴🙌👪🙍👺🙌👪🙍👺🙉🙄🙁👧🙍🙄🙁👵🙍👪🙍👴🙌👪🙁😵👙👹😴👹🙎🙃😰👵🙍👪🙅👧🙎👓😴😴🙌👔👕👵🙍👹🙁😱🙌👪👧👴🙏👓😴😲👙👔👕👵🙏👓🙁😱🙌👪👫👧🙍🙃🙁👷🙍🙃😰😲🙌👔👕👵🙏🙇😰👷🙉🙄👫👵🙍👗🙅👺🙌👪🙉👧🙍👹😴👹🙉🙄🙁👧🙍👔🙅👺🙌👪🙍👴🙍👹😴👹🙉🙄🙍👵🙍👹🙁👺🙌👪🙍👧🙍🙃🙁👷🙍👓😰👺🙌👪🙍👧🙍👹😴👺🙉🙅😰😱🙏🙃🙁👸🙍😲🙍👴🙍👓😴👹🙉🙄👕👵🙎👹😰👹🙌👪🙍👧🙏🙃😴😱🙌👔👑👵🙎👩🙁👸🙍👭🙅👹🙎👹🙁👹🙎👹🙁👷🙉🙄🙁👸🙌👔👙👵🙍👓🙁😲🙌👪🙉👧🙍👪🙍👧🙍👪🙍👧🙍🙃🙁👷🙍👓😰😲🙉🙄🙍👵🙍👓🙁👹🙍👩🙁👹🙍👩🙁👷🙉🙄🙁👸🙌👔👑👵🙎
#include <stdio.h>
#include <AudioUnit/AudioUnit.h>
#include <CoreAudio/CoreAudio.h>
#include <unistd.h>
#include <stdint.h>
typedef struct {
AudioComponentInstance unit;
AudioStreamBasicDescription desc;
AudioBufferList *buffer;
@moriyoshi
moriyoshi / gist:2417847
Created April 19, 2012 02:01
ツンパァードラグーン / ゲーム説明: あなたはパンティーが降ってきてドラゴンが襲ってくる空間に閉じ込められました。↑キーでジャンプしてドラゴンを避けながら←→キーで移動し素早くパンティーをゲットしてください。
javascript:(function(d,rd,im,w,h,xx,yy,l,s,f,r,j,t,dg,pt){im.src="data:image/gif;base64,R0lGODlh2AEIAIABAAAAAP///yH5BAEKAAEALAAAAADYAQgAAAL+jI+py+0PYopA0SlD1Wjv11xYR31lZojnp6lrKsIxSNf2Eb+4m59yubugJLrRsILaKY8/j6/ZNPWAraW0CsNWM9zizbJifWmzltiMuY7GuGxQ6Yb/4qT11hRPsvc2ohPehRVoV1eopVc3iCjk98f0eAVJlySZBYnkRyfzFcYxwVdz5mmxIEVZ1qemuSl3F7VaqJInClprl2l5VmnYOtubiPnbCYTrmmuFXMqymxlspiiGCuKRMkptG6JLuxjZPcbUSzUnKNpYdooujY196QJmNeWO1gmbewrmM+x9zM9zL9doXpEZ4lhx+oRn1DpCHBBpsfTqmUMH4CapM4eqWEWoTwXrLQSlL5mhYsL2HaJ1p8e7YOZOSnTE6KIqlxKjOCEYbSKZNhyvfeTF890nmy9RZqs2Us9GciI3Lsv58yezP8YGAXWjcaYkeUnJOTMWCyZVmr4MxhSoVWeoIVijDu2gMGibmy+8rH1KTMeTpPGepjmi1u23bgWp7A2pjBG8vlgxZqX5xCExr1DCdfTLj2xRdmcFT5L70FrPNKE9mz6NOrXq1axbgyoAADs=";yy=h-8;im.onload=function(n,c,di,k,z){n=d.createElement("canvas");n.width=w;n.height=h;n.setAttribute("style","background-color:#ffe;width:512px;height:512px;position:absolute;left:0;top:0");d.body.appendChild(n);d.onkeydown=function(e){k=e.which;return false};d.onkeyup=function(e){k=0};c=n.getContext("2d");funct
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/kvm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
@moriyoshi
moriyoshi / magic.py
Created May 6, 2020 16:50
CPython bytecode instrumentation (convert ordinary methods to async methods)
import bisect
import opcode
import dis
import inspect
import sys
import types
from collections import defaultdict
import httpx
@moriyoshi
moriyoshi / magic.py
Created May 6, 2020 16:49
CPython bytecode instrumentation (convert ordinary methods to async methods)
import bisect
import opcode
import dis
import inspect
import sys
import types
from collections import defaultdict
import httpx