Skip to content

Instantly share code, notes, and snippets.

View psyked's full-sized avatar

James Ford psyked

View GitHub Profile
import couk.psyked.air.printscreen.events.PrintScreenMonitorEvent;
import couk.psyked.air.printscreen.PrintScreenMonitor;
private var monitor:PrintScreenMonitor
private function init():void {
monitor = new PrintScreenMonitor(100);
monitor.addEventListener(PrintScreenMonitorEvent.ADD_SCREENSHOT,
updateImage);
monitor.addEventListener(PrintScreenMonitorEvent.CHANGE_SCREENSHOT,
/*
* A Fish Eye Menu in Actionscript 2
* converted by James Ford
*
* based on A Fish Eye Menu in Actionscript 3
* from shinedraw.com
*/
var IMAGES:Array = [ "image1", "image2", "image3", "image4", "image5", "image6", "image7" ]; // images
@psyked
psyked / gist:1025740
Created June 14, 2011 20:01
Format FQL in ActionScript
function formatFQL(input:String):String
{
var output:String = "";
var indent:String = "";
var queries:Array = input.split("SELECT");
for (var i:int = 1; i < queries.length; i++) {
indent += " ";
output += "SELECT" + queries[i].split("FROM").join("\n" + indent + "FROM").split("WHERE").join("\n" + indent + "WHERE").split("IN").join("\n" + indent + "IN").split("ORDER").join("\n" + indent + "ORDER");
indent += " ";
output += "\n" + indent;
@psyked
psyked / linktastic.css
Created July 10, 2011 13:07
Auto-matic link type icons
a[href^="http:"] {
display:inline-block;
padding-right:14px;
background:transparent url(/Images/ExternalLink.gif) center right no-repeat;
}
a[href^="mailto:"] {
display:inline-block;
padding-left:20px;
line-height:18px;
background:transparent url(/Images/MailTo.gif) center left no-repeat;
a[href$='.pdf'] {
display:inline-block;
padding-left:20px;
line-height:18px;
background:transparent url(Images/PDFIcon.gif) center left no-repeat;
}
<script type="text/javascript">
//<![CDATA[
document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.psyked.co.uk%2Fflash%2Ffotb2011-highlight-1.htm&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; align: left; margin: 2px 0px 2px 0px"></iframe>')
//]]>
</script>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.psyked.co.uk%2Fflash%2Ffotb2011-highlight-1.htm&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; align: left; margin: 2px 0px 2px 0px"></iframe>
@psyked
psyked / RateMe.js
Created March 7, 2012 10:08 — forked from dawsontoth/app.js
"Rate my app in Appcelerator Titanium Mobile" as a commonJS module.
function RateMe(ios_url, goog_url, usecount) {
if(!Ti.App.Properties.hasProperty('RemindToRate')) {
Ti.App.Properties.setString('RemindToRate', 0);
}
var remindCountAsInt = parseInt(Ti.App.Properties.getString('RemindToRate'), 10);
var newRemindCount = remindCountAsInt += 1;
if(remindCountAsInt === -1) {
// the user has either rated the app already, or has opted to never be
// reminded again.
@psyked
psyked / gist:5237761
Last active December 15, 2015 09:19
Converting old ActionScript 2 trace(); statements to HTML5-eque console.log() statements with a regular expression
Find: trace\(([A-Z a-z 0-9"'=_\-.+,\\/\(\)\[\]:#!<>%]*)\);
Replace: ExternalInterface.call("console.log", $1);
@psyked
psyked / implementation.js
Last active December 17, 2015 06:48
An example of how the Decorator pattern might work in Javascript.
// ==== Sample implementation
var modal = new Modal();
modal.maximise(); // outputs "Error: undefined is not a method (windowInstance.maximise)"
MaximiseDecorator.addTo(modal);
modal.maximise(); // outputs "I'm going to maximse myself!"
MaximiseDecorator.removeFrom(modal);
modal.maximise(); // outputs "Error: undefined is not a method (windowInstance.maximise)"