Skip to content

Instantly share code, notes, and snippets.

Mike Hemesath mhemesath

Block or report user

Report or block mhemesath

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View splunk_clean_paths.py
from django.core.management import base
from django.core.cache import get_cache
from django.conf import settings
from django.core.management import call_command
import StringIO
import re
import urls
View month.html.erb
<% start_date = date.beginning_of_month.beginning_of_week - 1.day %>
<% end_of_month = date.end_of_month.end_of_week %>
<% weeks = (start_date...end_of_month).each_slice(7).to_a %>
<table>
<thead>
<% (0..6).each do |i| %>
<th><%= (start_date + i.days).strftime('%a') %></th>
<% end %>
</thead>
View settings.py
PIPELINE_LESS_ARGUMENTS = '--include-path=' + ':'.join([
'{0}/static/less'.format(app_module.filename)
for app_module in [pkgutil.get_loader(app) for app in INSTALLED_APPS]
])
View d3pyramid
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<!--[if lte IE 8]><script src="../r2d3.v2.js"></script><![endif]-->
<!--[if gte IE 9]><!-->
<script src="../lib/d3/d3.v2.js"></script>
<!--<![endif]-->
</head>
<body><div id="pyramidDiagram"></div></body>
<script>
@mhemesath
mhemesath / async_task_middleware.py
Last active Aug 21, 2019
MIddleware to allow celery tasks to be batched per request.
View async_task_middleware.py
from celery import task
class AsyncTaskMiddleware(object):
"""
Dynamically adds an async task queue to the request to be executed when the
response is processed.
All tasks added to the request are executed using a single asynchronous celery task.
Once the task is executed, it will execute each individual task in its own celery
task.
@mhemesath
mhemesath / transformToMatrix.js
Created Oct 9, 2012
Converts a SVG transform string into a Raphael Matrix object.
View transformToMatrix.js
function toMatrix(transform) {
var transforms = transform.split(' '),
matrix = Raphael.matrix();
for (var i=0; i<transforms.length; i++) {
var match = /^(\w+)\((.+)\)$/.exec(transforms[i]),
tranform = match[1],
values = toFloatArray(match[2]);
if ('translate' === transform) matrix.translate.apply(matrix, values);
@mhemesath
mhemesath / gist:2771836
Created May 22, 2012
Stylus Right-To-Left Support
View gist:2771836
.foo {
p { color: #333; text-align: rtl(right, left); }
}
// Output
.foo p { color: #333; text-align: left; }
html[dir="rtl"] .foo p { text-align: right; }
You can’t perform that action at this time.