Skip to content

Instantly share code, notes, and snippets.

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

corbpie cp6

🏠
Working from home
View GitHub Profile
@cp6
cp6 / MYSQL_backup_compress.bat
Last active November 13, 2017 03:34
Backup MYSQL and compress with a batch file
@echo off
color 0E
title MySQL backup.
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" & set "MS=%dt:~15,3%"
set "dirname=%DD%_%MM%_%YY%_%HH%%Min%"
@cp6
cp6 / youtube_sub_last_upload.php
Created July 9, 2018 06:47
View when your YouTube subscribed last upload was
<?php
ini_set('max_execution_time', 120);//2 minutes
error_reporting(0);
$api_key = '';//Your YouTube/Google api key
$your_ch_id = '';//YOur YouTube channel id
function call_api($call, $type)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
@cp6
cp6 / LAC_fixture.txt
Created October 31, 2018 05:32
LAC fixture 2018/19 NBA
GAMENUMBER_HOME_AWAY
1_LAC_DEN
2_LAC_OKC
3_LAC_HOU
4_NOP_LAC
5_HOU_LAC
6_LAC_WAS
7_OKC_LAC
8_PHI_LAC
9_ORL_LAC
@cp6
cp6 / page_system.php
Created July 3, 2019 09:20
Simple PHP MySQL page system
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];//If ?page= is set use it
} else {
$page = 0;//No ?page= found so we are at page 1 which is a zero
}
$db = new PDO('mysql:host=localhost;dbname=DATABASE;charset=utf8mb4', 'USERNAME', 'PASSWORD');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function pagination_system($page_number, $items_per_page)
@cp6
cp6 / date_dir.php
Created July 12, 2019 01:04
Create directory based on Year, Month and Day PHP
<?php
function create_date_dir($start_dir = ''){
$year = date("Y");
$month = date("m");
$day = date("d");
$directory = "".$start_dir."$year/$month/$day/";
if(!is_dir($directory)){
mkdir($directory, 755, true);
}
}
@cp6
cp6 / create_icon.php
Last active July 19, 2019 03:52
Create png letter icon with PHP
<?php
function create_icon($first_letter, $second_letter, $save_as)
{
$image = ImageCreate(64, 64) or die ("Error making image");//Make the base image (64 x 64)
$background_color = ImageColorAllocate($image, rand(0, 255), rand(0, 255), rand(0, 255));//Base image background color (random)
$text_color = ImageColorAllocate($image, 255, 255, 255);//White text for font
$font = '/var/www/html/ariel.ttf';//Defined font file
if ($second_letter == ''){//Positioning for one vs two letters
$string = "$first_letter";
$img = imagettftext($image, 36, 0, 17, 47, $text_color, $font, $string);
@cp6
cp6 / writecorbpie.css
Created October 19, 2019 03:28
Write corbpie blog theme style
body {
color: #BAD5EE;
background-color: #1C2030;
font-family: 'Inconsolata', monospace
}
.site-wrapper {
background-color: #1C2030
}
@cp6
cp6 / openweathermap_class.php
Created November 14, 2019 05:34
Forecast and current weather data with OpenWeatherMap API
<?php
class weatherApp
{
const URI = 'https://api.openweathermap.org/data/2.5/';
private $api_key;
private $data;
/**
* Sets api key
@cp6
cp6 / corbpieBlogPoster.php
Last active January 28, 2020 04:52
reddit blog poster class
<?php
class corbpieBlogPoster
{
private $accessToken;
private $tokenType;
private $clientId;
private $clientSecret;
private $authMode = 'basic';
@cp6
cp6 / http_request_db.php
Last active February 4, 2020 01:12
Simple PHP page HTTP request to MySQL table
<?php
function insert_request()
{
$db = new PDO('mysql:host=127.0.0.1;dbname=requests;charset=utf8mb4', 'USERNAME', 'PASSWORD');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$referer = NULL;
if (isset($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
}
$insert = $db->prepare('INSERT IGNORE INTO `data` (`ip`, `referer`, `method`, `user_agent`, `code`, `dir`, `time`) VALUES (?,?,?,?,?,?,?)');