Skip to content

Instantly share code, notes, and snippets.

View adamcjoiner's full-sized avatar

Adam C. Joiner adamcjoiner

View GitHub Profile
@adamcjoiner
adamcjoiner / brainhub-developer-toolbox.markdown
Last active September 19, 2023 15:40
BrainHub / Developer Toolbox
$(function() {
$('.login_button').click(function() {
doLogin();
});
$('#send_chat_form').submit(function() {
var message = $(this).find('.message').val();
sendMsg(message);
$('#chat').append('<div class="msg">me: ' + message + '</div>');
$(this).find(".message").val('');
@adamcjoiner
adamcjoiner / rest-endpoint-html.js
Created October 30, 2019 14:12
REST endpoint with HTML response (Node.js+Express.js)
var express = require('express');
var app = express();
var port = 3010;
var title = 'Homepage';
var home = '<h1>'+title+'</h1>';
app.get('/', function (req, res) {
@adamcjoiner
adamcjoiner / custom-template.php
Created May 23, 2019 22:08
A boilerplate custom page template file for Wordpress child themes
<?php
/*
Template Name: Custom Page Template
Author: Adam C. Joiner
Note: This template can be utilized by selecting it from the "Page Template" dropdown on the right hand side of the Wordpress page editor screen and then clicking Save.
*/
get_header();
/* Page content goes here */
@adamcjoiner
adamcjoiner / log.js
Last active March 23, 2019 12:04
Adds on/off capability and custom message coloring to console logs.
/*
Module Name: LogJS
Description: Adds on/off and custom coloring functions to console logs
Author: Adam C. Joiner
Author URI: http://www.adamcjoiner.com/
Usage: log.on(); // off by default
log.post('message') // log to console in white text
log.debug('email sent successfully'); // gray text
log.info('sending email'); // yellow text
log.warning('server responded with no data');
@adamcjoiner
adamcjoiner / secure.php
Last active October 11, 2020 23:36
PHP: Simple password protected page with md5 (found on: https://stackoverflow.com/questions/4115719/easy-way-to-password-protect-php-page)
<?php
$user = $_POST['user'];
$pass = md5($_POST['pass']);
$hash = "enter your md5 hash here";
if($user == "admin"
&& $pass == $hash)
{
echo "Secure content:";
include("content.html");
@adamcjoiner
adamcjoiner / jquery.checkurl.js
Last active November 19, 2024 09:09
Use jQuery's $.ajax to ping a URL and report the response
$.ajax({url: "http://www.google.com/",
type: "HEAD",
timeout:1000,
statusCode: {
200: function (response) {
console.log('Status 200: Page is up!');
},
400: function (response) {
console.log('Status 400: Page is down.');
},
@adamcjoiner
adamcjoiner / wp-admin-modal-dialog.php
Created June 6, 2018 20:38 — forked from anttiviljami/wp-admin-modal-dialog.php
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
@adamcjoiner
adamcjoiner / animate-and-reset.js
Created February 20, 2018 15:53
Add CSS animation to element and then reset it (to animate it again)
$('#btn-animate').click(function() {
// Shake the 'Codes' dropdown
animEl = $('#dropdown-codes');
animEl.addClass('shake animated'); // ~add the anim. CSS class
animEl.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (e) {
animEl.removeClass('shake animated'); // ~remove it when finished
});
});
@adamcjoiner
adamcjoiner / fullscreen.js
Created October 15, 2017 18:17
Make your web app load in full screen mode when added to iOS Homescreen
/*
Found on StackOverflow:
iPhone Safari Web App opens links in new window
https://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window
I have problem with web after adding icon to Home Screen. If the web is launched from Home Screen, all links will open in new window in Safari (and lose full screen functionality). How can I prevent it? I couldn't find any help, only the same unanswered question.
ANSWER: