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 / screenshot.js
Last active Jul 10, 2019
Save a screenshot with selenium-webdriver for JavaScript
View screenshot.js
var webdriver = require('selenium-webdriver');
var fs = require('fs');
var driver = new webdriver.Builder().build();
webdriver.WebDriver.prototype.saveScreenshot = function(filename) {
return driver.takeScreenshot().then(function(data) {
fs.writeFile(filename, data.replace(/^data:image\/png;base64,/,''), 'base64', function(err) {
if(err) throw err;
});
@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 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>
@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;
}
@mnpenner
mnpenner / driver.js
Created Sep 5, 2013
Selenium, PhantomJS, Node, Screenshots and Sizzle
View driver.js
var webdriver = require('selenium-webdriver');
var fs = require('fs');
var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.phantomjs())
.build();
webdriver.WebDriver.prototype.saveScreenshot = function(filename) {
return driver.takeScreenshot().then(function(data) {
fs.writeFile(filename, data.replace(/^data:image\/png;base64,/,''), 'base64', function(err) {
@mnpenner
mnpenner / color.js
Last active Jul 9, 2016
RGB <-> HSL+HSL, for Node.js
View color.js
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param {number} r The red color value
* @param {number} g The green color value
* @param {number} b The blue color value
* @return {array} The HSL representation
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 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 [專]
@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>
You can’t perform that action at this time.