This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
class Calculator(tk.Tk): | |
def __init__(self): | |
super().__init__() | |
self.title("Calcuator") | |
self.buttons = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creates a Tkinter application that shows the current time as a word wall | |
# For more information see: https://www.hashbangcode.com/article/creating-word-clock-python-and-tkinter | |
# | |
# 0123456789ABC | |
# 0 ITRISUHALFTEN | |
# 1 QUARTERTWENTY | |
# 2 FIVEQMINUTEST | |
# 3 PASTMTOSAMOPM | |
# 4 ONENTWOZTHREE | |
# 5 FOURFIVESEVEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following code will print out the current time as a sentence. | |
# See https://www.hashbangcode.com/article/converting-current-time-sentence-python for information on this code. | |
def translate_to_or_past(minute): | |
to_or_past = '' | |
if 3 <= minute < 33: | |
to_or_past = 'PAST' | |
elif 33 <= minute <= 57: | |
to_or_past = 'TO' | |
return to_or_past |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Entity { | |
public $positionX = 0; | |
public $positionY = 0; | |
public function __construct($x, $y) { | |
$this->positionX = $x; | |
$this->positionY = $y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mp3 { | |
protected $tags = []; | |
protected $versions = [ | |
0x0 => '2.5', | |
0x1 => 'x', | |
0x2 => '2', | |
0x3 => '1', | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\mymodule\Form; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Drupal\Core\Flood\FloodInterface; | |
use Drupal\Component\Utility\Crypt; |
NewerOlder