Skip to content

Instantly share code, notes, and snippets.

@ajford
ajford / ant.py
Created May 29, 2012 03:23
Simple implementation of Langston's Ants
import random
class Board(object):
def __init__(self,x,y, ant_count=1, blank=True, random_factor=0):
self.width = x
self.height = y
self.board = [ [ False for i in range(x)] for j in range(y) ]
self.ants = [ Ant(self) for i in range(ant_count) ]
@ajford
ajford / app.py
Created May 29, 2012 21:23
Flask-WTF CSRF Demo for rduplain/flask-wtf/#32
from flask import Flask
from flask.ext.wtf import Form, TextField
SECRET_KEY = "asdfhjgfdsyuhgfcxdsrethgf"
class MyForm(Form):
name = TextField('Name')
app = Flask(__name__)
@ajford
ajford / post-recieve
Created October 26, 2012 03:41
Static site deployment via git post-receive hook
#!/bin/sh
# Deploy hook for static sites (or similar application).
#
# Written by Anthony Ford <[email protected]>
#
# Essentially clones the repo into a directory then removes
# the git related files.
REPO_DIR=`pwd`
@ajford
ajford / app.py
Last active September 7, 2019 03:56
Flask MethodView test
from flask import (Flask, Blueprint)
from flask.views import MethodView
DEBUG = True
app = Flask(__name__)
class TestAPI(MethodView):
"Testing Flask MethodView"
@ajford
ajford / Vagrantfile
Last active August 29, 2015 14:08
Vagrant mount issue
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "box-cutter/centos64-i386"
@ajford
ajford / .ycm_extra_conf.py
Last active April 12, 2021 11:55
PlatformIO/YouCompleteMe Integration
"""
YouCompleteMe extra configuration for Platformio based
projects.
Based on the `.ycm_extra_conf.py` by @ladislas in his Bare-Arduino-Project.
Anthony Ford <github.com/ajford>
"""
import os
@ajford
ajford / unblock_analytics
Last active August 29, 2015 14:21
Unblock analytics on uBlock
@@||google-analytics.com^
@@||customer.io^
@@||optimizely.com^
@@||kissmetrics.com^
@ajford
ajford / App dir
Created May 5, 2016 17:23
uwsgi/nginx example
/var/www/apps
├── FoobarApp/
│ └── foobar/
│ ├── __init__.py
│ ├── static/
│ │ ├── imgs/
│ │ │ └── favicon.ico
│ │ └── js/
│ │ ├── admin.js
│ │ ├── common.js
@ajford
ajford / wtformstest.py
Created May 19, 2016 19:14
Example demonstrating the use of WTForms keyword arguments to set disabled state
import wtforms as wtf
class MyForm(wtf.Form):
sel = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
default=1)
class MyDisabledForm(wtf.Form):
sel1 = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
default=1,render_kw={'disabled':'disabled'})
sel2 = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
@ajford
ajford / Readme.mkd
Created December 25, 2016 02:09
Systemd service file for justseed.it downloader

This gist assumes the justseedit pieces downloader jar is placed in a directory named .justseedit within the home directory of a user with a username of user. Feel free to change this location to wherever you please.

It also assumes that /usr/bin/java/ is a compatible java implementation (at the time of writing, Oracle JRE 8).

It is recommended that you run the downloader manually via java -jar first, so you can verify that it's functioning correctly first. Don't forget you will need to modify the settings/api.txt and settings/piece_downloader.txt with your settings (at minimum the api key for your account.

If you wish to use the justseed.it downloader instead of the pieces downloader, you can change line 6 of the service file