Skip to content

Instantly share code, notes, and snippets.

View watahani's full-sized avatar

WataruHaniyama watahani

  • Microsoft
  • Japan
View GitHub Profile
@watahani
watahani / mailToArchive.gs
Last active February 23, 2018 04:00
mail labeled move to archive for gmail
var labels = PropertiesService.getScriptProperties().getProperty('GMAIL_ARCHIVE_LABELS');
function mail_to_archive() {
var labellist = labels.split(',');
labellist.forEach(
function to_archive(value) {
if (value) {
var label = GmailApp.getUserLabelByName(value);
if (label == null) {
GmailApp.createLabel(value);
apt-get update
apt-get install -y libcurl3 opensc
curl https://developers.yubico.com/YubiHSM2/Releases/yubihsm2-sdk-1.0.1-ubuntu1604-amd64.tar.gz | tar zx -C ./
dpkg -i yubihsm2-sdk/libyubihsm1_1.0.1-1_amd64.deb
dpkg -i yubihsm2-sdk/libyubihsm-dev_1.0.1-1_amd64.deb
dpkg -i yubihsm2-sdk/yubihsm-connector_1.0.1-1_amd64.deb
dpkg -i yubihsm2-sdk/yubihsm-shell_1.0.1-1_amd64.deb
dpkg -i yubihsm2-sdk/yhwrap_1.0.1-1_amd64.deb
dpkg -i yubihsm2-sdk/yubihsm-pkcs11_1.0.1-1_amd64.deb
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing/>
<settings pass="windowsPE">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing/>
<settings pass="windowsPE">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
# The MIT License (MIT)
# Copyright (c) 2018 haniyama_wataru@sgk.jp
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
import os
from mkdocs.config.base import load_config
"""
mkdocs.yml から存在しないページを作成するヘルパー関数です。
usages:
> python make_pages.py
or
@watahani
watahani / verifySafetyNetAttestation.js
Last active December 4, 2020 09:18
verify SafetyNet Attestation
const base64url = require("base64url")
const cbor = require('cbor')
const crypto = require('crypto')
const jsrsasign = require('jsrsasign')
//sample attestation ;)
const attestationResponse = {
"attestationObject": "o2NmbXRxYW5kcm9pZC1zYWZldHluZXRnYXR0U3RtdKJjdmVyaDE0MzY2MDE5aHJlc3BvbnNlWRS9ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbmcxWXlJNld5Sk5TVWxHYTJwRFEwSkljV2RCZDBsQ1FXZEpVVkpZY205T01GcFBaRkpyUWtGQlFVRkJRVkIxYm5wQlRrSm5hM0ZvYTJsSE9YY3dRa0ZSYzBaQlJFSkRUVkZ6ZDBOUldVUldVVkZIUlhkS1ZsVjZSV1ZOUW5kSFFURlZSVU5vVFZaU01qbDJXako0YkVsR1VubGtXRTR3U1VaT2JHTnVXbkJaTWxaNlRWSk5kMFZSV1VSV1VWRkVSWGR3U0ZaR1RXZFJNRVZuVFZVNGVFMUNORmhFVkVVMFRWUkJlRTFFUVROTlZHc3dUbFp2V0VSVVJUVk5WRUYzVDFSQk0wMVVhekJPVm05M1lrUkZURTFCYTBkQk1WVkZRbWhOUTFaV1RYaEZla0ZTUW1kT1ZrSkJaMVJEYTA1b1lrZHNiV0l6U25WaFYwVjRSbXBCVlVKblRsWkNRV05VUkZVeGRtUlhOVEJaVjJ4MVNVWmFjRnBZWTNoRmVrRlNRbWRPVmtKQmIxUkRhMlIyWWpKa2MxcFRRazFVUlUxNFIzcEJXa0puVGxaQ1FVMVVSVzFHTUdSSFZucGtRelZvWW0xU2VXSXliR3RNYlU1MllsUkRRMEZUU1hkRVVWbEtTMjlhU1doMlkwNUJVVVZDUWxGQlJHZG5SVkJCUkVORFFWRnZRMmRuUlVKQl
#!/usr/bin/env python
'''
put this file to "/etc/mackerel-agent/check-gitlab-version.py"
and add /etc/mackerel-agent/mackerel-agent.conf
if env not set, hostname is got from hostname command
[plugin.checks.gitlab_version]
command = "python /etc/mackerel-agent/check-gitlab-version.py"
env = { HOST = "https://your.gitlab.host" }
# String To Base64
function Encode-Base64 {
[OutputType([String])]
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True)]
[String]$plainText
)
process {
$byte = ([System.Text.Encoding]::Default).GetBytes($plainText)
$b64enc = [Convert]::ToBase64String($byte)
# iex (New-Object System.Net.WebClient).downloadString("https://gist.githubusercontent.com/watahani/c54377a3b84fe965b439583e845f9766/raw/278e68045b487e0f85adb30740278074ba2a44fd/Setup-AzureVM.ps1")
# [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Set-ExecutionPolicy RemoteSigned
$runReg = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$runRegKeyName = "azureVMSetup"
function Disable-Services {