Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

http://www.rbs.me.uk

« Newer Snippets
Older Snippets »
Showing 1-10 of 16 total  RSS 

.htaccess redirect

// description of your code here

// insert code here..

.htaccess error404.php

// This goes in .htaccess in the web root.

# error docs
ErrorDocument 404 /error404.php


// Use existing site template to start 404 page then add this code in your main content div.

<h1>Page not found</h1>
<?php
/* Error 404 code for ***** website */

$webmaster = "webmaster@camrider.com";
$host     = getenv("REMOTE_HOST");
$referrer = getenv("HTTP_REFERER"); 
$path     = getenv("REQUEST_URI"); 

// time in this format: 13/Nov/2000:10:50:38
$time = strftime("%d/%b/%Y:%T");

if ($referrer == "") {
  $referrer = "";
} else {
  $referrer = "<p>You came to this page from $referrer, this could be a broken link so please <a href=\"mailto:$webmaster?subject=Error 404 on $path from $referrer\">email the webmaster</a> to inform us of this.</p>";
}


?>
<h2>Sorry, we couldn't find the page <?php echo $path ?> on this website</h2>
<?php echo $referrer; ?>
<p>Please use the navigation links to help locate what you're looking for.</p>

Mencoder settings

From Real Media to QuickTime compatible


mencoder ~/Desktop/wpa90_220k.rm -o ~/Desktop/wpa90_23.avi -ovc lavc -oac lavc -ss 00:41:10 -endpos 00:01:20


mencoder ~/Desktop/wpa90_23.avi -o ~/Desktop/wpa90_232.avi -ovc xvid -xvidencopts bitrate=400 -oac lavc -lavcopts acodec=mp3



Applescript Export QT Streaming Movie

// description of your code here

 export movie 1 to save_location as hinted movie using default settings

UNIX tar Commands

// how the heck do you do the stuff you do with zip but with tar

create tar file
tar cvf filename.tar monkey.txt monkey2.txt

add a file
tar uvf filename.tar monkey.txt

extract tar file
tar xvf filename.tar

list contents
tar tf monkey.tar

Handling Accented Characters with Python Regular Expressions

[A-z] just isn't good enough!

import re
string = 'riché'
print string
riché

richre = re.compile('([A-z]+)')
match = richre.match(string)
print match.groups()
('rich',)

richre = re.compile('(\w+)',re.LOCALE)
match = richre.match(string)
print match.groups()
('rich',)

richre = re.compile('([é\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

richre = re.compile('([\xe9\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

richre = re.compile('([\xe9-\xf8\w]+)')
match = richre.match(string)
print match.groups()
('rich\xe9',)

string = 'richéñ'
match = richre.match(string)
print match.groups()
('rich\xe9\xf1',)

richre = re.compile('([\u00E9-\u00F8\w]+)')
print match.groups()
('rich\xe9\xf1',)

matched = match.group(1)
print matched
richéñ


DVD Authoring Workflow

MPEG Streamclip edit ->
DeMux to mpv + aif/m1a ->
optional Audacity edit aif ->
rename m1a>mp2 ->
Sizzle Authoring

MPEG Streamclip edit ->
Convert to mpeg ->
ffmpegx crop and convert to MPEG4 (2 pass mencoder ac3 audio) (HQ) ->
Meta Hoot Chapters ->
iDVD Authoring

Analyse a MySQL Table for Inefficiencies

// description of your code here

SELECT * FROM tags PROCEDURE ANALYSE()

Analyse a MySQL Query for inefficiencies

// description of your code here

EXPLAIN SELECT t2.dbid, t2.tag, COUNT(t2.dbid) * 20 AS match_count
FROM tags AS t1, tags AS t2
WHERE t1.dbid = '105318'
AND t2.tag = t1.tag
AND t1.dbid != t2.dbid
GROUP BY t2.dbid
ORDER BY match_count;

Return ordered list of near match items based on tag matches

// description of your code here

select t2.dbid, t2.tag, count(t2.dbid) as match_count from tags as t1, tags as t2 where t1.dbid = '105319' and t2.tag = t1.tag and t1.dbid != t2.dbid GROUP BY t2.dbid 1 ORDER BY match_count;

« Newer Snippets
Older Snippets »
Showing 1-10 of 16 total  RSS