Skip to content

Instantly share code, notes, and snippets.

Avatar
🐞

Ben Lopatin bennylope

🐞
View GitHub Profile
@bennylope
bennylope / blogspot_to_jekyll.rb
Created Oct 5, 2011 — forked from kennym/blogspot_to_jekyll.rb
Migrate your blogger blog posts to jekyll.
View blogspot_to_jekyll.rb
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@bennylope
bennylope / pagination.rb
Created Oct 18, 2011
Jekyll pagination, pageN pages into /blog/ directory
View pagination.rb
module Jekyll
class Pagination < Generator
# This generator is safe from arbitrary code execution.
safe true
# Generate paginated pages if necessary.
#
# site - The Site.
#
@bennylope
bennylope / remotefiles.conf
Created Oct 19, 2011
nginx remote file proxying
View remotefiles.conf
location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) {
# Do not allow people to mess with this location directly
# Only internal redirects are allowed
internal;
# nginx has to be able to resolve the remote URLs
resolver 8.8.8.8;
# Location-specific logging
#access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main;
@bennylope
bennylope / gist:1894706
Created Feb 23, 2012
Canonical URLs with Jekyll
View gist:1894706
<link rel="canonical" href="http://yourdomain.com{{ page.url | replace:'index.html','' }}" />
View in-browser-tests.py
from django.test import LiveServerTestCase
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.webdriver import WebDriver
class MySeleniumTests(LiveServerTestCase):
@classmethod
def setUpClass(cls):
@bennylope
bennylope / gaussian_replacement.py
Created May 18, 2012
Quick example of creating a recolorized (one-color) image
View gaussian_replacement.py
# Replacement for ImageFilter.GaussianBlur which always sets the
# blur radius to the default of 2.
# Code from http://aaronfay.ca/content/post/python-pil-and-gaussian-blur/
import ImageFilter
class MyGaussianBlur(ImageFilter.Filter):
name = "GaussianBlur"
@bennylope
bennylope / LICENSE
Last active Feb 10, 2021
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
View LICENSE
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license
View gist:3902361
if CONF.has_key?("mounts")
for folder in CONF['mounts']
config.vm.share_folder(folder['name'], folder['virtual'], folder['host'], :nfs => true)
end
end
View Vagrantfile.rb
require "yaml"
# Load up our vagrant config files -- vagrantconfig.yaml first
_config = YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig.yaml"), File::RDONLY).read)
# Local-specific/not-git-managed config -- vagrantconfig_local.yaml
begin
_config.merge!(YAML.load(File.open(File.join(File.dirname(__FILE__),
"vagrantconfig_local.yaml"), File::RDONLY).read))
View cbv-dynamic-template.py
### MODEL
# -*- coding: utf-8 -*-
"""
Models for the "flatpages" project
"""
import time
import socket
from django.db import models