Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / revert_locale_lang.php
Created April 14, 2014 08:04
Drupal 7: revert language column to "und" on locale uninstallation, this is not for site with multilanguage, only for site with unused/unconfigured locale
<?php
// Use this to identify possible table needs to be updated
// SELECT DISTINCT TABLE_NAME
// FROM INFORMATION_SCHEMA.COLUMNS
// WHERE COLUMN_NAME IN ('language')
// AND TABLE_SCHEMA='<YOUR_DATABASE>';
// include other custom fields
$tables = array(
@ckng
ckng / swapused.sh
Last active August 29, 2015 13:59
Get current swap usage for all running processes
#!/bin/bash
# swapused.sh
# -- Get current swap usage for all running processes
# --
# -- rev.0.4, 2014-04-11, Chin Kiong Ng - sort kb asc
# -- rev.0.3, 2012-09-03, Jan Smid - alignment and intendation, sorting
# -- rev.0.2, 2012-08-09, Mikko Rantalainen - pipe the output to "sort -nk3" to get sorted output
# -- rev.0.1, 2011-05-27, Erik Ljungstrom - initial version