Skip to content

Instantly share code, notes, and snippets.

View aaronmader's full-sized avatar

Aaron Mader aaronmader

View GitHub Profile
@aaronmader
aaronmader / frog.py
Created September 13, 2019 19:17
Dynamic solution to the frog problem.
####################
# Can you solve the frog problem?
# Regarding the video: https://www.youtube.com/watch?v=ZLTyX4zL2Fc
# By: Aaron Mader
#
# Note: This code doesn't actually NEED to be recursive, you could just iterate your way up from 1 to n.
# But your fractions will get pretty large (around n=500) before you run out of recursion depth
# (which happens at n=1000), so it doesn't really matter.
####################
@aaronmader
aaronmader / sanity_check.js
Created October 16, 2018 20:31
A simple script to attempt to identify the cause of differences between running puppeteer in headless and non-headless mode.
#!/usr/bin/env nodejs
const puppeteer = require('puppeteer');
function get_url(url, headless){
return new Promise(async function(resolve, reject){
const browser = await puppeteer.launch({headless: headless});
const page = await browser.newPage();
page.setViewport({'width':1920, 'height':1080});
page.goto(url).then(async function(){
@aaronmader
aaronmader / cleanup_nocrash.py
Last active November 25, 2015 15:04
A more robust version of the django 'cleanup' command, which requires less effort from the transaction handler of your database.
from datetime import datetime, timedelta
from django.core.management.base import NoArgsCommand
from django.contrib.sessions.models import Session
from django.db.transaction import commit
class Command(NoArgsCommand):
def handle_noargs(self, **options):
""" the conventional django cleanup method crashes when there's a few million records in django_sessions
so, do this without crashing.