Skip to content

Instantly share code, notes, and snippets.

🖐
👁❤️open source software …

Michael Hulse mhulse

🖐
👁❤️open source software …
Block or report user

Report or block mhulse

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
@mhulse
mhulse / models.py
Created Jun 17, 2011
Django basic/simple category/sub-category model.
View models.py
# ...
class Category(Base):
slug = models.SlugField(_(u'slug'), max_length=100, unique=True)
title = models.CharField(_(u'title'), max_length=250)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
class Meta:
verbose_name_plural = 'Categories'
@mhulse
mhulse / fromhex.bash
Last active Sep 26, 2019
Bash function to convert hex to 256 terminal color.
View fromhex.bash
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
# http://unix.stackexchange.com/a/269085/67282
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
@mhulse
mhulse / allow_tags.py
Created Feb 4, 2012
[Django 1.3] Template tag that allows Django tags in variables (i.e. flatpage content).
View allow_tags.py
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
# http://www.soyoucode.com/2011/set-variable-django-template
# http://djangosnippets.org/snippets/861/
# http://stackoverflow.com/questions/4183252/what-django-resolve-variable-do-template-variable
# https://docs.djangoproject.com/en/dev/ref/templates/api/
@mhulse
mhulse / SelectActiveLayers.jsx
Last active Aug 2, 2019
Adobe Illustrator script to select highlighted layers. Written by @Qwertyfly and only slightly modified by me. Original code and discussion can found here: https://forums.adobe.com/message/8328893
View SelectActiveLayers.jsx
#target illustrator
function make() {
var name = 'temp'; // Action name.
var set = 'temp'; // Set name.
var level = app.userInteractionLevel;
var action;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
@mhulse
mhulse / javascript-plugin-patterns-FOUND-protoytpe-newed.js
Last active Jun 28, 2019
Some of my favorite JavaScript plugin design patterns: The Facade Pattern, The Revealing Module Pattern, Immediately-invoked Function Expressions (IIFE)s, The Module Pattern imports and exports
View javascript-plugin-patterns-FOUND-protoytpe-newed.js
// http://callmenick.com/post/slide-and-push-menus-with-css3-transitions
(function(window) {
'use strict';
/**
* Extend Object helper function.
*/
function extend(a, b) {
@mhulse
mhulse / Super simple background image slideshow.css
Last active Apr 14, 2019
Super simple jQuery background-image random slideshow (using CSS3 for the transition and gets the image paths via HTML5 `data` attribute).
View Super simple background image slideshow.css
[data-slides] {
background-image: url(../../uploads/banner1.jpg); /* Default image. */
background-repeat: no-repeat;
background-position: center top;
background-size: cover;
transition: background-image 1s linear;
}
/* Use additional CSS to control the `height` of `[data-slides]`, like so: */
@mhulse
mhulse / image-average-file-name.sh
Last active Mar 23, 2019
Image Magick command to convert images to the images average color and print file name in center of image
View image-average-file-name.sh
magick mogrify \
-colors 1 \
-shave 1x1 \
-bordercolor black \
-border 1 \
-pointsize 48 \
-fill black \
-gravity center \
-annotate +0+0 "%[f]" \
*
@mhulse
mhulse / Amazon S3 snippets and Transmit FTP cloud settings.md
Last active Feb 22, 2019
Amazon S3 snippets... Transmit FTP cloud settings... Other related goodies...
View Amazon S3 snippets and Transmit FTP cloud settings.md

S3 Website "Index Document"

index.html:

<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
@mhulse
mhulse / am_script2.py
Created Dec 13, 2012
Simple Python accessors (@getter/@Setter and @deleter) example/test using mixin and decorators... I'm using Python 2.6 for testing.
View am_script2.py
import pprint
# pprint.pprint(dir(obj))
# pprint.pprint(list)
# $ python manage.py runscript am_script2
class BaseMixin(object):
#----------------------------------
# Init:
@mhulse
mhulse / css.css
Created Jan 29, 2019
Slick Carousel CSS/JS; putting here for posterity’s sake
View css.css
.ap_library {
position: relative;
}
.ap_library > :first-child {
margin-top: 0;
}
.ap_library > :last-child {
margin-bottom: 0;
}
.ap_library {
You can’t perform that action at this time.