Skip to content

Instantly share code, notes, and snippets.

View SeanJA's full-sized avatar
🦑
🦖

SeanJA SeanJA

🦑
🦖
View GitHub Profile
@SeanJA
SeanJA / svn2git-authors.sh
Created March 23, 2011 13:23
generate a git-style authors list out of svn logs
usage:
cd /my/svn/repo
./path/to/svn2git-authors.sh > authors.txt
@SeanJA
SeanJA / build.xml
Created March 23, 2011 14:25
precommit-hook to run ant tasks and store the results and then add them to the commit
<?xml version="1.0" encoding="utf-8" ?>
<project name="Webads">
<!--This target runs the phpcs-->
<target name="phpcs">
<!--unix-->
<exec dir="${basedir}" executable="phpcs" failonerror="false" osfamily="unix">
<arg line="--standard=Cake --extensions=php,module,inc ${basedir}"/>
</exec>
</target>
@SeanJA
SeanJA / is_prime.php
Created April 4, 2011 12:58
Overkill prime checker
<?php
function is_prime_overkill($int){
static $ints;
if(!$ints){
//quick skips
$ints = array(0=>false, 1=>false, 2=>true, 3=>true, 4=>false, 5=>true);
}
$index = strval($int);
if(!isset($ints[$index])){
$ints[$index] = true;
<?php
function daterange_range($starttime, $endtime = null) {
$return = "";
//set the endtime to the start time if there isn't an endtime provided
$endtime = empty($endtime) ? $starttime : $endtime;
//turn them into timestamps if they are not timestamps already
$endtime = ((int)$endtime == $endtime && is_int($endtime))? $endtime:strtotime($endtime);
$starttime = ((int)$starttime == $starttime && is_int($starttime))? $starttime:strtotime($starttime);
//boolean values to prevent test duplication,
@SeanJA
SeanJA / font-face.css
Created April 30, 2011 01:24
fontface example
@font-face{
font-family:'CodenameCoderFree4FBold';
src:url('/fonts/codenamecoderfree4f-bold-webfont.eot');
src:url('/fonts/codenamecoderfree4f-bold-webfont.eot?iefix') format('eot'),
url('/fonts/codenamecoderfree4f-bold-webfont.woff') format('woff'),
url('/fonts/codenamecoderfree4f-bold-webfont.ttf') format('truetype'),
url('/fonts/codenamecoderfree4f-bold-webfont.svg#webfont9UM32sTt') format('svg');
font-weight:normal;
font-style:normal;
}
@SeanJA
SeanJA / oas_clicktag.as
Created May 10, 2011 16:41
oas clicktag
//-- Action Script 2 version:
//this is the click tag action
//that should be attached to your button
on (release){
getURL (_root.clickTAG, "_blank");
}
//-- Action Script 3 version:
@SeanJA
SeanJA / phpdocced.class.php
Created May 30, 2011 17:26
a class with phpdocs
<?php
/**
* @property int $id An identifier
* @property string $name A name
*/
class parent_class{
protected $_data = array();
/**
* magic function __get
@SeanJA
SeanJA / fibonacci_sequence_generator.php
Created June 1, 2011 02:31
Fibonacci Sequence iterator, because hey... why not?
<?php
class Fibonacci_Sequence implements Iterator {
private $start;
public function __construct($start=0){
$this->start = $start;
}
public function current() {
return round(
(pow(((1 + sqrt(5)) / 2), $this->key) - pow((-1 / (1 + sqrt(5)) / 2), $this->key)) / sqrt(5)
@SeanJA
SeanJA / random_math_question_positive_only.php
Created June 6, 2011 16:58
Generate a random math question that always has a positive answer
<?php
/**
* Starting with an answer, generate a math question to get the result
* @param int $answer Your desired answer
* @return string The equation to arrive at that answer
*/
function generate_simple_math($answer){
$operations = 2;
$min_number = 1;
@SeanJA
SeanJA / spacer_gif.html
Created June 13, 2011 12:48
spacers... they can be put together to make an even bigger spacer!
<!-- for the love of god... stop doing this! -->
<!-- the alternating order pattern is aesthetically pleasing though... -->
<img src="/images/spacer.gif" width="575" height="3" /><br />
<img src="/images/bn_btm.gif" height="3" width="575" /><br />
<img src="/images/bn_btm.gif" height="3" width="575" /><br />
<img src="/images/spacer.gif" width="575" height="3" /><br />