Skip to content

Instantly share code, notes, and snippets.

View Cojad's full-sized avatar
🤣
Hacking for blockchain

Jason Chiang Cojad

🤣
Hacking for blockchain
View GitHub Profile
@Cojad
Cojad / Caddyfile
Created June 12, 2025 05:12 — forked from vanodevium/Caddyfile
Caddy server: enable CORS for any domain
(cors) {
@cors_preflight method OPTIONS
header {
Access-Control-Allow-Origin "{header.origin}"
Vary Origin
Access-Control-Expose-Headers "Authorization"
Access-Control-Allow-Credentials "true"
}
@Cojad
Cojad / fpm_get_status_with_auth.php
Last active June 2, 2025 13:56 — forked from EhsanCh/fpm_get_status.php
PHP-FPM real-time status page (Single file without the need for web server configuration) with simple auth
<?php
// Use HTTP Basic Authentication for verification
$username = 'admin';
$password = 'Passw0rd!'; // Please use your own password!!
// Check if the client has provided correct credentials
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $username || $_SERVER['PHP_AUTH_PW'] !== $password) {
// Send authentication request headers
header('WWW-Authenticate: Basic realm="Restricted Area"');
header('HTTP/1.0 401 Unauthorized');
@Cojad
Cojad / mini_google_authenticator.php
Last active May 21, 2025 10:01
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));
@Cojad
Cojad / yaml.userscript.js
Last active November 4, 2022 07:09
Load npm js in tampermonkey
// ==UserScript==
// @name load jQuery and yaml on 越南商店
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://sites.google.com/view/nicsolas/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @require https://github.com/plohoj/userscript-requirejs/releases/download/0.0.2/userscript-require.js
@Cojad
Cojad / git-cache-meta.sh
Last active October 16, 2021 08:11 — forked from andris9/git-cache-meta.sh
git-cache-meta -- simple file meta data caching and applying.
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
# 2014-02-25 change filetime from accessed time to modifpeied time by cojad
# 2012-03-05 - added filetime, andris9
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
@Cojad
Cojad / uefi-x64.exe
Last active June 9, 2021 23:19
tiny exe to detect uefi/legacy boot
@Cojad
Cojad / ato.cmd
Last active June 1, 2021 04:48
ato
cscript //B "%windir%\system32\slmgr.vbs" /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
cscript //B "%windir%\system32\slmgr.vbs" /skms zh.us.to
wscript "%windir%\system32\slmgr.vbs" /ato
cd "C:\Program Files (x86)\Microsoft Office\Office16"
cscript OSPP.VBS /sethst:zh.us.to
cscript OSPP.VBS /act
@Cojad
Cojad / React-Native-WebView-Cookies.js
Created April 25, 2018 20:15 — forked from xxxxlr/React-Native-WebView-Cookies.js
React Native Trick: Get Cookies of WebView without using any native modules such as react-native-cookies. Might be helpful for getting JWT while making OAuth2 👽
// @flow
import React, { Component } from 'react';
import {
WebView,
} from 'react-native';
class LoginScreen extends Component {
state = {
cookies : {},
@Cojad
Cojad / cloudflare_update.php
Last active September 4, 2017 04:40
update Cloudflare with PHP file wrapper
<?php
$postdata = array(
'type' => 'A',
'name' => 'a.xxx.tw', //你的domain name
'content' => '123.123.123.123' // 你要更新的對應ip地址
);
$opts = array('http' =>
array(
'method' => 'PUT',
'header' => "X-Auth-Email: 你的信箱@gmail.com\r\n" .
@Cojad
Cojad / jQueryLoader.js
Created August 18, 2017 09:35
load jQuery via bookmark
javascript: (window.jQuery) ? console.log('jQuery '+jQuery.fn.jquery+' already loaded!') : (function(e, s) {
e.src = s;e.onload = function() {/*jQuery.noConflict();*/
console.log('jQuery '+jQuery.fn.jquery+' injected');
};
document.head.appendChild(e);
})(document.createElement('script'), 'http://code.jquery.com/jquery-2.2.4.min.js');
jQuery("<h1>test</h1>").attr("style","position:fixed;z-index:9999;width:100%;background-color:rgba(0,255,0,.5);text-align:center").appendTo(document.body).fadeOut( 1500 ).queue(function() { jQuery(this).remove(); });