Skip to content

Instantly share code, notes, and snippets.

@mundry
mundry / optimized-ga.js
Last active February 28, 2019 03:54
Mathias Bynens' optimized Google Universal Analytics snippet. (See http://mathiasbynens.be/notes/async-analytics-snippet)
// Mathias Bynens' optimized Google Universal Analytics snippet.
// http://mathiasbynens.be/notes/async-analytics-snippet
(function(window, document, variableName, scriptElement, firstScript) {
window['GoogleAnalyticsObject'] = variableName;
window[variableName] || (window[variableName] = function() {
(window[variableName].q = window[variableName].q || []).push(arguments);
});
window[variableName].l = +new Date;
scriptElement = document.createElement('script'),
firstScript = document.scripts[0];
@mundry
mundry / Gemfile
Last active October 19, 2016 17:55
Script to generate a make-style list of dependencies for a SASS file.
source "https://rubygems.org"
gem "sass"
@mundry
mundry / Makefile
Created May 9, 2014 18:23
A Makefile to build SASS files with automatically generated dependencies from a target's imports.
OUTPUT_DIR := build
SOURCES_DIR := styles
DEPS_DIR := .deps
RM := rm -rf
RUBY := ruby
SASS := scss
SASS_OPTIONS := --unix-newlines
SASS_OPTIONS += --style compressed
SASS_OPTIONS += --precision 8
@mundry
mundry / .gitignore
Last active August 29, 2015 14:01
C program to print the current local time to standard output.
local-time
@mundry
mundry / sha1.c
Last active August 29, 2015 14:01
Generate the Sha1 of a string using OpenSSL.
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
// gcc -o sha1 sha1.c -lcrypto
int main(void) {
const unsigned char ibuf[] = "compute sha1";
unsigned char obuf[20];
@mundry
mundry / Java8DateTimeApiExample.java
Last active August 29, 2015 14:02
Java 8 Date/Time-API example
import java.time.Duration;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class Java8DateTimeApiExample {
public static void main(String[] args) {
ZonedDateTime now = ZonedDateTime.now();
int daysOffset = (int) (Math.random() * 10) + 1;
@mundry
mundry / index.html
Created June 27, 2014 13:48
Moment.js setup
<script src="moment.js"></script>
<script src="de.js"></script>
<script>
(function(){
var timestamp = document.querySelector("[data-timestamp]");
timestamp.innerHTML = moment.unix(timestamp.getAttribute("data-timestamp")).format("dddd, Do MMMM YYYY, H:mm:ss");
}())
</script>
@mundry
mundry / grid-generator.py
Created July 2, 2014 15:04
Script to generate CSS rules for columns of a grid system.
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# Number of digits after the dot to be output in the CSS rule.
PRECISION = 8
def generate_grid(columns, className, collapseThreshold=1):
"""
Generates CSS code for a grid system.
columns - The number of columns the grid consists of.
@mundry
mundry / screenshot.png
Last active August 29, 2015 14:04
Success Message
screenshot.png
@mundry
mundry / gcd.c
Last active August 29, 2015 14:07
A C program to calculate the greatest common divisor of two numbers using the Euclidean algorithm.
#include <stdio.h>
#include <inttypes.h>
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a - (((int) (a / b)) * b));
}
int main(int argc, char const *argv[]) {
if (argc >= 3) {
const unsigned short pairs = (argc - 1) / 2;