Skip to content

Instantly share code, notes, and snippets.

View marcus-at-localhost's full-sized avatar
💭

Marcus marcus-at-localhost

💭
View GitHub Profile
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authorization');
if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/plain') !== false) {
$format = 'text';
} else {
header('Content-Type: application/json');
$format = 'json';
}
@marcus-at-localhost
marcus-at-localhost / FuzzyDateParser.php
Last active February 2, 2019 18:33 — forked from ewiger/FuzzyDateParser.php
[Parse Date in Text] A wrapper around PHP date_parse and date_parse_from_format and optionally format the output #date
<?php
/**
* FuzzyDateParser is meerly a "convinience" wrapper around date_parse and date_parse_from_format
* functionality from ext/date/lib/timelib code (which does all the
* scanning and other "fuzzy" guessing work).
*
* @see http://www.php.net/manual/en/function.date-parse.php
* @see http://php.net/manual/en/function.date-parse-from-format.php
* @see http://stackoverflow.com/questions/15350309/heuristic-fuzzy-date-extraction-from-the-string
*
@marcus-at-localhost
marcus-at-localhost / index.php
Created September 7, 2018 12:52 — forked from Rayne/index.php
Fat-Free Framework with PHP Debugger Tracy
<?php
/**
* The following example combines Fat-Free Framework
* with the PHP Debugger (Toolbar) Tracy.
*
* @see https://github.com/bcosca/fatfree/issues/999
*/
use Tracy\Debugger;
@marcus-at-localhost
marcus-at-localhost / BaseController.php
Created September 7, 2018 07:21 — forked from unnikked/BaseController.php
BaseController class that I use in my FatFreeFramework projects. Based on https://github.com/interagent/http-api-design
<?php
namespace controller\api;
/**
* Base Controller class, it provides some helper methods
* to his child classes.
*
* You can make api calls by setting X-Auth-Token header
* value. All parameters all passed in x-www-urlencoded
@marcus-at-localhost
marcus-at-localhost / firebase_pre-request_script.js
Created August 31, 2018 21:07 — forked from moneal/firebase_pre-request_script.js
Postman pre-request script to create a Firebase authentication JWT header.
/**
* This script expects the global variables 'refresh_token' and 'firebase_api_key' to be set. 'firebase_api_key' can be found
* in the Firebase console under project settings then 'Web API Key'.
* 'refresh_token' as to be gathered from watching the network requests to https://securetoken.googleapis.com/v1/token from
* your Firebase app, look for the formdata values
*
* If all the data is found it makes a request to get a new token and sets a 'auth_jwt' environment variable and updates the
* global 'refresh_token'.
*
* Requests that need authentication should have a header with a key of 'Authentication' and value of '{{auth_jwt}}'
@marcus-at-localhost
marcus-at-localhost / README.md
Created June 23, 2018 10:10 — forked from ndarville/README.md
How to export and rehost your Tumblr site

How to export and rehost your Tumblr site

(Update: Version 3.2.0 of Jekyll looks like it's breaking a few things, so I've changed the guide to make you specifically install the version I was using, 3.1.3. I believe this is the issue: jekyll/jekyll#5145.)

You will be using jekyll-import to export your Tumblr site, Jekyll to (re)create it, and Surge to rehost it.

Setup and installation

You will need:

@marcus-at-localhost
marcus-at-localhost / anonymize_ip.php
Created March 27, 2018 22:10 — forked from svrnm/anonymize_ip.php
Anonymize IPv4 and IPv6 addresses
<?php
function anonymize_ip($ip) {
if($ip = @inet_pton($ip)) {
return inet_ntop(substr($ip, 0, strlen($ip)/2) . str_repeat( chr(0), strlen($ip)/2 ));
}
return '0.0.0.0';
}
?>
@marcus-at-localhost
marcus-at-localhost / geo.js
Created January 8, 2018 20:35 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@marcus-at-localhost
marcus-at-localhost / businesses.json
Created January 4, 2018 08:11 — forked from zross/businesses.json
Leaflet.js Tips, Step 4 (filter geojson markers)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcus-at-localhost
marcus-at-localhost / remove_diacritics.js
Last active January 3, 2018 15:01 — forked from yeah/remove_diacritics.js
Remove diacritics (Umlauts, Accents, Special characters) in JavaScript
String.prototype.replaceDiacritics = function(){
var string = this.toString();
var diacriticsMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'Ae','letters':/[\u00C4\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},