Skip to content

Instantly share code, notes, and snippets.

@stevereich
stevereich / googleURL.cfc
Created September 27, 2012 05:43
Coldfusion Functions for Google URL Shortener API
<cfscript>
component output="false" {
public googleURL function init(apiKey)
description="Initialize this CFC as an object"
{
variables.apiKey = arguments.apiKey;
return this;
}
public string function ShortenURL(required string url)
@stevereich
stevereich / formatPhone.cfc
Created September 28, 2012 08:20
Function to Format Phone Number with RegEx and Coldfusion
<cfscript>
component output="false" {
public formatPhone function init(){
return this;
}
public string function formatPhone(required string phoneNumber)
description="Strips out anything that isn't a number and then takes the first 10 digits and formats them to our spec: (404) 555-1212"
output="false"
@stevereich
stevereich / bloggerFBComments.html
Created October 3, 2012 04:38
Facebook comment count on blogger
// this code goes right after <data:post.body/>
<b:if cond='data:post.isFirstPost'>
<script>(function(d){
var js, id = &#39;facebook-jssdk&#39;; if (d.getElementById(id)) {return;}
js = d.createElement(&#39;script&#39;); js.id = id; js.async = true;
js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&quot;;
d.getElementsByTagName(&#39;head&#39;)[0].appendChild(js);
}(document));</script>
</b:if>
@stevereich
stevereich / filter.cfc
Created October 13, 2012 01:39
Coldfusion function to substitute bad words entered into a form field for either asterisks or a string of of characters.
<cfscript>
component output=false {
public filters function init(dsn)
description="Initialize component as an object and store as an application variable. This will
make the just a single hit to the database and store the word list in memory to be used anytime."{
variables.datasource = arguments.dsn;
var q = new query();
var badWordQuery = 0;
q.setDatasource(variables.datasource);
q.setName(badWordQuery);
@stevereich
stevereich / wordFilter.cfm
Created October 13, 2012 01:42
Form to demonstrate the bad word filter.cfc
<html>
<head>
<title>Bad Word Filter</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
$(function(){
$filterBox = $('#filterBox');
$frmWords = $('#frmWords');
$thewords = $('#thewords');
$buttonCheck = $('#buttonCheck').click(function(){
@stevereich
stevereich / ajax_badwords.cfm
Created October 13, 2012 01:45
Coldfusion handler for bad words filter.
<cfscript>
if(structkeyexists(form, "filterBox")){
variables.checkString = form.filterBox;
if(structKeyexists(form, "replaceString")){
if(form.replaceString EQ "0"){
variables.cleanText = application.filters.filterWords(variables.checkString,0);
}
else{
variables.cleanText = application.filters.filterWords(variables.checkString,1);
}
@stevereich
stevereich / shuffle.cfm
Created October 13, 2012 01:50
Shuffle Array with Coldfusion
<cfscript>
CreateObject( "java", "java.util.Collections" ).Shuffle(variables.badwordArray);
</cfscript>
@stevereich
stevereich / charLength.sql
Created October 14, 2012 23:28
SQL Query ordering by character length.
SELECT
*
FROM
badwords
ORDER BY CHAR_LENGTH(strBadWord) DESC
@stevereich
stevereich / applicationFilters.cfm
Created October 17, 2012 06:22
Setting a CFC Object as an application variable in Coldfusion
<cfscript>
application.filters = CreateObject("component", "myCFCs.filters").init(application.settings.dsn_filters); //pass datasource to object
</cfscript>

Fixed Background Illusion

This bit of CSS demonstrates how two fixed backgrounds (in this case, one black and white, the other color) can be layered so that the view port div of the top layer, appears to change the state of the bottom layer. This effect works well with a blurred/clear image as well. Your imagination is the limit! Enjoy!

A Pen by Steve Reich on CodePen.

License.