This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upload (req, res) { | |
var Formidable = require('formidable'), | |
form = new Formidable.IncomingForm(); | |
form.encoding = 'utf-8'; | |
form.onPart = function (part) { | |
if (!part.filename) { | |
form.handlePart(part); | |
} else { | |
(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numberArray = [1,3,6,15,25,50]; | |
var testValue = 19; | |
var fn = closestMatch(numberArray, testValue); | |
alert(fn); | |
function closestMatch(numbers, value){ | |
var closestValue, smallestDiff, absoluteDiff | |
var len = numbers.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.utils { | |
import flash.events.Event; | |
public class EventType extends Event { | |
public var arg:*; | |
public function EventType(type:String, bubbles:Boolean = false, cancelable:Boolean = false, ... a:*) { | |
super(type, bubbles, cancelable); | |
arg = a; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getReplies($comment_post_id, $commentID){ | |
$wp_comments = $this->wpdb->prefix . "comments"; | |
$childData = array(); | |
$data = $this->wpdb->get_results( "SELECT * FROM $wp_comments | |
WHERE $wp_comments.comment_post_ID = $comment_post_id AND $wp_comments.comment_parent != 0"); | |
$dataLength = count($data); | |
for($i = 0; $i< $dataLength; $i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function StartTimer ($what='') { | |
global $MYTIMER; $MYTIMER=0; //global variable to store time | |
//if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') return; //only show for my IP address | |
echo '<p style="border:1px solid black; color: black; background: yellow;">'; | |
echo "About to run <i>$what</i>. "; flush(); //output this to the browser | |
//$MYTIMER = microtime (true); //in PHP5 you need only this line to get the time | |
list ($usec, $sec) = explode (' ', microtime()); | |
$MYTIMER = ((float) $usec + (float) $sec); //set the timer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doesFileExist(urlToFile) | |
{ | |
var xhr = new XMLHttpRequest(); | |
xhr.open('HEAD', urlToFile, false); | |
xhr.send(); | |
if (xhr.status == "404") { | |
return false; | |
} else { | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Call this function and pass in the name of the font you want to check for availability. | |
// | |
function doesFontExist(fontName) { | |
// creating our in-memory Canvas element where the magic happens | |
var canvas = document.createElement("canvas"); | |
var context = canvas.getContext("2d"); | |
// the text whose final pixel size I want to measure | |
var text = "abcdefghijklmnopqrstuvwxyz0123456789"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myArray = ["bar", "foo", "zorb", "bar", "baz", "fum", "baz"]; | |
Array.prototype.removeDuplicates = function() { | |
var input = this; | |
var hashObject = new Object(); | |
for (var i = input.length - 1; i >= 0; i--) { | |
var currentItem = input[i]; | |
if (hashObject[currentItem] == true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.addEventListener("DOMContentLoaded", preloadImages, true); | |
var loadedImages = 0; | |
var imageArray = new Array("path-to-image", "path-to-image"); | |
function preloadImages(e) | |
{ | |
for (var i=0; i<imageArray.length; i++) { | |
var tempImage = new Image(); | |
tempImage.addEventListener("load", trackProgress, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>Stripe Sample Form</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script> | |
<script type="text/javascript" src="https://js.stripe.com/v1/"></script> | |
<script type="text/javascript"> |
OlderNewer