Skip to content

Instantly share code, notes, and snippets.

@chrislaskey
chrislaskey / iptables.rules
Created January 15, 2013 21:37
Example generic iptable rules file for forwarding traffic from port 80 to port 8080, used in this case for configuring Jenkins/Hudson to run on port 80. Initial commit is the default iptable rules' output from `iptables-save > /etc/iptables.up.rules` on Ubuntu Server 12.04. The revised commit are the updated rules to forward traffic from port 80…
## Filter Table
*filter
:INPUT ACCEPT [971:197590]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [95:9682]
-A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
COMMIT
@chrislaskey
chrislaskey / flask_application.wsgi
Created February 23, 2013 21:49
Example of a basic .WSGI template for Python Flask deployments using Apache with Mod_WSGI
#!/usr/bin/env python
# Adding the current directory to the Python path is easy:
import os
import sys
this_dir = os.path.dirname(__file__)
sys.path.insert(0, this_dir)
# Now that the Python path includes the current directory, any
# application specific modules can be loaded just like this was
@chrislaskey
chrislaskey / .htaccess
Last active December 17, 2015 17:09
Apache .htaccess configuration for auto-appending `.php` filename extension.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
# The two RewriteCond rules are boilerplate, they make sure files that exist
# on the server (CSS, JS, images, etc) will not have their URLs rewritten and
# be served directly.
# The RewriteRule captures all remaining URL requests, and adds a .php to the end.
@chrislaskey
chrislaskey / RequestParser.py
Last active December 20, 2015 08:59
A real world example of a Python Flask utility class used in the simpledocs.co and chrisandgitte.com projects. The gist shows the progression from a minimum viable product first, to a refactored library class for general use. The unit tests used in the refactor are appended in a final commit for completeness.
#
# File lib/requestparser.py
#
class RequestParser:
def parse(self, flask_request):
self.request = flask_request
return self._parse_request()
@chrislaskey
chrislaskey / profile.pp
Created February 19, 2014 14:47
Avoiding circular includes when using the profiles / roles pattern in Puppet
# Lesson: always use root scope when including a puppet module inside a profile or role file, e.g.:
# include ::module
# Wrong way
class profile::mail::exim {
include exim
# This expands to current namespace first:
# include profile::mail::exim
# Causing a circular dependency. Include does not throw duplicate errors, so this fails silently.
# Intended 'exim' module is never loaded

Keybase proof

I hereby claim:

  • I am chrislaskey on github.
  • I am chrislaskey (https://keybase.io/chrislaskey) on keybase.
  • I have a public key whose fingerprint is 8CD3 5967 D382 DEE0 28CD F5AA ABF2 E964 4FA7 88C0

To claim this, I am signing this object:

var reducer = (state = {}, action) => {
switch action.type {
case "CUSTOM_ACTION":
return merge({}, state, {value: action.value});
default:
state
}
}
@chrislaskey
chrislaskey / spec-js-generate_fixtures.js
Created August 8, 2016 16:05
Generate deserialized test fixtures objects from JSON:API response data
#!/usr/bin/env node
var fixtures = [
"spec/js/react/apps/fixtures/index.json",
"spec/js/react/apps/fixtures/show.json"
]
var fs = require("fs")
var Deserializer = require("jsonapi-serializer").Deserializer
var deserialize = new Deserializer({keyForAttribute: "camelCase"}).deserialize
@chrislaskey
chrislaskey / GIF-Screencast-OSX.md
Created October 10, 2017 16:25 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: