View Googl.php
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 | |
/** | |
* Googl | |
* | |
* For more information on this file and how to use the class please visit | |
* http://www.hashbangcode.com/blog/googl-url-shortening-service-class-php-528.html | |
* | |
* PHP version 5 | |
* |
View Config Merge
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 | |
require './vendor/autoload.php'; | |
// Set up the directories needed. | |
$parentDirectory = 'config/siteone'; | |
$siblingDirectory = 'config/sitetwo'; | |
$destinationDirectory = 'config/default'; |
View tictactoe.php
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 | |
function renderGame($state, $activeCell, $player) { | |
$output = ''; | |
$output .= 'Player:' . $player . PHP_EOL; | |
foreach ($state as $x => $line) { | |
$output .= '|'; | |
foreach ($line as $y => $item) { |
View snake.php
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 | |
function gameOver($snake) { | |
if ($snake->tail > 5) { | |
// If the trail is greater than 5 then check for end condition. | |
for ($i = 1; $i < count($snake->trail); $i++) { | |
if ($snake->trail[$i][0] == $snake->positionX && $snake->trail[$i][1] == $snake->positionY) { | |
die('dead :('); | |
} | |
} |
View FloodProtectedForm.php
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; |
View shoot.php
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; | |
} |
View time.py
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 |
View tkinter_time_wall.py
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 |
View calculator.py
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 = {} |
View detectkeys.php
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 | |
function translateKeypress($string) { | |
switch ($string) { | |
case "\033[A": | |
return "UP"; | |
case "\033[B": | |
return "DOWN"; | |
case "\033[C": | |
return "RIGHT"; |
OlderNewer