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 / 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.
@zeeforum
zeeforum / calendar.php
Created April 2, 2018 22:44
Create Calendar Between Two Dates in PHP (Including Start Date and Excluding End Date)
<?php
function createDatesTable($period, $start) {
$calendarStr = '';
foreach ($period as $key => $date_row) {
if ($start%7 == 0) {
$calendarStr .= '</tr><tr>';
}
$calendarStr .= '<td class="date">' . $date_row->format('d') . '</td>';
$start++;

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 / 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
@zeeforum
zeeforum / email-sender.py
Created August 30, 2022 23:02
Send Email Using Python
from email.message import EmailMessage
# Read Password from another file uncomment this line if you want to read password from another file
#from config import email_password
import ssl
import smtplib
# Sender Email
email_sender = "abc@test.com"
# Email Password for Authentication