Skip to content

Instantly share code, notes, and snippets.

View championswimmer's full-sized avatar

Arnav Gupta championswimmer

View GitHub Profile
@championswimmer
championswimmer / idea.sh
Created August 22, 2018 19:25
IntelliJ IDEA Launch Script (MacOS)
#!/bin/sh
ARG=$@
if [ "$ARG" == "." ]
then
ARG=$(pwd)
fi
echo "Opening IntelliJ IDEA with args = ${ARG}"
open -a "IntelliJ IDEA" --args $ARG
@championswimmer
championswimmer / logcat.txt
Created August 3, 2018 20:07
boot logcat
--------- beginning of system
01-06 17:57:36.324 779 779 E LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/password.key: open failed: ENOENT (No such file or directory)
01-06 17:57:36.325 779 779 E LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gatekeeper.pattern.key: open failed: ENOENT (No such file or directory)
01-06 17:57:36.327 779 779 E LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gatekeeper.gesture.key: open failed: ENOENT (No such file or directory)
01-06 17:57:36.327 779 779 E LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gesture.key: open failed: ENOENT (No such file or directory)
01-06 17:57:36.331 779 779 D SystemServerTiming: MakeLockSettingsServiceReady took to complete: 104ms
01-06 17:57:36.331 779 779 I SystemServer: StartBootPhaseLockSettingsReady
01-06 17:57:36.331 779 779 I SystemServiceManager: Starting phase 480
01-06 17
@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 January 23, 2025 04:49
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