Skip to content

Instantly share code, notes, and snippets.

View chriscauley's full-sized avatar

Chris Cauley chriscauley

View GitHub Profile
@chriscauley
chriscauley / demo.html
Created October 10, 2012 15:14
demo html file for intro so html
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="UTF-8">
<title>WaterColored Portfolio | A free CSS Template | made in PV.M Garage</title>
<meta name="description" content="Watercolored is a free css template released under Creative Common License by PV.M Garage">
<meta name="keywords" content="watercolored, web, design, xhtml, css, photoshop">
<meta name="author" content="Piervincenzo Madeo">
<meta name="keywords" content="watercolored, web, design, xhtml, css, photoshop">
<meta name="author" content="Piervincenzo Madeo">
<link href="http://www.pvmgarage.com/downloads/watercolored_portfolio/style.css" rel="stylesheet" type="text/css">
<style type="text/css"></style>
@chriscauley
chriscauley / reverseinlineform.py
Created November 20, 2012 23:16
reverse inline form
class DiabloAccountProductForm(forms.ModelForm):
product_name = forms.CharField(max_length=255)
sku = forms.CharField(max_length=255)
region = forms.ModelChoiceField(Region.objects.all())
account_name = forms.CharField(max_length=64)
code = forms.IntegerField()
def __init__(self,*args,**kwargs):
initial = kwargs.pop('initial',{})
instance = kwargs.get('instance',None)
product = getattr(instance,'product',Product())
function do_later () {
var args = arguments,
callback,
timeout;
if(args.length < 2) {
throw new Error("Function do_later requires at least two arguments, " + args.length + " given");
}
@chriscauley
chriscauley / mongo_to_django.py
Last active March 16, 2016 16:50
First attempt at creating a script to migrate from parse (mongodb) to django
import json, datetime, math, os
model_names = ['Subscription']
for model_name in model_names:
with open("%s.json"%model_name,'r') as f:
subscriptions = json.loads(f.read())
fields = {}
max_lengths = {}
nulls = {}
@chriscauley
chriscauley / nuke-space.js
Last active February 16, 2023 22:10
Nuke white space in <pre><code> tags
/*
Removes the minimum leading whitespace for each line in a pre > code tag.
Also optionally escapes html if you include the "nuke-html" class
When writing HTML snippets for slides or blogs, it's a pain to have to do this:
</div> <!-- original indentation level -->
<pre><code class="html">&lt;ul class="demo"&gt;
&lt;li&gt;No order here&lt;/li&gt;
&lt;li&gt;Or here&lt;/li&gt;
&lt;li&gt;Or here&lt;/li&gt;
(function() {
function _t(func) {
return function() {
return func(window.moment(new Date(this)));
}
}
String.prototype.date = _t(
function date(moment) { return moment.format("YYYY-MM-DD") }
)
String.prototype.verbose_date = _t(function (m){
for i in range(1,100):
if not i%15:
print "fizzbuzz"
elif not i%3:
print "fizz"
elif not i%5:
print "buzz"
# DANGERZONE!! This is globally overriding default python behavior. Caveat emptor
# FAKE_DATE=1999-01-01 python
# >>> import datetime_hack, datetime
# >>> datetime.date.today()
# 1999-01-01
import datetime
import os
@chriscauley
chriscauley / hack.js
Last active May 16, 2018 15:03
jquery datatables hack
// You'll want to change any place with a query selector to match your document. Otherwise this should be work for drag and drop
// I also am working with a massive spaghetti code mess, hence the global window funciton and the timeouts
// window.makeManagerDashSearch() should be called any time after the table is loaded (or even initiated as it refreshes itself
// also the final timeout with hiding the original search could probably be better accomplished with css
function debounce(func, wait, immediate) {
var timeout, wait = wait || 1000;
return function() {
var context = this, args = arguments;
var later = function() {
.wrapped {
.occurrence { display: flex; flex-direction: row-reverse !important; min-height: 0 !important; }
.occurrence h1 { width: 80%; }
.category { display: none; }
}
@yp-conference-days-tabs-underline-color: @teal;
@yp-conference-days-tabs-tab-num-items: 3;
@yp-conference-days-content-card-hover-filter: opacity(90%);
@yp-conference-days-content-card-comedy-background-color: #94959D;
@yp-conference-days-content-card-comedy-text-color: #5C5C5E;