Skip to content

Instantly share code, notes, and snippets.

Avatar

Douglas Duhaime duhaime

View GitHub Profile
View demo-middleware-1.js
const restaurantOwnerOnlyMiddleware = (req, res, next) => {
const {restaurantId} = req.params; // in this case, the id is part of the path
const user = req.user; // available if you're using Google Firebase Authentication Middleware
const hasPermission = (id, user) => true; // do your checks here instead
if (!hasPermission(restaurantId, user)) {
res.status(403).send("Unauthorized");
return;
}
View map, filter and reduce explained
map(['🐮','🍠', '🐔', '🌽'], cook);
=> ['🍔', '🍟', '🍗', '🍿'];
filter(['🍔', '🍟', '🍗', '🍿'], isVegetarian);
=> ['🍟', '🍿'];
reduce(['🍔', '🍟', '🍗', '🍿'], eat);
=> ['💩'];
@tcya
tcya / index.html
Last active Jun 20, 2022
海德沙龙刷机包
View index.html
<!DOCTYPE html>
<html>
<head>
<title>海德沙龙刷机包</title>
<style>
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
}
View hello.md

👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋

View biggan-search.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johnhw
johnhw / umap_sparse.py
Last active Jan 2, 2023
1 million prime UMAP layout
View umap_sparse.py
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
View convert_daily_to_monthly.py
################################################################################################
# name: convert_daily_to_monthly.py
# desc: takes inout as daily prices and convert into monthly data
# date: 2018-06-15
# Author: conquistadorjd
################################################################################################
import pandas as pd
import numpy as np
print('*** Program Started ***')
@gladiatorAsh
gladiatorAsh / pwd.js
Created May 17, 2018
List of most used passwords (Why this approach??)
View pwd.js
{passwords:"123456,password,12345678,qwerty,123456789,12345,1234,111111,1234567,dragon,123123,baseball,abc123,football,monkey,letmein,shadow,master,696969,mustang,666666,qwertyuiop,123321,1234567890,pussy,superman,654321,1qaz2wsx,7777777,fuckyou,qazwsx,jordan,123qwe,000000,killer,trustno1,hunter,harley,zxcvbnm,asdfgh,buster,batman,soccer,tigger,charlie,sunshine,iloveyou,fuckme,ranger,hockey,computer,starwars,asshole,pepper,klaster,112233,zxcvbn,freedom,princess,maggie,pass,ginger,11111111,131313,fuck,love,cheese,159753,summer,chelsea,dallas,biteme,matrix,yankees,6969,corvette,austin,access,thunder,merlin,secret,diamond,hello,hammer,fucker,1234qwer,silver,gfhjkm,internet,samantha,golfer,scooter,test,orange,cookie,q1w2e3r4t5,maverick,sparky,phoenix,mickey,bigdog,snoopy,guitar,whatever,chicken,camaro,mercedes,peanut,ferrari,falcon,cowboy,welcome,sexy,samsung,steelers,smokey,dakota,arsenal,boomer,eagles,tigers,marina,nascar,booboo,gateway,yellow,porsche,monster,spider,diablo,hannah,bulldog,junior,london,purple,co
@naught101
naught101 / separate_points.py
Created Feb 16, 2018
Separating points on a map
View separate_points.py
def lat_lon_hex_mesh(bounds, d=3):
"""Creates a hexagonal lat/lon mesh within bounds that has a radial separation of d"""
lone, lonw, lats, latn = bounds
# heigt of equilatral triangle from radial distance sqrt(r^2 - (r/2)^2)
h = np.sqrt(0.75) * d
w = d / 2
lat_vals = np.arange(lats, latn, h)
View line_girl.rb
W = 500
H = 585
W1 = W - 1
H1 = H - 1
def setup
@img = load_image '../scratch/girl.png'
@img.filter BLUR, 3
@img.load_pixels
end