Skip to content

Instantly share code, notes, and snippets.

View rahilwazir's full-sized avatar
🎯
Focusing (kinda)

Rahil Wazir rahilwazir

🎯
Focusing (kinda)
View GitHub Profile
@rahilwazir
rahilwazir / Email Server (Linux, Unix, Mac).md
Created December 9, 2020 18:26 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@rahilwazir
rahilwazir / wp-admin-add-posts-state.php
Created April 10, 2019 14:04 — forked from martijn94/wp-admin-add-posts-state.php
Snippet to add post state to a WordPress page
<?php
//======================================================================
// Add post state to the projects page
//======================================================================
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 );
function ecs_add_post_state( $post_states, $post ) {
@rahilwazir
rahilwazir / mkgit-centos6.sh
Last active March 15, 2017 13:33 — forked from eyecatchup/mkgit-centos6.sh
Bash script to install the latest Git version on CentOS 6.x.
#!/usr/bin/env bash
# Install the latest version of git on CentOS 6.x
# Install Required Packages
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
sudo yum install gcc perl-ExtUtils-MakeMaker
# Uninstall old Git RPM
sudo yum remove git
@rahilwazir
rahilwazir / post-merge
Created November 18, 2016 08:31 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@rahilwazir
rahilwazir / edd-sort-archive-by-sales.php
Created November 8, 2016 09:58 — forked from mindctrl/edd-sort-archive-by-sales.php
Sort the downloads archive in Easy Digital Downloads by number of sales
<?php
/*
Plugin Name: Easy Digital Downloads - Sort archive by number of sales
*/
function jp_sort_downloads_archive( $query ) {
if ( is_post_type_archive( 'download' ) && $query->is_main_query() ) {
$query->set( 'meta_key', '_edd_download_sales' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
}
@rahilwazir
rahilwazir / gist:73e3827e777bfa5b58db
Last active September 15, 2015 13:18 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@rahilwazir
rahilwazir / authentication_with_bcrypt_in_rails_4.md
Last active August 29, 2015 14:27 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
npm run configuration
  • JavaScript file: /usr/local/lib/node_modules/npm/bin/npm-cli.js
  • Application parameters: run start
grunt run/debug configuration
  • JavaScript file: /usr/local/lib/node_modules/grunt-cli/bin/grunt
Issue Tracker