Skip to content

Instantly share code, notes, and snippets.

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

Philip Norton philipnorton42

🏠
Working from home
View GitHub Profile
@philipnorton42
philipnorton42 / calculator.py
Last active November 1, 2021 09:04
A calculator, created with Tkinter and Python. See https://www.hashbangcode.com/article/creating-simple-calculator-application-tkinter-python for more informaiton.
import tkinter as tk
class Calculator(tk.Tk):
def __init__(self):
super().__init__()
self.title("Calcuator")
self.buttons = {}
'''
Conway's Game Of Life With Tkinter In Python
See https://www.hashbangcode.com/article/conways-game-life-tkinter-python for
a detailed breakdown of this code.
'''
import tkinter as tk
from tkinter import Canvas
import random, math
class game_of_life(tk.Tk):
'''
Hitomezashi Stitch Patterns
See https://www.hashbangcode.com/article/drawing-hitomezashi-stitch-patterns-tkinter-canvas-python for
a detailed breakdown of this code.
'''
import tkinter as tk
from tkinter import Canvas
import random, math
class Pattern(tk.Tk):
@philipnorton42
philipnorton42 / Base64FileManagerService.php
Created June 19, 2022 08:56
A Drupal service class that can extract base64 encoded files from HTML content.
<?php
namespace Drupal\mymodule;
use Drupal\Core\File\Exception\FileNotExistsException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\file\FileRepositoryInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
@philipnorton42
philipnorton42 / sparkline.php
Created September 17, 2023 11:56
A script for generating sparklines in PHP. See https://www.hashbangcode.com/article/creating-sparklines-php for more information.
<?php
/**
* A script for generating sparklines in PHP.
*
* To use this script, create an image tag and pass a data parameter to it.
* <code>
* <img src="/sparkline.php?&data=10,40,20,10,0,20,40,50,100,20"/><br>
* </code>
*
* You can also alter the width and height of the chart by passing w and h.