Skip to content

Instantly share code, notes, and snippets.

View mirfan's full-sized avatar
💭
I may be slow to respond.

Mohammed Irfan mirfan

💭
I may be slow to respond.
View GitHub Profile
@mirfan
mirfan / season_from_date.php
Created February 20, 2024 11:33
Get season name from date. A modernized version of https://stackoverflow.com/a/7928049
function getSeason(string $date): string {
$seasons = ['Winter', 'Spring', 'Summer', 'Fall'];
$timestamp = strtotime($date);
$date_year = date('Y', $timestamp);
return match (true) {
$timestamp < strtotime($date_year . '-03-21') || $timestamp >= strtotime($date_year . '-12-21') => $seasons[0],
$timestamp >= strtotime($date_year . '-09-23') => $seasons[3],
$timestamp >= strtotime($date_year . '-06-21') => $seasons[2],
@ariporad
ariporad / README.md
Last active December 7, 2017 17:53
git-refork

git-refork

I really wanted a way to re-sync a fork with upstream, so this is it. Just put it in your path, and make sure that you have a remote called upstream that points to the original project.

WARNING: For forks only. If you use it on a non-fork project, bad things will happen. This will re-write history, so be careful.

@mlakkadshaw
mlakkadshaw / setup.sh
Last active December 25, 2015 12:28
Setup automatic deployment on your server using this shell script. After this shell script is executed you can deploy code using "git push server master"
#!/bin/bash
# A bash script to setup GIT like deployment on your server
echo "Enter your server address e.g 25.32.132.1 or yourserver.com"
read serverAddress
echo "Enter Username which you use to login to your server e.g ubuntu"
read username
echo "Enter path of the private key (optional)"
read privateKeyPath
echo "Path of your server directory where code should reside: e.g ~/code or /var/www (required)"
read tempPath
@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active September 25, 2025 14:56
An Open Letter to Developers Everywhere (About Cryptography)
@davidsklar
davidsklar / fix-broken-utf-8.php
Created August 25, 2015 17:23
Fixing Broken UTF-8
<?php
function fixBrokenUTF8($contents) {
static $replacement = chr(0xEF) . chr(0xBF) . chr(0xBD);
$expectingNewChar = true;
$expectedLength = 0;
$expectedIndex = 0;
$i = 0;
$out = "";
@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active August 26, 2024 23:46
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@jaceklaskowski
jaceklaskowski / deployment-tool-ansible-puppet-chef-salt.md
Last active July 11, 2025 05:01
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea
@paulirish
paulirish / bling.js
Last active September 13, 2025 12:13
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@ericelliott
ericelliott / essential-javascript-links.md
Last active June 14, 2025 18:43
Essential JavaScript Links