Skip to content

Instantly share code, notes, and snippets.

View rodneyrehm's full-sized avatar

Rodney Rehm rodneyrehm

View GitHub Profile
@rodneyrehm
rodneyrehm / urlify.php
Created April 8, 2011 11:52
Reduce (UTF-8) strings to alphanumeric
<?php
/*
consider decomposing the characters to "capture" more "obscure" characters such as ṩ
- http://www.php.net/manual/en/normalizer.normalize.php#92592
*/
/**
* Normalize a string to only contain alphanumeric characters and dashes.
*
@rodneyrehm
rodneyrehm / output.html
Created August 12, 2016 09:37
markdown-it-adjust-heading-levels
<!-- { firstLevel: 3 } -->
<h3>First <em>Level</em> headline</h3>
<p>first level content</p>
<h4>Second Level headline alpha</h4>
<p>second level content alpha</p>
<h5>Third Level headline alpha</h5>
<p>third level content alpha</p>
<h4>Second Level headline bravo</h4>
<p>second level content bravo</p>
@rodneyrehm
rodneyrehm / gist:8013067
Created December 17, 2013 21:41
JavaScript - URL validation RegExp
// see http://rodneyrehm.de/t/url-regex.html#imme_emosol for the complete table
// expression by
var url_pattern = /^(https?|ftp|torrent|image|irc):\/\/(-\.)?([^\s\/?\.#-]+\.?)+(\/[^\s]*)?$/i;
var valid = [
"http://foo.com/blah_blah",
"http://foo.com/blah_blah/",
"http://foo.com/blah_blah_(wikipedia)",
"http://foo.com/blah_blah_(wikipedia)_(again)",
@rodneyrehm
rodneyrehm / gist:40e7946c0cff68a31cea
Last active November 7, 2022 09:11
Diagrams for Documentation

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

@rodneyrehm
rodneyrehm / FileDownload.php
Created October 23, 2011 19:26
PHP: FileDownload
<?php
class FileDownload
{
public static $_response_status = array(
200 => 'OK',
201 => 'Created',
204 => 'No Content',
206 => 'Partial',
207 => 'Multi-Status', // WTF ??
@rodneyrehm
rodneyrehm / anti-keygrabber.user.js
Last active July 5, 2022 01:31
GreaseMonkey: Prevent Web Applications From Grabbing Certain HotKeys
// ==UserScript==
// @name anti key-grabber
// @description Prevent web apps from capturing and muting vital keyboard shortcuts
// @grant none
// @version 1.1
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode === 116) {
@rodneyrehm
rodneyrehm / sentry-clean-debug-information-files.js
Created July 17, 2019 15:19
Sentry Cleanup: Debug Information Files
const axios = require('axios')
const LinkHeader = require('http-link-header')
const nextPage = (header) => {
const link = LinkHeader.parse(header)
const [ next ] = link.get('rel', 'next')
return next && next.results === 'true' ? next.uri : null
}
@rodneyrehm
rodneyrehm / mb_range.php
Created October 22, 2011 15:35
PHP: mb_range() - Unicode compatible range('A', 'Z')
<?php
mb_internal_encoding('UTF-8');
/**
* multibyte string compatible range('A', 'Z')
*
* @param string $start Character to start from (included)
* @param string $end Character to end with (included)
* @return array list of characters in unicode alphabet from $start to $end
@rodneyrehm
rodneyrehm / datauri.php
Created November 17, 2011 09:12
PHP: datauri.php - convert image to data-uri
#!/opt/local/bin/php
<?php
/*
1) replace the shebang (first line) with the path to your php binary
(probably something like /usr/bin/php)
2) move the file to /usr/local/bin/datauri.php
(this should be in your PATH)
3) chmod ugo+rx /usr/local/bin/datauri.php
(make the script executable for everyone)
@rodneyrehm
rodneyrehm / README.md
Created December 23, 2020 16:21
Patching expo for expo-constants, expo-linking and expo-font to work in Bare Workflow

Patching Expo to work in all workflows (Bare and Managed)

{
  "expo": {
    "entryPoint": "index.js"
  }
}