Skip to content

Instantly share code, notes, and snippets.

View sajith-rahim's full-sized avatar
🏠
Working from home

Sajith Rahim sajith-rahim

🏠
Working from home
View GitHub Profile
let regex_map: HashMap<&str, Regex> = [
("credit_card", Regex::new(r"\b(\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4})\b").unwrap()),
("email", Regex::new(r"\b([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4})\b").unwrap()),
("url", Regex::new(r"((?:https?|ftp)://[^\s/$.?#].[^\s]*)").unwrap()),
("ip_address", Regex::new(r"\b((?:\d{1,3}\.){3}\d{1,3})\b").unwrap()),
("social_security", Regex::new(r"\b(\d{3}-\d{2}-\d{4})\b").unwrap()),
("ipv6_address", Regex::new(r"([0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7})").unwrap()),
("phone_number", Regex::new(r"\b(\d{3}[-.\s]?\d{3}[-.\s]?\d{4})\b").unwrap()),
("srv_dns", Regex::new(r"\b(.+?)\s+IN\s+SRV\s+\d+\s+\d+\s+\d+\s+(.+)\b").unwrap()),
("mac_address", Regex::new(r"([0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5})").unwrap()),
@sajith-rahim
sajith-rahim / serve_gh_js_via_cdn.md
Last active December 29, 2022 12:35
Using / Hosting and distributing js files in Github via jsDelivr

Hosting and serving js files in Github via jsDelivr

Use jsDelivr Github Tool

Manual Steps

  1. Open the raw version of your file in Github and copy the url
sequenceDiagram
    participant dotcom
    participant iframe
    participant viewscreen
    dotcom->>iframe: loads html w/ iframe url
    iframe->>viewscreen: request template
    viewscreen->>iframe: html & javascript
    iframe->>dotcom: iframe ready
    dotcom->>iframe: set mermaid data on iframe
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({startOnLoad:true});
</script>
<style>
.mermaid { /* add custom styling */ }
</style>
<!--This will render scripts when the document loads once.
@sajith-rahim
sajith-rahim / git-09-11-2016.md
Last active August 20, 2022 22:03
Old Git Notes.

Version Control System

Types

  1. Local VCS
				> stored in hardisk.
				> no interaction/sharing
				> lost if HDD fails
  1. Centralized VCS
# ghub:Johnson468
import pyautogui
import time
import sys
from datetime import datetime
pyautogui.FAILSAFE = False
numMin = 1
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Paths;
// Day of week that is K days later
// Given current day as day of the week and an integer K,
// the task is to find the day of the week after K days.
import java.util.*;
class Solution {
public static String KDaysLater(String day, int k){
List<String> days = List.of("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
@sajith-rahim
sajith-rahim / Trie.java
Created January 30, 2022 17:15
Trie Autocomplete
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TrieNode {
char c;
Map<Character, TrieNode> children;
boolean isWord;
@sajith-rahim
sajith-rahim / LRU.java
Created January 30, 2022 17:14
LRU Cache
import java.util.HashMap;
class Entry {
int value;
int key;
Entry left;
Entry right;
}