Skip to content

Instantly share code, notes, and snippets.

View BenFausch's full-sized avatar

Ben Fausch BenFausch

View GitHub Profile
@BenFausch
BenFausch / generateSSL.sh
Created March 28, 2018 16:47
wordpress local nginx setup with https
#this creates generic ssl certs (will be unsafe, but usuable for local) for any local servers that use ssl_certificate in their nginx conf
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
@BenFausch
BenFausch / update.sql
Last active April 2, 2018 17:09
wordpress https updates
.htaccess file will need the following:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
run this sql:
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://digitalbureau.com', 'src="https://digitalbureau.com');
UPDATE digitalbureau_com.wp_posts SET `guid` = REPLACE (`guid`, 'http://digitalbureau.com', 'https://digitalbureau.com') WHERE post_type = 'attachment';
src:
@BenFausch
BenFausch / replace.php
Created April 10, 2018 16:22
multiple string replacements with php str_replace
//loops through each array by key, so $quotes[0] replaces $replace[0]
$quotes = ["\\'",'\\"'];
$replace = ["'",'"'];
$newsletter_article_html = str_replace($quotes, $replace, $newsletter_article_html);
return $newsletter_article_html;
@BenFausch
BenFausch / verticalstripes.css
Created April 12, 2018 17:01
vertical stripe background using repeating gradient
background: repeating-linear-gradient(to right, $white, $white 20px, $bg-grey 20px, $bg-grey 130px);
@BenFausch
BenFausch / random.ks
Created May 8, 2018 16:59
Random color 1 liner
let randomColor = '#' + (Math.random() * 0xFFFFFF << 0).toString(16);
@BenFausch
BenFausch / random.js
Created May 8, 2018 21:38
Random opacity
let randomOpacity = (Math.random() * (0.50 - 1) + 1).toFixed(2);
// in react:
<p key={k} style={{opacity: randomOpacity}}>
@BenFausch
BenFausch / setup.sh
Created May 16, 2018 16:41
Tensorflow setup for gcloud micro box including ssh
#config ssh:
#add rsa.pub to instance metadata
#1. go to gcloud instance, click edit
#2. go to 'custom metadata' section, add 'enable-oslogin':TRUE
#3. click 'show and edit' under SSH key section, add the contents outputted by command 'cat ~/.ssh/id_rsa.pub' to add your public ssh key (use the outputted username as the key here ex. benfausch)
#4. go to gcloud terminal through gcloud webpage, run 'mkdir .ssh && touch .ssh/authorized_keys', then authorized_keys > "your ouputted public ssh key here"
#5. go to normal terminal, then use same username gcloud uses in browser terminal (ex benjamin_fausch_gmail), your private SSH key, and the public IP of the instance
#=>=>=>=> ssh -i id_rsa benjamin_fausch@35.123.17.04
#6. then you can just use ssh benjamin_fausch@35.xxx and create an alias
@BenFausch
BenFausch / carousel.js
Created May 24, 2018 20:45
Carousel slider logic for 3 piece carousel
@BenFausch
BenFausch / detectSwipe.js
Created May 25, 2018 17:07
swipe detection in Vanilla
let touchstartX = 0;
let touchstartY = 0;
let touchendX = 0;
let touchendY = 0;
const gestureZone = document.getElementById('gestureZone');
gestureZone.addEventListener('touchstart', function(event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
@BenFausch
BenFausch / run.sh
Created June 11, 2018 20:50
webfaction letsencrypt
#REF:
#https://github.com/will-in-wi/letsencrypt-webfaction
#To install letsencrypt on webfaction
GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib gem2.2 install letsencrypt_webfaction
#Edit $HOME/.bash_profile to add the function below:
function letsencrypt_webfaction {