Skip to content

Instantly share code, notes, and snippets.

View modemlooper's full-sized avatar
🏠
Working from home

mödemlooper modemlooper

🏠
Working from home
View GitHub Profile
@modemlooper
modemlooper / .gitignore
Created May 14, 2019 18:15
gitignore wp-content
# -----------------------------------------------------------------
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
#
# To ignore uncommitted changes in a file that is already tracked, use
# git update-index --assume-unchanged
#
# To stop tracking a file that is currently tracked, use
# git rm --cached
@modemlooper
modemlooper / cat-to-tags.php
Created May 4, 2019 17:40
Copy categories to tags then add tags to posts - WordPress
// Lets create our tags. We will use wp_insert_term hooked to init
function emg_add_cat_to_tags() {
// Get all categories
$categories = get_categories( [ 'hide_empty' => 0 ] );
// Probably totally unnecessary, but check for empty $categories
if ( ! $categories ) {
return;
}
@modemlooper
modemlooper / wordpress-upload-base64.php
Created January 9, 2019 19:14
Upload a base64 string as image to the WordPress media library
/**
* Save the image on the server.
*/
function save_image( $base64_img, $title ) {
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img = str_replace( 'data:image/jpeg;base64,', '', $base64_img );
@modemlooper
modemlooper / distance.js
Created November 28, 2018 05:06
calculate distance
function distance(lat1, lon1, lat2, lon2, unit) {
if ((lat1 == lat2) && (lon1 == lon2)) {
return 0;
}
else {
var radlat1 = Math.PI * lat1/180;
var radlat2 = Math.PI * lat2/180;
var theta = lon1-lon2;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
"headers": [
{
"source": "/build/app/**",
"headers": [
{
"key": "Link",
"value": "public, max-age=31536000"
}
]
},
@modemlooper
modemlooper / unblock.js
Last active April 17, 2018 22:44
unblock all twitter followers
/* eslint-disable camelcase, comma-dangle */
const Twit = require('twit');
const Future = require('fluture');
const { Either, Reader } = require('ramda-fantasy');
const logError = x => console.error(x); // eslint-disable-line no-console
const log = x => console.log(x); // eslint-disable-line no-console
// getBlocks :: TwitterClient -> Future
// get all of your blocks
@modemlooper
modemlooper / htaccess.txt
Created April 16, 2018 23:01
htaccess for stencil apps so they load dynamic urls
#Remove .html from urls
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
# Is it a file? serve it, is it not a file? serve index.html
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
@modemlooper
modemlooper / letsencrypt.md
Created March 30, 2018 02:32
Installing Let's Encrypt with Cerbot on DigitalOcean & ServerPilot

Let's Encrypt

SSH as root into the server

ssh root@SERVER_IP_ADDRESS

Install Certbot

wget https://dl.eff.org/certbot-auto
@modemlooper
modemlooper / fix.css
Created January 5, 2018 17:18
ionic header padding fix slide from modal
.toolbar-ios {
height: 44px + $cordova-ios-statusbar-padding;
padding-top: $cordova-ios-statusbar-padding;
}
.toolbar-title-ios {
padding-top: $cordova-ios-statusbar-padding;
}
@modemlooper
modemlooper / block-activity-types.php
Last active December 14, 2017 17:19
block bp activity types from saving to db
function wp43566_activity_dont_save( $activity_object ) {
$exclude = array(
'joined_group',
'activity_update',
'new_member',
'created_group',
'updated_profile',
'new_avatar',
'new_event',
'friendship_accepted',