Skip to content

Instantly share code, notes, and snippets.

View waaaaRapy's full-sized avatar

waaaaRapy

  • Osaka, Japan
View GitHub Profile
@waaaaRapy
waaaaRapy / totp.js
Last active November 10, 2023 03:28
Time-Based One-Time Password Generator (RFC6238)
// work on node v10.15.3
const DIGIT = 6;
const TIME_STEP = 30;
/**
* Calculate TOTP value defined in [RFC6238](https://tools.ietf.org/html/rfc6238)
*
* @param {Buffer} key shared secret between client and server
* @param {Date} date date to calculate totp value.
@waaaaRapy
waaaaRapy / chunked.lua
Created September 23, 2016 21:47
Toshiba FlashAir Lua -- send large binary response using chunked transfer
print([[
HTTP/1.1 200 OK
Content-Type: image/jpeg
Transfer-Encoding: chunked
]])
IMG = "/img.jpg"
chunk_size = 8192
size = lfs.attributes(IMG).size
@waaaaRapy
waaaaRapy / dd.html
Created June 6, 2016 10:00
hugo definition-list shortcode
{{ $str := print .Inner }}
{{ $str := replace $str "<ul>" "<dl>"}}
{{ $str := replace $str "</ul>" "</dl>"}}
{{ $str := replace $str "<ol>\n<li>" "<dd>" }}
{{ $str := replace $str "</li>\n</ol>" "</dd>" }}
{{ $str := replace $str "<li>" "<dt>" }}
{{ $str := replace $str "</li>" "</dt>" }}
{{ markdownify $str }}
@waaaaRapy
waaaaRapy / flickr.html
Created June 2, 2016 17:14
hugo flickr shortcodes
{{$api_key := "&api_key=[YOUR API KEY]"}}
{{$user := or (.Get "user") "[YOUR USER NAME]"}}
{{$api_url := "https://api.flickr.com/services/rest/?format=json&nojsoncallback=1"}}
{{$size := (getJSON $api_url "&method=flickr.photos.getSizes" $api_key "&photo_id=" (.Get "id")).sizes.size}}
{{$title := .Get "title"}}
{{$width := .Get "width"}}
{{$height:= .Get "height"}}
@waaaaRapy
waaaaRapy / sudo.vbs
Last active May 21, 2016 16:13
sudo on windows using WScript.ShellExecute
Option Explicit
If WScript.Arguments.Count = 0 Then
WScript.Echo "Usage: sudo program [arg1 arg2 ...]" & vbCrLf & _
"Run `program` with paramators as root in new console window"
Else
Dim ShellApp, WshShell
Dim cmd, varg, i
Set WshShell = CreateObject("WScript.Shell")
cmd = WshShell.ExpandEnvironmentStrings("%COMSPEC%")
'Build paramator