Skip to content

Instantly share code, notes, and snippets.

View dwightgunning's full-sized avatar
:shipit:

Dwight Gunning dwightgunning

:shipit:
View GitHub Profile
<script src="http://js.pusherapp.com/1.10.1/pusher.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// Enable pusher logging - don't include this in production
Pusher.log = function(message) {
if (window.console && window.console.log) window.console.log(message);
};
// Flash fallback logging - don't include this in production
#!/usr/bin/env python
"""
Lint python files before commit with flake8 and pep8 lint tools.
You can define lint settings in '.pep8' file in the project root.
Section '[pep8]' if for pep8 linter, and section '[flake8]' is for flake8.
INSTALL:
1. sudo pip install flake8 pep8
2. Save this file to '.git/hooks/pre-commit' file in your git repository
@dwightgunning
dwightgunning / template_tags.py
Created February 18, 2016 00:55
[Cactus] Revised 'static' template that supports a 'static-url' config key to enable an external static url
#coding:utf-8
import os
import logging
from django.template.base import Library
from django.conf import settings
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
logger = logging.getLogger(__name__)
@dwightgunning
dwightgunning / crowdfire-bookmarklets
Created March 3, 2017 13:12
CrowdFire bookmarklets
// Prepend with 'javascript:' in Chrome
// Hat tip to Nick Parsons: https://github.com/nparsons08
// Follow
function follow() {var items = document.querySelectorAll("[data-action='FOLLOW']"); console.log("Following " + items.length + " items..."); for (i=0; i<items.length; i++) {items.item(i).click();}}; follow();
// Unfollow
function unfollow() {var items = document.querySelectorAll("[data-action='UNFOLLOW']"); console.log("Unfollowing " + items.length + " items..."); for (i=0; i<items.length; i++) {items.item(i).click();}}; unfollow();
// Q1
<?php
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who();
}
@dwightgunning
dwightgunning / streamblogredirecttests.py
Created August 25, 2017 14:33
Tests for the (sub)-domain redirects set on the Stream blog - https://getstream.io/blog/
"""Tests for the (sub)-domain redirects set on the Stream blog.
See: https://getstream.io/blog/
Runs with Python 2.7 and 3.6
Dependencies:
- requests==2.18.4
Copyright (c) 2017 Dwight Gunning and other contributors
@dwightgunning
dwightgunning / linux-upskill-challenge-notes.md
Created October 5, 2020 07:03
My notes from the Linux Upskill Challenge (Sept 2020)

Linux Upskill Challenge - Notes

Day 1 - Accessing your server

Prohibit password login for the 'root' account: PermitRootLogin prohibit-password

Day 2 - Basic navigation

Use man and search with less/vim command syntax

@dwightgunning
dwightgunning / readme.md
Created December 31, 2022 00:19 — forked from lgg/readme.md
Keepass file format explained

Keepass file format explained

I’m currently working (I’m just at the beginning, and I’m quite slow) on a personal project that will use Keepass files (kdb and kdbx).
I tried to find some documentation about .kdb and .kdbx format, but I didn’t find anything, even in the Keepass official website. I you want to know how these file formats are structured, you must read Keepass’s source code. So I wrote this article that explains how Keepass file format are structured, maybe it will help someone.

@dwightgunning
dwightgunning / nba_season_dates.py
Created September 17, 2023 11:27
Proof-of-concept function to determine the NBA season (ie. year) based on a given date
import bisect
from datetime import datetime
from typing import (
Optional
)
import pytz
LEAGUE_OFFICE_TZ = pytz.timezone('America/New_York')
def datetime_league_tz(year, month, day):