See demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
test $# != 1 && cat <<USAGE && exit 1 | |
Usage: $0 MAIL_ID | |
== Output Example == | |
[ | |
{ | |
"datime": "20190520195647", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/expect -f | |
set timeout 60 | |
log_file -noappend $env(HOME)/log/ptt.log | |
spawn telnet ptt.cc | |
expect "new" | |
send "$env(PTT_ID)\r" | |
expect ":" | |
send "$env(PTT_PWD)\r" | |
expect { | |
"您想刪除其他重複登入的連線嗎" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2019 Weihang Jian <tonytonyjan@gmail.com> | |
export default async (src, dest) => { | |
const exif = await retrieveExif(src); | |
return new Blob([dest.slice(0, 2), exif, dest.slice(2)], { | |
type: "image/jpeg" | |
}); | |
}; | |
export const SOS = 0xffda, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function read_file(path) | |
local file, errorMessage = io.open(path, "rb") | |
if not file then | |
error("Could not read the file:" .. errorMessage .. "\n") | |
end | |
local content = file:read "*all" | |
file:close() | |
return content | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Copyright (c) 2022 Weihang Jian <https://tonytonyjan.net> | |
# | |
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cgi' | |
require 'json' | |
require 'active_support' | |
def verify_and_decrypt_session_cookie(cookie, secret_key_base) | |
cookie = CGI::unescape(cookie) | |
salt = 'encrypted cookie' | |
signed_salt = 'signed encrypted cookie' | |
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000) | |
secret = key_generator.generate_key(salt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Copyright (c) 2022 Weihang Jian <https://tonytonyjan.net> | |
# | |
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2020 Jian Weihang <tonytonyjan@gmail.com> | |
# frozen_string_literal: true | |
module Rfc2047 | |
TOKEN = /[\041\043-\047\052\053\055\060-\071\101-\132\134\136\137\141-\176]+/.freeze | |
ENCODED_TEXT = /[\041-\076\100-\176]*/.freeze | |
ENCODED_WORD = /=\?(?<charset>#{TOKEN})\?(?<encoding>[QBqb])\?(?<encoded_text>#{ENCODED_TEXT})\?=/.freeze | |
ENCODED_WORD_SEQUENCE = /#{ENCODED_WORD}(?:\s*#{ENCODED_WORD})*/.freeze | |
class << self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'id_check' | |
require 'taiwanese_id_builder' | |
require 'TaiwanUserID' | |
n = 100000 | |
Benchmark.bmbm do |x| | |
x.report('wayne5540 '){ n.times{ TaiwaneseIdBuilder.valid?('A123456789') } } | |
dummy = Object.new.extend(TaiwanUserID) | |
x.report('kaochenlong'){ n.times{ dummy.is_valid?('A123456789') } } |
NewerOlder