Skip to content

Instantly share code, notes, and snippets.

View pauljacobson's full-sized avatar
:octocat:

Paul Jacobson pauljacobson

:octocat:
View GitHub Profile
@philipbl
philipbl / import.py
Created August 15, 2012 22:57
Imports Evernote HTML into DayOne
from optparse import OptionParser
from HTMLParser import HTMLParser
import os
import glob
import sys
import re
class Entry():
def __init__(self):
self.tags = []
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@derekkwok
derekkwok / encode.py
Last active December 5, 2020 12:14
Simple python script to encode videos using ffmpeg
"""
This python script encodes all files that have the extension mkv in the current
working directory.
Sources:
http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide
"""
import subprocess, os
#-------------------------------------------------------------------------------
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@jamsinclair
jamsinclair / aws-minecraft-setup.sh
Last active May 24, 2022 05:25
A bash script to setup a simple Minecraft Server on an AWS Micro EC2 Instance. Installs server, configures cron to run server on reboot, adds some aliases for easy stop/start of minecraft server.
#!/bin/sh
runMinecraftCommand="java -Xms256M -Xmx768M -jar minecraft_server.jar nogui"
startScript="start.sh"
echo "Great let's get minecraft setup!"
# Sanity check, do we have java installed?
if ! hash java 2>/dev/null; then
echo "You don't have java installed. You're gonna have a tough time."
echo "Are you sure you selected the default Amazon Linux HVM ami?"
@danielwrobert
danielwrobert / wordpress-xml-splitter.py
Last active November 12, 2023 08:44
WordPress XML Splitter
'''
Created on May 8, 2010 by @anasimtiaz
Updated on May 28, 2016 by @danielwrobert
This is a "fork" of original script.
Original script URL: http://anasimtiaz.com/?p=51
'''
@robvolk
robvolk / es6_fetch_example.js
Last active October 17, 2019 16:46
AJAX requests in ES6 using fetch()
// ES6 Fetch docs
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('https://some.url.com')
.then(response => {
if (response.ok) {
return Promise.resolve(response);
}
else {
return Promise.reject(new Error('Failed to load'));
@ljharb
ljharb / array_iteration_thoughts.md
Last active April 22, 2024 10:15
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@dvirsky
dvirsky / gendocs.py
Last active September 12, 2021 16:12
Generate Markdown documentation from a python package
# This script generates mkdocs friendly Markdown documentation from a python package.
# It is based on the the following blog post by Christian Medina
# https://medium.com/python-pandemonium/python-introspection-with-the-inspect-module-2c85d5aa5a48#.twcmlyack
import pydoc
import os, sys
module_header = "# Package {} Documentation\n"
class_header = "## Class {}"
function_header = "### {}"
@TheFrostlixen
TheFrostlixen / batch_ren.py
Last active May 17, 2021 10:37
Python script to batch rename files via regex
import glob, os
# point path to directory containing the shows
# load episode titles into `ep.txt`
path = r"I:\Videos\show"
new_filenames = []
with open(path + '\\ep.txt', 'r') as f:
for line in f:
new_filenames.append(line)