Skip to content

Instantly share code, notes, and snippets.

View asika32764's full-sized avatar

Simon Asika asika32764

View GitHub Profile
@asika32764
asika32764 / spinner.rb
Created June 24, 2016 01:01 — forked from ellemenno/spinner.rb
ascii spinner
#!/usr/bin/env ruby
# encoding: UTF-8
@dot_cycle = ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']
#braille random: 0x2800 - 0x28ff
@z_arrow = ['←','↖','↑','↗','→','↘','↓','↙']
@z_b = ['b','ᓂ','q','ᓄ']
@z_d = ['d','ᓇ','p','ᓀ']
@asika32764
asika32764 / mini_google_authenticator.php
Created April 22, 2022 10:30 — forked from Cojad/mini_google_authenticator.php
Very small implementation of Google's OTP Authenticator
<?php
// copied from python code at https://stackoverflow.com/a/23221582/3103058
function base32_decode($key) {
// https://www.php.net/manual/en/function.base-convert.php#122221
$key = strtoupper($key);
list($t, $b, $r) = array("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "", "");
foreach(str_split($key) as $c)
$b = $b . sprintf("%05b", strpos($t, $c));
foreach(str_split($b, 8) as $c)
$r = $r . chr(bindec($c));
@asika32764
asika32764 / github-oauth2-client.php
Last active January 28, 2024 19:44
Simple PHP example of using Github's OAuth 2 API. (Please see comments for PHP 8.1 later and latest API version.)
<?php
define('OAUTH2_CLIENT_ID', '');
define('OAUTH2_CLIENT_SECRET', '');
$authorizeURL = 'https://github.com/login/oauth/authorize';
$tokenURL = 'https://github.com/login/oauth/access_token';
$apiURLBase = 'https://api.github.com/';
session_start();
@asika32764
asika32764 / dbExport.java
Created December 3, 2023 10:32 — forked from frontrangerider2004/dbExport.java
Export all SQLite database files from your Android Application's private data directory to the SD Card
public static void exportAllDatabases(final Context context) {
Log.d(LOG_TAG, "exportAllDatabases: ");
File sd = Environment.getExternalStorageDirectory();
if (sd.canWrite()) {
final File[] databases = new File(context.getFilesDir().getParentFile().getPath() + "/databases").listFiles();
for (File databaseFile: databases) {
final String backupFilename = databaseFile.getName() + "-" + Build.SERIAL +
"-" + System.currentTimeMillis() + ".db";
File backupFile = new File(sd, backupFilename);
FileChannel inputChannel = null;
@asika32764
asika32764 / arc-places.json
Created June 13, 2023 20:25 — forked from jthomassie/arc-places.json
d3 globe arcs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*
* Copyright 2007 Richard Chen
* mail: richardchen0310@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@asika32764
asika32764 / check-vat.php
Created February 24, 2023 10:03
(PHP) 台灣公司統編驗證函式
<?php
/**
* 依照 2023 年最新規則進行驗證
*
* @see https://www.fia.gov.tw/singlehtml/3?cntId=c4d9cff38c8642ef8872774ee9987283
*
* @param string $vat
*
* @return bool
@asika32764
asika32764 / tinymce-fetch-remote-img.js
Last active October 25, 2022 17:31
TinyMCE fetch remote images to local
editor.on('PastePostProcess', (e) => {
setTimeout(async () => {
const doc = new DOMParser().parseFromString(editor.getContent(), `text/html`);
const promises = [];
for (const img of doc.querySelectorAll('img')) {
const src = img.src;
const p = new Promise((resolve) => {
fetch(src)
@asika32764
asika32764 / README.md
Last active October 9, 2022 09:29
在 Windows 中用 WinRAR.exe 實現 zip & unzip 指令

在 Windows 中用 WinRAR.exe 實現 zip & unzip 指令

安裝方式

首先你需要安裝 WinRAR,然後在任何你想放指令的位置(例如 C:\bin),將環境變數指向到這邊來。

接著下載這兩個 bat 檔,放在你環境變數指向的位置即可。

使用方式