Skip to content

Instantly share code, notes, and snippets.

View SeanJA's full-sized avatar
🦑
🦖

SeanJA SeanJA

🦑
🦖
View GitHub Profile
@SeanJA
SeanJA / drupal_email_login.php
Created August 17, 2011 01:52
Allow drupal users to login with their email address as well
<?php
//"stolen" and modified from code in login toboggan
/**
* Capture the form stubmit and check the form_id if it matches a login form, then
* it will check it as an email using an extra validation step
* @param array $form The current form (I guess...)
* @param array $form_state The state of the current form (I guess...)
* @param string $form_id The unique identifier for this form
* @see hook_form_alter
@SeanJA
SeanJA / node.module.patch
Created August 9, 2011 15:28
node.module patch to fix date check
--- node.module 2011-08-09 10:36:01.000000000 -0300
+++ node.module 2011-08-09 12:25:13.000000000 -0300
@@ -803,9 +803,10 @@
// are dealing with an anonymous user we set the user ID to 0.
form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name)));
}
-
+ $strtotime = strtotime($node->date);
// Validate the "authored on" field. As of PHP 5.1.0, strtotime returns FALSE instead of -1 upon failure.
- if (!empty($node->date) && strtotime($node->date) <= 0) {
@SeanJA
SeanJA / something.module.php
Created June 24, 2011 19:03
get cron job descriptions out of your custom modules from elysia_cron
<?php
/**
* get cron job descriptions out of your custom modules from elysia_cron
* @param string $op
*/
function something_cronapi($op){
switch($op){
case "list":
return array('something_cron'=>'This is my cron function');
break;
//select everything based on the target href
//if js is turned off, focus on the correct input
$('a.select-all').click(function(e){
e.preventDefault();
var target_input = $(this).attr('href');
$(target_input).select();
});
@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 />
@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 / 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 / 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 / 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 / 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;
}