Skip to content

Instantly share code, notes, and snippets.

View Temmyhlee's full-sized avatar

Temmyhlee Temmyhlee

View GitHub Profile
@Temmyhlee
Temmyhlee / gist:e71b132f33276c18723c696d0bb26c00
Created May 28, 2018 07:18 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@Temmyhlee
Temmyhlee / functions.php
Created December 18, 2017 05:47
Security for WordPress, headers, Strict-Transport-Security
/*
* This file is just for WordPress security and thats about it
* Copy in functions.php
* Uses send_headers as opposed to wp_header so as to ensure it works even when the webiste is cached
*/
add_action('send_headers', function(){
// Enforce the use of HTTPS
header("Strict-Transport-Security: max-age=31536000; includeSubDomains");
// Prevent Clickjacking
@Temmyhlee
Temmyhlee / .htaccess
Created December 18, 2017 05:33
Redirects www, non-www, https://www to https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST}#%{HTTPS}s ^www\.([^#]+)#(?:off|on(s)) [NC]
RewriteRule ^ http%2://%1%{REQUEST_URI} [R=301,L]
</IfModule>
@Temmyhlee
Temmyhlee / index.html
Created November 21, 2016 01:15
Colour Guessing Game
<!DOCTYPE html>
<html>
<head>
<title>Colour Guessing game</title>
</head>
<body onload="do_game()">
<script type="text/javascript">
var colors = [];
var target;
var guess_input;
@Temmyhlee
Temmyhlee / script.py
Created November 11, 2016 11:08
Class Average in Python
# 1. Define a function called get_class_average that has one argument students. You can expect students to be a list containing your three students.
# 2. First, make an empty list called results.
# 3. For each student item in the class list, calculate get_average(student) and then call results.append() with that result.
# 4. Finally, return the result of calling average() with results.
lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
@Temmyhlee
Temmyhlee / contributor-upload.php
Last active September 22, 2016 22:28
Add media upload capability to contributor on WordPress
<?php
//Do not add the line above
if ( current_user_can('contributor') && !current_user_can('upload_files') )
//checks if the current user is a contributor
add_action('admin_init', 'allow_contributor_uploads');
function tayo_allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
@Temmyhlee
Temmyhlee / functions.php
Created August 30, 2016 19:28
Change post meta Filed under to Category
// Customize the post meta function
add_filter( 'genesis_post_meta', 'post_meta_filter' );
function post_meta_filter( $post_meta ) {
if ( is_single() ) {
// change the category and tags to anything you like
$post_meta = '[post_tags sep=", " before="' . __( 'Tags:', 'temmyhlee' ) . ' "] [post_categories sep=", " before="' . __( 'Category:', 'temmyhlee' ) . ' "]';
return $post_meta;
}
}
@Temmyhlee
Temmyhlee / credit.php
Created August 27, 2016 10:20
Change credit text in Genesis footer.
//Add Copyright text
add_filter ( 'genesis_footer_creds_text', 'temmyhlee_custom_footer_credits', 10, 7);
function temmyhlee_custom_footer_credits ($creds ) {
;
$creds = '<p>[footer_copyright]. Made with <i class="ion-heart"></i> by <a href="http://temmyhlee.com/" target="_top">Temmyhlee</a> &middot; Supported by <a href="http://moorgist.com" target="_blank">Moorgist.com</a></p> <p class = "affiliate"> Do note that I drop affiliate links all over this site as it helps me get bucked up. (Take no offence).</p>';
return $creds;
}
//* Add new widget Between Posts Area
genesis_register_sidebar( array(
'id' => 'between-posts-area',
'name' => __( 'Between Posts Area', 'basicwp-theme' ),
'description' => __( 'This widget show between and after few posts.', 'basicwp-theme' ),
) );
//* Add widget area between and after 3 posts
add_action( 'genesis_after_entry', 'basicwptheme_between_posts_area' );
@Temmyhlee
Temmyhlee / functions.php
Created August 2, 2016 18:44 — forked from About2git/functions.php
Random ad after every second post in Genesis.
<?php
//* Do NOT include the opening php tag
add_action( 'genesis_after_entry', 'google_ad' );
/**
* Insert one random ad after every second post.
*
* Scope: Posts page and all category archives.
*
* @author Sridhar Katakam