Skip to content

Instantly share code, notes, and snippets.

View neokoenig's full-sized avatar

Tom King neokoenig

View GitHub Profile
<cfsilent>
<!---Flickr Params--->
<cfparam name="flickr" default="http://www.flickr.com/services/rest/" />
<cfparam name="key" default="Your API Key Here" />
<cfparam name="userid" default="Your User ID Here">
<!---url.reinit used to manually refresh-->
<cfparam name="url.reinit" default="">
<cfoutput>
<h2>Photos</h2>
<!--XML last cached #application.FlickrXmlstarted#--->
<cfloop from="1" to="#ArrayLen(photosets)#" index="i">
<cfoutput>
<div id="photoset" class="clear">
<!---Output primary image--->
<img class="left" src="http://farm#photosets[i].XmlAttributes['farm']#.static.flickr.com/#photosets[i].XmlAttributes['server']#/#photosets[i].XmlAttributes['primary']#_#photosets[i].XmlAttributes['secret']#_s.jpg">
<!---output title--->
@neokoenig
neokoenig / gist:1031443
Created June 17, 2011 13:48
Starter CSS based on Blueprint CSS for use with CFWheels helpers
/*************************************************
FORMS
Notes: Add this predefined values to your /config/settings.cfm file:
Then, just make sure you add #startFormTag(class="generic")# to any form you want this CSS applied to.
<cfscript>
// Form Field Defaults
set(functionName="textField,textFieldTag,textArea,textAreaTag,passwordField,passwordFieldTag,select,selectTag,fileField,fileFieldTag",
prependToLabel="<div class='field'>",
@neokoenig
neokoenig / gist:1064613
Created July 5, 2011 10:23
Password Hashing and Salting 1
<cfset thePassword='myPassword1'>
<cfset passwordHash=Hash(thePassword, 'SHA-512') />
@neokoenig
neokoenig / gist:1064615
Created July 5, 2011 10:23
Password Hashing and Salting 2
<cfset salt=createUUID() />
<cfset passwordHash=Hash(thePassword & salt, 'SHA-512') />
@neokoenig
neokoenig / gist:1064616
Created July 5, 2011 10:24
Password Hashing and Salting 3
<!---Get the key--->
<cfset authKeyLocation=expandpath('../auth/key.txt')>
<cffile action="read" file="#authKeyLocation#" variable="authkey">
<!--- New password hashing --->
<!--- Generate a salt, this is never stored in it's plain form--->
<cfset theSalt=createUUID() />
<!--- Hash the password with the salt in it's plain form--->
<cfset passwordHash=Hash(thePassword & theSalt, 'SHA-512') />
<!--- The encrypted salt to store in the database, using the authKey--->
@neokoenig
neokoenig / gist:1136749
Created August 10, 2011 13:05
Nested Function example
#truncate(
text=stripTags(body),
length=300,
truncateString="#linkTo(
text='... Read More &raquo;',
route='blog',
action='view',
key=id)#"
)#
@neokoenig
neokoenig / ActiveDirectoryLDAPcfWheels.cfm
Created September 18, 2011 14:12
Active Directory / LDAP example in cfWheels
<--------Main.cfc----------->
<cffunction name="init">
<cfscript>
// AD Auth, application wide: if I wanted to only restrict a subset a pages, I could use 'only' instead of except below.
// This filter call should be in every controller you wish to protect
filters(through="loginRequired", except="login,dologin");
// Login
verifies(only="dologin", post=true, params="username,password", error="Both username and password are required", handler="login");
</cfscript>
@neokoenig
neokoenig / latestPHPBB3
Created February 5, 2012 18:11
Get Latest Posts from PHPBB3 to display from another website
<?php
// This gets the latest posts from your PHPBB3 install and outputs them as a UL; results are limited to forum.id's 1,2 and 3 in this example;
$connection = mysql_connect(localhost,"YOURDATABASEUSER","YOURDATABASEPW") or die("Service Currently Unavailable");
$db = mysql_select_db("YOURPHPBB3DATABASENAME",$connection) or die("Service Currently Unavailable");
$sql = "SELECT `phpbb_topics`.`forum_id`, `phpbb_topics`.`topic_id`, `phpbb_topics`.`topic_title`, `phpbb_forums`.`forum_id`, `phpbb_forums`.`forum_name`,`phpbb_forums`.`parent_id` FROM `phpbb_topics`
Inner Join `phpbb_forums` ON `phpbb_forums`.`forum_id` = `phpbb_topics`.`forum_id` WHERE `phpbb_forums`.`parent_id` = 1 OR `phpbb_forums`.`parent_id` = 2 OR `phpbb_forums`.`parent_id` = 2
order by topic_last_post_time desc limit 0,10";
$result = mysql_query($sql) or die("Service Currently Unavailable");
echo "<ul>";
for($x=1;$x<=10;$x++){
@neokoenig
neokoenig / gist:2924644
Created June 13, 2012 15:06
Example CFWHeels Forms for Per
<--- edit.cfm // NB, boostrapDateSelect() is using that bootstrap plugin I did--->
<cfparam name="Signpost">
<cfparam name="allCategories">
<cfoutput>
<cfif params.action EQ "edit">
<h1>Edit Signpost</h1>
<p>#linkTo(text="View Signpost", route="Signposts", action="view", key=Signpost.key(), class="btn btn-primary")#</p>
#startFormTag(action="update", route='admin', controller='Signposts')# #hiddenField(objectname="Signpost", property="id")#
<cfelse>
<h1>Add New Signpost</h1>