Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe di Stefano joeydi

View GitHub Profile
@joeydi
joeydi / validator_json_to_html.py
Created May 8, 2020
Validator.nu JSON to HTML
View validator_json_to_html.py
#!/usr/local/bin/python3
import sys
import argparse
import html
import requests
from pprint import pprint
ICON_INFO = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M13 7.5a1 1 0 11-2 0 1 1 0 012 0zm-3 3.75a.75.75 0 01.75-.75h1.5a.75.75 0 01.75.75v4.25h.75a.75.75 0 010 1.5h-3a.75.75 0 010-1.5h.75V12h-.75a.75.75 0 01-.75-.75z"></path><path fill="currentColor" fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12a9.5 9.5 0 1119 0 9.5 9.5 0 01-19 0z"></path></svg>'
ICON_ERROR = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M12 7a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 7zm1 9a1 1 0 11-2 0 1 1 0 012 0z"></path><path fill="currentColor" fill-rule="evenodd" d="M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1zM2.5 12a9.5 9.5 0 1119 0 9.5 9.5 0 01-19 0z"></path></svg>'
@joeydi
joeydi / post-receive.sh
Created Sep 24, 2019
Craft CMS post-receive hook
View post-receive.sh
#!/bin/bash
WORK_TREE="/var/www/example"
GIT_DIR="/var/repo/example.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
@joeydi
joeydi / installwp.sh
Created Oct 20, 2018
Download WordPress, Create Database, and Install - Requires WP CLI
View installwp.sh
#!/bin/bash
# Download WordPress, create database, configure, and install
if [ $1 ]
then
echo "Installing in directory $1"
mkdir $1
cd $1
@joeydi
joeydi / views.py
Created Jun 10, 2016
Form/FormSet cleaned_data handling
View views.py
if isinstance(cleaned_data, list):
cleaned_data = [self.process_cleaned_data(form_data) for form_data in cleaned_data]
else:
cleaned_data = self.process_cleaned_data(cleaned_data)
@joeydi
joeydi / batch.py
Created Nov 19, 2014
Simple WordPress Content Scraper/Importer
View batch.py
import os
import lxml.html
import urllib
import BeautifulSoup
from pprint import pprint
from wordpress_xmlrpc import Client, WordPressPage
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
View Example Open Graph Tags
<meta property="og:type" content="article" />
<meta property="og:title" content="Web Design & Development from Burlington, VT - Okay Plus" />
<meta property="og:description" content="Critical thinking, clean code and responsive design. These are the tools I use to bring digital experiences to life online." />
<meta property="og:url" content="http://okaypl.us/" />
<meta property="og:site_name" content="Okay Plus" />
@joeydi
joeydi / functions.php
Last active Nov 15, 2017
WordPress SEO Open Graph Image Size Filter
View functions.php
<?php
function my_opengraph_image_size() {
return 'large';
}
add_filter( 'wpseo_opengraph_image_size', 'my_opengraph_image_size', 10, 1 );
@joeydi
joeydi / skrollr-video.js
Created Sep 25, 2014
Attempt to play video frame by frame with scroll. Don't try this at home, kids.
View skrollr-video.js
videos.each(function () {
var video = $(this).get(0);
video.addEventListener('loadedmetadata', function () {
console.log(video.duration);
});
});
skrollr.init({
render: function(data) {
View uptime.py
from threading import Thread
import requests ## pip install requests
import time
import smtplib
## email sending function
def email_sender(input_message, email_to, client):
''' function to send email '''
to = email_to
gmail_user = '' ## email of sender account
View vpr-composer
initComposer = function() {
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpRequest = new activeXObject("Microsoft.XMLHTTP");
You can’t perform that action at this time.