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 / 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 / PHP_delete_a_folder_recursively
Last active August 29, 2015 13:58
A simple function to delete a folder recursively. Very danger! Watch out!
<?php
// A simple function to delete a folder recursively. Very danger! Watch out!
// PHP用遞迴把資料夾給砍掉,殺傷力強大,請謹慎使用。
// V1.1 use readdir() instead of glob() for better non-english file name support in php4
// source unknown, modified by Jason Chiang
// xcojad at gmail.com
$folder_name="PEAR";
$folder_name="upload";
@Cojad
Cojad / child_values.js
Last active September 7, 2016 08:55
list hierarchy javascript object values
child = function(obj,name){
for( var index in obj){
switch(typeof obj[index]) {
case "object": child(obj[index],name+"."+index);break;
case "string": console.log(name+"."+index+" = \"" + obj[index] + "\"");break;
case "number": console.log(name+"."+index+" = " + obj[index]);break;
case "boolean": console.log(name+"."+index+" = \""+ (obj[index]) ? "true":"false" + "\"");break;
}
}
}
@Cojad
Cojad / mac_office2011_uninstall.sh
Created November 24, 2016 05:12
Remove Office 2011 completely
#!/bin/sh
# IMPORTANT!!!
# This script try to wipe out all office 2011 files but would also delete some other Microsoft files.
# So you are adviced to reinstall other microsoft product which not belong to office 2011.
osascript -e 'tell application "Microsoft Database Daemon" to quit'
osascript -e 'tell application "Microsoft AU Daemon" to quit'
osascript -e 'tell application "Office365Service" to quit'
#Closes all Office applications
osascript -e 'tell application "Microsoft Excel.app" to quit without saving'
@Cojad
Cojad / line.sh
Last active February 22, 2017 04:43
設定時間自動在OSX對Line視窗按下Enter按鍵
#!/usr/bin/php
<?php
$stage=0; //如果不要有語音提醒把 $stage=0; 改成 $stage=1;
$USA=false;
($USA) ? date_default_timezone_set("America/New_York") : date_default_timezone_set("Asia/Taipei");
echo
"==================== 自動切換至line視窗, 並且按下Enter ========================
+ usage: line
+ 在下一個分零秒整, 切換到line視窗, 並且按下Enter
@Cojad
Cojad / 轉換TG_GIF.scpt
Created May 31, 2017 10:23
轉換影片格式到Telegram GIF的無聲 h264編碼的.mp4格式的Droplet AppleScript
-- 改編自 AppleScript範例 Recursive File Processing Droplet.app
-- 存檔時請存成 .app 格式
-- 支援輸入的副檔名請修改 line 25: property extension_list
-- 請記得修改 line 117: ffmpeg執行檔的路徑, 本script需要依賴ffmpeg來完成轉換
-- 本Script支援 單檔案/多檔案 但不支援資料夾遞迴處理, 如果要支援僅需把 line 81註解, line 82取消註解即可.
-- 如有疑問請使用 Telegram 聯繫 https://tg.me/Cojad aka @Cojad 柯姊
(*
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software ( the "Apple Software" ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source an
@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(); });
@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 / 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 / mini_google_authenticator.php
Last active July 5, 2023 09:15
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));