Skip to content

Instantly share code, notes, and snippets.

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

modemlooper modemlooper

🏠
Working from home
View GitHub Profile
*******HOMEPAGE
import { Component, h } from '@stencil/core';
@Component({
tag: 'app-home',
styleUrl: 'app-home.css'
})
export class AppHome {
<ion-item>
<ion-label>Sort Method</ion-label>
<ion-select value="recent">
<ion-select-option value="recent">Most Recent</ion-select-option>
<ion-select-option value="location">Location</ion-select-option>
</ion-select>
</ion-item>
<ion-list-header>
<ion-label>
@modemlooper
modemlooper / htaccess
Created January 21, 2020 01:42
runcloud redirect htaccess
RewriteEngine On
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
@modemlooper
modemlooper / sign.php
Created October 2, 2019 17:30 — forked from wouterdewinter/sign.php
Tutorial: Securing private content on AWS Cloudfront
<?php
/**
* Sign a private asset url on cloudfront
*
* @param $resource full url of the resources
* @param $timeout timeout in seconds
* @return string signed url
* @throws Exception
*/
@modemlooper
modemlooper / proxy.js
Last active July 18, 2019 01:03
http-proxy
var fs = require('fs');
var httpProxy = require('http-proxy');
var http = require('http');
var https = require('https');
var express = require('express');
var app = express();
app.use(function (req, res, next) {
console.log(req);
if (req.url === '/') {
@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"
}
]
},