Skip to content

Instantly share code, notes, and snippets.

View capjamesg's full-sized avatar
writing words and code

James capjamesg

writing words and code
View GitHub Profile
@capjamesg
capjamesg / analytics.sh
Created October 7, 2020 08:35
A bash script to parse my nginx access logs.
#!/bin/bash
rm /home/james/logs/*
log_files=/home/james/logs/
# Copy log files to temporary directory
cp /var/log/nginx/access*.gz $log_files
@capjamesg
capjamesg / hcard.py
Created June 16, 2021 07:05
Print a hcard with a thermal printer
import mf2py
import main
import requests
import os
from Adafruit_Thermal import *
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
printer.setLineHeight(28)
@capjamesg
capjamesg / markdown_jekyll_to_img_tags.py
Created July 11, 2021 09:12
This program converts ![]() markdown image syntax to an img tag with a u-photo microformats2 class.
import os
for filename in os.listdir("_posts/"):
if ".md" in filename:
with open("_posts/{}".format(filename), "r") as file:
line_number = 0
line_to_replace = ""
lines = list(file.readlines())
final_img_tag = ""
for l in lines:
@capjamesg
capjamesg / macros.lua
Created July 18, 2021 08:17
Some of my Keybow macros.
require "keybow"
muted = false
-- this code lets me press multiple keys at once (use a keyboard shortcut)
-- I found the modifier function online but cannot remember the source
function modifier(key, ...)
for i = 1, select('#', ...) do
local j = select(i, ...)
@capjamesg
capjamesg / robots.py
Last active August 10, 2021 10:06
robots.txt parser in Python
import requests
HEADERS = {
"User-agent": "YOUR USER AGENT"
}
SITE_URL = "jamesg.blog"
def find_robots_directives():
"""
@capjamesg
capjamesg / checkins.rb
Created September 11, 2022 17:11
Script for generating checkins from a CSV on my website
require "csv"
for c in CSV.foreach("cafes.csv", :quote_char => '"', :col_sep =>', ', :headers => true)
slug = c['place_name'].downcase.gsub(/[^a-z0-9]+/i, '-')
front_matter = "
---
layout: checkin
latitude: #{c["lat"]}
longitude: #{c["long"]}
@capjamesg
capjamesg / cracklepop.lisp
Created September 21, 2022 12:29
An implementation of CracklePop in Lisp.
(defun cracklepop (num)
(cond
((and (= (mod num 3) 0) (= (mod num 5) 0)) "CracklePop")
((= (mod num 3) 0) "Crackle")
((= (mod num 5) 0) "Pop")
(num)))
(loop for val from 1 below 100 do (print (cracklepop val)))
@capjamesg
capjamesg / gist:9a0ff6c443286abe7c9223d754665c6b
Created September 21, 2022 20:45 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
SELECT COUNT(page) AS mf2_count FROM `httparchive.all.pages` WHERE date = "2022-08-01" AND payload LIKE "%authorization_endpoint%";
# Code to advance discussion around url_summary implementation
# Still in development
from urllib.parse import urlparse
url = "https://github.com/capjamesg/indieweb-utils/pulls/1"
callbacks = {
"github.com": [
lambda path: "A comment on pull request " + path[1] if len(path) > 2 and path[2] == "pulls" else "",