Skip to content

Instantly share code, notes, and snippets.

@iambigd
iambigd / AjaxTextureLoader.js
Created December 27, 2018 04:05 — forked from jbreckmckye/AjaxTextureLoader.js
Loading THREE textures with onProgress events
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 October 4, 2016 03:03 — forked from kublaios/pdo_duplicate_key_update.php
PDO ON DUPLICATE KEY UPDATE for multiple insert rows
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 April 28, 2016 14:08 — 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.
<!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">
@iambigd
iambigd / jquery.ajaxqueue.js
Created November 20, 2015 08:57 — forked from extralam/jquery.ajaxqueue.js
jQuery AJAX queues
/*
:: 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',
(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 = {});
/* Side notes for calling out things
-------------------------------------------------- */
/* Base styles (regardless of theme) */
.bs-callout {
margin: 20px 0;
padding: 15px 30px 15px 15px;
border-left: 5px solid #eee;
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@iambigd
iambigd / asset.php
Created July 30, 2013 13:45 — forked from dcsg/asset.php
<?php
// require 'path/to/vendor/autoload.php';
use Assetic\Asset\FileAsset;
$asset = new FileAsset('path/to/file.js');
header('Content-Type: application/javasript');
echo $asset->dump();
<?php
namespace app\extensions\helper;
use Assetic\AssetWriter;
use Assetic\AssetManager;
use Assetic\FilterManager;
use Assetic\Asset\AssetCache;
use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;