Skip to content

Instantly share code, notes, and snippets.

@shandanjay
shandanjay / Main.java
Last active June 23, 2024 11:15
Highest product of triplets of a given list of integers
package org.example;
public class Main {
// Only using java.lang package Math.max(int, int) & Math.min(int, int) methods
public static int highestProductOfTriplets(int[] nums) {
if (nums.length < 3 ) {
throw new IllegalArgumentException("Array must contain at least 3 integers");
}
@shandanjay
shandanjay / vidqgif.sh
Created January 31, 2024 17:01 — forked from bodqhrohro/vidqgif.sh
Compress a video to a tiny GIF with a very strong quantization and no dithering
#!/bin/sh
# parameters: input, output
# make a 256-colors palette first
palettefull=$( mktemp --suffix=.png )
ffmpeg -i "$1" -vf 'palettegen' -y "$palettefull"
# quantize the palette (palettegen's builting limiter
# tries to preserve too much similar shades)
palettequant=$( mktemp --suffix=.png )
@shandanjay
shandanjay / windows_hardening.cmd
Created November 20, 2022 22:56 — forked from mackwage/windows_hardening.cmd
Script to perform some hardening of Windows OS
:: Windows 10 Hardening Script
:: This is based mostly on my own personal research and testing. My objective is to secure/harden Windows 10 as much as possible while not impacting usability at all. (Think being able to run on this computer's of family members so secure them but not increase the chances of them having to call you to troubleshoot something related to it later on). References for virtually all settings can be found at the bottom. Just before the references section, you will always find several security settings commented out as they could lead to compatibility issues in common consumer setups but they're worth considering.
:: Obligatory 'views are my own'. :)
:: Thank you @jaredhaight for the Win Firewall config recommendations!
:: Thank you @ricardojba for the DLL Safe Order Search reg key!
:: Thank you @jessicaknotts for the help on testing Exploit Guard configs and checking privacy settings!
:: Best script I've found for Debloating Windows 10: https://github.com/Sycnex/Windows10Debloater
:
@shandanjay
shandanjay / gist:749f05cfd03c3ddb90dd73fd4a3cbe0d
Created November 12, 2022 16:31 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
@shandanjay
shandanjay / gist:16e847840d630f35ccce31151c661105
Created November 12, 2022 16:30 — forked from Dufgui/gist:72debe81068bf3ecd7d8
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
import re
import PyPDF2
import spacy
class PdfParser():
def __init__(self, file_path):
self.file_path = file_path
def pdf_reader(self) -> str:
content = ''
opener = open(self.file_path, 'rb')
@shandanjay
shandanjay / ssl_certs.md
Created January 18, 2021 07:21 — forked from tpowellcio/ssl_certs.md
Creating SSL Certs

#Creating Certificates Reference

  1. From a terminal:
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  1. Enter the requested information:
  2. Common Name: The fully-qualified domain name, or URL, you're securing. If you are requesting a Wildcard certificate, add an asterisk (*) to the left of the common name where you want the wildcard, for example *.coolexample.com.
  3. Organization: The legally-registered name for your business. If you are enrolling as an individual, enter the certificate requestor's name.
@shandanjay
shandanjay / fibonacci-nth.clj
Created February 3, 2019 04:37
A Multimethod solution to get the nth item in fibonacci series
(defmulti fibonacci identity)
(defmethod fibonacci 0 [_] 1)
(defmethod fibonacci 1 [_] 1)
(defmethod fibonacci :default [n] (+ (fibonacci (- n 1) ) (fibonacci (- n 2) )) )
@shandanjay
shandanjay / gist:e6bb94a7afa3bc04619089e5560886d8
Created September 15, 2018 01:22 — forked from cgmartin/gist:5880732
WebSocket subprotocol and origin validation with HTTP Kit
(ns my.server
(:use org.httpkit.server
[clojure.string :only [split trim lower-case]])
(:import [org.httpkit.server AsyncChannel]))
(defn origin-match? [origin-re req]
(if-let [req-origin (get-in req [:headers "origin"])]
(re-matches origin-re req-origin)))
@shandanjay
shandanjay / import-tar-gz.sh
Created June 20, 2018 06:31 — forked from infusion/import-tar-gz.sh
Import a tar.gz file to MySQL
tar xzOf dump.sql.tar.gz | mysql -u $user -p $database