Skip to content

Instantly share code, notes, and snippets.

View piyushchauhan2011's full-sized avatar
🏠
Working from home

Piyush Chauhan piyushchauhan2011

🏠
Working from home
View GitHub Profile
@piyushchauhan2011
piyushchauhan2011 / bump_version
Created November 14, 2021 11:17 — forked from ericclemmons/bump_version
Bash script to merge, tag, & push the "develop" branch
#!/usr/bin/env bash
echo "Checking out master branch"
git checkout master
git pull origin master
git log master..develop
read -p "Review your changes..."
echo "Merging develop branch"
@piyushchauhan2011
piyushchauhan2011 / release.sh
Created November 14, 2021 11:16 — forked from adamreisnz/release.sh
A script to automate merging of release branches
#!/usr/bin/env bash
# Assuming you have a master and dev branch, and that you make new
# release branches named as the version they correspond to, e.g. 1.0.3
# Usage: ./release.sh 1.0.3
# Get version argument and verify
version=$1
if [ -z "$version" ]; then
echo "Please specify a version"
@piyushchauhan2011
piyushchauhan2011 / merge
Created November 14, 2021 11:16 — forked from tmiller/merge
Bash script to merge master into all branches
#!/bin/bash
# Merges the master branch into all other branches
#
# Process:
#
# - Save the name of the current branch
# - If the current branch is not master then checkout master.
# - Pull the latest changes for master from its upstream branch.
# - Loop over each local branch.
@piyushchauhan2011
piyushchauhan2011 / helper.ts
Last active April 18, 2021 11:24
Run in Transaction test helper - TypeORM
export function createRunInTransactionHelper<T extends BaseEntity>(
entity: EntityTarget<T>,
initFn: (tManager: EntityManager, repo: Repository<T>) => Promise<void>,
) {
return (fn: (repo: Repository<T>) => Promise<void>) => {
return getConnection().manager.transaction(async (tManager) => {
const repo = tManager.getRepository<T>(entity);
await initFn(tManager, repo);
await fn(repo);
@piyushchauhan2011
piyushchauhan2011 / http-errors.js
Created April 4, 2021 23:48 — forked from joyrexus/http-errors.js
HTTP Error classes in Node.js
'use strict';
const statusCodes = require('http').STATUS_CODES;
function createError(code, name) {
return function(message) {
Error.captureStackTrace(this, this.constructor);
this.name = name;
this.message = message;
this.statusCode = code;
}

What Hiring Should Look Like

This is definitely not the first time I've written about this topic, but I haven't written formally about it in quite awhile. So I want to revisit why I think technical-position interviewing is so poorly designed, and lay out what I think would be a better process.

I'm just one guy, with a bunch of strong opinions and a bunch of flaws. So take these suggestions with a grain of salt. I'm sure there's a lot of talented, passionate folks with other thoughts, and some are probably a lot more interesting and useful than my own.

But at the same time, I hope you'll set aside the assumptions and status quo of how interviewing is always done. Just because you were hired a certain way, and even if you liked it, doesn't mean that it's a good interview process to repeat.

If you're happy with the way technical interviewing currently works at your company, fine. Just stop, don't read any further. I'm not going to spend any effort trying to convince you otherwise.

@piyushchauhan2011
piyushchauhan2011 / app.js
Created September 26, 2020 10:15 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@piyushchauhan2011
piyushchauhan2011 / mod.ts
Created July 28, 2020 04:30
Deno Server example with routes
import {
serve,
ServerRequest,
} from "https://deno.land/std@0.61.0/http/server.ts";
import { Status } from "https://deno.land/std@0.61.0/http/http_status.ts";
class User {
constructor(public name: string, public age: number) {}
}
@piyushchauhan2011
piyushchauhan2011 / mod.ts
Created July 26, 2020 12:47
Heredoc with Deno.run cmd
let p = Deno.run({
cmd: [
"sh",
"-c",
`
echo hello
echo hello2
cat << EOF
pwd: $PWD
@piyushchauhan2011
piyushchauhan2011 / README.md
Created July 20, 2020 01:49 — forked from bvis/README.md
Docker Env Vars expanded with secrets content

Variables by Secrets

Sample script that allows you to define as environment variables the name of the docker secret that contains the secret value. It will be in charge of analyze all the environment variables searching for the placeholder to substitute the variable value by the secret.

Usage

You can define the next environment variables: