Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stringfellow
stringfellow / pong-chat.md
Last active December 21, 2022 11:33
ChatGPT wrote Pong in an IIFE..!

Me: Using the language Javascript, create an IIFE that will play the game of Pong when run in a chrome debug console.

ChatGPT: Here is an example of how you could create an immediately invoked function expression (IIFE) that plays the game of Pong when run in a Chrome debug console:

Copy code

(function() {
  // set up canvas
@stringfellow
stringfellow / problem.md
Last active August 8, 2018 10:45
Celery hang problem

Celery 4.1.0, Redis client 2.10.6, Redis server 4.0

I have a problem that seems to be related to synchronous subtasks, except that none of the workarounds (or indeed the errors/warnings that I should expect from the docs) are having any effect.

I have 3 worker servers, A B and C

  • A and B run the same codebase.
  • A calls apply_async of a Task1. Get/Forget not called (it doesn't care about the result itself, but we want the result stored in the backend)
  • Task1 gets run by server B.
  • Within Task1 (now executed on server B) - Task2 from another codebase is called - using send_task (since the codebase is not shared here).

Keybase proof

I hereby claim:

  • I am stringfellow on github.
  • I am stringfellow (https://keybase.io/stringfellow) on keybase.
  • I have a public key ASDXUKQ063VHceGQE6EEdI1OX86qMYngre_FK_7K5eqnnQo

To claim this, I am signing this object:

@stringfellow
stringfellow / slinear vs linear
Last active September 7, 2018 11:52
linear & slinear interpolation of constant data
pandas slinear: [60.0, 60.0, 60.0, 60.0, 59.999999999999993, 60.0, 60.0, 60.0]
pandas linear: [60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0]
scipy slinear: [60.0, 60.0, 60.0, 60.0, 59.999999999999993, 60.0, 60.0, 60.0]
scipy linear: [60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0, 60.0]
F
======================================================================
FAIL: Proof that linear and slinear are not equal.
----------------------------------------------------------------------
Traceback (most recent call last):
File "....", line 329, in test_slinear_versus_linear
@stringfellow
stringfellow / stacked_area_hover.py
Created October 10, 2016 14:11
Showing how to make a Bokeh stacked area with hover labels per-series
def stacked_area(df, colours, series_noun, **kwargs):
"""Return a stacked area plot."""
columns = df.columns
areas = stacked(df, columns)
x2 = np.hstack((df.index[::-1], df.index))
p = figure(
width=900, height=600, tools=[
SaveTool(),
HoverTool(tooltips=[(series_noun, "@name")])
@stringfellow
stringfellow / middleware.py
Created March 17, 2016 16:04
Simple Django profiling middleware
# -*- coding: utf-8 -*-
import cProfile
import pstats
from django.conf import settings
class ProfileStatsMiddleware(object): # pragma: no cover
"""Super light-weight cProfile/pstats profile middleware."""
@stringfellow
stringfellow / ebay_sold_averagerer.js
Created January 1, 2016 20:12
eBay sold item averagerer
x=y=0;$('.bidsold').each(function(){x++;y+=parseFloat($(this).html().trim().substr(1,5))});y/x;
call "C:\OSGeo4w64\bin\o4w_env.bat"
IF NOT EXIST C:\mapproxy (
easy_install virtualenv
mkdir C:\mapproxy
cd C:\mapproxy
virtualenv --system-site-packages env
env\Scripts\activate
pip install pyreadline MapProxy ipython lxml
mapproxy-util create -t base-config mapactionproxy
cd mapactionproxy
@stringfellow
stringfellow / silence_if_ok.sh
Created July 12, 2012 10:09
Bash wrapper script to silence cron if there are no errors, and print out if there are
#!/bin/bash
logfile=$$.log
exec 6>&1
exec > $logfile 2>&1
$*
RETVAL=$?
exec 1>&6 6>&-
if [ $RETVAL -ne 0 ]; then
echo "FAILURES:"
cat $logfile