Skip to content

Instantly share code, notes, and snippets.

View nicholasdunbar's full-sized avatar

Nicholas Dunbar nicholasdunbar

View GitHub Profile
@nicholasdunbar
nicholasdunbar / headline_style.php
Last active June 23, 2023 14:20
Convert a String to Title Case (also known as Headline Style or Up Style) Take a string, capitalize the first and last words of the title and all nouns, pronouns, adjectives, verbs, adverbs, and subordinating conjunctions (if, because, as, that, and so on) for example: "Rules for Capitalizing the Words in a Title."
// Converts a string to Title Case based on one set of title case rules
// Put <no_parse></no_parse> around content that you don't want to be parsed by the title case rules
// Test the function :
// echo titleCase("this is a test <no_parse>do you not believe me</no_parse> here is the rest of the string");
// Which would yield the following output :
// This Is A Test do you not believe me Here Is The Rest of The String
@nicholasdunbar
nicholasdunbar / ResizeWindow.as
Last active August 29, 2015 13:56
Bare bones resizable window in ActionScript 3 (AS3) without Flex library dependancies. See example here http://actionscript-flash-guru.com/blog/16-code-for-a-resizable-window-in-as3.php
package com.actionscriptflashguru {
//native libs
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.TextEvent;
import flash.events.EventDispatcher;
@nicholasdunbar
nicholasdunbar / exampleOfPureXML
Last active August 29, 2015 13:56
Example of byte code level XML in ActionScript 3 (AS3)
var testXml = <l>
<a atribute1="sadsdaf" atribute2="asdfsda">
<b>
<g>test</g>
</b>
<c>asdfdsaf</c>
</a>
</l>;
@nicholasdunbar
nicholasdunbar / embedVarsInXML.as
Last active August 29, 2015 13:56
Example of XML with embedded variables in ActionScript 3 (AS3)
// Variables to embed:
// Tag names:
var l:String = "l";
var a:String = "a";
var b:String = "b";
var g:String = "g";
var c:String = "c";
// Attribute name
var atribute1:String = "atribute1";
// Attribute value
@nicholasdunbar
nicholasdunbar / dirXML.as
Last active September 4, 2015 04:12
A Depth-First Recursive Tree Traversal of an XML Tree in ActionScript 3 (AS3)
/*****
* Function Name:
* dirXml
* Description:
* Print out an XML Tree to the console (trace) using a "Depth-First Tree Traversal"
* http://en.wikipedia.org/wiki/Tree_traversal#Depth-first
******/
//How to Use this function (function source code below):
/*
//Example:
@nicholasdunbar
nicholasdunbar / CustomizeAstraTree.as
Last active August 29, 2015 13:56
Example of how to use and customize the Yahoo! Astra tree menu for ActionScript 3.0 (AS3)
//Astra depends on some component libraries.
//For instructions on how to set up go to the following URL
//http://www.actionscript-flash-guru.com/blog/19-tree-menu-with-actionscript-as3.php
//set up the tree
import TreeCustom;var mytree:TreeCustom = new TreeCustom();
mytree.setSize(500,200);
this.addChild(my tree);
mytree.init();
@nicholasdunbar
nicholasdunbar / FBML_request_form.xml
Last active August 29, 2015 13:56
Example of old fb:request-form in deprecated Facebook FBML
<fb:fbml>
<fb:request-form
action=""
target=""
method="POST"
invite="true"
type="Sketch 'n Pass"
content="Check out my drawing :)
<fb:req-choice url='<?php echo $config->topURL."/".$config->fbAppName."/?".$this->inviteURLVars;?>'
label='Check it out'
@nicholasdunbar
nicholasdunbar / fb_apprequests.js
Last active August 29, 2015 13:56
Example of using Facebook JavaScript API to do apprequests
FB.ui({
method: 'apprequests',
title:'Suggest '+fbAppName+' to your friends',
message: 'I thought you would dig this app!',
data: 'gameID=96'
}, onInviteFriend);
//jquery required for ajax function
onInviteFriend = function(response) {
@nicholasdunbar
nicholasdunbar / get_fb_user_ids_from_request.php
Last active August 29, 2015 13:56
This extracts the user IDs that were sent an fb app request using the JavaScript Facebook API
//This code is depricated, with the release of the PHP GRAPH LIB v4.0, still the API calls for getting userIDs is very similar.
//This parses the data generated in this piece of code https://gist.github.com/nicholasdunbar/8809354
public function getUserIDsFromRequests($sentRequestsStr){
$config = Zend_Registry::get ( 'config' );
$sentRequestsArray = explode(",", $sentRequestsStr);
$sentRequestsLen = count ( $sentRequestsArray );
$sentUsersStr = "";
if ($config->isFacebookApp){
$facebook = new Facebook(array(
@nicholasdunbar
nicholasdunbar / ul_wrap_example.html
Created February 4, 2014 19:32
A UL list where each element is wrapped according to its containers dimensions. Multiple row ul or multi-line list using CSS and HTML.
<!--
This shows you how to take something like this:
http://www.actionscript-flash-guru.com/example_files/embed_scripts/multi_row_css_example.html
to this:
http://www.actionscript-flash-guru.com/example_files/embed_scripts/multi_row_css_example_2.html
-->
<style type="text/css">
ul.miltiline {