Skip to content

Instantly share code, notes, and snippets.

View chrisgrande's full-sized avatar

Christopher Grande chrisgrande

View GitHub Profile
@cyberdelia
cyberdelia / mixin.py
Created September 21, 2011 08:26
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
@parkerl
parkerl / extract_and_download_images_from_css.md
Created February 8, 2012 18:31
Extract image URLs from a CSS file and download them onto a new server (Linux)

#Extract Image URLs and WGet Them to a New Server#

This was a fun problem. I needed to move all the images referenced in a CSS file to another server. I didn't want to just grab all the image files as there were a bunch I didn't need. Here is how I went about it. I am sure you could do it in one step but doing it this way gives you a chance to check for errors.

First you may want to use wget http://otherserver/the_css.css to pull the CSS file on to the target server if it is still on the old server as it was in my case.

  1. User grep to extract the URLs from the css file into another file. (You may need to adjust the regular expression if you have funny characters in your file names) Note the use of the -o flag that tells grep to only print out that part of the line that matches the expression rather than the entire line.

     grep -o '\/path\/to\/files\/[a-zA-Z0-9/.:_-]*' the_css.css > images.txt
    
@dankrause
dankrause / _hover_example.py
Last active March 8, 2024 18:31
Example code to use the (unofficial, unsupported, undocumented) hover.com DNS API.
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)
@rickychilcott
rickychilcott / pro_tools_11_munki.sh
Last active October 26, 2021 23:45
My (working) attempt to get PT 11 to install successfully
#!/bin/bash
# Copy the com.avid.bsd.DigiShoeTool Helper Tool
PHT_DIGISHOETOOL="/Library/PrivilegedHelperTools/com.avid.bsd.DigiShoeTool"
/bin/cp "/Applications/Pro Tools.app/Contents/Library/LaunchServices/com.avid.bsd.DigiShoeTool" $PHT_DIGISHOETOOL
/usr/sbin/chown root:wheel $PHT_DIGISHOETOOL
/bin/chmod 544 $PHT_DIGISHOETOOL
# Create the Launch Deamon Plist for com.avid.bsd.DigiShoeTool
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@erikng
erikng / swupd.conf
Last active December 26, 2015 10:58
Mountain Lion Server - Maverick Client Support
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Darwin/9
RewriteRule ^/index\.sucatalog$ http://%{HTTP_HOST}/cgi-bin/SoftwareUpdateServerGetCatalog?/index-leopard.merged-1.sucatalog
RewriteCond %{HTTP_USER_AGENT} Darwin/10
RewriteRule ^/index\.sucatalog$ http://%{HTTP_HOST}/cgi-bin/SoftwareUpdateServerGetCatalog?/index-leopard-snowleopard.merged-1.sucatalog
RewriteCond %{HTTP_USER_AGENT} Darwin/11
RewriteRule ^/index\.sucatalog$ http://%{HTTP_HOST}/cgi-bin/SoftwareUpdateServerGetCatalog?/index-lion-snowleopard-leopard.merged-1.sucatalog
RewriteCond %{HTTP_USER_AGENT} Darwin/12
RewriteRule ^/index\.sucatalog$ http://%{HTTP_HOST}/cgi-bin/SoftwareUpdateServerGetCatalog?/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
@vimishor
vimishor / 503.html
Last active December 31, 2015 05:59
Custom 503 page while deploy on openshift | License: MIT
<!DOCTYPE html>
<html>
<head>
<title>Deploy in progress. Please try again in few minutes</title>
<style type="text/css" />
body {color: #666; text-align: center; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; sans-serif; margin:0; width: 800px; margin: auto; font-size: 14px; }
h1 { font-size: 56px; line-height: 100px; font-weight: normal; color: #456; }
h2 { font-size: 24px; color: #666; line-height: 1.5em; }
h3 { color: #456; font-size: 20px; font-weight: normal; line-height: 28px; }
hr { margin: 18px 0; border: 0; border-top: 1px solid #EEE; border-bottom: 1px solid white; }
@bryanzak
bryanzak / ARDFixer.command
Last active March 3, 2017 05:36
ARD Admin 3.7.1 Fixer - a script to cause ARD Admin to effectively "forget" all cached IP and DNS information for known computers. This deals with a problem in ARD Admin 3.7.1 where it seems to be too aggressive in caching this information
#!/bin/bash
SCRIPT_VERSION="1.0"
# some background info here: https://discussions.apple.com/message/24596710#24596710
# verify ARD Admin version
# quit ARD Admin - if running, wait 10 seconds
# kill cfprefsd
# rename plist
# sed
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@cabal95
cabal95 / pro_tools_12_munki.sh
Last active December 29, 2016 21:42 — forked from rmanly/pro_tools_11_munki.sh
Updated script to work with Pro Tools 12
#!/bin/bash
# looks like they changed they name again
# https://groups.google.com/forum/#!topic/munki-dev/w38roCmEgH0
# I have 11.2.1.203 and it is now just 'shoe'
# Changed once again, 12.0.0.456 and it is 'shoetoolv120'
# Copy the com.avid.bsd.shoe Helper Tool
PHT_SHOE="/Library/PrivilegedHelperTools/com.avid.bsd.shoetoolv120"