Skip to content

Instantly share code, notes, and snippets.

View johnie's full-sized avatar
httpster

Johnie Hjelm johnie

httpster
View GitHub Profile
@johnie
johnie / NSA Navigation
Created August 11, 2013 15:19
Simple scrollspy
var lastId,
topMenu = $("#Navigation"),
topMenuHeight = topMenu.outerHeight()+0,
menuItems = topMenu.find("a"),
scrollItems = menuItems.map(function(){
var item = $($(this).attr("href"));
if (item.length) { return item; }
});
menuItems.click(function(e){
@johnie
johnie / git fetch
Created September 16, 2013 07:27
Use this if you encounter pull conflicts.
git fetch --all
git reset --hard origin/master
git fetch downloads the latest from remote without trying to merge or rebase anything.
Then the git reset resets the master branch to what you just fetched.
@johnie
johnie / bayern.json
Created August 8, 2014 20:49
Bayern München Game Schedule 2014/15
{
"data": {
"team": "Bayern München",
"season": "2014/15",
"squad": [
{"tee": 1, "name": "Manuel Neuer", "position": "GK"},
{"tee": 22, "name": "Tom Starke", "position": "GK"},
{"tee": 4, "name": "Dante", "position": "DF"},
{"tee": 13, "name": "Rafinha", "position": "DF"},
{"tee": 17, "name": "Jérôme Boateng", "position": "DF"},
@johnie
johnie / getUrlParam
Last active August 29, 2015 14:05
Quickly find a param in url with location.search
function $_GET(q,s) {
s = (s) ? s : window.location.search;
var re = new RegExp('&'+q+'=([^&]*)','i');
return (s=s.replace(/^\?/,'&').match(re)) ?s=s[1] :s='';
}
@johnie
johnie / chelsea.json
Created August 24, 2014 11:42
Chelsea Game Schedule 2014/15
{
"data": {
"team": "Chelsea",
"season": "2014/15",
"squad": [
{"tee": 1, "name": "Petr Čech", "position": "GK"},
{"tee": 23, "name": "Mark Schwarzer", "position": "GK"},
{"tee": 46, "name": "Jamal Blackman", "position": "GK"},
{"tee": 13, "name": "Thibaut Courtois", "position": "GK"},
{"tee": 2, "name": "Branislav Ivanović", "position": "DF"},
@johnie
johnie / drupal-npm.md
Last active August 29, 2015 14:08
Fix issue with running Gulp in Drupal

Add this to package.json

"scripts": {
  "prepublish": "find node_modules -name '*.info' -exec rm -f {} \\;"
}
@johnie
johnie / wgetsite.sh
Last active August 29, 2015 14:12
Download website with wget
#!/bin/bash
if [ -z "$1" ]
then
echo "Which website would like to download?"
exit 1
fi
wget \
--recursive \
@johnie
johnie / fabfile.py
Created January 11, 2015 20:37
Simple Fabric deploy
from __future__ import with_statement
import os.path
from fabric.api import *
from fabric.contrib.project import *
"""
Environments
"""
@johnie
johnie / browsealoud.js
Created January 13, 2015 13:33
browsealoud.js
var $bajq, domUrl, browsealoud = {
CAPTURE_ANALYTICS: false,
BASE_ADDRESS: "babm.texthelp.com",
URL_INFO_ADDRESS: "babm.texthelp.com",
COOKIE_NAME: "__ba_plus",
ELEMENT_PREFIX: "_ba_",
GA_PROPERTY_ID: "UA-4669579-7",
LIGHTBOX_WIDTH: 450,
LIGHTBOX_HEIGHT: 160,
LANG_MAP: [{