Skip to content

Instantly share code, notes, and snippets.

View mochipon's full-sized avatar
🏠
Working from home

Masaki Tagawa mochipon

🏠
Working from home
View GitHub Profile
@mochipon
mochipon / dump-inventory-by-cli.py
Created November 1, 2022 05:47
コマンドランナーを使って show inventory を実行して結果を CSV っぽく出力するやつ
import json
import time
# `pip install dnacentersdk xmltodict` is needed
from dnacentersdk import api
import xmltodict
# Create a DNACenterAPI connection object
dnac = api.DNACenterAPI(
username="username",
@mochipon
mochipon / lambda_function.py
Created December 9, 2021 14:22
Open Sesame with Cisco Meraki
"""
This function handles incoming webhooks from Meraki and lock the door with a smart lock.
The following environment variables must be set:
kmsEncryptedSesameApiKey - SESAME API key (KMS encrypted)
kmsEncryptedSesameSecret - SESAME device secret (KMS encrypted)
kmsEncryptedMerakiSharedSecret - Meraki shared secret for webhooks (KMS encrypted)
sesameUuid - SESAME device UUID (plain)
"""
@mochipon
mochipon / keynote.scpt
Created June 24, 2021 00:53 — forked from lambdamusic/keynote.scpt
Apple Keynote: export presenter notes
-- HOWTO:
-- after saving it, open with Script Editor (default) and run it
-- PREREQUISITES:
-- make sure your Keynote presentation is open in the background
-- AFTER EXPORT:
-- if you can't open the file due to encoding errors, open with Sublime (or another a text editor) and then "File / Save with encoding / UTF8"
tell application "Keynote"
@mochipon
mochipon / LICENSE
Created March 8, 2021 02:42
Link-State Tracking now comes back with EEM
CISCO SAMPLE CODE LICENSE
Version 1.1
Copyright (c) 2018 Cisco and/or its affiliates
These terms govern this Cisco Systems, Inc. ("Cisco"), example or demo
source code and its associated documentation (together, the "Sample
Code"). By downloading, copying, modifying, compiling, or redistributing
the Sample Code, you accept and agree to be bound by the following terms
and conditions (the "License"). If you are accepting the License on
behalf of an entity, you represent that you have the authority to do so
@mochipon
mochipon / README.md
Last active December 13, 2019 21:55
Winter illumination meets NETCONF/YANG

How to use

$ git clone https://gist.github.com/0fa4719f25ba5710bf6300cd72b57aff.git illumination
$ cd illumination
$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements.txt
$ python main.py -u username hostname.example.com GigabitEthernet1
@mochipon
mochipon / README.md
Last active May 14, 2020 12:44
マネーフォワードの家計簿にて Kyash クレジットカードチャージ (振替) に関する重複を排除する

これはなに

マネーフォワードで Kyashそのチャージ元 クレジットカード を連携させているときに多発する問題を解決するスクリプト。

Kyash でクレジットカードチャージをしたとき、マネーフォワードがその履歴を Kyash, クレジットカードそれぞれから取得できるタイミングが違う(Kyash は即時取得できるが、クレジットカードは大抵遅い)。そのため、2 つの履歴(振替)を関連付けることができずに、家計簿上で 2 つの項目として表示されることになる。

image

このスクリプトは、一旦 2 つの履歴について振替の解除を行い、改めて 2 つの入出金記録を関連付けながら振替として設定する。

@mochipon
mochipon / main.py
Created June 27, 2019 06:59
無線 LAN 設定のためのカスタムインターフェイス (Catalyst9800 with NETCONF/YANG)
from jinja2 import Environment, FileSystemLoader
from ncclient import manager
from flask import Flask, jsonify, render_template, request
import xmltodict
app = Flask(__name__)
host = '<ipaddress or fqdn>'
username = '<username>'
password = '<password>'
@mochipon
mochipon / README.md
Last active January 16, 2023 04:56
大量に手に入れた nanaco ギフトを一瞬でアカウントに登録する

Usage

同じディレクトリに list.txt を作ってギフト券情報を保存する

$ cat list.txt
LpJ4FAOf0OZUJDK4
 [管理番号:NAN190516Z123456]
 https://www.nanaco-net.jp/pc/emServlet?gid=LpJ4FAOf0OZUJDK4
@mochipon
mochipon / README.md
Last active June 12, 2019 05:34
DevNet & Programmability テクニカル セッション 2019

これはなに

あるユーザに送信したダイレクトメッセージを過去○日分一気に削除するスクリプト(デフォルトで 14 日間)

つかいかた

$ virtualenv -p python3 v
$ . v/bin/activate
$ pip install requests.txt