Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Andre Marcelo-Tanner kzap

🏠
Working from home
View GitHub Profile
@coderanger
coderanger / __main__.py
Last active April 26, 2020 10:17
Django on Twisted with Prometheus
View __main__.py
"""
Support for running `python -m myapp`.
"""
from myapp.wsgi import main
if __name__ == "__main__":
main()
@kzap
kzap / showCommitsByAuthorDate.sh
Last active April 20, 2017 19:23
Show Git Commits Across All Branches By Dates in Reverse Order (By Author Date)
View showCommitsByAuthorDate.sh
# show author date and grep matching dates
git log --pretty=format:"%C(yellow)%h%Creset%C(cyan)%C(bold)%d%Creset %C(cyan)(%cr|%ai)%Creset %C(green)%aE%Creset %s" \
--all --no-merges --reverse --author="Andre" | grep -E "2017-01-(0[1-9]|1[0-9]|2[0-9]|3[0-1])"
@Mika-
Mika- / google-analytics.amp.html
Created October 18, 2015 10:34
Use Google Analytics in AMP HTML
View google-analytics.amp.html
<amp-pixel src="https://ssl.google-analytics.com/collect?v=1&amp;tid=UA-12345678-1&amp;t=pageview&amp;cid=$RANDOM&amp;dt=$TITLE&amp;dl=$CANONICAL_URL&amp;z=$RANDOM"></amp-pixel>
/*
* Required parameters:
* v = API version number (currently 1)
* tid = Google Analytics property identifier (UA-12345678-1)
* t = hit type
* cid = client id (you should implement this via cookie etc.)
* z = random string to bypass caching (amphtml generates this to $RANDOM variable)
@kzap
kzap / ubuntu-init-script.sh
Last active August 29, 2015 14:24
Ubuntu Build Init Script - configures a Rackspace Cloud server with all the necessary things you might want. Recommended flavor is a minimum 4-8GB as the disk partitions for /tmp and /var/log are 4-8GB
View ubuntu-init-script.sh
#!/bin/bash -x
# DESCRIPTION: The following UserData script is created to configure a Rackspace Cloud server
# with all the necessary things you might want.
# Recommended flavor is a minimum 4-8GB as the disk partitions for /tmp and /var/log are 4-8GB
#
# Can be used from CLI with nova or supernova
# example:
# supernova lincusa boot --image "Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)" --flavor performance1-8 --key-name {YOUR_KEY} --user-data "ubuntu-init-script.sh" --config-drive true {YOUR_SERVER_NAME}
#
@tknerr
tknerr / Vagrantfile
Last active February 19, 2023 22:46
Sample Vagrantfile that works with all providers (virtualbox, aws, managed) and in combination with the vagrant-omnibus plugin
View Vagrantfile
#
# Vagrantfile for testing
#
Vagrant::configure("2") do |config|
# the Chef version to use
config.omnibus.chef_version = "11.4.4"
def configure_vbox_provider(config, name, ip, memory = 384)
config.vm.provider :virtualbox do |vbox, override|
@kzap
kzap / addControllerMap.php
Created October 20, 2012 01:35
klein.php controller#action helper function
View addControllerMap.php
<?php
function addControllerMap($controllerMapCollection, $method = array('GET', 'POST'), $route = '*', $controllerMap = null) {
global $__controllerMaps;
// parse arguments
$args = func_get_args();
switch (count($args)) {
case 1:
$controllerMap = $controllerMapCollection;
@eranation
eranation / gist:3241616
Created August 2, 2012 22:51
MongoDB Aggregation Framework way for "select count (distinct fieldName) from someTable" for large collections
View gist:3241616
//equivalent of "select count (distinct fieldName) from someTable"
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ])
@manast
manast / interval.js
Last active March 26, 2023 23:33
Accurate Javascript setInterval replacement
View interval.js
function interval(duration, fn){
var _this = this
this.baseline = undefined
this.run = function(){
if(_this.baseline === undefined){
_this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()