Skip to content

Instantly share code, notes, and snippets.

@zetas
zetas / ceilometer.conf
Created May 19, 2015 02:56
Grizzly Ceilometer Config
####################
# Existing
####################
database_connection = mongodb://{{ db_host }}:{{ db_port }}/{{ db_name }}
###################
# Proposed
###################
@zetas
zetas / ceilometer_contexts.py
Last active August 29, 2015 14:21
Ceilometer Context Changes
#########################
# Existing Method
########################
class MongoDBContext(OSContextGenerator):
interfaces = ['mongodb']
def __call__(self):
mongo_servers = []
replset = None
@zetas
zetas / QnA.php
Created April 3, 2015 16:00
Refactor of question/answer post form code for reddit
<?php
/**
* Ideally you would have two tables, one for questions with the following schema:
*
* id INT PrimaryKey
* question_text VARCHAR
* correct_answer_id INT
*
* and one for answers:
@zetas
zetas / update_stats.php
Created December 2, 2014 20:53
Status Display
<?php
require_once dirname(__FILE__) . '/config.php';
use nzedb\libraries\Cache;
use nzedb\libraries\CacheException;
use nzedb\db\Settings;
/**
* Update this directive to reflect your chosen webserver.
* Currently we only support nginx or apache out of the box.
@zetas
zetas / views.py
Last active January 31, 2018 17:18
CheckoutView implementing Stripe Subscriptions from a recent Django project
class CheckoutView(View):
form_class = CheckoutForm
template = 'account/checkout.html'
email_template_name = 'account.checkout_success'
def create_sub(self, user, customer, plan, quantity):
subscription = customer.subscriptions.create(plan=plan, quantity=quantity)
user.stripe_subscription_id = subscription.id
user.save()
@zetas
zetas / spartz_schemas.sql
Created June 6, 2014 09:58
Spartz Schemas
-- This is all generated by Laravel via migrations I created. It is effectively what I would have done by hand,
-- though I generally don't leave 255 character fields laying around everywhere and I'm a bit better with my indexing :)
--
-- Table structure for table `cities`
--
DROP TABLE IF EXISTS `cities`;
CREATE TABLE `cities` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@zetas
zetas / APIController.php
Created June 6, 2014 09:37
Spartz Controller
<?php
/**
* Created by DavidDV <ddv@qubitlogic.net>
* For project Spartz
* Created: 6/3/14
* <http://[github|bitbucket].com/zetas>
*/
class APIController extends BaseController {
@zetas
zetas / geocalc_test.php
Last active August 29, 2015 14:02
Crazy geospatial radius calculation
<?php
$db = new PDO('mysql:host=localhost;port=3306;dbname=homestead', 'homestead', 'secret');
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
#4980,Long Prairie,MN,verified,45.971955,-94.866789
$lat = 45.971955;
$lon = -94.866789;
@zetas
zetas / Gruntfile.js
Created May 11, 2014 06:35
New and improved gruntfile
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*!\n' +
' * <%= pkg.name %> v<%= pkg.version %>\n' +
' * <%= pkg.description %>\n' +
@zetas
zetas / package.json
Created May 5, 2014 18:28
Package.json for previously posted gruntfile.
{
"name": "Writerr",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-compass": "~0.7.2",