Skip to content

Instantly share code, notes, and snippets.

View bergantine's full-sized avatar

Bergantine bergantine

View GitHub Profile
@bergantine
bergantine / gist:3900752
Last active October 11, 2015 18:27
Try and catch the button... non minified JS from http://www.romneytaxplan.com/. #demo #javascript
function getDirection(f, b) {
var h = f.width(),
d = f.height(),
a = (b.x - f.offset().left - h / 2) * (h > d ? d / h : 1),
c = (b.y - f.offset().top - d / 2) * (d > h ? h / d : 1),
g = Math.round((Math.atan2(c, a) * (180 / Math.PI) + 180) / 90 + 3) % 4;
switch (g) {
case 0:
return "top";
case 1:
@bergantine
bergantine / gist:4033360
Last active October 12, 2015 13:27
Django Template localhost switch. #django #djangotemplate
{% ifequal request.get_host '127.0.0.1:8000' %}
{# Include something only to be executed on "localhost" here. #}
{% else %}
{# Include something only to be executed in production here. #}
{% endifequal %}
@bergantine
bergantine / prompt.sh
Created November 7, 2012 20:15 — forked from tobiassjosten/prompt.sh
Bash Prompt with Git. #bash #shell
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\e[0;32m\]'
c_path='\[\e[1;34m\]'
c_git_clean='\[\e[0;37m\]'
c_git_staged='\[\e[0;32m\]'
c_git_unstaged='\[\e[0;31m\]'
else
c_reset=
@bergantine
bergantine / gist:4035311
Last active June 24, 2022 14:02
Django: Specify Test Database. #django #test #database
# Useful if dev settings are pointed at the production or staging database on a remote host
# In the dev settings, after the `DATABASES` configuration, add a second wrapped in an `if` statement
import sys
if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
@bergantine
bergantine / gist:4035433
Last active October 12, 2015 13:38
Google Analytics Event Tracking. #googleanalytics #javascript
// requires jQuery
// insert after _gaq is declared but before you talk to Google
// track all clicks on links as events
$('a').click(function(e) {
var debug = false; // if set to true will log instead of calling google
if (this.hostname && this.hostname !== location.hostname) {
var eCat = 'External Link';
} else {
@bergantine
bergantine / gist:4128679
Last active July 25, 2020 15:58
Django Template Tag and Filter Test File. #django #djangotemplate
{# asdf #}
{# {{ var }} {% if %} ... {% endif %} #}
{{ asdf }}
<script type="text/javascript">
fruits = new Array('apples', 'oranges', 'bananas');
for (var i=0; i < fruits.length; i++) {
alert(fruits[i]);
@bergantine
bergantine / Filter
Last active October 13, 2015 08:47
#Google #Analytics #Ignore User by User Defined Variable.
Setup a new filter in Google Analytics with the following configuration:
Filter Type: Custom Filter
Filter Field: User Defined
Filter Pattern: no_report
Case sensitive No
@bergantine
bergantine / gist:4340665
Last active December 9, 2015 22:58
Remove iOS button styling on an input (SASS + Compass). #html #html5 #safari #safarimobile #ios #button #input #form
input[type="submit"]
+experimental(appearance, none) // safari mobile does funny things
@bergantine
bergantine / gist:4487752
Last active September 6, 2020 22:39 — forked from dhc02/gist:4487729
Concatenate files in a directory into a single file. #ruby #donnieclapp
# Iterates over files and subdirectories in directorie[s] given as arguments
# and adds raw text of those files to merged.txt in the working directory
# where the script is called
# Call like this:
# ruby merge.rb {absolute path portion to delete} {directory to scan} [{directory to scan}]
# For example:
# ruby merge.rb /Users/donnieclapp/Projects/ ~/Projects/htl-website/myproject/static_media/stylesheets
# create or open the merged.txt file for writing (in working directory)
@bergantine
bergantine / gist:4742424
Last active December 12, 2015 08:09 — forked from murtaugh/1. single-line.html
Blockquote semantics enhanced by figure. #html #html5 #figure #happycog
Single line, no attribution:
<figure class="quote">
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
</figure>
Single line, with attribution and optional cite:
<figure class="quote">
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>