Skip to content

Instantly share code, notes, and snippets.

@leefish
leefish / validate-currency.js
Last active April 1, 2018 15:40 — forked from lksedor/validate-currency.js
Currency validation method for the jQuery Validation plugin. Decimal place is optional but if included, it requires 2 places. Also, the dollar sign is optional. EDIT: Original gist did not work with $ sign being optional. This gist adds the optional functionality for dollar, euro and pound.
// Validation method for variable currency
$.validator.addMethod("currency", function (value, element) {
return this.optional(element) || /^(?:(\$|€|£))?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/.test(value);
}, "Please specify a valid amount");
.select2-container .select2-choice {
height: 34px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background-color: #fff;
background-image: none;
background: #fff;
}
$plugins->add_hook('datahandler_pm_insert', 'pm_insert');
$plugins->add_hook('private_do_send_end', 'pm_private_end');
function pm_insert($handler)
{
global $cache;
static $last_uid;
if(!isset($cache->cache['pmcache']))
{
$lateststatus = '';
$query = $db->simple_select('users', 'uid,username,custom_status,custom_status_date,usergroup,displaygroup', 'custom_status != \'\' AND custom_status_date > 0', array('order_by' => 'custom_status_date', 'order_dir' => 'DESC', 'limit' => $mybb->settings['custom_status_latest']));
while ($userstatus = $db->fetch_array($query))
{
$bgcolor = alt_trow();
$userstatus['username'] = format_name($userstatus['username'], $userstatus['usergroup'], $userstatus['displaygroup']);
$userstatus['username'] = '<a href="member.php?action=profile&uid='.intval($userstatus['username']).'"> '.$userstatus['username'].'</a>';
$userstatus['date'] = my_date($mybb->settings['dateformat'], $userstatus['custom_status_date'], '', false).", ".my_date($mybb->settings['timeformat'], $userstatus['custom_status_date']);
$userstatus['status'] = htmlspecialchars_uni($userstatus['custom_status']);
$userstatus['custom_status'] = htmlspecialchars_uni($userstatus['custom_status']);
<!-- Something like this -->
<script>
Modernizr.load({
test: Modernizr.mq('(min-width:400px)'),
yep: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/not-small-screen-stuff.js">',
});
</script>
<!-- Or -->
<script>
@leefish
leefish / marquee.coffee
Created November 10, 2012 18:37 — forked from eric1234/marquee.coffee
<marquee> element lives! - Emulating the behavior of the old marquee element with CoffeeScript/JavaScript
class @Marquee
constructor: (@element, @options={}) ->
# Set defaults
@options['duration'] or= 30
@options['wrapAround'] = true unless 'wrapAround' of @options
@options['direction'] or= 'forward'
# If everything fits don't bother with all this mess
@leefish
leefish / MyXBL_Postbit function.php
Created October 23, 2012 09:13
A simple demonstration of how to cut the number of queries used in a MyBB plugin using the postbit hook
<?php
function myxbl_postbit(&$post) {
global $mybb, $db, $lang, $pids;
$lang->load('myxbl');
static $myxbl;
if (!is_array($myxbl) && $mybb->input['method'] != "quickreply") // Check that the $myxbl variable is not an array. Also ensure we are not using the quick reply - without this check quick replies won't bne posted right as the $pids variable cannot be referenced
{