Skip to content

Instantly share code, notes, and snippets.

@NV
NV / README.md
Created April 12, 2010 11:28
JavaScript Timer class. setInterval pool. Much more powerful than prototype.js's periodicalExecuter

JavaScript Timer

Run 5 times, with one second delay between calls

t1 = new Timer(500, function(){
  console.log(this.count);
  if (this.count >= 5) {
    this.stop();
  }

});

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by Isaac Holmlund (isaacch@gmail.com) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="type" nillable="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="action"/>
<xs:enumeration value="action-attack"/>
<xs:enumeration value="action-duration"/>
<xs:enumeration value="action-reaction"/>
@johnhunter
johnhunter / jQuery.reduce.js
Created October 27, 2010 19:48
jQuery.reduce - a jQuery plugin for functional programming
/*
jQuery.reduce - a jQuery plugin for functional programming
@author John Hunter
created 2010-09-17
use: $.reduce(arr, fnReduce, valueInitial);
fnReduce is called with arguments: [valueInitial, value, i, arr]
reduce will never be jQuery core - its not prototype :p (http://dev.jquery.com/ticket/1886)
*/
(function ($) {
@aymanfarhat
aymanfarhat / urlobject.js
Last active July 27, 2017 00:04
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
@PizzaBrandon
PizzaBrandon / jquery.waituntilexists.js
Last active August 24, 2023 14:23 — forked from buu700/jquery.waituntilexists.js
Updated waitUntilExists plugin
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
@cybercase
cybercase / product.js
Last active February 10, 2023 10:59
Python-like itertools.product function in javascript
function product() {
var args = Array.prototype.slice.call(arguments); // makes array from arguments
return args.reduce(function tl (accumulator, value) {
var tmp = [];
accumulator.forEach(function (a0) {
value.forEach(function (a1) {
tmp.push(a0.concat(a1));
});
});
return tmp;
@rmkane
rmkane / MooToolsTimer.md
Last active August 29, 2015 14:08
Timer and TimerTask written using the MooTools framework.

#MooTools Timer Example

Below is a code snippet that uses the Timer and TimerTask classes.

##Script

function print(id, value) {
    document.getElementById(id).innerHTML = value;
}
@rmkane
rmkane / clock-face.svg
Last active October 9, 2015 15:17 — forked from mbostock/.block
Digital Clock
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eblahm
eblahm / fishyTitle.js
Created October 20, 2015 12:55
Make a 🐟 Swim Across Your Browser Tab
var renderIntervalInMillis = 50;
var characterWidth = 80;
var i = 0;
var whitespace = (new Array(characterWidth)).join('\u205f');
setInterval(function() {
var position = whitespace.length - (i++ % whitespace.length);
document.title = whitespace.substring(0, position) + '🐟' + whitespace.substring(position + 1);
}, renderIntervalInMillis);
anonymous
anonymous / GAME_MASTER_v0_1.protobuf
Created July 16, 2016 16:31
Pokemon Go decoded GAME_MASTER protobuf file v0.1
Result: 1
Items {
TemplateId: "BADGE_BATTLE_ATTACK_WON"
Badge {
BadgeType: BADGE_BATTLE_ATTACK_WON
BadgeRanks: 4
Targets: "\nd\350\007"
}
}
Items {