Skip to content

Instantly share code, notes, and snippets.

View gwhitcher's full-sized avatar

George Whitcher gwhitcher

View GitHub Profile
@gwhitcher
gwhitcher / api.js
Created April 21, 2022 01:16
CRUD with nodejs, MySQL, and express
//requires
var mysql = require('mysql');
const express = require("express");
const app = express();
const { apiHost, apiPort, apiKey, mysqlSettings } = require('./config.json');
//web server
app.listen(apiPort, apiHost, () => {
console.log("Application started and listening on http://" + apiHost + ":" + apiPort);
});
@gwhitcher
gwhitcher / default.js
Created August 24, 2018 01:13
Easy WordPress AJAX
//Ajax for filter (replace DOMAIN.com with your domain name)
$("#postFilterLinks a").click(function(e) {
e.preventDefault();
var dataID = $(this).attr("data-id")
$.ajax({
type: "GET",
url: "http://DOMAIN.com/posts-filter",
data: "categoryID="+dataID,
success: function(html) {
$("#postsFiltered").html(html);
<?php
function getRecentForumTopics() {
$communityUrl = 'http://www.domain.com/';
$apiKey = 'API KEY';
$endpoint = '/forums/topics';
$vars = '?sortDir=desc&perPage=4';
$curl = curl_init( $communityUrl . 'api' . $endpoint.$vars );
curl_setopt_array( $curl, array(
CURLOPT_RETURNTRANSFER => TRUE,
<?php
function getWordpressPosts() {
$wordpressUrl = 'http://domain.com/';
$endpoint = '/wp/v2/posts/';
$vars = '';
$curl = curl_init( $wordpressUrl . 'wp-json' . $endpoint.$vars );
curl_setopt_array( $curl, array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC
import { Component } from 'react'
class Sample extends Component {
render() {
const { title, description, body } = this.props
return (
<div className="member">
<h1>{title}</h1>
<p>{description}</p>
@gwhitcher
gwhitcher / GalleryController.php
Last active January 4, 2017 20:21
CakePHP 3 Click and Drag Reorder and MoveUp/MoveDown
<?php
class GalleryController extends AppController {
public function index() {
$this->set('title_for_layout', 'Gallery');
$this->loadModel('Gallery');
$this->paginate = [
'limit' => 10,
'order' => [
'Gallery.position' => 'desc'
]