Skip to content

Instantly share code, notes, and snippets.

View championswimmer's full-sized avatar

Arnav Gupta championswimmer

View GitHub Profile
@championswimmer
championswimmer / C++ Templates vs Java Generics.md
Created July 28, 2018 01:20
C++ Templates vs Java Generics

Templates in C++ vs Generics in Java

Templates and generics allow us to achieve very similar results using very similar code syntax in C++ and Java respectively. But despite that, the implementation of these two features and their semantics are vastly different under the hood.

Syntax and Usage

Templates

Let us consider first the case of a template called Pair in C++.

@championswimmer
championswimmer / Writing Vuex modules in neat Typescript classes.md
Created July 14, 2018 00:04
Writing Vuex modules in neat Typescript classes

Writing Vuex modules in neat Typescript classes

Typescript/ES7 Decorators to make Vuex modules a breeze

Installation

npm install -D vuex-module-decorators
@championswimmer
championswimmer / verified.sql
Created June 8, 2018 09:47
all users with one verified and multiple unverified accounts
SELECT
count("email") AS "count",
count("verifiedemail") as "Verified",
max("createdAt") as "Last Attempt",
min("createdAt") as "First Attempt",
"public"."users"."email" AS "email"
FROM "public"."users"
GROUP BY "public"."users"."email"
HAVING
count("email") > 1 AND
@championswimmer
championswimmer / extract-7z.sh
Created May 24, 2018 11:28
Extract All archives into respective folders
for f in *.7z
do
echo $f
fn="${f%.*}"
mkdir -p "./$fn"
cd "./$fn"
7z e "../$f"
cd ..
done
@championswimmer
championswimmer / getters.ts
Created May 3, 2018 08:31
fetch_getters.ts
function Module<S> (module: Function & {state:any}) {
const state = new (module.prototype.constructor)({})
if (!module.state) {
module.state = <S>{}
}
const getters = Object.entries(Object.getOwnPropertyDescriptors(module.prototype))
.filter(([key, descriptor]) => typeof descriptor.get === 'function')
.forEach(([key,descriptor]) => console.log(descriptor.get.toString())
@championswimmer
championswimmer / colleges.json
Last active April 19, 2023 13:33
Top 100 Engineering Colleges India JSON File
[
{
"college":"IIT, Delhi (Delhi)"
},
{
"college":"IIT, Bombay (Mumbai)"
},
{
"college":"IIT, Kharagpur (Kharagpur)"
},
@championswimmer
championswimmer / Strict Sequelize: Typescript Overkill.md
Created January 19, 2018 22:46
Strict Sequelize: Typescript Overkill

Very Strict Sequelize: Into the land of Typescript Overkill

Disclaimer: If you believe that Typescript is a conspiracy by Microsoft to turn Javascript into C# and you believe in the religion of monkey-patching objects, then please do not proceed further. This article will burn your soul if you read it

Typescript: Enforce 'correct' code

Ever since I have started using Typescript, I cannot imagine writing large projects in plain JS anymore. My relationship to Typescript is best explained by this very nicely articulated piece by Tom Dale

While Typescript can make working with frontend frameworks like Angular and Vue a whole new revelation, using it on backend projects can have equally pleasing results. What I like about Typescript is the strictness can be turned a few notches up or down based on your requirements. And as you keep turning the strictness up by notches, you start seeing Typescripting starting to blo

@championswimmer
championswimmer / kotlin_stdlib_funcs.kt
Created January 17, 2018 01:52
Kotlin Stdlib Functions Explained
class Vehicle (
var wheels: Int,
val color: String,
val hornSound: String
) {
fun playHorn() {
println(hornSound)
}
fun getAxles () = wheels / 2
@championswimmer
championswimmer / spaceship.zsh-theme
Created November 23, 2017 16:29
spaceship.zsh-theme
#
# Spaceship ZSH Theme
#
# Author: Denys Dovhan, denysdovhan.com
# License: MIT
# https://github.com/denysdovhan/spaceship-zsh-theme
# ------------------------------------------------------------------------------
# CONFIGURATION
# The default configuration that can be overridden in .zshrc
source $HOME/.profile
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/championswimmer/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.