Skip to content

Instantly share code, notes, and snippets.

View rod-dot-codes's full-sized avatar

Rodney Hawkins rod-dot-codes

View GitHub Profile
@rod-dot-codes
rod-dot-codes / custom_view_middleware.py
Created December 8, 2014 08:45
This view which runs off a middleware just redirects it to to the function since if it goes any further down the chain CSRF fails it.
# Create your views here.
from redirects.models import get_redirect
from django.http.response import HttpResponseRedirectBase, HttpResponseNotFound
import logging
logger = logging.getLogger(__name__)
from django_bouncy.views import endpoint
@rod-dot-codes
rod-dot-codes / through_relationship.py
Last active September 22, 2015 19:50
Gist that illustrates the use of a through relationship in Django
from django.db import models
from django.contrib.auth.models import User
import datetime
from datetime import timedelta
import uuid
from django.db.models.signals import post_save,pre_save
from django.dispatch import receiver
class Image(models.Model):
""" This is an image. Declaring it seperate to the blog allows it to be reused.
@rod-dot-codes
rod-dot-codes / qq.cs
Created August 21, 2014 11:59
MSMQ Messaging Console Application that sends Payload to the server specified. Was intended to be used with Fundamental Fund Management System South Africa's MSMQ implementation.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Messaging;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using NDesk.Options;
namespace Send_MSMQ
@rod-dot-codes
rod-dot-codes / Stored Procedure into Temp Table .sql
Created August 8, 2014 13:05
Stored Procedure into a Temporary Table SQL Query
IF OBJECT_ID('tempdb..#tempRecon') IS NOT NULL
DROP TABLE #tempRecon
SELECT * into #tempRecon FROM OPENROWSET('SQLNCLI', 'Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx','SET FMTONLY OFF;SET NOCOUNT ON;EXEC rpt.xxx')
SELECT * FROM #tempRecon
order by Diff desc
@rod-dot-codes
rod-dot-codes / CreateWorkers.sql
Last active August 29, 2015 14:05
Create's SQL Simulated Workers
DECLARE @Process VARCHAR(1) = 'C'
--CREATE DATABASE SimulatedWorkers;
--GO
--DROP TABLE SimulatedWorkers.dbo.Jobs;
--GO
--CREATE TABLE SimulatedWorkers.dbo.Jobs (
--JobId int PRIMARY KEY IDENTITY(1,1), JobCommand VARCHAR(max), JobStatus VARCHAR(1), LockedByWorker uniqueidentifier, JobOutput VARCHAR(max)
--)
--GO
@rod-dot-codes
rod-dot-codes / PutYourCodeHere.cs
Created March 24, 2014 18:33
The NML Code Challenge Runner in C# for passing to the CUDA kernel.dll
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@rod-dot-codes
rod-dot-codes / Cuda.cu
Created March 24, 2014 18:32
The CUDA Code for the Game of Life project.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//Dependent on your Nvidia graphics card. Mine had a BLOCK_SIZE of 32.
#define BLOCK_SIZE 32
#define TILE_SIZE 32
//Rounds the value up to a multiple of BLOCK_SIZE.
//Usage found down south: dim3 dimGridProj(iDivUp(rowCount,BLOCK_SIZE), iDivUp(columnCount,BLOCK_SIZE));
@rod-dot-codes
rod-dot-codes / 0_reuse_code.js
Created November 29, 2013 08:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rod-dot-codes
rod-dot-codes / LinqPad-QueueMe.cs
Created October 31, 2013 09:45
Read the last message of a C# Queue
MessageQueue queue = new MessageQueue("FormatName:DIRECT=OS:<queue_address>")
{
MessageReadPropertyFilter = new MessagePropertyFilter
{
ArrivedTime = true,
Body = true
}
};
Console.WriteLine(queue.CanRead.ToString());
Console.WriteLine(queue.CanWrite.ToString());
@rod-dot-codes
rod-dot-codes / fabfile.py
Created October 17, 2013 14:01
A simple Fabfile which can be used to install Salt. Version 2 of this file, will use a Jinja configuration template for both master and minion and simply overwrite the files on each deployment. Example deployment: fab install_salt:True
#!/usr/bin/python
from __future__ import with_statement
from fabric.api import local, settings, abort, run, cd,env,sudo
from fabric.contrib.console import confirm
env.hosts = ['<server>']
env.user = '<user>'
salt_interface = '0.0.0.0' #Bind to all
salt_master = 'salt.<domain>' #Set up your subdomain salt, I like this version.