Skip to content

Instantly share code, notes, and snippets.

Mark Penner mnpenner

Block or report user

Report or block mnpenner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Model.php
<?php
namespace Expressive;
class Model extends \Eloquent {
protected static $fields = [];
protected static $unguarded = true;
function __construct(array $attributes = []) {
if(static::$fields) {
View FileSystemLoader.js
var nunjucks = require('nunjucks');
var gaze = require('gaze');
var lib = require('nunjucks/src/lib');
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
// Node <0.7.1 compatibility
var existsSync = fs.existsSync || path.existsSync;
View filter_select_options.js
exports.bindSelectDataFilter = function(select1, select2, dataAttr, backFilter) {
var $select1 = $(select1);
var $select2 = $(select2);
var $options = $select2.find('option'); // we need to cache these outside of the DOM; unfortunately this will break <optgroups>
var changeFunc = function() {
var $oldOption = $select2.find('option:selected');
var selectValue = $select1.val();
if(selectValue && selectValue != '0') {
$select2.html($options.filter(function() {
var dataValue = $(this).data(dataAttr);
View jquery.validator.defaults.js
$.validator.setDefaults({
onfocusout: function(element, event) {
if(element.tagName === 'TEXTAREA' || (element.tagName === 'INPUT' && element.type !== 'password')) {
element.value = $.trim(element.value);
}
return $.validator.defaults.onfocusout.call(this, element, event);
}
});
View countries.json
[{"timezones":["Europe\/Andorra"],"code":"AD","continent":"Europe","name":"Andorra","capital":"Andorra la Vella"},{"timezones":["Asia\/Kabul"],"code":"AF","continent":"Asia","name":"Afghanistan","capital":"Kabul"},{"timezones":["America\/Antigua"],"code":"AG","continent":"North America","name":"Antigua and Barbuda","capital":"St. John's"},{"timezones":["Europe\/Tirane"],"code":"AL","continent":"Europe","name":"Albania","capital":"Tirana"},{"timezones":["Asia\/Yerevan"],"code":"AM","continent":"Asia","name":"Armenia","capital":"Yerevan"},{"timezones":["Africa\/Luanda"],"code":"AO","continent":"Africa","name":"Angola","capital":"Luanda"},{"timezones":["America\/Argentina\/Buenos_Aires","America\/Argentina\/Cordoba","America\/Argentina\/Jujuy","America\/Argentina\/Tucuman","America\/Argentina\/Catamarca","America\/Argentina\/La_Rioja","America\/Argentina\/San_Juan","America\/Argentina\/Mendoza","America\/Argentina\/Rio_Gallegos","America\/Argentina\/Ushuaia"],"code":"AR","continent":"South America","name":"Argen
@mnpenner
mnpenner / mode-mysql.js
Created Apr 16, 2013
MySQL mode for Ace editor. Based on existing pgsql mode with MySQL keywords and functions.
View mode-mysql.js
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
View ordinal.php
function ordinal($number) {
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
$mod100 = $number % 100;
return $number . ($mod100 >= 11 && $mod100 <= 13 ? 'th' : $ends[$number % 10]);
}
@mnpenner
mnpenner / Set.js
Last active Dec 22, 2015
Collects and compiles any .js, .css and .less files
View Set.js
module.exports = function(arr) {
var map = {};
this.contains = function(val) {
return map.hasOwnProperty(val);
};
this.add = function(val) {
map[val] = true;
};
@mnpenner
mnpenner / Custom_hg.xml
Created Oct 16, 2013
PhpStorm Command Line Tool support for Mercurial
View Custom_hg.xml
<?xml version="1.0" encoding="UTF-8"?>
<framework xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schemas/frameworkDescriptionVersion1.1.3.xsd" name="Custom_hg" invoke="/usr/bin/hg" alias="hg"
enabled="true" version="2">
<help><![CDATA[Mercurial Distributed SCM]]></help>
<command>
<name>add</name>
<help>add the specified files on the next commit</help>
</command>
<command>
<name>addremove</name>
View big_list_of_naughty_sql_chars.txt
naughty becomes charsets
0x0027 0x005C 0x27 UCS-2 [\] UCS-2BE [\] UCS-2LE [尀] UTF-16 [\] UTF-16BE [\] UTF-16LE [尀]
0x0127 0x015C 0x27 UCS-2 [Ŝ] UCS-2BE [Ŝ] UCS-2LE [封] UTF-16 [Ŝ] UTF-16BE [Ŝ] UTF-16LE [封]
0x0227 0x025C 0x27 UCS-2 [ɜ] UCS-2BE [ɜ] UCS-2LE [専] UTF-16 [ɜ] UTF-16BE [ɜ] UTF-16LE [専]
0x0327 0x035C 0x27 UCS-2 [͜] UCS-2BE [͜] UCS-2LE [尃] UTF-16 [͜] UTF-16BE [͜] UTF-16LE [尃]
0x0427 0x045C 0x27 UCS-2 [ќ] UCS-2BE [ќ] UCS-2LE [射] UTF-16 [ќ] UTF-16BE [ќ] UTF-16LE [射]
0x0527 0x055C 0x27 UCS-2 [՜] UCS-2BE [՜] UCS-2LE [尅] UTF-16 [՜] UTF-16BE [՜] UTF-16LE [尅]
0x0627 0x065C 0x27 UCS-2 [ٜ] UCS-2BE [ٜ] UCS-2LE [将] UTF-16 [ٜ] UTF-16BE [ٜ] UTF-16LE [将]
0x0727 0x075C 0x27 UCS-2 [ݜ] UCS-2BE [ݜ] UCS-2LE [將] UTF-16 [ݜ] UTF-16BE [ݜ] UTF-16LE [將]
0x0827 0x085C 0x27 UCS-2 [࡜] UCS-2BE [࡜] UCS-2LE [專] UTF-16 [࡜] UTF-16BE [࡜] UTF-16LE [專]
You can’t perform that action at this time.