Skip to content

Instantly share code, notes, and snippets.

View gschoppe's full-sized avatar

Greg Schoppe gschoppe

View GitHub Profile
@gschoppe
gschoppe / wp_update_watch.php
Created December 6, 2018 16:35
WordPress Update Watch
<?php
if( !empty($_GET['request']) ) {
$current_version = "";
$url = "https://api.wordpress.org/core/version-check/1.7/";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url
));
$result = curl_exec($curl);
function DB(projectID) {
this.projectID = projectID;
this.types = {
'INT64' : "INT64",
'NUMERIC' : "NUMERIC",
'BIGNUMERIC': "BIGNUMERIC",
'FLOAT64' : "FLOAT64",
'BOOL' : "BOOL",
'STRING' : "STRING",
@gschoppe
gschoppe / Class-IntervalManager.js
Last active January 24, 2021 19:43
Class to simplify management of intervals
function IntervalManager() {
this.intervals = [];
// Public
this.setInterval = function(callback, interval, name) {
if (!name) {
name = "" + Date.now() + "|" + Math.random();
}
var newInterval = {
'name': name,
@gschoppe
gschoppe / Class-ImageScaler.js
Last active January 30, 2021 17:09
A simple JS class to manage client-side cropping. ImageScaler supports setting a focal point for the image, as well as selecting a zoom level for the crop
function ImageScaler(canvas, focus, zoom) {
if (canvas) {
this.canvas = canvas;
} else {
this.canvas = document.createElement("CANVAS");
}
if (focus) {
this.focus = focus;
} else {
this.focus = {x:.5,y:.5};
@gschoppe
gschoppe / Class-CropInterface.js
Last active January 31, 2021 17:21
A simple class to convert a div, or other block-level element, into a zoom and crop interface for images. Sample Implementation: https://codepen.io/gschoppe/pen/xxRxwaO
function CropInterface(el, w, h, resolutionMultiple) {
// handle parameters
this.el = el;
if (!w) { w = 100; }
this.w = w;
if (!h) { h = 100; }
this.h = h;
this.r = w / h;
if (!resolutionMultiple) { resolutionMultiple = 1; }
this.resolutionMultiple = resolutionMultiple;