Skip to content

Instantly share code, notes, and snippets.

View A1rPun's full-sized avatar
🌊
Fractalicious

Thom Bakker A1rPun

🌊
Fractalicious
  • The Netherlands
View GitHub Profile
;var _ = (function () {
function lo() { }
lo.prototype = {
//XMLHttpRequest wrapper
ajax: function() {
var a = arguments,
requestData,
opts = { method: 'GET', data: null, url: '', async: true, done: null, fail: null, always: null };
@A1rPun
A1rPun / Enum
Last active August 29, 2015 14:05
function mune(){
var a=Array.isArray(arguments[0]) ? arguments[0] : arguments;
for(var i=0,l=a.length,l=l>31?31:l;i<l;i++){this[a[i]] = 1 << i}
}
@A1rPun
A1rPun / Async
Last active August 29, 2015 14:05
var async = {
waterfall: function (listOfRequests, callback) {
var callbacks = 0;
function handleCallback() {
callbacks++;
if (callbacks === listOfRequests.length) {
callback();
} else {
listOfRequests[callbacks](handleCallback);
}
@A1rPun
A1rPun / scrollspy.js
Last active November 16, 2015 23:02 — forked from pascaldevink/scrollspy.js
/*
Copyright (C) 2021 Pascal de Vink (Tweakers.net)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@dciccale
dciccale / README.md
Last active December 9, 2015 17:49
requestAnimationFrame shim in 155 bytes (127 gzipped)

requestAnimationFrame shim

Cross-browser requestAnimationFrame in 155 bytes of JavaScript.

//let's cache the event
var priorEvt;
function getMousePos(evt) {
//set and store..
priorEvt = evt = evt || priorEvt;
//get the bounding rectangle
var rect = canvas.getBoundingClientRect();
//lastly, return the x and y coordinates
if (evt)
@basp
basp / CropFieldFlurlExample.cs
Last active December 1, 2016 09:25
Converting GeoJSON to CropFields with Flurl
void Main()
{
var result = "http://localhost:3000/test.json"
.GetAsync()
.ReceiveCropFields()
.Dump();
}
static class HttpResponseMessageExtensions
{
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / ascci_hex_string.js
Created December 19, 2016 16:13
Tiny helpers: ASCII HEX STRING
function string2ascii(string, sep) {
return string.split('')
.map(e => e.charCodeAt(0)).join(sep ? sep : '');
}
function string2hex(string, sep) {
return string.split('')
.map(e => e.charCodeAt(0).toString(16)).join(sep ? sep : '');
}
@dciccale
dciccale / README.md
Last active May 22, 2018 09:14
Cross-browser triggerEvent function done with 127 bytes of JavaScript

triggerEvent

Cross-browser function to trigger DOM events.

@renanpvaz
renanpvaz / f.js
Last active April 14, 2019 23:01
JavaScript function pattern matching inspired by Haskell's
f = (...fns) => {
const [main, ...variations] = fns.reverse()
const ƒunction = (...appliedArgs) => {
const variation = variations.find(
args => appliedArgs.every(
(appliedArg, i) => args.slice().splice(0, args.length - 1)[i] === appliedArg
)
)