Skip to content

Instantly share code, notes, and snippets.

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

Adam Doe adamdoe

🏠
Working from home
View GitHub Profile
@adamdoe
adamdoe / data.json
Last active October 24, 2022 14:40
Bar Chart > Example Data #d3
[
{
"Date": "2013-01",
"Value": "53"
},
{
"Date": "2013-02",
"Value": "165"
},
{
@adamdoe
adamdoe / callbacks.md
Last active May 24, 2022 02:56
callbacks #javascript

‎‎​

@adamdoe
adamdoe / ReactContext.md
Last active May 23, 2022 04:56
ReactContext #React

React Context

example

// MyContext.js
import React from 'react'
const MyContext = createContext()
export default MyContext

// App.js
@adamdoe
adamdoe / Animal.js
Last active June 1, 2021 22:05
Animal.js #js
/**
* ES6 Classes
* Notes:
* - instead of adding methods to the prototype
* can add them directly to class.
*/
class Animal {
constructor(name, age) {
this._name = name;
this._age = age;
@adamdoe
adamdoe / functions.php
Last active March 13, 2021 20:27
WordPress - Admin Functions #wordpress
<?php
/******************************************************************
* Admin Footer
******************************************************************/
function change_admin_footer(){
echo '<span id="footer-note">Theme made by <a href="http://www.yourcompany.com/" target="_blank">Your Company</a>.</span>';
}
add_filter('admin_footer_text', 'change_admin_footer');
@adamdoe
adamdoe / Last Updated Stamp
Last active April 30, 2020 05:29
WordPress - Check modified time after published time #wordpress
function add_last_updated()
{
$post_time = strtotime(get_post_time('m.d.Y'));
$mod_time = strtotime(get_post_modified_time('m.d.Y'));
$mod_date = get_the_modified_time('m.d.Y');
$date = get_the_date('m.d.Y');
$display_date = ($post_time < $mod_time ? $mod_date : $date);
if ($post_time != $mod_time)
{
@adamdoe
adamdoe / .gitignore
Last active April 30, 2020 05:24 — forked from eddt/wordpress gitignore
WordPress - .gitignore #wordpress
*.log
.htaccess
sitemap.xml
sitemap.xml.gz
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
@adamdoe
adamdoe / sql
Last active April 30, 2020 05:11
WordPress - SQL Statements for Migration #wordpress
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@adamdoe
adamdoe / data.sql
Created March 4, 2019 18:19
WordPress SQL for post, category, user data
SELECT
p.ID,
p.post_author,
p.post_date,
u.display_name,
p.post_title,
p.post_content,
t.name
FROM wp_posts as p
INNER JOIN wp_postmeta as pm ON (p.ID = pm.post_id)
@adamdoe
adamdoe / footer.php
Created July 26, 2018 13:04
For WordPress AJAX Urls