Skip to content

Instantly share code, notes, and snippets.

View parkr's full-sized avatar
📡
E.T. Phone Home

Parker Moore parkr

📡
E.T. Phone Home
View GitHub Profile
@mrryanjohnston
mrryanjohnston / Dockerfile
Created January 31, 2014 07:23
Running Jekyll from a Docker container. Uses a busybox container to host the Jekyll data (see http://docs.docker.io/en/latest/use/working_with_volumes/).
FROM ubuntu:12.04
#Install Ruby
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install ruby1.9.1 ruby1.9.1-dev make
#Pygments doesn't seem to want to work regardless of version installed
RUN gem install pygments.rb
#Install Jekyll
RUN gem install jekyll
@benbalter
benbalter / jekyll-csv.rb
Created May 27, 2014 22:06
Converts `.csv` files in a `_csvs` directory of a Jekyll site to `site.data` content
require 'csv'
module JekyllCsv
class Generator < Jekyll::Generator
def generate(site)
dir = File.expand_path "_csvs", site.source
return if site.safe && File.symlink?(dir)
entries = Dir.chdir(dir) do
Dir['*.csv']
@sdb
sdb / ril2ip.py
Created March 11, 2011 23:09
copy bookmarks from Read It Later to Instapaper
#! /usr/bin/env python
"""
Script to copy all bookmarks from Read It Later to Instapaper.
See also http://readitlaterlist.com/api/docs/#get
and http://www.instapaper.com/api/simple
"""
import urllib, urllib2, json
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
class Instapaper < OmniAuth::Strategies::XAuth
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
client_options = {
:title => 'Instapaper',
@parkr
parkr / line_count.py
Created September 20, 2011 01:34
Python Line Count
#! /usr/bin/env python
# By Parker Moore, http://www.parkermoore.de/
# Referenced the following URLs and compiled:
# http://lookherefirst.wordpress.com/2007/12/03/check-if-an-entry-is-a-file-or-directory-in-python/
# http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python
import sys, os
def file_len(fname):
@webchi
webchi / environment.rb
Created March 19, 2012 00:56
Custom form error messages for rails and yaml.de css framework
# This this replacemnt for default rails field_with_errors for using http://www.yaml.de/docs/index.html#yaml-forms
# Add this to ./config/environment.rb file
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<label/
%|<div class="ym-error"><p class="ym-message">#{[instance.error_message].join(', ')}</p>#{html_tag}</div>|.html_safe
else
%|<div class="ym-error">#{html_tag}</div>|.html_safe
end
@voidfiles
voidfiles / expandurl.py
Last active December 12, 2015 09:29
I wanted to share clean URL's directly from my phone. This is most specifically geared towards feedburner URL's, but could be just short URL's as well. This script unwraps any URL's surrounded with ** in the text on your clipboard. Unwraps them, and clears out unwanted query params. Then opens the text in felix for posting.
"""
Pythonist script to expand any URL surrounded by **'s
"""
import clipboard
import requests
import webbrowser
import urlparse
from urllib import quote, urlencode
@imathis
imathis / Guardfile
Last active December 19, 2015 11:19
Guard-Jekyll-Plus is a fancy Guard script for managing "smart" Jekyll builds. Changes in the source directory to non-template files will trigger a simple filesystem copy (or delete) to the destination directory. Changes to template files (configured by file extension) will trigger a Jekyll build.
require 'guards/guard-jekyll-plus.rb'
# Sample guard
guard :jekyll do
watch /^source/
watch '_config.yml'
end
@dhcole
dhcole / profile.md
Last active January 19, 2016 10:07
Profiling the `jekyll new` site
posts seconds time
1 0.824 0:0.824
100 2.644 0:2.644
1000 25.071 0:25.071
5000 186.715 3:6.715
10000 536.904 8:56.904

chart

@th0ma5w
th0ma5w / extract_horoscope.py
Created January 12, 2011 14:41
extract context from downloaded html files
"""
Example of using the old BeautifulSoup API to extract content from downloaded html files into CSV... if you're doing this sort of thing today, I recommend using the newer lxml interface directly, but lxml also has a BeautifulSoup compatibility layer.
"""
import os