Skip to content

Instantly share code, notes, and snippets.

View janrenn's full-sized avatar

janrenn janrenn

View GitHub Profile
@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
@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' '
<?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');
//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, '-_' );
@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) {
$replace(%title%,á,a,ä,a,à,a,č,c,ç,c,ď,d,é,e,ě,e,è,e,ë,e,í,i,ï,i,ì,i,ľ,l,ň,n,ñ,n,ó,o,ö,o,ò,o,ô,o,õ,o,ř,r,š,s,ť,t,ú,u,ü,u,ů,u,ý,y,ÿ,y,ž,z,þ,th,ð,d,æ,ae,ƒ,f)
$replace(%title%,Á,A,Ä,A,À,A,Č,C,Ç,C,Ď,D,É,E,Ě,E,È,E,Ë,E,Í,I,Ï,I,Ì,I,Ľ,L,Ň,N,Ñ,N,Ó,O,Ö,O,Ò,O,Ô,O,Õ,O,Ř,R,Š,S,Ť,T,Ú,U,Ü,U,Ů,U,Ý,Y,Ÿ,Y,Ž,Z,Þ,TH,Ð,D,Æ,AE,Ƒ,F)
@janrenn
janrenn / .stylelintrc.json
Last active March 27, 2019 13:55
.stylelintrc
{
"plugins": [
"stylelint-selector-bem-pattern"
],
"extends": [
"stylelint-config-standard",
"stylelint-config-visionapps-order"
],
"rules": {
"at-rule-empty-line-before": null,
@janrenn
janrenn / htmlhintrc.json
Created March 27, 2019 16:28
htmlhintrc
{
"tagname-lowercase": true,
"attr-lowercase": true,
"attr-value-double-quotes": true,
"doctype-first": true,
"tag-pair": true,
"spec-char-escape": true,
"id-unique": true,
"src-not-empty": true,
"attr-no-duplication": true,
$trim($num(%track%,2) - $replace(%artist%,Ç,C,À,A,á,a,ä,a,à,a,č,c,ç,c,ď,d,é,e,ě,e,è,e,ë,e,í,i,ï,i,ì,i,ň,n,ñ,n,ó,o,ö,o,ò,o,ô,o,õ,o,ř,r,š,s,ť,t,ú,u,ü,u,ů,u,ý,y,ÿ,y,ž,z,þ,th,ð,d,æ,ae,ƒ,f,Á,A,Ä,A,À,A,Č,C,Ç,C,Ď,D,É,E,Ě,E,È,E,Ë,E,Í,I,Ï,I,Ì,I,Ň,N,Ñ,N,Ó,O,Ö,O,Ò,O,Ô,O,Õ,O,Ř,R,Š,S,Ť,T,Ú,U,Ü,U,Ů,U,Ý,Y,Ÿ,Y,Ž,Z,Þ,TH,Ð,D,Æ,AE,Ƒ,F) - $replace(%title%,Ç,C,À,A,á,a,ä,a,à,a,č,c,ç,c,ď,d,é,e,ě,e,è,e,ë,e,í,i,ï,i,ì,i,ň,n,ñ,n,ó,o,ö,o,ò,o,ô,o,õ,o,ř,r,š,s,ť,t,ú,u,ü,u,ů,u,ý,y,ÿ,y,ž,z,þ,th,ð,d,æ,ae,ƒ,f,Á,A,Ä,A,À,A,Č,C,Ç,C,Ď,D,É,E,Ě,E,È,E,Ë,E,Í,I,Ï,I,Ì,I,Ň,N,Ñ,N,Ó,O,Ö,O,Ò,O,Ô,O,Õ,O,Ř,R,Š,S,Ť,T,Ú,U,Ü,U,Ů,U,Ý,Y,Ÿ,Y,Ž,Z,Þ,TH,Ð,D,Æ,AE,Ƒ,F))