Skip to content

Instantly share code, notes, and snippets.

@pirey
pirey / functions.php
Last active May 24, 2022 10:52
Wordpress `the_content` filter, for adding class to img element in the page content
<?php
// other stuff ...
// register our filter to the wordpress action 'the_content',
// it will then be called when we call the_content() from anywhere in our template
add_filter( 'the_content', 'add_classlist_to_img' );
function add_classlist_to_img( $content ) {
// used to detect img tag element
$locateElement = '/\<img.*?\/\>/';
@pirey
pirey / domain_name_pattern.txt
Last active December 30, 2016 08:04
Simple domain name filtering
# including any dots
/^[^\w\d]+|-(?<!\w)+|[^\w\d\.-]+|\s+|_+|[^\w\d]+$/
# match any dots except the last dot before tld
/^[^\w\d]+|-(?<!\w)+|\.(?!\w+$)|[^\w\d\.-]+|\s+|_+|[^\w\d]+$/
@pirey
pirey / someservice.spec.js
Last active December 30, 2016 08:03
solution for $httpBackend unexpected requests in jasmine spec for angularjs project
describe('testing using $httpBackend in ionic app', function() {
var yourAsyncService;
var $httpBackend;
// prepare our service and $httpBackend
beforeEach(function() {
// load module that holds our service
// make sure the required module is loaded
module('module_name');
@pirey
pirey / package.json
Created July 25, 2016 07:02
ionic project with npm script as build tool
{
"name": "generator-ionic-npm",
"version": "1.1.1",
"description": "Ionic app generator for yeoman using npm scripts as build tool",
"scripts": {
"scss": "node-sass --output-style compressed -o www/css src/scss",
"lint": "jshint src",
"concat": "node npm_scripts/concat.js",
"concat-vendor": "node npm_scripts/concat.vendor.js",
"uglify": "uglifyjs www/js/app.bundle.js -c -m -o www/js/app.bundle.min.js",