Skip to content

Instantly share code, notes, and snippets.

View technicool's full-sized avatar
🧯
Fixing or making bugs :)

Marshall Anschutz technicool

🧯
Fixing or making bugs :)
View GitHub Profile
@technicool
technicool / Rate Limiter.md
Last active October 27, 2021 18:21
Rate limiting only using a single scalar value per user/actor

You can use this by importing the function into the console (or your app)

> x = rateLimit(a, {rps: 1, grace: 2}); a = x[1]; x
[ true, 1635358774575 ]
> x = rateLimit(a, {rps: 1, grace: 2}); a = x[1]; x
[ false, 1635358774575 ]
> x = rateLimit(a, {rps: 1, grace: 2}); a = x[1]; x
[ false, 1635358774575 ]
> x = rateLimit(a, {rps: 1, grace: 2}); a = x[1]; x
@technicool
technicool / index.js
Created February 28, 2020 16:42
StackPath script to show request headers, including GEO information
let reqCount = 0;
// sample script
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
reqCount += 1;
const headers = new Headers();
//Set the proper content-type so the browser understands what we're sending back
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Dromedary CodePipeline provisioning
Parameters:
ArtifactStoreBucket:
Type: String
Description: S3 bucket to use for artifacts. Just bucket Name; not URL. IAM user
should have access to the bucket.
Default: codepipeline-us-east-1-XXXXXXXXXXX
GitHubToken:
@technicool
technicool / github-issues-to-csv.sh
Created November 1, 2016 16:52
Create a CSV with all Github issues from a repository
#!/bin/sh
echo "Enter your username for Github: "
read username
echo "Which repository (Enter org and project) [google/googlemock]: "
read repo
repo="${repo:=google/googlemock}"
echo "id, state, title, body, user" > issues.csv
curl --silent -u $username https://api.github.com/repos/$repo/issues | \
{
"status": 0,
"id": "356faecf2e67a5a516b740b6",
"app_key": "356faecf2e67a5a516b740b6.ie5ggaE4FtrA_6xr5sJlFOD7r7_AA_aW4uvP3yxABA"
}
@technicool
technicool / curl_commands.sh
Last active August 2, 2016 14:35
How to create an API key on SamsungVR,com
curl https://samsungvr.com/auth/login \
--data "email=marshall%40samsungvr.com&password=<yourpassword>" \
-c samsungvr.cookiejar &&
curl https://samsungvr.com/applications \
--data "{\"app_name\":\"YourAppName\"}" \
-b samsungvr.cookiejar
@technicool
technicool / npm-issues.md
Created April 5, 2016 17:39
NPM Issues on April 4'th

First, run a new isolated container:

docker run --rm -it ubuntu bash

Now, setup npm and try to install package:

apt-get update && apt-get install -y npm
npm install grunt

You might see some funky garbage in your terminal window. Sometimes, it will hang, so expect to kill your session out of band.

@technicool
technicool / pizzahut_pi_day.py
Created March 14, 2016 17:47
For Pizza Hut's problem on PI day 2016
## For Pizza Hut's problem on PI day:
## http://blog.pizzahut.com/flavor-news/national-pi-day-math-contest-problems-are-here-2/
##
## I’m thinking of a ten-digit integer whose digits are all distinct. It happens that the
## number formed by the first n of them is divisible by n for each n from 1 to 10.
## What is my number?
##
def dnumber(digits, howmany):
@technicool
technicool / stacktrace.java
Created January 8, 2016 23:38
Intuit Stack Trace
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:693)
at org.eclipse.persistence.platform.server.ServerPlatformBase.launchContainerRunnable(ServerPlatformBase.java:415)
at org.eclipse.persistence.internal.sessions.coordination.CommandPropagator.asynchronousPropagateCommand(CommandPropagator.java:97)
at org.eclipse.persistence.sessions.coordination.RemoteCommandManager.propagateCommand(RemoteCommandManager.java:221)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.mergeChangesIntoParent(UnitOfWorkImpl.java:3278)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitRootUnitOfWork(UnitOfWorkImpl.java:1314)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commit(UnitOfWorkImpl.java:1074)
at com.paycycle.data.Transaction.commit(Transaction.java:418)
http://stream.nextvr.com.cdnga.net/live/lunar20.mp4/chunklist.m3u8