Skip to content

Instantly share code, notes, and snippets.

View element121's full-sized avatar

element121 element121

  • UK
View GitHub Profile
@element121
element121 / compoundMonthly.html
Last active September 3, 2019 12:06
Monthly interest compounding calculator
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8" />
</head>
<body>
<label for="investYears">Investment term</label>
@element121
element121 / youtube_channel_stats.php
Last active June 27, 2017 14:05
PHP Code to use YouTube's API to get statisticts on one or more YouTube Channels by their name.
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
// Youtube API to get stats for a channel
// Example call, but you will need an API key from Google to use the API
// https://www.googleapis.com/youtube/v3/channels?part=statistics&forUsername=kontor&key={YOUR_API_KEY}
// Returns:
<?php
if (isset($_POST['number']))
{
// Grab the POSTed number input field
$number = $_POST['number'];
$number_range = $_POST['number_range'];
// Use filter_var to check if the value is a valid number
<?php
if (isset($_POST['email']))
{
// Grab the POSTed email address input field
$email = $_POST['email'];
// Use filter_var to check if the email address is valid
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
echo("$email is not a valid email address");
CREATE TABLE IF NOT EXISTS `gc_countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sequence` int(11) NOT NULL DEFAULT '0',
`name` varchar(128) COLLATE utf8_bin NOT NULL,
`iso_code_2` varchar(2) COLLATE utf8_bin NOT NULL DEFAULT '',
`iso_code_3` varchar(3) COLLATE utf8_bin NOT NULL DEFAULT '',
`address_format` text CHARACTER SET utf8 NOT NULL,
`postcode_required` int(1) NOT NULL DEFAULT '0',
`status` int(1) NOT NULL DEFAULT '1',
<?php
// PHP Code to add a member to a MailChimp list using their API v3.0
// As described in this blog post: http://element121.com/2016/04/30/how-to-add-a-subscriber-using-mailchimps-api-with-php/
// http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/
/*
curl --request POST \
--url 'https://usX.api.mailchimp.com/3.0/lists/57afe96172/members' \
--user 'anystring:apikey' \
--header 'content-type: application/json' \
-- This is MySQL sample provided from http://element121.com/2016/02/02/how-to-join-the-same-table-three-times-in-a-single-sql-query-statement/
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jan 11, 2016 at 10:57 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
include('simple_html_dom.php');
// Call a remote file
$html = file_get_html("http://ww.site-to-scrape.com/page.php");
// Then access the DOM to find what you need, for example the title of the web page:
foreach($html->find('title') as $e)
{
echo $e->innertext . '<br>';
}
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 3.4.9
-- http://www.phpmyadmin.net
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Table structure for table `vehicle_makes_models_style`
--
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>