Skip to content

Instantly share code, notes, and snippets.

View alecbw's full-sized avatar

Alec Barrett-Wilsdon alecbw

View GitHub Profile
@levelsio
levelsio / gist:5bc87fd1b1ffbf4a705047bebd9b4790
Last active July 24, 2024 12:04
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
# 2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same!
Send me your ChatGPT text adventure game on X, I'd love to try it!
@jroakes
jroakes / Remove Stop Words from Google Data Studio Field
Last active March 22, 2021 16:48
Use NLTK Stopwords List to group similar text fields in Google Data Studio
REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(LOWER(<field_to_convert>), "[^\\w]+", " "), "(\\ |^)(me|my|the|of|myself|we|our|ours|ourselves|you|your|yours|yourself|yourselves|he|him|his|himself|she|her|hers|herself|it|its|itself|they|them|their|theirs|themselves|what|which|who|whom|this|that|these|those|am|is|are|was|were|be|been|being|have|has|had|having|do|does|did|doing|a|an|the|and|but|if|or|because|as|until|while|of|at|by|for|with|about|against|between|into|through|during|before|after|above|below|to|from|up|down|in|out|on|off|over|under|again|further|then|once|here|there|when|where|why|how|all|any|both|each|few|more|most|other|some|such|no|nor|not|only|own|same|so|than|too|very|can|will|just|don|should|now|i|t|s)(\\ |$)", " "), "[\\s]{2,}", " ")
class Stick:
def __init__(self, color, length, weight):
self.color = color
self.length = length
self.weight = weight
stick = Stick('yellow', 1, 0.324)
@AndrewIngram
AndrewIngram / utils.py
Last active December 12, 2020 09:10
Django one-off on_save callbacks
from django.db import transaction
from django.db import models
from django.db.models.signals import post_save
def on_save(obj: models.Model, callback, on_commit=False):
"""
Attaches a one-off callback that's triggered after a Django model instance is
saved. Optionally makes use of transaction.on_commit to defer until any wrapping
transaction has also committed.
@swyxio
swyxio / Newton-1.29.vb
Last active July 10, 2022 08:34
Newton - my VBA utility library for doing matrix multiplication and other useful automations during my finance days https://twitter.com/swyx/status/1327041894853922816
Attribute VB_Name = "Newton"
'Newton Utilities, written by swyx
'Project initiated Jan 1 2012
'V1 released Feb 5 2012
'V1.1 added and renamed functions, updated helpfiles Apr 8 2012
'V1.2 spline interp extraction from surface, n_RandomWalk. released Jun 15 2012
'V1.21 n_Corr, n_TangencyPortfolio, n_CovMat subsumed into n_Cov, fixed n_GetTimeSeries, n_AutoCorr, n_Lag, n_Pval, added PValues to n_Regress, n_Payback, n_ChartMakeScatter
'V1.22 n_Granger, pval for n_Corr, n_Divide, n_Curve, n_PriceIRS, upgraded n_BuildCurve
'V1.23 n_PriceFwd/Rate, n_AutoRegress/n_Remove_AutoRegress (needs work), augmented n_PriceOption for pricing FXO, digitals, and returning greeks
'V1.24 n_FXOVolCurve, n_FormatAsPercent linked to ctrl+shift+5, n_FormatInc/DecreaseDecimalPlace
@markketai
markketai / markket-intro-to-ads.ipynb
Created October 23, 2020 21:25
Markket - Intro to Ads.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mroberts444
mroberts444 / hist_perimeters.py
Created September 28, 2020 06:03
CA Fire Perimeters
import geopandas as gpd
import pandas as pd
import fiona
import sys
import numpy as np
import folium
from folium.plugins import Search
#data from https://frap.fire.ca.gov/mapping/gis-data/
#create a list of layers within a file geodatabase
https://jennamolby.com/how-to-use-cookies-to-capture-url-parameters/
let YOUR_DOMAIN = "YOUR_DOMAIN.TLD" // ex: scrapingbee.com
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@vadivelselvaraj
vadivelselvaraj / compact.py
Last active November 10, 2022 04:20
CompactParquetFiles
# Read the S3 folder as glue dynamic data frames
input_dyf = glueContext.create_dynamic_frame_from_options("s3", {
"paths": [ inputPath ],
"recurse": True,
"groupFiles": "inPartition"
},
format = "parquet"
)
# Repartition them as required
@gwen001
gwen001 / ejs.sh
Last active July 7, 2024 07:33
onliner to extract endpoints from JS files of a given host
curl -L -k -s https://www.example.com | tac | sed "s#\\\/#\/#g" | egrep -o "src['\"]?\s*[=:]\s*['\"]?[^'\"]+.js[^'\"> ]*" | awk -F '//' '{if(length($2))print "https://"$2}' | sort -fu | xargs -I '%' sh -c "curl -k -s \"%\" | sed \"s/[;}\)>]/\n/g\" | grep -Po \"(['\\\"](https?:)?[/]{1,2}[^'\\\"> ]{5,})|(\.(get|post|ajax|load)\s*\(\s*['\\\"](https?:)?[/]{1,2}[^'\\\"> ]{5,})\"" | awk -F "['\"]" '{print $2}' | sort -fu
# using linkfinder
function ejs() {
URL=$1;
curl -Lks $URL | tac | sed "s#\\\/#\/#g" | egrep -o "src['\"]?\s*[=:]\s*['\"]?[^'\"]+.js[^'\"> ]*" | sed -r "s/^src['\"]?[=:]['\"]//g" | awk -v url=$URL '{if(length($1)) if($1 ~/^http/) print $1; else if($1 ~/^\/\//) print "https:"$1; else print url"/"$1}' | sort -fu | xargs -I '%' sh -c "echo \"\n##### %\";wget --no-check-certificate --quiet \"%\"; basename \"%\" | xargs -I \"#\" sh -c 'linkfinder.py -o cli -i #'"
}
# with file download (the new best one):
# but there is a bug if you don't provide a root url