Skip to content

Instantly share code, notes, and snippets.

View hassansin's full-sized avatar
👋
Working from home

Hassansin hassansin

👋
Working from home
View GitHub Profile
@hassansin
hassansin / prepare-commit-msg.sh
Last active March 2, 2023 01:06
Clubhouse - Git Hooks
#!/bin/sh
# If commit message does not refer to any CH story number,
# this hook will parse the CH story from the current branch and
# append it to the commit message
#
# Example:
# Branch: hassansin/ch1643/custom-subdomains
# commit message: add support for EU base urls
# appended commit message: Add support for EU base urls [ch1643]
@hassansin
hassansin / request-response.go
Last active April 13, 2023 10:44
Request-response pattern over asynchronous protocol using Go channel
package main
import (
"errors"
"fmt"
"math/rand"
"net/http"
"sync"
"time"
@hassansin
hassansin / send-to-kindle.js
Created September 22, 2017 09:52
Webtask to send any Webpage to Kindle as PDF
'use latest';
import nodemailer from 'nodemailer@2.5.0';
import request from 'request@2.81.0';
module.exports = function(context, cb) {
const url = context.query.url;
const kindleAddress = context.query.address || context.secrets.KINDLE_ADDRESS;
if (!url) {
return cb(null, "missing url parameter");
@hassansin
hassansin / README.md
Last active February 14, 2024 17:09
Remote Debugging with XDebug 2.1

XDebug

A PHP extension that allows you to:

  1. walk through your code by Remote Debugging
  2. find bottlenecks in your application by Profiling
  3. find Code Coverage in a single request
  4. trace your application by logging all function calls
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.3/benchmark.min.js"></script>
</head>
<body>
@hassansin
hassansin / send.js
Created September 26, 2016 00:49
Send Joke with AWS SNS
#!/usr/bin/env node
/**
* Send a Joke to your mobile using AWS SNS service
* Usage:
* ./send.js phoneNumber [firstName] [lastName]
*
*/
const http = require('http');
@hassansin
hassansin / .bashrc
Last active August 18, 2019 08:09
dotfiles
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@hassansin
hassansin / README.md
Last active September 16, 2023 13:32
Working with MongoDB TTL (Time-To-Live) Index
@hassansin
hassansin / commands.js
Last active September 3, 2020 16:35
MongoDB commands
db.collection.createIndex( { orderDate: 1, zipcode: -1 }, {background: true} )
db.events.ensureIndex( { "timestampISO": 1 }, { expireAfterSeconds: 120*24*60*60 } ) // <3.0, TTL index, 120day retention period
db.collection.getIndexes() //get all indexes
db.collection.dropIndex("name"); //drop single index
db.collection.dropIndexes(); //drop all indexes
db.collection.find({ email: 'test@sendgrid.com' }).explain("executionStats") // <3.0 : https://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
//https://docs.mongodb.org/manual/tutorial/measure-index-use/
db.collection.explain("executionStats").find({ email: 'test@sendgrid.com' }) // 3.0 +
db.events.totalIndexSize() // in bytes, should not exceed RAM
@hassansin
hassansin / .block
Last active March 9, 2016 23:32
D3 Chronograph Stopwatch
license: gpl-3.0
height: 300
border: no