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
@mnpenner
mnpenner / mysql.js
Last active Jul 5, 2018
JoinMonster MySQL Dialect
View mysql.js
/* eslint-disable no-restricted-syntax, no-use-before-define */
import _ from 'lodash';
import {log} from '../debug';
import {
interpretForOffsetPaging,
orderColumnsToString,
// interpretForKeysetPaging,
// keysetPagingSelect,
// offsetPagingSelect,
validateCursor,
View jquery-ui-datepicker-fixed-position-patch.js
const checkOffset = $.datepicker._checkOffset;
$.extend($.datepicker, {
_checkOffset: function(inst, offset, isFixed) {
if(!isFixed) {
return checkOffset.apply(this, arguments);
}
let isRTL = this._get(inst, "isRTL");
let obj = inst.input[0];
View address_to_location.html
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Location to Timezone</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.0.0/normalize.min.css">
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/0.11.0/fetch.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.10.0/lodash.min.js"></script>
<style>
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 [專]
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
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);
}
});
@mnpenner
mnpenner / startswith_benchmark.php
Last active Jun 8, 2017
Various StartsWith implementations
View startswith_benchmark.php
<?php
function substr_startswith($haystack, $needle) {
return substr($haystack, 0, strlen($needle)) === $needle;
}
function preg_match_startswith($haystack, $needle) {
return preg_match('~' . preg_quote($needle, '~') . '~A', $haystack) > 0;
}
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 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;
You can’t perform that action at this time.