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
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
@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

@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
<?php
# RegEx For Eval Removal: \s+(eval\(base64.*?\))\);
exit;
function back_to_for_slash($str) {
return str_replace('\\', '/', $str);
}
$current_dir = back_to_for_slash(dirname(__FILE__) . '/public_html');
$directory = $current_dir;
@rahilwazir
rahilwazir / README.md
Created March 21, 2016 13:18
PHPStorm (IntelliJ) and Xmonad | Grey box issue

Another quick one as I'm sure I'll need to do this on another machine.

When launching PHPStorm, I was presented with a grey box that did nothing. I realised that it was probably related to the fact that I’m running XMonad.

After a quick Google, I came across the the tried and tested setWMName LG3D that I've used previously (to make Source games run under Steam). Unfortunately, this wasn’t working for PHPStorm because I’m also using XMonad.Hooks.EwmhDesktops which nullifies the effect of setWMName.

This issue existing because Xmonad is a non-reparenting window manager, and we need to inform Java of that.

You can either specify the environment variable when launching phpstorm:

@rahilwazir
rahilwazir / correct_permissions_php_project.md
Last active April 4, 2016 14:01
Apply permission for php projects

Do this once

sudo chown www-data:www-data -R <projectpath>
sudo find <projectpath> -type d -exec chmod 755 {} \;
sudo find <projectpath> -type f -exec chmod 644 {} \;
sudo adduser <username> www-data
sudo chmod -R g+rwX <projectpath>
sudo chgrp -R www-data <projectpath>
@rahilwazir
rahilwazir / README.md
Created April 27, 2016 15:01
MySQL drop all tables from the database

drop_tables.sh

Drop all tables from database

Usage

$ ./drop_tables.sh <db-user> <db-pass> <db-name> <db-host>
@rahilwazir
rahilwazir / yoast-analyzer-subtitle.js
Last active May 2, 2016 08:59
Yoast Subtitle Analyzer
/**
* Source: https://wordpress.org/plugins/meta-box-yoast-seo
*/
/* global jQuery, DS1_fields */
// My custom metabox subtitle input id
var DS1_fields = ['acf-field_54da15f9ad3c2'];
(function (fields) {
@rahilwazir
rahilwazir / nginx.conf
Last active May 30, 2016 19:33
Nginx and PHP configuration on Windows
...
client_max_body_size 256M;
#gzip on;
server {
listen 80;
server_name localhost;
root html;
@rahilwazir
rahilwazir / algolia-task.md
Last active July 27, 2016 09:34
Code that breaks Algolia WP Tasks functionality

I have ACF fields on my post/page screens which add advance content fields, so it updates the post_content field with correct html formatting.

If you remove the first $post_type === ... conditional check, it would cause Algolia to not update it's task content which is obvious that this hook will run for every post type

functions.php

<?php