Skip to content

Instantly share code, notes, and snippets.

View SeanJA's full-sized avatar
🦑
🦖

SeanJA SeanJA

🦑
🦖
View GitHub Profile
//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 / 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;
@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 / 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 / JSDebug.php
Created September 30, 2011 16:01
debugging in the console from php
<?php
/**
* @method void error() error(string $name, mixed $var)
* @method void exception() exception(string $name, mixed $var)
* @method void info() info(string $name, mixed $var)
* @method void log() log(string $name, mixed $var)
* @method void trace() trace(string $name, mixed $var)
* @method void warn() warn(string $name, mixed $var)
@SeanJA
SeanJA / jquery.proxy.js
Created March 22, 2012 12:59
jquery.proxy.js
if(typeof jQuery.proxy === 'undefined'){
jQuery.extend({
proxy : function( fn, proxy, thisObject ) {
if ( arguments.length === 2 ) {
if ( typeof proxy === "string" ) {
thisObject = fn;
fn = thisObject[ proxy ];
proxy = undefined;
} else if ( proxy && !jQuery.isFunction( proxy ) ) {
@SeanJA
SeanJA / tweets-to-image.php
Created May 1, 2012 19:45
Turn your twitter avatar into your tweets (with the colour and stuff...)
<?php
$username = 'seanja';
if (!file_exists('cache')) {
mkdir('cache', $mode = 0777);
}
if (!file_exists('cache')) {
die('couldn\'t make a cache folder, make one yourself called "cache" in the same dir as this file.');
}
#ffs don't do this
for i in 1..10
if i == 1
next #continue
else
#do stuff
end
end
@SeanJA
SeanJA / gist:2637382
Created May 8, 2012 17:05
most useless fucking error ever

Thanks a lot exact target for this helpful error:

Unable to generate preview:
A_SCRIPTINGA scripting error has occurred.
An error occurred when attempting to parse HtmlEmailBody content for HTML content.
MemberID: 1234151
JobID: 0
ListID: 123423

Content Begins With: %%[

@SeanJA
SeanJA / php.sublime-build
Created May 16, 2012 19:51
php.sublime-build
{
"cmd": ["php", "-f", "$file"],
/* what is this for? */
"file_regex": ".* in (.*?) on line ([0-9]*)",
"selector": "source.php"
}