Skip to content

Instantly share code, notes, and snippets.

Folding

  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
  • zr decreases the foldlevel by one.
  • zR decreases the foldlevel to zero -- all folds will be open.
@jfialkoff
jfialkoff / git_cheat.txt
Last active August 8, 2018 21:16
Git cheatsheet
Show log of modified files:
git log --name-only
Previous revision of a file:
git show REVISION:path/to/file
Merge upstream git branch:
git fetch upstream
git merge upstream/master
@jfialkoff
jfialkoff / campaignscraper.py
Last active August 29, 2015 14:06
Script to do a search Penn DOS contributor search by name and year.
# -*- coding: utf-8 -*-
import csv
import logging
import re
import sys
import time
import unittest
from bs4 import BeautifulSoup
from selenium import webdriver
def groupreduce(iterable, groups, is_part_of_group, add_item_to_group):
"""
Reduces a sorted iterable into groups.
>>> iterable = iter((1, 2, 8, 12, 32, 35))
>>> groups = (10, 20, 30, 40, 50)
>>>
>>> def is_part_of_group(group_id, item):
>>> return group_id-10 <= item < group_id
>>>
@jfialkoff
jfialkoff / functional.py
Created August 26, 2013 21:41
A collection of functional tools.
from django.utils.functional import curry
def spicy_curry(kallable, *args, **kwargs):
class CurryMixin(object):
def __init__(self, *moreargs, **morekwargs):
return super(CurryMixin, self).__init__(
*(args+moreargs), **dict(kwargs, **morekwargs))
res = type(kallable.__name__, (CurryMixin, kallable), {})
return res
@jfialkoff
jfialkoff / str_tools.py
Created August 26, 2013 14:21
Some useful string tools
def strjoin(*args, **kwargs):
""" Concatenates the arguments, ignoring any arguments that are empty or
None.
"""
delim = kwargs.get('delim', '\n')
res = ''
first = True
for arg in args:
@jfialkoff
jfialkoff / super_admin_email_handler.py
Last active December 19, 2015 09:08
This is an email handler like Django's built-in email hander that allows you to optionally send emails to admins even if it's lower priority than ERROR. You can also include additional content in the email. For example, logging.info('Something happened.', extra={'tell_admins': True, 'email_content': 'Some more info to put in the email.'})
import logging
import traceback
from django.conf import settings
from django.core import mail
from django.utils.log import AdminEmailHandler
from django.views.debug import ExceptionReporter
from django.views.debug import get_exception_reporter_filter
from .str_tools import strjoin
@jfialkoff
jfialkoff / event_formatter.py
Last active December 12, 2015 05:48
Takes a list of plain-text gigs (or events) in descending date order, and formats them for the web. Sample input in code.
"""
Takes a list of plain-text gigs (or events) in descending date order, and formats
them for the web in ascending date order. Here's an example of the input that's
expected (make sure to hit CTRL+D at the end of the input:
3/7: City Tap (Pay Notes) - 80%
City Tap (Philadelphia): City Tap House Philadelphia, PA
Shimmy
Drums: Alex (Pay Notes)
?Bass: Matt (Pay Notes)