Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
#!/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
#!/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
// jQuery non-linear/easing step
$({countValue:0}).animate(
{countValue:346},
{
duration: 1000,
easing: 'easeOutQuart',
step: function (value) {
console.log(value);
}
}
// 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;
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/
/**
* 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);
<?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
/**
* 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) {
/**
* 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)
*/
/*
Simple styles to have section elements skew at one end
*/
.section {
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
}