Skip to content

Instantly share code, notes, and snippets.

@looping84
looping84 / rAF.js
Created January 14, 2014 07:37 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@looping84
looping84 / 24.md
Created February 24, 2017 07:43 — forked from bradoyler/24.md
The 24 game in javascript

The 24 Game

  • tests one's mental arithmetic.

How it works:

  • You are randomly given four digits, each from one to nine, with repetitions allowed.
  • The goal is to enter an expression that evaluates to 24
Tips:
  • Only multiplication, division, addition, and subtraction operators/functions are allowed.
  • Division should use floating point or rational arithmetic, etc, to preserve remainders.
@looping84
looping84 / BehaviorTree.lua
Created June 29, 2017 10:10 — forked from mrunderhill89/BehaviorTree.lua
Behavior Tree implementation in Lua.
--[[
This behavior tree code was taken from our Zelda AI project for CMPS 148 at UCSC.
It is for the most part unmodified, and comments are available for each function.
Author: Kevin Cameron (mrunderhill89)
]]--
BT = {}
BT.__index = BT
BT.results = {success = "success"
,fail = "fail"
@looping84
looping84 / example.lua
Created July 3, 2017 06:46 — forked from mebens/example.lua
Doubly linked list in Lua
require("list")
local a = { 3 }
local b = { 4 }
local l = list({ 2 }, a, b, { 5 })
l:pop()
l:shift()
l:push({ 6 })
l:unshift({ 7 })
@looping84
looping84 / highlight.js
Created December 7, 2018 11:43 — forked from liudongmiao/highlight.js
highlight word
function highlightWord(root, word, className) {
// base on https://stackoverflow.com/a/10730063
// word is lower-case
var walker, textNodes = [];
walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
acceptNode: function (node) {
if (node.nodeType === Node.TEXT_NODE && node.textContent.toLowerCase().indexOf(word) >= 0) {
return NodeFilter.FILTER_ACCEPT;
} else {