Skip to content

Instantly share code, notes, and snippets.

Wei Chih Tsai iambigd

View GitHub Profile
@iambigd
iambigd / AjaxTextureLoader.js
Created Dec 27, 2018 — forked from jbreckmckye/AjaxTextureLoader.js
Loading THREE textures with onProgress events
View AjaxTextureLoader.js
const THREE = require('three');
function AjaxTextureLoader() {
/**
* Three's texture loader doesn't support onProgress events, because it uses image tags under the hood.
*
* A simple workaround is to AJAX the file into the cache with a FileLoader, then extract that into a
* texture with a separate TextureLoader call.
*/
@iambigd
iambigd / pdo_duplicate_key_update.php
Created Oct 4, 2016 — forked from kublaios/pdo_duplicate_key_update.php
PDO ON DUPLICATE KEY UPDATE for multiple insert rows
View pdo_duplicate_key_update.php
function test() {
$sql = "INSERT INTO `table` (`id`, `name`) VALUES (?,?),(?,?) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`) ";
$values = array(1, "test", 2, "so so");
$stmt = $this->db->prepare($sql);
$stmt->execute($values);
}
@iambigd
iambigd / gist:635d528d31966ea0c468a6f9cd2c6fd1
Created Apr 28, 2016 — forked from jrue/gist:4980704
This gist is an example of using HTML5 video as the background of a <div> element. It uses MediaElement.js for better compatibility with older browsers. This works on iPad, but not iPhone as the iPhone launches a native player.
View gist:635d528d31966ea0c468a6f9cd2c6fd1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page Title</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!-- Download from http://mediaelementjs.com/ We only need the build folder -->
<script src="build/mediaelement-and-player.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="build/mediaelementplayer.min.css" type="text/css" media="screen" charset="utf-8">
View jquery.ajaxqueue.js
/*
:: Enhanced Version @extralam ::
Allows for ajax requests to be run synchronously in a queue , remove queue
Usage::
var queue = new $.AjaxQueue();
// add with tag name or not , both ok
queue.add('test',{
url: 'url',
View gridster.resize-patch.js
(function($) {
$.Gridster.generate_stylesheet = function(opts) {
var styles = '';
var max_size_x = this.options.max_size_x;
var max_rows = 0;
var max_cols = 0;
var i;
var rules;
opts || (opts = {});
@iambigd
iambigd / gist:fcc2c5be78613755b204
Created Mar 30, 2015
殺掉佔用8080 port的process
View gist:fcc2c5be78613755b204
rem @echo off
FOR /F "tokens=5" %%P IN ('netstat -ano ^| findstr " 8080.*LISTENING " ') DO TaskKill.exe /PID %%P /T /F
pause
@iambigd
iambigd / xml
Last active Aug 29, 2015
Parsing and serializing XML
View xml
function XmlToString(xmlData)
{
var xmlString;
//IE
if (window.ActiveXObject)
{
xmlString = xmlData.xml;
//xmlString = xmlData.xml ? xmlData.xml : (new XMLSerializer()).serializeToString(xmlData);
}
else
@iambigd
iambigd / jqplot-realtime
Created Dec 18, 2014
How to display real time data with jqplot
View jqplot-realtime
<HTML>
<HEAD>
<!--[if lt IE 9]><script type="text/javascript" src="http://cdn.jsdelivr.net/excanvas/r3/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.enhancedLegendRenderer.min.js"></script>
<link href="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function(){
@iambigd
iambigd / gist:8630211d2210cdecc357
Last active Aug 29, 2015
jQuery plugin Template
View gist:8630211d2210cdecc357
/*
* Template plugin
* @author ken.tsai@advantech.com.tw
* @date 20141022
*/
;(function($) {
//define plugin name
var pluginName = 'jqueryPlugin';
View gist:373cbcbab4a31bb73163
<!--
The log4javascript testing
@author bigd
@date 2014/9/9
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
You can’t perform that action at this time.