Skip to content

Instantly share code, notes, and snippets.

@teeli
teeli / Dockerfile
Last active August 1, 2017 07:33
Wuhu Docker Configuration
FROM php:5.6-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt mysql mysqli \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
COPY config/php.ini /usr/local/etc/php/
@teeli
teeli / codedeploy-to-slack.js
Last active October 13, 2022 13:18
CodeDeploy notifications to Slack (AWS Lambda via SNS)
var https = require('https');
var util = require('util');
exports.handler = function (event, context) {
console.log(JSON.stringify(event, null, 2));
console.log('From SNS:', event.Records[0].Sns.Message);
var severity = "good";
var message = event.Records[0].Sns.Message;
var messageJSON = JSON.parse(message);
@teeli
teeli / watch_url.sh
Created July 29, 2016 09:51
Watch a URL for changes and output the diff
#!/bin/bash
#
# This script checks if content in a specific URL has changed
# and shows the diff.
#
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
date=`date +%Y-%m-%d_%H:%M:%S`
echo "Starting process at $date in $dir"
filename="$dir/file.txt"
@teeli
teeli / pre-commit
Last active July 5, 2016 13:26
Pre-commit hook for Git to run ESLint and CSSComb before every commit to prevent committing bad code
#!/bin/sh
#
# Run ESLint and CSSComb before every commit to prevent committing bad code
#
HAS_NODE=`which node 2> /dev/null || which nodejs 2> /dev/null || which iojs 2> /dev/null`
#
# There are some issues with Source Tree because paths are not set correctly for
# the given environment. Sourcing the bash_profile seems to resolve this for bash users,
@teeli
teeli / silverstripe-i18n.js
Created January 29, 2016 14:04
A drop-in non-jquery replacement for Silverstripe's i18n.js
if(typeof(ss) == 'undefined') ss = {};
/*
* Lightweight clientside i18n implementation.
* Caution: Only available after DOM loaded because we need to detect the language
*
* For non-i18n stub implementation, see framework/javascript/i18nx.js
*
* Based on jQuery i18n plugin: 1.0.0 Feb-10-2008
*
@teeli
teeli / scrollToHash.js
Last active August 29, 2015 14:14
Animate scroll to anchor on hash links (jQuery)
var offset = offset || 0;
$('a[href*=#]').on('click', function (event) {
event.preventDefault();
// create a dummy element on current scroll position so we can write hash to document.location without scrolling immediately
$('body').prepend('<div style="position: absolute;top:' + window.scrollY + 'px" id="' + this.hash.substr(1) + '" class="scroll-placeholder"></div>');
document.location.hash = this.hash.substr(1);
$(this.hash + '.scroll-placeholder').remove();
// animate scroll
$('html,body').animate({scrollTop: $(this.hash).offset().top + offset}, 500);
});
@teeli
teeli / grid.scss
Last active December 22, 2015 07:48
Couple of simple mixins to help with responsive grids in SCSS
/*
* Simple grid system
*/
@mixin clearfix() {
*zoom: 1;
&:before,
&:after {
content: " "; /* 1 */
display: table; /* 2 */