Skip to content

Instantly share code, notes, and snippets.

@goldhand
goldhand / anagrams.py
Created September 12, 2013 17:04
anagrams
__author__ = '@goldhand'
import itertools
import os
import sys
_root = os.path.dirname(os.path.abspath(__file__))
_lib = os.path.join(_root, 'lib')
__author__ = '@goldhand'
import itertools
import os
import sys
_root = os.path.dirname(os.path.abspath(__file__))
_lib = os.path.join(_root, 'lib')
@goldhand
goldhand / settings.py
Created October 27, 2013 22:01
Cool settings configuration from @pydanny's django-cookiecutter
# -*- coding: utf-8 -*-
"""
Django settings for onegreek project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
@goldhand
goldhand / wpl_project_setup
Last active August 29, 2015 14:08
Django/Python Web Dev Setup
$ sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 curl libxslt-dev libpq-dev git python python-virtualenv
$ mkdir $VENV/$PROJECTNAME
$ virtualenv $VENV/$PROJECTNAME
$ source $VENV/$PROJECTNAME/bin/activate
$ cd $PROJECTS
$ mkdir $PROJECTNAME
$ cd $PROJECTNAME
class LocalCzar(Local):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dtf',
'USER': 'charina',
}
}
@goldhand
goldhand / parallax
Created January 30, 2015 01:07
simple javascript parallax script
// Create cross browser requestAnimationFrame method:
window.requestAnimationFrame = window.requestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.msRequestAnimationFrame
|| function(f){setTimeout(f, 1000/60)}
var parallaxElem = document.getElementById('parallax-content');
var scrollRate = .5; // move parallaxElem at 50% of scroll rate
@goldhand
goldhand / scrolling angular
Last active August 29, 2015 14:14
messing with scrolling in angularjs
$rootScope.scrollLevel = {
'one': false,
'two': false,
};
$rootScope.scrollY = window.pageYOffset;
$rootScope.scrollingDown = false;
$rootScope.scrollingUp = false
window.onscroll = function () {
if($rootScope.scrollY>window.pageYOffset){
$rootScope.scrollingDown = false;
@goldhand
goldhand / scrollTools.js
Last active August 31, 2017 01:10
a few functions that use scroll
(function() {
// author: Will Farley
// github: @goldhand
// Create cross browser requestAnimationFrame method:
window.requestAnimationFrame = window.requestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.msRequestAnimationFrame
@goldhand
goldhand / No Access Control Allow Origin Header is present
Created February 4, 2015 21:33
XMLHttpRequest cannot load {resource}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{request_origin}' is therefore not allowed access
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>access-control-allow-origin</AllowedHeader>
<ExposeHeader>access-control-allow-origin</ExposeHeader>
</CORSRule>
</CORSConfiguration>
@goldhand
goldhand / selectColor.js
Created February 9, 2015 21:06
Selects a color based on "color" query
<script>
(function(){
function getQueryString() {
var queryString= [];
var hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
queryString.push(hash[0]);