Skip to content

Instantly share code, notes, and snippets.

@preetpalS
preetpalS / find_file.d
Last active August 20, 2023 11:18
Command line utility to find files using globs or regex (written in D)
import std.file, std.stdio;
immutable string programInformation = "Searches for files based on their names.\n"
~ "Search case sensitivity depends on the OS (macOS and Windows are case-insensitive while non-macOS POSIX systems are case-sensitive).\n\n"
~ "OPTIONS:";
immutable string versionInformation = "Filename Searcher (find_file) 1.0.1\n"
~ "Copyright (C) 2022 Preetpal Sohal.\n"
~ "License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\n"
~ "This is free software: you are free to change and redistribute it.\n"
@preetpalS
preetpalS / font-lock+.el
Created October 10, 2022 02:35
Version of font-lock+.el modified to not use 'cl package (which is deprecated)
;;; font-lock+.el --- Enhancements to standard library `font-lock.el'.
;;
;; Filename: font-lock+.el
;; Description: Enhancements to standard library `font-lock.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
;; Copyright (C) 2007-2018, Drew Adams, all rights reserved.
;; Created: Sun Mar 25 15:21:07 2007
;; Version: 0
;; Package-Requires: ()
@preetpalS
preetpalS / multi-monitor-window-maximization.c
Last active March 6, 2021 15:47
AutoHotKey script replacement in C for multi-monitor window maximization (Windows only)
// Compile with: cl /O2 /GL src\main.c
#include "stdbool.h"
// #include "stdio.h"
#include "windows.h"
#include "winuser.h"
#pragma comment( lib, "user32.lib")
@preetpalS
preetpalS / multi-monitor-window-maximization.d
Last active March 13, 2021 09:28
AutoHotKey script replacement in D for multi-monitor window maximization (Windows only)
// Compilation tested with ldc2 and dmd. D BetterC compatible.
// I compile with: ldc2 -O3 -release -mcpu=native -m64 -betterC -static main.d
// import core.stdc.stdio : printf;
// import std.stdio;
import core.sys.windows.windows;
import core.sys.windows.winuser;
pragma(lib, "user32.lib");
@preetpalS
preetpalS / bug-workarounds.el
Created February 21, 2021 07:54
Bug workarounds for Emacs
;; Provides workarounds for some bugs
;; Fixes issues related to not being able to connect to HTTPS (use at your own risk)
(when (version< emacs-version "26.3")
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
;; Fixes issue in certain packages related to change listed in Emacs news (for Emacs 28):
;; ** The WHEN argument of 'make-obsolete' and related functions is mandatory.
;; The use of those functions without a WHEN argument was marked obsolete
@preetpalS
preetpalS / firefox_autocomplete_related_monkey_patch.rb
Last active February 14, 2021 04:56
Rails forms fix for Firefox auto-complete behaviour (monkey patch)
# frozen_string_literal: true
commands = [
'brakeman -w3',
'rubocop -ac .rubocop.yml',
'reek -c .reek.yml'
]
# Note if any of the commands does not exit with 0, the whole process fails
commands.each do |command|
@preetpalS
preetpalS / openssl-notes.txt
Created May 4, 2020 09:52 — forked from tsaarni/openssl-notes.txt
Generate self-signed certs with different key types
*** RSA
# Generate self-signed certificate with RSA 4096 key-pair
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout rsakey.pem -out rsacert.pem
# print private and public key
openssl rsa -in rsakey.pem -text -noout
# print certificate
openssl x509 -in rsacert.pem -text -noout
@preetpalS
preetpalS / random_password_generator.rb
Last active November 16, 2018 14:23
Simple command line random password generator (Ruby)
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
class RandomPasswordGenerator
VERSION = %w(0.1.0)
CORE_CHARACTER_SET = [('a'..'z').to_a,
('A'..'Z').to_a,
@preetpalS
preetpalS / handle_sigbreak_on_windows.rb
Created May 6, 2018 05:59
Handling SIGBREAK signals with existing SIGINT signal handlers on Windows in Ruby
# Sets up clean SIGBREAK signal handling on Windows by taking advantage of existing
# SIGINT signal handlers.
(-> {
Signal.trap(21) do
raise SignalException, 'INT'
end
}).call if Gem.win_platform?