Skip to content

Instantly share code, notes, and snippets.

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

wktk

🏠
Working from home
View GitHub Profile
@wktk
wktk / humanity-solver.user.js
Last active December 21, 2023 08:04
はてラボ人間性センター自動入力
// ==UserScript==
// @name Humanity Solver
// @version 1
// @grant none
// @include http://human.hatelabo.jp/quiz?*
// @include https://human.hatelabo.jp/quiz?*
// ==/UserScript==
// 下記URLを参考に過不足分を補正したもの
// https://web.archive.org/web/20210104141218/https://anond.hatelabo.jp/20210104230501
#include "Keyboard.h"
void setup() {
Keyboard.begin();
delay(2000);
Keyboard.print("pi\n");
delay(2000);
Keyboard.print("raspberry\n");
delay(2000);
Keyboard.print("sudo reboot now\n");
@wktk
wktk / listtls.sh
Last active February 17, 2020 03:50
Test TLS 1.0, 1.1, 1.2 connection
# brew install coreutils
function listtls() {
timeout 3 openssl s_client -connect "$1:443" -servername "$1" -tls1 < /dev/null > /dev/null 2>&1 && echo -n 1 || echo -n 0
timeout 3 openssl s_client -connect "$1:443" -servername "$1" -tls1_1 < /dev/null > /dev/null 2>&1 && echo -n 1 || echo -n 0
timeout 3 openssl s_client -connect "$1:443" -servername "$1" -tls1_2 < /dev/null > /dev/null 2>&1 && echo -n 1 || echo -n 0
# timeout 3 openssl s_client -connect example.com:443 -tls1_3 < /dev/null > /dev/null 2>&1 && echo -n 1 || echo -n 0
echo ", $1"
}
@wktk
wktk / main.go
Last active October 2, 2019 02:42
WHOIS Server in Golang
package main
import (
"bufio"
"log"
"net"
"strings"
)
func main() {
@wktk
wktk / slack_verify_request.js
Last active March 12, 2020 05:31
Verify Slack signature with Node.js (on Lambda)
const crypto = require('crypto');
const verifySlackSignature = (event) => {
const rawString = `v0:${event.headers['X-Slack-Request-Timestamp']}:${event.body}`;
const hmac = crypto.createHmac('sha256', process.env['SLACK_SIGNING_SECRET']);
return `v0=${hmac.update(rawString).digest('hex')}` === event.headers['X-Slack-Signature'];
};
@wktk
wktk / index.js
Last active August 23, 2018 06:02
Add CORS headers to HTTP responces with AWS Lambda for API Gateway
const axios = require('axios');
exports.handler = async (event) => {
const response = await axios.get(process.env.ENDPOINT_URL, { params: event.queryStringParameters });
return { statusCode: 200, headers: { "access-control-allow-origin": "*" }, body: JSON.stringify(response.data) };
};
@wktk
wktk / say.rb
Created July 13, 2018 14:48
Web UI to call the `say` command on Mac
require 'rack'
voices = `say -v ?`.each_line.map { |l| l.gsub(/ #.*/, '').split(/\s{2,}/) }.to_h
html = DATA.read.sub(
'{VOICES}',
voices.map { |k, v| "<option value='#{k}'>#{k} (#{v})</option>" }.join
)
app = -> (env) do
params = URI.decode_www_form(env['rack.input'].read).to_h
@wktk
wktk / dirtycop
Last active April 12, 2018 07:02 — forked from MaxLap/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@wktk
wktk / shinsei_bank_helper.user.js
Last active January 29, 2018 20:47
shinsei_bank_helper.user.js
// ==UserScript==
// @name Shinsei Bank Helper
// @description Disables Security-keyboard for use with password managers
// @namespace https://gist.github.com/wktk/f70a90ecfd8b73a734b8153271cec2bf
// @match https://*.shinseibank.com/FLEXCUBEAt/LiveConnect.dll*
// @version 1
// @grant none
// ==/UserScript==
(() => {
@wktk
wktk / output.txt
Created June 16, 2017 17:51
ruby libusb segv
/Users/user/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/libusb-0.6.2/lib/libusb/dev_handle.rb:47: [BUG] Segmentation fault at 0x00000000000000
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.