View ghostupdate.sh
#!/bin/bash | |
PROJECT=$(pwd) | |
CURRENT_GHOST_VERSION=$(ghost version) | |
NEW_GHOST_VERSION=$(ghost check-update) | |
if [ ! -z "$NEW_GHOST_VERSION" ] | |
then | |
echo "Upgrading $CURRENT_GHOST_VERSION -> $NEW_GHOST_VERSION" | |
ghost stop |
View GithubWidget.js
import React from 'react' | |
import PropTypes from 'prop-types' | |
import { StaticQuery, graphql } from 'gatsby' | |
import { FaGithub, FaCode, FaStar, FaCodeBranch, FaProjectDiagram } from 'react-icons/fa' | |
/** | |
* Github widget | |
*/ | |
const GithubWidget = ({ data }) => { |
View Makefile
SRCPATH := $(shell pwd) | |
PROJECTNAME := $(shell basename $(CURDIR)) | |
ENTRYPOINT := $(PROJECTNAME).ini | |
define HELP | |
Manage $(PROJECTNAME). Usage: | |
make run - Run $(PROJECTNAME). | |
make restart - Purge cache & reinstall modules. | |
make deploy - Pull latest build and deploy to production. |
View TwitterWidget.js
import React from 'react' | |
import PropTypes from 'prop-types' | |
import { StaticQuery, graphql } from 'gatsby' | |
import { FaTwitter, FaUsers, FaRetweet, FaHeartbeat, FaReply } from 'react-icons/fa' | |
import { AiOutlineCalendar } from 'react-icons/ai' | |
const TwitterWidget = ({ data }) => { | |
const tweets = data.tweets.edges | |
const twitterProfile = data.twitterProfile.user | |
const twitterProfileURL = `https://twitter.com/${twitterProfile.screen_name}/` |
View pandas_dataframe_difference.py
def dataframe_difference(df1, df2, which=None): | |
"""Find rows which are different.""" | |
comparison_df = df1.merge(df2, | |
indicator=True, | |
how='outer') | |
if which is None: | |
diff_df = comparison_df[comparison_df['_merge'] != 'both'] | |
else: | |
diff_df = comparison_df[comparison_df['_merge'] == which] | |
diff_df.to_csv('data/diff.csv') |
View find_dead_link_images.py
"""Collects locally stored images listed in report generated from https://www.deadlinkchecker.com/""" | |
import pandas as pd | |
import os | |
from shutil import copyfile | |
def read_csv_of_images(): | |
"""Read CSV of broken images generated from link checker.""" | |
links_df = pd.read_csv('data/brokenlinks.csv') | |
links_df.dropna(subset=['anchor'], inplace=True, axis=0) |
View timeit.py
def timeit(method): | |
"""Print execution time of decorated function.""" | |
def timed(*args, **kw): | |
ts = time.time() | |
result = method(*args, **kw) | |
te = time.time() | |
if 'log_time' in kw: | |
name = kw.get('log_name', method.__name__.upper()) | |
kw['log_time'][name] = int((te - ts) * 1000) | |
else: |
View pymysql_tutorial.py
import sys | |
import pymysql | |
import logging | |
class Database: | |
"""Database connection class.""" | |
def __init__(self, config): | |
self.host = config.db_host |
View image_optimize.py
import os | |
import json | |
import glob | |
import PIL | |
from PIL import Image | |
def get_all_images(): | |
"""Create an array of PNGs and JPGs.""" | |
img_arr = [] |
NewerOlder