Skip to content

Instantly share code, notes, and snippets.

@sang-d
sang-d / spiral.py
Created November 7, 2022 09:32
spiral print
"""
Print a matrix m x n following sprial-in clockwise direction from top left
Example:
matrix:
1 2 3 4 5 6 7 8
9 0 1 2 3 4 5 6
7 8 9 0 1 2 3 4
5 6 7 8 9 0 1 2
sprial print:
1 2 3 4 5 6 7 8 6 4 2 1 0 9 8 7 6 5 7 9 0 1 2 3 4 5 3 2 1 0 9 8
@sang-d
sang-d / buildWhenAffected.sh
Created July 15, 2020 09:54 — forked from naesheim/buildWhenAffected.sh
CircleCi - only build features that has changed
##################
### config.yml ###
##################
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
@sang-d
sang-d / git-dmz-flow.md
Created September 23, 2019 12:33 — forked from djspiewak/git-dmz-flow.md
Git DMZ Flow

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

Keybase proof

I hereby claim:

  • I am sang-d on github.
  • I am sangdinh (https://keybase.io/sangdinh) on keybase.
  • I have a public key ASAnuW9Qqr-VkvlKrt-U3Sm3vmeGAFetl9DbHnRDyWjw9Qo

To claim this, I am signing this object:

@sang-d
sang-d / Activate Office 2019 for macOS VoL.md
Created September 7, 2019 12:35 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref

@sang-d
sang-d / Jenkinsfile
Created July 21, 2019 16:47 — forked from bvis/Jenkinsfile
Jenkin pipeline definition example to be integrated with Docker Swarm cluster in our CI/CD environment
pipeline {
agent { node { label 'swarm-ci' } }
environment {
TEST_PREFIX = "test-IMAGE"
TEST_IMAGE = "${env.TEST_PREFIX}:${env.BUILD_NUMBER}"
TEST_CONTAINER = "${env.TEST_PREFIX}-${env.BUILD_NUMBER}"
REGISTRY_ADDRESS = "my.registry.address.com"
SLACK_CHANNEL = "#deployment-notifications"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.7.2/redux.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.js"></script>
Q = int(input().strip(' '))
# print(Q)
class Node():
def __init__(self, val=None, next=None):
self.val = val
self.next = next
class Stack():
def __init__(self, head=None):
@sang-d
sang-d / README.md
Created July 5, 2017 03:36 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@sang-d
sang-d / check_jwt_sig.py
Created June 5, 2017 10:11 — forked from rondomondo/check_jwt_sig.py
Two methods/examples of how to decode and verify the signature of AWS cognito JWT web tokens externally. This uses RSA key pair and alternatively PKCS1_v1_5. See https://gist.github.com/rondomondo/efff911f2c41c295e23415e94e12b8d3 for example of signing and verification by downloading an ISSUERS PKI SSL certificate from the signers website, and h…
#!/usr/bin/env python
import os
import time
import json
import base64
import requests
import argparse
from base64 import urlsafe_b64decode, b64decode
from Crypto.Hash import SHA256, SHA512