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 | |
/** | |
* Composite Slug Field Type. | |
* | |
* File: PERCH_PATH/addons/fieldtypes/compslug/compslug.class.php | |
* Usage: <perch:content id="slug" type="compslug" for="lastname firstname" suppress="true" /> | |
* @author Jamie York | |
**/ | |
class PerchFieldType_compslug extends PerchFieldType | |
{ |
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
-- Update record revision numbers for a region, so they display in Perch. | |
-- Replace :regionID and :revisionNum | |
UPDATE perch2_content_items pci | |
INNER JOIN | |
( | |
SELECT | |
itemID, | |
MAX(itemRev) AS itemRevMax | |
FROM perch2_content_items |
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
-- Delete Spammers. | |
delete from GDN_User where ((CountDiscussions = 0 and CountComments = 0) or About != '' or Name = '[Deleted User]') and Admin = 0; | |
delete from GDN_User where CountVisits = 0 and Admin = 0; | |
delete from GDN_UserRole where UserID not in (select UserID from GDN_User); | |
-- Cleanup Data. | |
delete from GDN_Discussion where InsertUserID not in (select UserID from GDN_User); | |
delete from GDN_Comment where InsertUserID not in (select UserID from GDN_User); | |
delete from GDN_UserDiscussion where UserID not in (select UserID from GDN_User); | |
delete from GDN_Session where UserID not in (select UserID from GDN_User); |
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 | |
// ICU Decimal Patterns: | |
// http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details | |
$price = 1560.52; | |
$formatter = new NumberFormatter('en_CA', NumberFormatter::CURRENCY); | |
// Default ICU Decimal Pattern: | |
echo $formatter->getPattern(); // ¤#,##0.00;(¤#,##0.00) | |
echo $formatter->format($price); // $1,560.52 |
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
RewriteEngine On | |
RewriteBase / | |
# Rewrite: non-www to www | |
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L] | |
# Rewrite: www to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [R=301,L] |
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
#!/usr/bin/env ruby | |
# GMVault: http://gmvault.org/ | |
# Unzips GMVault compressed emails (.eml.gz). | |
# Enter an absolute path, e.g., /Users/Username/gmvault-db/db | |
print 'Enter the directory path containing the zip files: ' | |
path = STDIN.gets.chomp.chomp('/') | |
path = path + '/**/*.eml.gz' |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>iFrame</title> | |
</head> | |
<body> | |
<!-- Page Content --> | |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<script> |
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
# WGet Manual: http://www.gnu.org/software/wget/manual/wget.html | |
# Link Checker: http://wummel.github.io/linkchecker/ | |
# Archiving URLs: http://www.gwern.net/Archiving%20URLs | |
# Download Webpage: http://superuser.com/questions/55040/save-a-single-web-page-with-background-images-with-wget | |
# Output Directory: http://stackoverflow.com/questions/8986139/wget-output-directory-prefix | |
# WARC Files: http://www.archiveteam.org/index.php?title=Wget_with_WARC_output | |
# Add -r or --recursive to get the whole website. | |
wget -T 10 -e robots=off -E -H -k -K -p -nH -nd -P /path/to/dir [URL] | |
wget --timeout 10 --execute robots=off --adjust-extension --span-hosts --convert-links --backup-converted --page-requisites --random-wait --no-host-directories --no-directories --directory-prefix --mirror --html-extension /path/to/dir [URL] |
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
#!/usr/bin/env ruby | |
# Clone Github Gists. | |
# Usage: ruby clone-gists.rb username /clone/path | |
user, dir = ARGV | |
dir = File.expand_path(dir.to_s) | |
unless File.directory?(dir) | |
require 'fileutils' |
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 | |
// Function. | |
function controller($class) { | |
$args = func_get_args(); | |
$class = array_shift($args); | |
return function() use ($class, $args) { | |
if (count($args) > 0) { | |
$reflection = new ReflectionClass($class); | |
return $reflection->newInstanceArgs($args); |