Skip to content

Instantly share code, notes, and snippets.

View enkr1's full-sized avatar
🎯
If you actually try your best, you can't lose.

ENKR | Jing Hui PANG | ε½­η«žθΎ‰ enkr1

🎯
If you actually try your best, you can't lose.
View GitHub Profile
@mahdiyazdani
mahdiyazdani / redirect-to-post-if-search-results-return-one-post.php
Created October 16, 2016 17:50
Redirect To Post If Search Results Return One Post
<?php
function my_redirect_single_post() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
exit;
}
}
@mahdiyazdani
mahdiyazdani / redirect-new-registered-user-to-specific-page.php
Created October 16, 2016 17:42
Redirect New Registered Users to a Specific Page
<?php
function my_registration_redirect(){
return home_url( '/finished/' );
}
add_filter( 'registration_redirect', 'my_registration_redirect' );
@mahdiyazdani
mahdiyazdani / add-confirm-password-field-into-woocommerce-registration-form.php
Created October 8, 2016 19:26
Add confirm password field into WooCommerce registration form
<?php
/**
* Add the code below to your theme's functions.php file
* to add a confirm password field on the register form under My Accounts.
*/
function woocommerce_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract( $_POST );
if ( strcmp( $password, $password2 ) !== 0 ) {
@btfak
btfak / useHexo.md
Created May 26, 2016 09:41
How to use Hexo and deploy to GitHub Pages
@garvs
garvs / wc-assign-other-role-instead-customer.php
Created May 5, 2016 01:15
Assign to new WooCommerce registered user another role instead of customer
/**
* Replace 'customer' role (WooCommerce use by default) with your own one.
**/
add_filter('woocommerce_new_customer_data', 'wc_assign_custom_role', 10, 1);
function wc_assign_custom_role($args) {
$args['role'] = 'subscriber';
return $args;
}
@RickieL
RickieL / launch-nmp.sh
Last active July 18, 2022 03:38 — forked from un1ko85/new_gist_file.sh
Starting and stopping NginX / MySQL / PHP-FPM on Mac OS X
#!/usr/local/bin/zsh
DirConf="/usr/local/etc"
PIDPATH="/usr/local/var/run"
PHPVersion="5.6"
MYSQL="/usr/local/bin/mysql.server"
NGINX="/usr/local/bin/nginx"
PHPFPM="/usr/local/sbin/php-fpm"
MEMCACHED="/usr/local/bin/memcached -m 24 -P $PIDPATH/memcached.pid -u root"
@hohl
hohl / .htaccess
Last active July 19, 2023 05:19
rewrite URLs to remove .html ending and always hide "index.html"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
@parmentf
parmentf / GitCommitEmoji.md
Last active October 24, 2025 22:54
Git Commit message Emoji

Inspired by dannyfritz/commit-message-emoji

See also gitmoji.

Commit type Emoji
Initial commit πŸŽ‰ :tada:
Version tag πŸ”– :bookmark:
New feature ✨ :sparkles:
Bugfix πŸ› :bug:
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@ericavonb
ericavonb / git-commit-style-guide.md
Last active October 21, 2025 15:26
Git Commit Style Guide

Git Commit Style Guide

Inspiration: Deis Commit Style Guide

I often quote Deis in sections below.

Motivation

It makes going back and reading commits easier. It also allows you to spend less time thinking about what your commit message should be.