Skip to content

Instantly share code, notes, and snippets.

View sohamkamani's full-sized avatar
🐦
🐧

Soham Kamani sohamkamani

🐦
🐧
View GitHub Profile
@sohamkamani
sohamkamani / rsa.js
Last active December 24, 2024 15:57
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})
@sohamkamani
sohamkamani / localstorage_lru_cache.html
Created July 21, 2020 16:27
An example of how to implement LRU cache with eviction using the HTML5 localStorage API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LocalStorage With LRU Eviction</title>
</head>
<body>
<button id="btn-set">Set</button><br />
Key: <input id="input-set-key" /><br />
@sohamkamani
sohamkamani / create_tables.sql
Last active October 12, 2023 19:01
Script to create tables for my tutorial on https://www.sohamkamani.com/sql-guide/
CREATE TABLE books (
bookid serial PRIMARY KEY,
title text,
author text,
published date,
stock int
);
INSERT INTO
books (bookid, title, author, published, stock)
@sohamkamani
sohamkamani / gist:52c0e24fa776c2b36aa9e088a0f6120b
Created September 20, 2023 11:11
Java formatting stylegiude
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="13">
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="13">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>