Skip to content

Instantly share code, notes, and snippets.

View wmelton's full-sized avatar

Wes wmelton

View GitHub Profile
@wmelton
wmelton / js-array-loop-performance.js
Created November 11, 2022 14:37
JS Array loop performance - reduce() vs for-let vs forEach() vs for-of
(() => {
const recursiveReduce = (array) => {
return array.reduce(
(obj, item) => {
if (typeof item.value === 'object')
obj[item.key] = recursiveReduce(item.value)
else
obj[item.key] = item.value
@wmelton
wmelton / proxy.nginx.conf
Created August 30, 2022 10:42 — forked from jujhars13/proxy.nginx.conf
nginx-mysql-proxy
#sudo wget http://nginx.org/download/nginx-1.9.12.tar.gz
#sudo tar -xvzf nginx-1.9.12.tar.gz
#cd nginx-1.9.12
#sudo apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g-dev
#sudo ./configure --with-stream && sudo make && sudo make install
# /usr/local/nginx/conf/nginx.conf - NGINX configuration file
worker_processes 1;
@wmelton
wmelton / bayes-ann.py
Created February 4, 2020 03:19
Bayesian ANN
// Likely broken
import numpy as np
import pymc3 as pm
from keras.layers import Input, Dense
class GaussWeights(object):
def __init__(self):
self.count = 0
@wmelton
wmelton / minimal-analytics-snippet.js
Created December 16, 2019 22:59 — forked from DavidKuennen/minimal-analytics-snippet.js
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@wmelton
wmelton / query.json
Created June 20, 2019 19:20
Failing Query
{
"search_filter": {
"albums":["48947"],
"ctas":[],
"apps": [{
"id": "13590",
"status_ids": ["6"]
}]
},
"order": {
@wmelton
wmelton / in-place-search-replace.sh
Created May 10, 2019 15:51
In-place search and replace using grep and sed
grep -Rl text_to_find directory_to_search 2>/dev/null | while read line; do sed -i 's/text_to_find/replacement_text/g' $line; done
@wmelton
wmelton / bookingpal-error.html
Created April 10, 2019 14:06
Error returned in the REST API from BookingPal
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>504 gateway time-out</title> <style> html, body{ padding: 0; margin: 0; width: 100%; min-height: 100%; height: 100%; } body { font-family: 'Open Sans' ,sans-serif; } header { background-color: #003760; color: #fff; height: 64px; width: 100%; overflow: hidden; } .logo { background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAAgCAYAAAB0FGakAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD
@wmelton
wmelton / hamming-distance.java
Created February 14, 2019 15:55
Inverse Hamming Distance function for E
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@wmelton
wmelton / Fall-Foliage-Embed-Code.html
Last active August 27, 2018 12:22
Fall Foliage Embed Code
<object data=https://smokymountains.com/fall-foliage-map-embed/ width="640px" height="450px" style="overflow:hidden;border-width: 1px;width: 640px;height: 450px">
<embed src=https://smokymountains.com/fall-foliage-map-embed/>
</object>
@wmelton
wmelton / Rank-By-PDF.py
Last active June 17, 2020 17:36
Rank by PDF
import math
def rankByPDF(alpha, beta):
mu = alpha / (alpha + beta)
std_error = 1.65 * math.sqrt( (alpha * beta) / ( ( (alpha + beta)**2) * (alpha + beta + 1) ) )
return mu - std_error
##
## Property A: 20 5-Stars and 2 1-Stars
## Alpha = 1 + (20 * 1) + (2 * 0.2) = 21.4