Skip to content

Instantly share code, notes, and snippets.

@slackorama
slackorama / panagram.py
Last active Jan 13, 2021
Solve the NYT spelling bee. Mind you this isn't perfect.
View panagram.py
#!/usr/bin/env python3
import sys
# called via `panagram.py ktocail`
# last letter in the word is required
def get_words(letters):
# prevent dupes
seen = set()
View blame_comma.js
// blame_comma.js -- loop through the files passed in and see who has commas
// in them
// find ../htdocs/js/ECM -type f -name "*.js" -print | xargs java -classpath /usr/share/yuicompressor-2.4.2/lib/rhino-1.6R7.jar org.mozilla.javascript.tools.shell.Main blame_comma.js
load('fulljslint.js');
load('runtime.js');
(function(args) {
@slackorama
slackorama / rpn.py
Created Apr 2, 2012
Python implementation of an RPN calculator
View rpn.py
#!/usr/bin/env python
# an rpn calculator in python
# > 19 2.14 + 4.5 2 4.3 / - *
# [85.297441860465113]
# only supports two operands and then an operator
import operator
ops = { '+': operator.add,
@slackorama
slackorama / app.py
Last active Jan 8, 2019
pull info from strava
View app.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cStringIO
import codecs
import csv
import logging
import sys
import webbrowser
@slackorama
slackorama / gh-starred-pinboard.py
Last active Jan 8, 2019
Make Github starred repos bookmarks in pinboard. I wish IFTTT did this.
View gh-starred-pinboard.py
#!/usr/bin/env python
# send github starred repos to pinboard
# Get the token here:
# https://api.pinboard.in/v1/user/api_token/info
from __future__ import print_function
import sys
@slackorama
slackorama / goodreads.py
Created Jan 8, 2019
get your read shelf from good reads and output an org table.
View goodreads.py
#!/usr/bin/env python
"""Grab the books from the current year from goodreads and emit an org mode table.
"""
from __future__ import print_function
import datetime
from email.utils import parsedate
import sys
import time
from xml.dom import minidom
View foobar.py
from lxml import objectify
tree = objectify.parse('/home/seth/Downloads/slackorama-2018-01-17-pettit-1-9725148.tcx')
root = tree.getroot()
namespaces = {'ns': 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2',
'ns3': 'http://www.garmin.com/xmlschemas/ActivityExtension/v2'}
for tp in root.xpath('//ns:Trackpoint', namespaces=namespaces):
print(tp.Time);
print(tp.xpath('.//ns:Extensions/ns3:TPX/ns3:Watts', namespaces=namespaces)[0])
@slackorama
slackorama / 02-124528.rtm.py
Created Dec 2, 2016
pull a list from rtm and dump it in org
View 02-124528.rtm.py
import rtm
token = '' # get this somewhere else
# this is the token and secret from the rtm-cli app so I assume putting it here is ok
milk = rtm.createRTM('cbc76268b901ccb8d9fc5f3aebc4ee1f',
'131beea786379309',
token
)
View es-index-rate.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import time
import requests
SLEEP_TIME = 5
View foo.el
(defun slack-lt/init-erc ()
"Initialize ERC"
(use-package erc
:init
(spacemacs/set-leader-keys
"aie" 'erc
"aiv" 'ssm-connect-slack-work
"aif" 'ssm-connect-freenode
"aib" 'ssm-connect-bitlbee
"aii" 'erc-track-switch-buffer)