Skip to content

Instantly share code, notes, and snippets.

@slackorama
slackorama / js-beautify.el
Created November 23, 2010 19:51
beautify some js code in emacs
;;; js-beautify.el -- beautify some js code
(defgroup js-beautify nil
"Use jsbeautify to beautify some js"
:group 'editing)
(defcustom js-beautify-args "--jslint-happy --brace-style=end-expand --keep-array-indentation"
"Arguments to pass to jsbeautify script"
:type '(string)
:group 'js-beautify)
@slackorama
slackorama / rpn.py
Created April 2, 2012 05:59
Python implementation of an RPN calculator
#!/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 / panagram.py
Last active January 13, 2021 02:08
Solve the NYT spelling bee. Mind you this isn't perfect.
#!/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()
// 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 / app.py
Last active January 8, 2019 19:17
pull info from strava
#!/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 January 8, 2019 19:00
Make Github starred repos bookmarks in pinboard. I wish IFTTT did this.
#!/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 January 8, 2019 00:15
get your read shelf from good reads and output an org table.
#!/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
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 December 2, 2016 21:35
pull a list from rtm and dump it in org
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
)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import time
import requests
SLEEP_TIME = 5