Skip to content

Instantly share code, notes, and snippets.

@dukeofgaming
dukeofgaming / gist:b6b5163450da244ca699
Last active Aug 29, 2015
Reverse proxy in Apache
View gist:b6b5163450da244ca699
#/etc/httpd/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName {hostname}
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
@dukeofgaming
dukeofgaming / gist:4cdee61ea2ec2734c4b5
Created Jun 9, 2014
Register autoload of classes in a folder with customizable file naming rule
View gist:4cdee61ea2ec2734c4b5
<?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),
View gist:9beed5e14d60a0cc2f3d
<?php
/*
/com_mycomponent
|-/views
| |-/response
| |-/tmpl
| | |-default.php
| | |-index.html
| |-view.raw.php
*/
View gist:6d44cb7482a92ed23df2
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]
View gist:0c1155ca45f8e19b6bb6
#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 Jun 9, 2014
IE7 display inline-block parse hack
View gist:d13c49de65750708531c
/*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 Jun 9, 2014
Recursively change permissions
View gist:010ddb1dc0877f997c31
#Taken from http://movabletripe.com/archive/recursively-chmod-directories-only/
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
View gist:8361b752a782826fdb8c
<?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 Jun 9, 2014
Create bootable USB in WIndows
View gist:76e9752ffe8009a1d0e0
#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 Jun 9, 2014
A shell script to encrypt a file so that only a SSL site's private key can decrypt
View gist:04e3217bbe195acc9d6d
#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