Skip to content

Instantly share code, notes, and snippets.

View hqmatics's full-sized avatar

Tjerk Hacquebord hqmatics

View GitHub Profile
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@hqmatics
hqmatics / .htaccess
Created August 9, 2012 19:46
Redirect to maintenance page
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REQUEST_URI} !images$
RewriteCond %{REMOTE_HOST} !^192\.168\.5\.102
RewriteRule $ /maintenance.html [R=302,L]
@hqmatics
hqmatics / gist:3347400
Created August 14, 2012 08:08
Install node.js
@hqmatics
hqmatics / gist:3350607
Created August 14, 2012 16:23
jQuery split into smaller files and load with ajax
function microAjax(url, callbackFunction) {
this.bindFunction = function (caller, object) {
return function() {
return caller.apply(object, [object]);
};
};
this.stateChange = function (object) {
if (this.request.readyState==4)
this.callbackFunction(this.request.responseText);
};
@hqmatics
hqmatics / gist:4136933
Created November 23, 2012 19:25
QNAP add cronjobs
1. Edit /etc/config/crontab and add your custom entry.
2. Run 'crontab /etc/config/crontab' to load the changes.
3. Restart cron, i.e. '/etc/init.d/crond.sh restart'
@hqmatics
hqmatics / couchpotato.sh
Created November 23, 2012 19:33 — forked from Remz-Jay/couchpotato.sh
QNAP NAS /opt/etc/init.d scripts (sickbeard, couchpotato, headphones)
#! /bin/sh
### BEGIN INIT INFO
# Provides: CouchPotato
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@hqmatics
hqmatics / netstat-functions.sh
Created July 14, 2013 19:52
netstat functions
# List connections for port
netstat -an | grep 12345
# List the number and type of active network connections
netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c
# Number of connections for each hosts
netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }'
# Number of connections for each port
@hqmatics
hqmatics / magento-add-block-to-template.phtml
Created July 15, 2013 07:28
Magento quick load cms block into template
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); ?>
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body<?php print $body_attributes;?>>
@hqmatics
hqmatics / passwordhashing.php
Created August 19, 2013 06:03
PHP Password hashing
<?php
$username = 'Admin';
$password = 'gf45_gdf#4hg';
// A higher "cost" is more secure but consumes more processing power
$cost = 10;
// Create a random salt
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');