Skip to content

Instantly share code, notes, and snippets.

View janrenn's full-sized avatar

janrenn janrenn

View GitHub Profile
@janrenn
janrenn / typography.js
Created December 5, 2018 22:45
Applies some basic typographic rules on text.
/**
* Applies some basic typographic rules on text.
*
* @param {String} text Text the rules should be applied on
* @param {Boolean} removeEmpty Whether to remove empty <p>s
* @returns {String} Adjusted text
* @version 0.2
* @author %AUTHOR%
*/
typography: function (text, removeEmpty) {
//truncation
//-------------
$ext = end( explode( '.', $filename ) );
$filename = substr( $filename, 0, -(strlen($ext) + 1) );
$filename = str_replace( '.', '-', $filename );
$filename_shortened = substr( $filename, 0, 70 );
if ( $filename_shortened != $filename ) {
$filename = preg_replace( '~(-|_)[^\-_]{0,' . floor( strlen($filename) / 2 ) . '}$~', '', $filename_shortened );
}
$filename = trim( $filename, '-_' );
<?php
//try http://example/wp-json/sap/v1/angular
function sap_rest_angular( $data ) {
$json = new stdClass();
// bloginfo
$json->bloginfo = new stdClass();
$json->bloginfo->name = get_bloginfo('name');
$json->bloginfo->description = get_bloginfo('description');
//$json->bloginfo->wpurl = get_bloginfo('wpurl');
//$json->bloginfo->url = get_bloginfo('url');
@janrenn
janrenn / .htaccess
Last active June 23, 2017 13:39
CSP
#common
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' *.avvo.com *.bbb.org *.facebook.net *.google-analytics.com *.google.com *.googleadservices.com *.googlesyndication.com *.googletagmanager.com *.gravatar.com *.gstatic.com *.newrelic.com *.nr-data.net *.olark.com *.twitter.com *.wp.com *.youtube.com *.ytimg.com *.cloudflare.com *.amazonaws.com *.googleapis.com; style-src 'unsafe-inline' * data:; img-src * data:; font-src 'unsafe-inline' * data:; frame-src 'self' *.avvo.com *.bbb.org *.doubleclick.net *.facebook.com *.googletagmanager.com *.olark.com *.wp.com *.youtube.com akismet.com example.com; child-src 'self' *.avvo.com *.bbb.org *.doubleclick.net *.facebook.com *.googletagmanager.com *.olark.com *.wp.com *.youtube.com akismet.com example.com; object-src 'none'; connect-src 'self' *.akismet.com *.bbb.org *.google.com *.olark.com akismet.com;"
#common+issuu
Header set Content-Security-Policy "default-src 'self'; script-src 'self' '
@janrenn
janrenn / strong-passwords.php
Created May 16, 2017 12:34 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by