Skip to content

Instantly share code, notes, and snippets.

View sobelk's full-sized avatar

Kieran Sobel sobelk

  • Newsela
  • New York, NY
View GitHub Profile
@sobelk
sobelk / react-markdown-toc.tsx
Created March 22, 2022 03:58
React Markdown TOC Proof-of-Concept
/*
This is based on an idea for building a table of contents on top of
React Markdown using a custom renderer. The original conversation is at
https://github.com/remarkjs/react-markdown/issues/48
*/
import React from "react";
import ReactMarkdown from "react-markdown";
from django.db.models import Q
def composite_in(columns, tuples):
return reduce(Q.__or__, [Q(**dict(zip(columns, t))) for t in tuples])
#
# MyModel.objects.filter(composite_in(
# ('col1', 'col2'),
# [(1,2), (1,3), (2,3)]))
#
#!/usr/bin/env python
import imaplib
import sys
from boto.ec2 import cloudwatch
email, password, mailbox = sys.argv[1:]
imap = imaplib.IMAP4_SSL('imap.gmail.com')
imap.login(email, password)
@sobelk
sobelk / tdbalance.sh
Created November 25, 2011 17:18
TD Bank check balance shell script
#!/usr/bin/sh
DOMAIN="onlinebanking.tdbank.com"
COOKIEJAR="cookiejar-tdbank"
USERAGENT='Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2'
USERNAME="username"
read -sp "Password: " PASSWORD; echo
curl \
"""
Simple py2exe compilation script for Windows. With a python file handler configured,
drag python script on to compile_wrapper.py. Runs py2exe for that file and cleans up
the temporary build/dist directories.
Setup options may need tweaking, and there is room for optimization
(see http://www.py2exe.org/index.cgi/OptimizingSize).
Requires:
py2exe, http://www.py2exe.org/index.cgi/FrontPage
"""
Django LaTeX custom template tag for equations (using amsmath).
Creates a .png in the project media directory and returns an img tag that references it.
Usage:
{% latex %}
x=\frac{-b \pm \sqrt {b^2-4ac}}{2a}
{% endlatex %}
// Cause a Fluid/Growl notification on Lala song change.
// I execute the following in the Firebug console with the Lala tab active.
// I would like to package it as a Jetpack, extension, or bundle it
// with an existing Lala extension.
// Yip implements the fluid/growl API on my computer.
function showLalaSongNotification(song) {
window.fluid.showGrowlNotification({