Skip to content

Instantly share code, notes, and snippets.

View bricklink-mod.user.js
@bert-w
bert-w / search.php
Created Mar 21, 2019
Find a high multiplicative persistence in PHP
View search.php
<?php
// INPUT VARS
$start = 2677889;
$end = 26888999;
/**
* @param integer $input
* @return false|int
*/
@bert-w
bert-w / .htaccess
Last active May 17, 2019
Generic htaccess rewrite to HTTPS
View .htaccess
# Rewrite non-https to https + www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
</IfModule>
# Rewrite non-https to https without www
@bert-w
bert-w / index.js
Created Aug 11, 2017
Speech Recognition using Appcelerator Titanium and Hyperloop
View index.js
'use strict';
/**
* Android sample showing speech recognition using Hyperloop.
*
* @version Titanium 6.1.2.GA
* @version Alloy 1.9.13
* @version Hyperloop 2.1.3
*/
@bert-w
bert-w / xssi.js
Created Jul 6, 2017
Connect/Express middleware to automatically prepend protective characters
View xssi.js
/**
* Connect/Express middleware to automatically prepend ")]}" plus a newline to your JSON response.
*
* Angular2 picks this up automatically and strips the response of these characters.
*
* Example: call res.json() anywhere in the route chain and it will follow the directions below.
*/
module.exports = function(req, res, next) {
res.json = function(data) {
var xssiProtection = ')]}\',\n';
@bert-w
bert-w / helpers.scss
Last active Jun 30, 2017
SCSS/SASS helpers for padding & margin classes
View helpers.scss
$type: (p:padding, m:margin);
$position: (t:top, l:left, b:bottom, r:right);
$range: 0 5 10 15 20 25 30 35 40;
/*
* Loop and create classes that serve as quick padding/margin modifiers.
* Explanation of class syntax:
*
* ".p-t-0" Assign a padding-top of 0px (!important).
* ".m-b-35" Assign a margin-bottom of 35px (!important).