This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Will print the 3rd line of all script files in the given folder (except 'myscripts') | |
for file in ~/scripts/*[^~"myscripts"] | |
do | |
tail -n+3 $file | head -n1 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vpntog [vpn.name] [on/off/state] | (Dis)connect to the given VPN | |
if [ "$2" == 'on' ]; then | |
nmcli con up id $1 | |
echo vpn @$1 > on | |
elif [ "$2" == 'off' ]; then | |
nmcli con down id $1 | |
echo proxy @$1 > off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# proxtog [on/off] | Toggle custom proxy settings on/off | |
state=$(gsettings get org.gnome.system.proxy mode) | |
if [ "$1" == 'on' ]; then | |
gsettings set org.gnome.system.proxy mode 'manual' | |
echo proxy > on | |
elif [ "$1" == 'off' ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery non-linear/easing step | |
$({countValue:0}).animate( | |
{countValue:346}, | |
{ | |
duration: 1000, | |
easing: 'easeOutQuart', | |
step: function (value) { | |
console.log(value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Snippet to sniff out the first-render CSS | |
(function() { | |
var CSSCriticalPath = function(w, d, opts) { | |
var opt = opts || {}; | |
var css = {}; | |
var pushCSS = function(r) { | |
if(!!css[r.selectorText] === false) css[r.selectorText] = {}; | |
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/); | |
for(var i = 0; i < styles.length; i++) { | |
if(!!styles[i] === false) continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newHash = '', | |
$mainContent = $('#content'); | |
$('nav').delegate('a', 'click', function() { | |
window.location.hash = $(this).attr('href'); | |
return false; | |
}); | |
// Not all browsers support hashchange | |
// For older browser support: http://benalman.com/projects/jquery-hashchange-plugin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Two snippets to query the GET variable from the URL | |
* | |
* @param variable | |
* @returns {*} value of the GET variable or false when it's missing | |
*/ | |
function queryGetVariable(variable) | |
{ | |
var query = window.location.search.substring(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validateDate($date, $format = 'Y-m-d H:i:s') | |
{ | |
$d = DateTime::createFromFormat($format, $date); | |
return $d && $d->format($format) == $date; | |
} | |
var_dump(validateDate('2012-02-28 12:12:12')); # true | |
var_dump(validateDate('2012-02-30 12:12:12')); # false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple type check for integers | |
* | |
* Interprets integer valued strings as integers (e.g. '22' will return true). | |
* | |
* @param value | |
* @returns {boolean} | |
*/ | |
function isInt(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the numeric equivalent of an English (shortened) month name | |
* | |
* It's best to keep the English version in the element's data | |
* attribute when dealing with translatable strings. | |
* | |
* @param monthStr long or short month name | |
* @returns {number} month's integer equivalent (1-12) | |
*/ |