Skip to content

Instantly share code, notes, and snippets.

@hadibadjian
hadibadjian / bash-short-pwd.sh
Last active October 27, 2019 06:25
bash-short-pwd.sh - Fish shell inspired shortened PWD for shell prompt.
#!/bin/bash
# Modified from http://stackoverflow.com/a/1617048/359287
# By Hadi Badjian @hadibadjian
#
# Usage:
# source ~/bash-short-pwd.sh
# export PS1='$(__short_pwd)$ '
#
# Example:
# ~/p/y/b/docs$
@hadibadjian
hadibadjian / .profile
Created March 1, 2015 03:14
.profile - bash configurations
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
source ~/git-prompt.sh
# https://gist.github.com/hadibadjian
source ~/bash-short-pwd.sh
export PS1='$(__short_pwd)\[\033[32m\]$(__git_ps1 " (%s)")\[\033[00m\]$ '
LS_COLORS=$LS_COLORS:'di=0;35:fi=0;37:ln=0;37:pi=0;37:so=5:bd=5:cd=5:or=31:mi=0:ex=33:*.rpm=90'
export LS_COLORS
@hadibadjian
hadibadjian / rails-rspec-plugin.md
Last active August 29, 2015 14:22
Create Rails plugin to consume RSpec.

requires: bundler

  • Genarate a new plugin and change the default dummy app location to spec/dummy
rails plugin new foobar --dummy-path=spec/dummy
  • Add development and test gems to Gemfile.
# sample Gemfile
@hadibadjian
hadibadjian / http_status_code_sym.md
Last active August 29, 2015 14:26
Rails HTTP Status Code to Symbol Map

1xx Informational

Status Code Status Message Symbol
100 Continue :continue
101 Switching Protocols :switching_protocols
102 Processing :processing

2xx Success

Status Code Status Message Symbol
@hadibadjian
hadibadjian / .clang-format
Created September 6, 2015 08:08
Clang-format Configuration File
---
Language: Cpp
AccessModifierOffset: 0
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
@hadibadjian
hadibadjian / README.md
Last active January 4, 2016 04:49
Managing Multiple SSH Keys

Preparation

  • Create different SSH Keys for each account. A simple SSH key can be generated using ssh-keygen -t rsa -C 'email@example.com'
  • Create a blank config file and include host details as in provided example file. Add an indentifier to differentiate hosts for similar host names.

Tree structure of ~/.ssh folder

/Users/hadi/.ssh/
├── config
├── id_rsa_example_enterprise
├── id_rsa_example_enterprise.pub
@hadibadjian
hadibadjian / README.md
Created April 9, 2016 09:22
Setting up API stubs using mockbin on MacOS

Installation

brew install redis

brew install npm

npm install mockbin

Configuration

@hadibadjian
hadibadjian / README.md
Created April 23, 2016 01:58
Change Xcode File Templates

Navigate to /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates and modify ___FILEBASENAME___.x accordingly.

@hadibadjian
hadibadjian / xcode-build-settings.md
Created June 27, 2016 01:27
Xcode Build Settings

Use the following command to generate Xcode build settings and configurations for a given target:

xcodebuild -project example.xcodeproj -target "Example" -showBuildSettings
@hadibadjian
hadibadjian / pre-request-script.js
Last active September 16, 2020 08:59
Postman HMAC Authorization
// inspired by https://gist.github.com/DinoChiesa/75796b27828cf8e15c91
function calculateHMAC(config, messageDictionary) {
var template = 'AppAuth method=${algorithm} applicationId=${applicationId} signature=${signature}';
var hashf = (function() {
switch (config.algorithm) {
case 'HMAC-SHA1': return CryptoJS.HmacSHA1;
case 'HMAC-SHA256': return CryptoJS.HmacSHA256;
case 'HMAC-SHA512': return CryptoJS.HmacSHA512;
default : return null;