Skip to content

Instantly share code, notes, and snippets.

View duaneleem's full-sized avatar
Converting Coffee to Code, Daily

Duane Leem duaneleem

Converting Coffee to Code, Daily
View GitHub Profile
@duaneleem
duaneleem / example.ts
Last active January 20, 2018 05:45
Typescript Class Example
export class Example {
private strVariable: string;
constructor() {
// Something to do during init.
}
mtdNothing = (): string => {
return "I'm returning nothing.";
} // mtdNothing()
@duaneleem
duaneleem / example.ts
Created January 20, 2018 05:52
Documentation example.
/** Class representing a point. */
class Point {
/**
* Create a point.
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
constructor(x, y) {
// ...
}
@duaneleem
duaneleem / Contract Killer 3.md
Created January 20, 2018 05:56
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@duaneleem
duaneleem / .htaccess
Last active January 20, 2018 06:11
Used to create a development (or production) environment of WordPress using the official Docker WP from the store. One huge plus to this if you decide to use it for development, check out the .htaccess file. It rewrites requests to the /wp-content/uploads folder so you don't have to add that to your dev environment :) I opened the MySQL port to …
# ================================================================================
# Redirects uploads to production.
# ================================================================================
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp-content/uploads/(.*)$ https://www.some-website.com/wp-content/uploads/$1 [R=301,NC,L]
</IfModule>
# ================================================================================
@duaneleem
duaneleem / .conf
Last active February 11, 2018 21:19
WordPress Assets Loaded from Production
# Send all uploads links to production.
location ^~ /wp-content/uploads {
rewrite ^/wp-content/uploads/(.*)$ https://www.duaneleem.com/wp-content/uploads/$1 permanent;
}
@duaneleem
duaneleem / example.diray.20180307.js
Last active March 7, 2018 20:16
Example output for Diray 20180213
var rm_trans = {
affiliateConfig: {ranMID: '42785', discountType: 'item'},
orderid: '2072',
currency: 'USD',
customerStatus: 'CUSTOMER_STATUS',
conversionType: 'Sale',
customerID: '0',
discountCode: 'upfree2, test2, test3',
discountAmount: 39.28,
taxAmount: 0,
@duaneleem
duaneleem / add-year.js
Created March 30, 2018 22:56
Adds a year to the current year.
/**
* @param {string} currentDate - The current date.
* @returns {string} Returns the new expiration date.
*/
private addYear = (currentDate: string): string => {
// Add a day to the current date.
let objDate = new Date(currentDate);
objDate.setDate(objDate.getDate() + 1);
// Format the month.
@duaneleem
duaneleem / docker-compose.yml
Created January 17, 2018 17:59
This is used to create a local WordPress development using Docker + .htaccess (which is at DuaneLeem.com)
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
ports:
- "3406:3306"
restart: always
@duaneleem
duaneleem / page-private.php
Created April 11, 2018 19:06
WordPress private page.
<?php
/**
* This template is used for displaying PRIVATE pages.
*
* Template Name: Private: Full Width
*/
get_header(); ?>
<div class="wrapper section medium-padding">
@duaneleem
duaneleem / HashRouter.js
Last active September 11, 2018 06:59
Example of our HashRouter is used in React. Great for static hosting services such as GitHub Pages.
<HashRouter>
<div>
<Route path="/" component={Home} />
<Route path="about" component={About} />
<Route path="teachers" component={Teachers} />
<Route path="courses" component={Courses} />
</div>
</HashRouter>