Skip to content

Instantly share code, notes, and snippets.

@imksoo
imksoo / deployAzureMonitorAgentLinuxVM.json
Created March 24, 2024 14:20
Configure Linux virtual machines to run Azure Monitor Agent with user-assigned managed identity-based authentication
{
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
@imksoo
imksoo / getBatteryStatus.js
Created October 3, 2023 12:55
ニチコンの家庭用蓄電池からEchonet Lite経由で充電残量を取得するJavascriptコード
const EchonetLite = require('node-echonet-lite');
const el = new EchonetLite({ type: 'lan' });
el.init((err) => {
if (err) {
console.log(err);
process.exit(1);
} else {
getBatteryStatus(el);
}
@imksoo
imksoo / nostr-sync.ts
Last active July 10, 2023 05:43
A script to copy all events between Nostr relays
import "websocket-polyfill";
import 'dotenv/config';
import * as Nostr from "nostr-tools";
import { RelayPool } from "nostr-relaypool";
import { NostrFetcher } from "nostr-fetch";
const SECKEY = process.env.SECKEY || "";
if (!process.env.SECKEY) {
console.error("秘密鍵を環境変数か.envファイルにSECKEYとして定義してください")
process.exit(1);
const fetch_count = 16;
const srcRelay = 'ws://localhost:8080'
const dstRelay = 'ws://localhost:8888'
let srcSocket;
let dstSocket;
let until = (new Date()) / 1000;
if (typeof (WebSocket) === 'undefined') {
const WebSocket = require('websocket').w3cwebsocket
srcSocket = new WebSocket(srcRelay)

Keybase proof

I hereby claim:

  • I am imksoo on github.
  • I am imksoo (https://keybase.io/imksoo) on keybase.
  • I have a public key ASAkvvFy6mc7Xxso8nAjuIUJllIvVqXUcO-JSOC9s4Vf7wo

To claim this, I am signing this object:

@imksoo
imksoo / copyNostrNotes.js
Created February 27, 2023 06:03
Script to duplicate past events(kind1) between relay servers
const srcRelay = 'wss://relay.snort.social'
const dstRelay = 'wss://relay-jp.nostr.wirednet.jp'
const authors = ['634bd19e5c87db216555c814bf88e66ace175805291a6be90b15ac3b2247da9b']
let srcSocket
let dstSocket
if (typeof (WebSocket) === 'undefined') {
const WebSocket = require('websocket').w3cwebsocket
srcSocket = new WebSocket(srcRelay)
dstSocket = new WebSocket(dstRelay)
@imksoo
imksoo / nostr_history.js
Last active March 16, 2023 05:40
Nostrのリレーから過去ログをあさってくるnode.js
const relay = 'wss://relay-jp.nostr.wirednet.jp'
const authors = ['634bd19e5c87db216555c814bf88e66ace175805291a6be90b15ac3b2247da9b']
function history (until = Math.floor(new Date() / 1000)) {
let socket
if (typeof (WebSocket) === 'undefined') {
const WebSocket = require('websocket').w3cwebsocket
socket = new WebSocket(relay)
} else {
socket = new WebSocket(relay)
@imksoo
imksoo / setup_hyper-v_host_guardian_service.md
Created April 8, 2022 23:16
Hyper-VでHost Guardian Service (HGS)をセットアップするメモ

Hyper-VでHost Guardian Service (HGS)をセットアップするメモ

自己署名証明書の作成

$certificatePassword = Read-Host -AsSecureString -Prompt 'Enter a password for the PFX file'

$signCert = New-SelfSignedCertificate -Subject 'CN=HGS Signing Certificate' -KeyUsage DataEncipherment, DigitalSignature Export-PfxCertificate -FilePath '.\signCert.pfx' -Password $certificatePassword -Cert $signCert

Remove the certificate from "Personal" container

Remove-Item $signCert.PSPath

@imksoo
imksoo / install_archlinux_on_hyper-v.md
Last active March 9, 2022 20:30
Arch LinuxをHyper-Vの仮想マシンに入れたときのメモ
@imksoo
imksoo / aws_security_group_with_port_range.tf
Created September 5, 2020 23:03
TerraformでAWS上のSecurity Groupを作るときにポート範囲付きでリスト化してサクッと作る
module "security_group_rules_with_port_range" {
source = "./modules/security_group_rules"
security_group_id = "sg-XXXXXXXX"
description = "Windows Active Directory ports"
type = "ingress"
self = true
rules = [
# DNS
{ protocol = "udp", port = "53" },
{ protocol = "tcp", port = "53" },