Skip to content

Instantly share code, notes, and snippets.

View bayleedev's full-sized avatar
🍿

Baylee Schmeisser bayleedev

🍿
View GitHub Profile
@bayleedev
bayleedev / output.txt
Created January 24, 2013 19:43
CURL Options by output number
CURLOPT_AUTOREFERER..............58
CURLOPT_BINARYTRANSFER...........19914
CURLOPT_RETURNTRANSFER...........19913
CURLOPT_COOKIESESSION............96
CURLOPT_CERTINFO.................172
CURLOPT_VERBOSE..................41
CURLOPT_CRLF.....................27
CURLOPT_DNS_USE_GLOBAL_CACHE.....91
CURLOPT_FAILONERROR..............45
@bayleedev
bayleedev / color-difference.js
Created October 15, 2022 00:12
Understanding color difference in LAB vs sRGB using "@thi.ng/color"
import { distCIEDE2000 } from "@thi.ng/color";
import distance from 'euclidean-distance';
const difference = (color1, color2) => {
return distCIEDE2000()(
'#' + (color1.red).toString(16) + (color1.green).toString(16) + (color1.blue).toString(16),
'#' + (color2.red).toString(16) + (color2.green).toString(16) + (color2.blue).toString(16),
)
}

Keybase proof

I hereby claim:

  • I am bayleedev on github.
  • I am mxbaylee (https://keybase.io/mxbaylee) on keybase.
  • I have a public key ASAGshYBVX4yu_D1IR9NZXiv1ooK-Hw6W-CNntE244dR5wo

To claim this, I am signing this object:

on randomString(aLength)
set randomChars to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
set aString to ""
repeat aLength times
set aString to aString & some item of randomChars
end repeat
return aString
end randomString
@bayleedev
bayleedev / extract.php
Created June 14, 2016 07:17
extract slack
<?php
function isDirectory($file, $items) {
if (strpos($file, '.') !== false) {
return false; // nothing with a dot is a directory
}
$regex = "/^" . preg_quote($file, '/') . "\//";
foreach ($items as $item) {
if (!!preg_match($regex, $item)) {
return true; // it found things inside!
@bayleedev
bayleedev / mongoose.js
Last active December 26, 2019 09:11
A better syntax for mongoose instance and static methods.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/foobar');
// bootstrap mongoose, because syntax.
mongoose.createModel = function(name, options) {
var schema = new mongoose.Schema(options.schema);
for (key in options.self) {
if (typeof options.self[key] !== 'function') continue;
schema.statics[key] = options.self[key];
}

Performance Test

The goal is to determine if the overhead of multiple setTimeout is heavier than a single setInterval.

Each test has 60 iterations of a function wait that takes 30ms to run, making the program time 60*30=1800ms, so running these files should capture the overhead by subtracting 1800ms from the total run time.

Timeout

It took around 1816ms or around ~16ms of overhead.

var b = 20;
function foo () {
var a = 10;
console.log('hello $a+$b=30'.replace(/\$\w+/g, function (el) {
return eval(el.substr(1))
}))
}
foo()
@bayleedev
bayleedev / aop.php
Created June 20, 2014 03:10
aspect oriented programming with traits in php
<?php
/**
* AOP Trait
* Used to created aop for your class.
*/
trait AOP {
public $filters = array();