This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In the snippets below, you must replace '/path/to/lib' with the correct path. | |
// does not support namespaces with underscores | |
spl_autoload_register(function ($class) { | |
$file = __DIR__ . '/path/to/lib/' . strtr(ltrim($class, '\\'), '_\\', '//') . '.php'; | |
is_readable($file) && (require $file); | |
}); | |
// for a particular namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
# Redirect /index.php (and /index) to / | |
RewriteCond %{THE_REQUEST} ^GET\ /(.*/)?index(\.php)?(\?.*)?\ HTTP/ | |
RewriteRule ^ http://%{HTTP_HOST}/%1 [L,R=301] | |
# Redirect /foo.php to /foo | |
RewriteCond %{THE_REQUEST} ^GET\ /(.*)\.php(\?.*)?\ HTTP/ | |
RewriteRule ^ http://%{HTTP_HOST}/%1 [L,R=301] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FilesMatch "\.(php[3456]?|pl|py|jsp|asp|html|htm|shtml|sh|cgi)$"> | |
Deny from all | |
</FilesMatch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(src, callback) { | |
var s = document.createElement("script"), | |
onEvent = ('onreadystatechange' in s) ? 'onreadystatechange' : 'onload'; | |
s[onEvent] = function () { | |
if (("loaded,complete").indexOf(this.readyState || "loaded") > -1) { | |
s[onEvent] = null; | |
if (callback) { | |
callback(); | |
} | |
s.parentNode.removeChild(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"gecko_spellcheck":"1","opt_plugins":"lists,autosave,fullscreen,paste,table","opt_theme_advanced_buttons1":"formatselect,bullist,numlist,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,undo,redo,cleanup,code","opt_theme_advanced_buttons2":"link,unlink,bold,italic,strikethrough,|,fontselect,fontsizeselect,forecolor,backcolor,|,table,image,pastetext,pasteword,fullscreen","opt_theme_advanced_buttons3":""} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Compares two remote directories using git diff (for color) by | |
# first copying all remote contents to local. | |
# | |
# USAGE: ./remote_diff path/from/www | |
TEMP1=~/.tmp_srv1_ | |
TEMP2=~/.tmp_srv2_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
-- Assumed to be trimmed | |
name | |
-- Does name contain multiple words? | |
,(LOCATE(' ', name) = 0) AS hasMultipleWords | |
-- Returns the end of the string back until reaches a space. | |
-- E.g. "John Doe" => "Doe" | |
-- E.g. "Francis Scott Key" => "Key" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Alter (or remove) querystring keys from a root-relative URI. | |
* @param array $values associative array (see http_build_query). Use null value to remove keys | |
* @param string $uri if not given, $_SERVER['REQUEST_URI'] will be used | |
* @return string | |
*/ | |
function alterQueryString($values = array(), $uri = null) { | |
$parts = parse_url($uri ? $uri : $_SERVER['REQUEST_URI']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
/** | |
* Enable all the supported cipher suites favoring stronger ciphers |