Skip to content

Instantly share code, notes, and snippets.

View younisshah's full-sized avatar
💤
I may be slow to respond.

Younis Shah younisshah

💤
I may be slow to respond.
  • Temasek
  • Singapore
View GitHub Profile
@younisshah
younisshah / base64_to_file.go
Last active March 18, 2022 05:34
Save a Base64 Image to disk (PNG and JPEG formats only)
package galileo_gists
import (
"strings"
"time"
"math/rand"
"os"
"encoding/base64"
"image"
"image/png"
@younisshah
younisshah / private-github-release-download.sh
Created July 17, 2017 10:08 — forked from illepic/private-github-release-download.sh
Download the latest release binary from a private GitHub repo. (i.e. a .tar.gz that you have manually uploaded in a GitHub release). Update OAUTH_TOKEN, OWNER, REPO, FILE_NAME with your custom values.
#!/usr/bin/env bash
# Authorize to GitHub to get the latest release tar.gz
# Requires: oauth token, https://help.github.com/articles/creating-an-access-token-for-command-line-use/
# Requires: jq package to parse json
# Your oauth token goes here, see link above
OAUTH_TOKEN="34k234lk234lk2j3lk4j2l3k4j2kj3lk"
# Repo owner (user id)
OWNER="your-user-name"
@younisshah
younisshah / install_nanomsg.sh
Created August 30, 2017 05:53
Installing nanomsg on Ubuntu 16.04 (Xenial Xerus)
#!/bin/sh
wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz -O nanomsg-1.0.0.tar.gz
tar -xzvf nanomsg-1.0.0.tar.gz
cd nanomsg-1.0.0
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build .
ctest -G Debug .
@younisshah
younisshah / bitmask.go
Created December 25, 2019 09:40
Intuitive explanation of bitmasks
package bits
import "fmt"
/*
* Check this (https://alemil.com/bitmask) for full article
*/
const (
CanRun = 1 << 0 // 1
CanBark = 1 << 1 // 2
@younisshah
younisshah / pg_diff_in_mins.md
Last active March 18, 2022 05:35
[PostgreSQL] Difference between two timestamps in minutes

In PostgreSQL, difference between two timestamps in minutes can be calculated by providing the EPOCH as a sub-field to the EXTRACT function, and the result from the EXTRACT will be divided by 60 to get the minutes.

Example

SELECT EXTRACT(EPOCH FROM ((NOW() + interval '1 day')::TIMESTAMPZ - NOW())) / 60 AS minutes
SELECT EXTRACT(EPOCH FROM (end_date - start_date)) / 60 AS minutes
@younisshah
younisshah / jenkins.md
Last active February 16, 2024 04:33
Running Docker in Jenkins (in Docker)
  1. Create a Dockerfile
FROM jenkins/jenkins:lts
 
USER root
RUN apt-get update \
      && apt-get install -y sudo \
      && rm -rf /var/lib/apt/lists/*
RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers