Skip to content

Instantly share code, notes, and snippets.

@ckng
ckng / script.js
Created April 29, 2014 10:34
IE8 last-child selector
(function ($) {
// IE8 last-child selector
Drupal.behaviors.lastChildIE8 = {
attach: function (context, settings) {
if (/msie [1-8]{1}[^0-9]/.test(navigator.userAgent.toLowerCase())) {
$('*:last-child').addClass('last-child');
}
}
};
@ckng
ckng / opcache.ini
Last active August 29, 2015 14:08
ZendOpCache
$ sudo apt-get install -y php-pear
$ sudo apt-get install -y build-essential php5-dev
$ sudo pecl search zendopcache
$ sudo pecl install zendopcache-7.0.3
$ sudo vi /etc/php5/conf.d/opcache.ini
$ sudo find / -name 'opcache.so'
$ sudo service php5-fpm restart
$ sudo service apache2 restart
@ckng
ckng / redis_mdel.sh
Created December 3, 2014 04:45
Redis: Bulk delete key
#!/bin/bash
if [[ -z $1 ]]
then
echo "Usage: $0 <key>, key: key to delete, e.g. \"mykey*\""
exit 1;
fi
# does not check if key exists
# if key does not exists, you likely get "ERR wrong number of arguments for 'del' command"
@ckng
ckng / flexbox.less
Last active August 29, 2015 14:20 — forked from wzr1337/flexbox.less
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
.old-flex-display(@display);
display: ~"-webkit-@{display}";
@ckng
ckng / gist:ba7a3735653ba15151c6
Created May 20, 2015 15:02
US States and Canada Provinces
US
AL|Alabama
AK|Alaska
AZ|Arizona
AR|Arkansas
CA|California
CO|Colorado
CT|Connecticut
DC|Dist. Columbia
DE|Delaware
@ckng
ckng / gist:a08805c5cbf81e82c569
Created June 7, 2015 03:05
AngularJS: Disable Debug Info for production
// Ref: https://docs.angularjs.org/guide/production#!
app.config(['$compileProvider', function ($compileProvider) {
// disable debug info
$compileProvider.debugInfoEnabled(false);
}]);
// Enabled back in browser console
angular.reloadWithDebugInfo();
@ckng
ckng / Preferences.sublime-settings
Last active October 8, 2015 03:58
Drupal Sublime Text user config
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by file type specific settings.
{
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"font_size": 12,
"ignored_packages":
[
"Vintage"
@ckng
ckng / swap-check.sh
Created November 2, 2015 13:31
Ubuntu: Check swap space usage by processes
#!/bin/bash
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n
@ckng
ckng / ubuntu-configure-sendmail-with-gmail
Created August 10, 2016 23:40 — forked from sshtmc/ubuntu-configure-sendmail-with-gmail
Ubuntu sendmail using smtp.gmail.com
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
@ckng
ckng / seed_derivatives.drush.inc
Created August 26, 2016 14:18 — forked from typhonius/seed_derivatives.drush.inc
This script can generate image derivatives for Drupal for warming up the filesystem prior to going live. Image derivative generation puts an amount of load on the servers so it images have been migrated from another server with no derivatives, it may be useful to pre-generate using this script.
<?php
/**
* Implements hook_drush_command().
*/
function seed_derivatives_drush_command() {
$items = array();
$items['seed_derivatives'] = array(
'description' => "Create image derivatives",