Skip to content

Instantly share code, notes, and snippets.

View gnanet's full-sized avatar

Gergely Nagy gnanet

View GitHub Profile
@skatebkp
skatebkp / defer java on loading
Created May 15, 2013 07:49
5. Defer loading of JavaScript If you must use JavaScript, then it is a good idea to defer the loading of this code until after the page load event has fired. Google actually provides a deferral script you can use to do this: codesource // Add a script element as a child of the body function downloadJSAtOnload() { var element = document.createEl…
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
@mfellner
mfellner / rsync-sshfs.sh
Created June 9, 2013 15:42
Sync a local and a remote directory with rsync over sshfs (e.g. when you only have sftp access). Note the defer_permissions option and the -c (checksum) flag. Tested on OS X with rsync 2.6.9 and sshfs 2.4.0 (fuse4x 0.9.2).
#!/bin/bash
SSH_USER="user@sftp.domain.com" # your sftp credentials
SSH_KEY="~/.ssh/id_rsa" # your ssh private key
DOCUMENT_ROOT="/www/vhosts/mywebsite.com/htdocs" # directory on the remote server
LOCAL_DIR="~/mywebsite.com/public" # directory on your local machine
REMOTE_DIR="_remote_dir" # temporary mount point
mkdir -p $REMOTE_DIR
sshfs $SSH_USER:$DOCUMENT_ROOT $REMOTE_DIR -o workaround=rename -o defer_permissions -o IdentityFile=$SSH_KEY
@textarcana
textarcana / mac_xwindows_x11_xvfb_headless_firefox_howto.md
Last active January 4, 2026 21:33
Headless Selenium on CentOS 6.3 (Mac XWindows / X11 / Xvfb / Headless Firefox / Selenium howto)

XWindows for Headless Selenium

X Wing art by Paul Harckham

How to set up a Headless Selenium Testing environment for CentOS 6.3.

On your CentOS 6.3 host

Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.

@markSci5
markSci5 / Git checkout remote branch
Created July 3, 2013 07:08
Git checkout remote branch
//To fetch a branch, you simply need to:
git fetch origin
//This will fetch all of the remote branches for you. With the remote branches
//in hand, you now need to check out the branch you are interested in, giving
//you a local working copy:
git checkout -b test origin/test
@AlexPashley
AlexPashley / pleskCommands.sh
Last active October 22, 2019 23:43
PLESK: Useful PLESK common commands
# USEFUL PLESK COMMANDS
# restart plesk
/etc/init.d/psa restart
# reload plesk configs (useful for vhost.conf)
/usr/local/psa/admin/sbin/websrvmng -a -v
# restart qmail
service qmail restart
@cjmosure
cjmosure / functions.php
Last active June 23, 2018 01:37
Disable single Wordpress plugin update notifications
<?php
// Disable update notification for individual plugins
function filter_plugin_updates( $value ) {
unset( $value->response['block-spam-by-math-reloaded/block-spam-by-math-reloaded.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
?>
@umidjons
umidjons / dirname_basename.js
Last active August 26, 2018 17:28
PHP dirname() and basename() alternatives for JavaScript
function basename( path )
{
return path.replace( /\\/g, '/' ).replace( /.*\//, '' );
}
function dirname( path )
{
return path.replace( /\\/g, '/' ).replace( /\/[^\/]*$/, '' );
}
console.log( dirname( '/srv/www/dev/umid/admin/cfg.admin.php' ) );
@scr34m
scr34m / subversion
Created August 10, 2013 15:50
debian svnserve init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: svnserve
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active May 7, 2026 18:53
CriticalCSS Bookmarklet and Devtool Snippet.js
(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 pair = styles[i].split(": ");

Responsive Video Examples

These examples show you how to do responsive video both HTML 5 based and embedded video from YouTube (can work with video embedded from other sites). All of the HTML and CSS on this page is based on the good work done by Thierry Koblentz and Chris Coyier. See the HTML for links to their work.

A Pen by chris0stein on CodePen.

License.