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 / sync_files.md
Last active August 4, 2016 16:05
rsync to sync files

Sync files/folders between two host

rsync -azP -e 'ssh -i /path/to/id_rsa_private_key' /files/source destination_host_user@111.111.111.111:/destination/path

Be sure to add ssh-add /path/to/id_rsa_private_key

Options:

  • -a It stands for "archive" and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
@rahilwazir
rahilwazir / .gitignore
Created October 10, 2016 18:58
WordPress .gitignore
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
.idea/
# wordpress specific
@rahilwazir
rahilwazir / calc.md
Last active October 28, 2016 09:41
Simple bash calculator
calc () {
    bc -l <<< "$@"
}

Example usage:

$ calc 65320/670
97.49253731343283582089

$ calc 65320*670

@rahilwazir
rahilwazir / cc.md
Created October 28, 2016 09:43
Bash Currency Converter

Code:

currency_convert() {
  curl -s "http://www.google.com/finance/converter?a=$1&from=$2&to=$3" | sed '/res/!d;s/<[^>]*>//g';
}

Usage:

@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 / core_fonts_fedora.md
Last active November 17, 2016 06:07
Core fonts in Fedora 24+
@rahilwazir
rahilwazir / keychain_ssh_passphrase.md
Created November 18, 2016 05:57
Keychain with SSH passphrase
@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 / connect_wifi_cli.md
Last active November 21, 2016 14:44
Connect to WiFi through CLI

List all wifi devices

$ nmcli c

Find your WiFi uuid and connect

$ nmcli c up uuid 
@rahilwazir
rahilwazir / refresh_wifi_network.md
Created November 21, 2016 14:49
Refresh WiFi network connection through CLI

Find your WiFi interface

$ ifconfig

In my case it's wlo1 and run

[root@localhost]# iwlist wlan0 scan