Skip to content

Instantly share code, notes, and snippets.

View macariojames's full-sized avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / upload2facebook
Created October 11, 2016 21:25 — forked from nseo/upload2facebook
A sample code to upload an image file to facebook using Facebook javascript sdk
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Hello FB</title>
</head>
<body>
<div id="fb-root"></div>
<div id="fb-content"></div>
<div>
@macariojames
macariojames / remove-video.js
Created November 2, 2016 18:26 — forked from danro/remove-video.js
Remove HTML5 video and clear src attribute to prevent leaks.
// remove audio + video + stop all the downloadin’
// assumes $video and $audio are jQuery selectors for <video> and <audio> tags.
var removeMedia = function () {
_.each([$video, $audio], function ($media) {
if (!$media.length) return;
$media[0].pause();
$media[0].src = '';
$media.children('source').prop('src', '');
$media.remove().length = 0;
});
@macariojames
macariojames / strong-passwords.php
Created April 27, 2017 21:46 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@macariojames
macariojames / wordpress-firebase.php
Created March 14, 2018 12:45 — forked from derekconjar/wordpress-firebase.php
An example of using Firebase and WordPress together. The idea is to use WP's custom post types and metaboxes to make content management easy, and sync with Firebase so that your websites have access to a real-time JSON feed of your custom data.
<?php
/**
* All custom functions should be defined in this class
* and tied to WP hooks/filters w/in the constructor method
*/
class Custom_Functions {
// Custom metaboxes and fields configuration
@macariojames
macariojames / .htaccess
Created April 1, 2018 14:07 — forked from ryansechrest/.htaccess
Sample configuration files for WordPress as Git submodule.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Prevent requests to index.php from being rewritten
RewriteRule ^index\.php$ - [L]
# Prefix specified PHP files with 'wordpress'
RewriteRule ^((wp-login|xmlrpc)\.php) wordpress/$1 [R=301,L]
@macariojames
macariojames / hide-wp-upcoming-events.php
Created April 19, 2018 20:06
Hide Upcoming Events from the WordPress Events and News Dashboard Widget
// Hide Upcoming Events from Dashboard Widget
// Basically just CSS; a display: none and then some personal choice
// formatting for the news items ~mj
function hide_wp_upcoming_events() {
?>
<style>
#community-events {
display: none;
}
@macariojames
macariojames / anchorScrollTop.js
Created August 1, 2018 19:04
Anchor link with fixed header scroll with padding
// For FAQ page nav scrolling
function anchorScrollTo() {
$('.anchor li a').on('click', function(e){
e.preventDefault();
var scrollTo = $($(this).attr('href'));
var headerHeight = $('.page_header').height();
console.log(scrollTo, headerHeight);
$('html,body').animate({
scrollTop: scrollTo.offset().top - headerHeight},
'slow');
@macariojames
macariojames / test-sendmail.php
Created August 10, 2018 19:07
Testing php sendmail is working correctly
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "emailtest@currentdomain.com";
$to = "myemail@currentdomain.com";
$subject = "PHP Mail Test script via currentdomain";
$message = "This is a test to check the PHP sendmail functionality.";
$headers = "From:" . $from;
if(mail($to,$subject,$message, $headers))
echo "Test email sent from currentdomain.";
@macariojames
macariojames / hide-php-file-extension
Created August 14, 2018 20:17
Nginx hide .php file extension but make sure the home page -- index.php -- page works
# This is in the server {} section of the /sites-available domain
location / {
#notice the $uri space $uri/ space before the @ function for the re-writes
try_files $uri $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
@macariojames
macariojames / gzip-compression-nginx.conf
Created August 16, 2018 19:09
gzip compression with nginx
via Jack Wallen @jlwallen
-- This goes in /etc/ngnix/ngnix.conf
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";