Skip to content

Instantly share code, notes, and snippets.

View Deathnerd's full-sized avatar

Wes Gilleland Deathnerd

  • eLink Design
  • Lexington, KY
View GitHub Profile
import mimetypes
import os
from theerrorisme.database import (
Column,
db,
SurrogatePK,
ModifiedCols
)
@Deathnerd
Deathnerd / autoupdate_date_modified_columns.py
Last active August 29, 2015 14:25
A SQLAlchemy mixin to provide auto-updating of a last_modified column
from sqlalchemy.event import listens_for
from sqlalchemy.orm import Session
class ModifiedCols(object):
date_created = Column(db.DateTime(), default=datetime.datetime.now())
last_modified = Column(db.DateTime(), default=datetime.datetime.now())
@listens_for(Session, "before_flush")
def update_action(session, flush_context, instances):
@Deathnerd
Deathnerd / gulpfile.js
Created July 12, 2015 23:16
Static site builder with Gulp
var gulp = require('gulp');
var rename = require('gulp-rename');
var fileinclude = require('gulp-file-include');
var browserSync = require('browser-sync');
var path = require('path');
var prettify = require('gulp-prettify');
var jpegoptim = require('imagemin-jpegoptim');
var pngquant = require('imagemin-pngquant');
var optipng = require('imagemin-optipng');
var reload = browserSync.reload;
@Deathnerd
Deathnerd / snippet.txt
Last active August 29, 2015 14:19
Stuff
; Keep data labels. Compiler needs to know that these are to be initialized in memory
; Multiple direct data types: Decimal numbers, strings, hex (0xFF)
; General 32 bit registers
; Standard general data types: BYTE, DWORD, WORD, QWORD, etc...
.data
plain BYTE ? ; I like this syntax
code BYTE ?
prompt BYTE "Enter a string: ", 0
msg BYTE "The encoded string is:",0
buf BYTE DUP(100)? ; This is a little confusing
for(int i = 1; i <= n; i++){
for(int j = 1; j <= 2 * i; j *= 2){
// do stuff
}
}
@Deathnerd
Deathnerd / jinja.xml
Created April 8, 2015 00:37
Jinja Pycharm Live Templates
<templateSet group="jinja">
<template name="jinelse" value="{% else %}&#10; $END$" description="A simple else line" toReformat="true" toShortenFQNames="true">
<context>
<option name="HTML_TEXT" value="true" />
<option name="HTML" value="true" />
<option name="Django" value="true" />
</context>
</template>
<template name="jinblock" value="{% block $BLOCKNAME$ %}&#10;$END$&#10;{% endblock %}&#10;" description="A generic jinja block" toReformat="true" toShortenFQNames="true">
<variable name="BLOCKNAME" expression="" defaultValue="" alwaysStopAt="true" />
index = "1"
color_codes = {
"0": ["white", "white", "white", "black", "black", "white", "black"],
"1": ["white", "white", "black", "black", "white", "white", "black"],
"2": [], # More line colors here
"3": [], # More line colors here
"4": [], # More line colors here
"5": [], # More line colors here
"6": [], # More line colors here
index = "1"
color_codes = {
"0": ["white", "white", "white", "black", "black", "white", "black"],
"1": ["white", "white", "black", "black", "white", "white", "black"],
"2": [], # More line colors here
"3": [], # More line colors here
"4": [], # More line colors here
"5": [], # More line colors here
"6": [], # More line colors here
@Deathnerd
Deathnerd / add_service_providers_prototype.php
Last active August 29, 2015 14:14
An example of how to append to the providers array and the aliases array for laravel
<?
$file = "app/config/app.php";
$file_contents = file($file);
//the blank line is needed for consistency
$service_providers = <<<SERVICE_PROVIDERS
'Shoulderscms\Shoulderscms\ShoulderscmsServiceProvider',
'Lavary\Menu\ServiceProvider',
'Jaybizzle\Safeurl\SafeurlServiceProvider',
@Deathnerd
Deathnerd / shortcode.php
Created December 13, 2014 20:55
An implementation of wordpress-esque shortcodes with argument handling
<?php
/**
* Created by PhpStorm.
* User: Deathnerd
* Date: 12/13/2014
* Time: 2:30 PM
*/
/**
* This takes html with a wordpress-esque shortcode block with the format of: