Skip to content

Instantly share code, notes, and snippets.

View zeeforum's full-sized avatar
🎯
Focusing

Zartash Zulfiqar zeeforum

🎯
Focusing
  • DatumSquare IT Services
  • Lahore, Punjab Pakistan
  • X @zeeforum
View GitHub Profile
@zeeforum
zeeforum / post-receive.sh
Created August 2, 2021 08:42 — forked from benfrain/post-receive.sh
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@zeeforum
zeeforum / crawler_detect.php
Created December 4, 2017 16:05 — forked from geerlingguy/crawler_detect.php
Detect crawlers/bots/spiders in PHP (simple and fast)
<?php
/**
* Check if the given user agent string is one of a crawler, spider, or bot.
*
* @param string $user_agent
* A user agent string (e.g. Googlebot/2.1 (+http://www.google.com/bot.html))
*
* @return bool
* TRUE if the user agent is a bot, FALSE if not.