Skip to content

Instantly share code, notes, and snippets.

View ahgood's full-sized avatar

Guojun ahgood

  • Fullstack Developer
  • Halifax
View GitHub Profile
@mtx-z
mtx-z / wp-bootstrap4.4-pagination.php
Last active January 16, 2025 16:15
Wordpress 5.4 Bootstrap 4.4 pagination (with custom WP_Query() and global $wp_query support) (UPDATED for Bootstrap 5: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* UPDATE for Bootstrap 5.0: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507
*
@stevekinney
stevekinney / web-performance.md
Last active January 2, 2025 14:53
Web Performance Workshop

Web Performance

Requirements

Repositories

@Acesmndr
Acesmndr / async.js
Created January 6, 2018 08:39
AJAX with callbacks and promises
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; // importing xmlhttprequest package because node doesn't support it out of the box
const superHeroes = ['Batman', 'Superman', 'WonderWoman', 'Flash', 'Cyborg', 'Aquaman', 'Green Lantern', 'Martian Manhunter']; // an array of request params
const completedFetchingData = () => { // function to be called when all ajax requests complete.
console.log('Just completed fetching the data');
}
const failedFetchingData = () => { // function to be called when data fetching fails
console.log('Failed to fetch the data');
}
const ajaxRequestWithPromise = (param) => {
@ubergesundheit
ubergesundheit / index.md
Created November 6, 2017 13:19
ngrok on raspberrypi on systemd
  • Download ngrok binary
  • Create /etc/systemd/system/ngrok.service
  • Create /opt/ngrok/ngrok.yml
@SamanSh999
SamanSh999 / changebg.sh
Created January 18, 2017 10:40 — forked from Reza-Rg/changebg.sh
A shell script to set Bing Background as wallpaper automatically on both OSX and Linux (requires wget & jq)
#!/usr/bin/env bash
if [ "$(uname)" = "Darwin" ]; then
jq=/usr/local/bin/jq
wget=/usr/local/bin/wget
image_folder_path="/Users/$USER/Documents/Images/Bing/"
mkdir -p $image_folder_path
@seventhqueen
seventhqueen / enable-chinese-characters-usernames.php
Created December 8, 2016 11:07
Enable Chinese usernames in Wordpress registration
function sanitize_chinese_user( $username, $raw_username, $strict ) {
if ( $username != $raw_username ) {
$username = $raw_username;
}
$username = strip_tags( $username );
// Kill Chinese characters
$username = preg_replace( '|[^a-z0-9 _.\-@一-龥]|ui', '', $username );
// Consolidate contiguous whitespace
@kstover
kstover / nf-after-load.js
Created November 10, 2016 18:47
Ninja Forms Three - After a form has loaded
// Create a new object for custom validation of a custom field.
var nameSpaceController = Marionette.Object.extend( {
initialize: function() {
this.listenTo( nfRadio.channel( 'form' ), 'render:view', this.doCustomStuff );
},
doCustomStuff: function( view ) {
var formModel = view.model; // formModel will be a Backbone model with all of our form data.
var formID = formModel.get( 'id' ); // We can use .get( 'setting' ) get get any of our form settings.
@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active March 7, 2025 05:00
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@lukecav
lukecav / remove-logout-link-wp-comment-form.php
Created October 7, 2016 21:28 — forked from renventura/remove-logout-link-wp-comment-form.php
Remove the "Logged in as {username}. Log Out?" link from the WordPress comment form.