Skip to content

Instantly share code, notes, and snippets.

@KMConner
KMConner / raspberry-pi-take-pictures
Created October 24, 2020 14:42
Take pictures using raspberry pi camera
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1024)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
ret, frame = cap.read()
print(ret)
cv2.imwrite('./foo.jpg', frame)
## requirements
@KMConner
KMConner / auto_transaction.lua
Created April 15, 2020 22:16
When a specified source is shown, the specifed scene will appear within the specied duration.
obs = obslua
showing_slide = false
slide_name_from = ""
slide_name_to = ""
duration_ms = 1000000
function scene_active_from_name(name)
local sceneSources = obs.obs_enum_sources()
local ret = false
for _, sceneSource in ipairs(sceneSources) do
@KMConner
KMConner / ip_country.py
Created May 24, 2019 10:37
Determine whether the specified IP address (both v4 and v6) is allocated or assigned to Japan
from urllib import request
from http.client import HTTPResponse
from typing import Iterable, Tuple, List
from ipaddress import IPv4Address, IPv6Address
import ipaddress
ALLOCATION_URL = 'https://ftp.apnic.net/stats/apnic/delegated-apnic-latest'
COUNTRY_CODE = 'JP'
@KMConner
KMConner / updateMydns.ps1
Created April 6, 2019 04:52
Update mydns.jp address information using powershell
Param(
[Parameter(Mandatory = $true)]
[String] $UserName,
[Parameter(Mandatory = $true)]
[String] $Password
)
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($UserName + ":" + $Password))
trigger:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
Register-ArgumentCompleter -Native -CommandName git -ScriptBlock {
param([string]$commandName, [string]$wordToComplete, [int]$cursorPosition)
function MatchOnly([string] $cmd, [string[]]$candidate){
$ret = $candidate -like "$cmd*"
if ($ret.Length -eq 0) {
return [System.String]::Empty
} elseif ($ret.Length -eq 1) {
return [System.Management.Automation.CompletionResult]::new($ret[0] + " ")
import requests
import sys
import os
import zipfile
import json
from typing import List
import time
from requests.auth import HTTPDigestAuth
ZIP_FILE_NAME = 'submitData.zip'
@KMConner
KMConner / ZaifDownloader.py
Created November 3, 2017 01:56
Downloads bitcoin chart history from waif.jp
"""
With this script, we can download BitCoin chart history from zaif.
"""
import time
import requests
import json
ONE_MONTH_SECONDS = 3600 * 24 * 30
@KMConner
KMConner / OCaml Memo.md
Last active November 6, 2017 04:33
OCaml に関するメモ

Install

Windows

なんか色々ややこしい...

Bash on Ubuntu on Windows なら簡単