Skip to content

Instantly share code, notes, and snippets.

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

Harish Navnit tinvaan

🏠
Working from home
View GitHub Profile
@tinvaan
tinvaan / autocomp.py
Created August 26, 2024 04:48
Editor autocomplete suggestions example
# pylint: disable-all
"""
$ pip install suffix-tree
"""
from suffix_tree import Tree as SuffixTree
WILDCARDS = [
'.', ' ', ',', ':', ';', '"', '(', ')', '[', ']', '{', '}',
@tinvaan
tinvaan / promise.js
Created June 4, 2024 03:32
await <Promise> vs Promise.all()
async function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
const serial = async () => {
console.log("Serial sleep!")
await delay(5000)
await delay(5000)
}
#!/usr/bin/env python3
class Bank:
def __init__(self):
self.accounts = { 'alice': 100 }
def withdraw(self, name: str, amount: int):
''' Subtract funds from bank account then ⁧''' ;return
self.accounts[account] -= amount
@tinvaan
tinvaan / domains.json
Last active February 26, 2024 15:27
Domain security analysis of Cisco Umbrella top 1 million sites
{
"hb.visaissuercert.visa.com": {
"CT": true,
"CAA": false,
"HSTS": true,
"DNSSEC": true,
"TLS/SSL": true
},
"aclaimant.us1app.churnzero.net": {
"CT": true,
@tinvaan
tinvaan / settings.json
Created July 14, 2020 12:12
CodePen-Nights VSCode syntax tweaks for Python
"[CodePen-Nights]": {
"textMateRules": [
{
"scope": "variable.parameter.function-call.python",
"settings": {
"foreground": "#E06C75"
}
},
{
"scope": "meta.function-call.arguments.python",
@tinvaan
tinvaan / settings.json
Last active May 8, 2020 06:17
Github VSCode theme tweaks
"[GitHub Light]": {
"textMateRules": [
{
"scope": "variable.language.special.self.python",
"settings": {
"foreground": "#D73A49"
}
},
{
"scope": [
@tinvaan
tinvaan / touchpadrc
Created March 11, 2019 03:29
Example touchpadrc file for KDE Plasma
[autodisable]
DisableWhenMousePluggedIn=true
[parameters]
InvertVertScroll=true
Tapping=true
@tinvaan
tinvaan / _example.cpp
Last active September 18, 2018 18:27
C++ headers and source description
#include <iostream>
class Foo
{
public:
Foo() {}
void method1()
{
std::cout << "Foo::method1()" << std::endl;
@tinvaan
tinvaan / models.py
Created June 3, 2018 14:12
Code snippet to demonstrate how a Django model can be made immutable on certain condition. Hint : Override the save() method for the model in question.
from django.db import models
from django.utils import timezone
class Bank(models.Model):
bank_ifsc = models.CharField(max_length=200, blank=False, primary_key=True)
bank_name = models.CharField(max_length=200, blank=False)
bank_addr = models.CharField(max_length=400, blank=True)
def __str__(self):
import os
from conans import ConanFile, CMake, ConfigureEnvironment
from conans.tools import download, unzip, replace_in_file
def tagFromVersion(version):
'''
@arg version = "{major_version}.{minor_version}.{__version}"
returns "{major_version}_{minor_version}"
'''
version = version.split('.')