Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / remove-empty-p.php
Last active January 3, 2023 01:11
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
@mariozig
mariozig / migrate_repo.sh
Last active May 26, 2024 20:57
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror git@your-gitlab-site.com:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
@jasdeepkhalsa
jasdeepkhalsa / interval.js
Created April 20, 2015 15:26
setTimeout and setInterval with pause and resume
// http://stackoverflow.com/questions/7279567/how-do-i-pause-a-window-setinterval-in-javascript
function RecurringTimer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
<template>
<div id="app">
<img class="logo" src="./assets/logo.png">
<Hello></Hello>
<Messages></Messages>
</div>
</template>
<script>
import Hello from './components/Hello'
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@akella
akella / shaurma.js
Created January 30, 2018 15:45
Plural intl
let items = new Intl.PluralRules('ru-RU');
let result,word;
for(var i = 0;i<25;i++){
if(items.select(i)=='one'){
word = 'шаурма';
}
if(items.select(i)=='few'){
word = 'шаурмы';
}
if(items.select(i)=='many'){
@karanssj4
karanssj4 / .eslintrc.js
Created March 2, 2018 07:57
Make eslint work with vueJs with eslint-plugin-vue (tested with eslint-plugin-vue v4.3.0)
// http://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
sourceType: 'module',
parser: 'babel-eslint',
},
env: {
browser: true,
<!DOCTYPE html>
<html>
<head>
<title>Fireside Chat</title>
<link rel="stylesheet" href="/style/style.css">
</head>
<body>
<h1>Fireside Chat</h1>
<div id="app">
<div v-if="state == 0">
@giggo1604
giggo1604 / vue.config.js
Created July 11, 2018 07:50
vue-cli 3.0 multi-page config with historyApiFallback
module.exports = {
pages: {
foo: {
entry: 'src/foo/main.js',
template: 'public/index.foo.html',
filename: 'index.foo.html'
},
bar: {
entry: 'src/bar/main.js',
template: 'public/index.bar.html',