Skip to content

Instantly share code, notes, and snippets.

@dukeofgaming
dukeofgaming / gist:b6b5163450da244ca699
Last active August 29, 2015 14:02
Reverse proxy in Apache
#/etc/httpd/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName {hostname}
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
@dukeofgaming
dukeofgaming / gist:4cdee61ea2ec2734c4b5
Created June 9, 2014 04:17
Register autoload of classes in a folder with customizable file naming rule
<?php
/**
* @author dukeofgaming
* @param string $path The path where the files with the classes are located (1 class per file always)
* @param function $rule Callback that receives the file name as parameter and returns the class name
*/
function autoloadPath($path,$rule=null){
$absolute_path = dirname(__FILE__).DS.$path;
$files = array_filter(
scandir($absolute_path),
<?php
/*
/com_mycomponent
|-/views
| |-/response
| |-/tmpl
| | |-default.php
| | |-index.html
| |-view.raw.php
*/
@dukeofgaming
dukeofgaming / gist:6d44cb7482a92ed23df2
Created June 9, 2014 04:12
Netbeans Macro Commands
Taken from http://six.vh.paanjoyhost.cn/?p=288:
Annotations Cycling [annotations-cycling]
Beep [beep]
Collapse All [collapse-all-folds]
Collapse All Java Code [collapse-all-code-block-folds]
Collapse All Javadoc [collapse-all-javadoc-folds]
Collapse Fold [collapse-fold]
Comment [comment]
Copy [copy-to-clipboard]
#Taken from:
# http://stevelosh.com/blog/2009/05/what-i-hate-about-mercurial/#hg-rm-is-a-confusing-mess
#Here’s part of the help for the hg rm command:
# This only removes files from the current branch,
# not from the entire project history. -A can be
# used to remove only files that have already been
# deleted, -f can be used to force deletion, and
# -Af can be used to remove files from the next
@dukeofgaming
dukeofgaming / gist:d13c49de65750708531c
Created June 9, 2014 04:12
IE7 display inline-block parse hack
/*Taken from: http://flipc.blogspot.com/2009/02/damn-ie7-and-inline-block.html*/
div.content_block{
display: inline-block; /*The way other browsers work correctly*/
/*IE7*/
zoom: 1; /*Meaningless for other than IE*/
*display: inline; /*Asterisk parse hack, ignored by smarter browsers*/
_height: Xpx; /*IE6 only parse hack, where X is the desired height*/
}
@dukeofgaming
dukeofgaming / gist:010ddb1dc0877f997c31
Created June 9, 2014 04:11
Recursively change permissions
#Taken from http://movabletripe.com/archive/recursively-chmod-directories-only/
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
@dukeofgaming
dukeofgaming / gist:8361b752a782826fdb8c
Created June 9, 2014 04:11
Inheritable PHP Singleton
<?php
class Object{
//...
private static $singletons = array();
public static function &singleton(){
$class = get_called_class();
if(!array_key_exists($class, self::$singletons)){
self::$singletons[$class] = new $class();
}
return self::$singletons[$class];
@dukeofgaming
dukeofgaming / gist:76e9752ffe8009a1d0e0
Created June 9, 2014 04:10
Create bootable USB in WIndows
#Create bootable drive, via: http://thelazyadmin.com/blogs/thelazyadmin/archive/2009/01/08/installing-windows-7-via-usb-or-sd-media.aspx
diskpart
list disk (find the disk number for the removable media)
select disk #
clean
create partition primary
select partition 1
active
format fs=fat32 quick
@dukeofgaming
dukeofgaming / gist:04e3217bbe195acc9d6d
Created June 9, 2014 04:09
A shell script to encrypt a file so that only a SSL site's private key can decrypt
#Taken from http://dpaste.de/61O8/
set -e
echo "Encrypting $2 for $1."
# make a directory to store results for this site
mkdir -p results/$1
# get that site's SSL certificate, validating it with the cacert.pem we have