Skip to content

Instantly share code, notes, and snippets.

View mingtsay's full-sized avatar
🇹🇼

Ming Tsay mingtsay

🇹🇼
View GitHub Profile
@mingtsay
mingtsay / oppose_cheat.js
Last active August 29, 2015 13:58 — forked from anonymous/oppose_cheat.js
Cheat script for www.oppose.tw
(function() {
$btnYes = $('.btn-yes')[0];
$btnNo = $('.btn-no' )[0];
$content = $('.show-content')[0];
function cheat() {
if (l = $content.innerHTML.length) {
l % 2 ? $btnNo.click() : $btnYes.click();
}
setTimeout(cheat);
@mingtsay
mingtsay / mcu_moodle_form.js
Last active August 29, 2015 14:01
for MCU Moodle form 5 stars and check all boxes
(function(d){
var f = d.getElementById("phpesp_response");
for (var i in f) {
if (f[i]) {
switch (f[i].type) {
case "radio":
if (f[i].value == 4) {
f[i].checked = true;
}
break;
setInterval(function () {
// 取得網頁上所有連結
var a = document.getElementsByTagName('a');
// 針對每個連結跑一次
for (var i in a) {
// 檢查是不是真的是連結
if (a.hasOwnProperty(i)) {
// 檢查是不是讚的連結
if (a[i].className == "UFILikeLink") {
// 檢查是不是還沒按過讚
Array.prototype.sayHi = function () {
var say = 'Hi, ' + this.join(', ') + '!';
window.alert(say);
}
var a = ['Bob', 'Alice', 'Emma'];
a.sayHi(); // this will alert: Hi, Bob, Alice, Emma!
for (var i in a) {
console.log(i, a.hasOwnProperty(i), a[i]);
<?php
$conn = new PDO("mysql:host=127.0.0.1;dbname=rfid;", "root", "");
$cursor = $conn->prepare("select * from :table ;");
//$cursor->execute(array(":table"=>"contrast"));
$cursor->bindValue(":table", "contrast");
$cursor->execute();
var_dump($cursor->fetch());
// var_dump($cursor);
@mingtsay
mingtsay / ibon-doc-refresh.js
Last active August 29, 2015 14:27
script for ibon document upload view status (for http://www.ibon.com.tw/printscan_ie.aspx#D0131)
// save the interval id for stop the script
window._ibon_doc_interval = setInterval(function() {
// function for get element by id
b = function(id) { return (this.getElementById ? this : document).getElementById(id); };
// close the status window if exists
if (a = b("majorContents"))
b.call(a.contentDocument, "inquiry_btn").getElementsByTagName("a")[0].click();
// fill in the document code
@mingtsay
mingtsay / mt.gettext.php
Created April 30, 2011 14:36
mt's gettext
<?php
/**
* Define: FILE_ROOT_PATH
* Set Value: $lang
* Create an ini file: i18n/lang.ini
* Call function: _gettext("Homepage") or someelse string
**/
function _gettext($text) {
global $lang;
$langs = parse_ini_file(FILE_ROOT_PATH . "i18n/lang.ini", true);
@mingtsay
mingtsay / dataurl.php
Created May 1, 2011 05:59
Data URL Praser
<?php
# Demo: http://mt.aa.am/dataurl.php
# data:[<MIME-type>][;charset=<encoding>][;base64],<data>
if(isset($_GET['uri']) || isset($_POST['uri']) || isset($_GET['file'])) {
if(isset($_GET['uri'])) $uri = $_GET['uri'];
else if(isset($_POST['uri'])) $uri = $_POST['uri'];
else if(isset($_GET['file'])) {
$file = $_GET['file'];
if(!(strtolower(substr($file, 0, 7)) == "http://" || strtolower(substr($file, 0, 8)) == "https://"))
@mingtsay
mingtsay / f.vbp
Created May 1, 2011 11:03
vb.net function check name
function 檢查姓名(byval 姓名 as string) as boolean
dim 檢查 as boolean
for i as integer = 1 to len(姓名)
檢查 = false
select case lcase(mid(姓名, i, 1))
case "0"
case "1"
case "2"
case "3"
case "4"
@mingtsay
mingtsay / chatroom.php
Created May 19, 2011 14:48
mt's Chatroom
<?php
$cls = true;
$use_same_db = false;
$old = true;
define("MT_TIMEOUT", 10);
function video_id($url) {
$parse_url = parse_url($url);
$query = array();