Skip to content

Instantly share code, notes, and snippets.

@preetpalS
preetpalS / pandoc-convert-to-org-for-viewing.el
Last active August 8, 2025 23:15
Emacs Lisp convert files to Org mode files using pandoc for viewing purposes
(defun init-pandoc-convert-to-org-file-and-view (fname)
"Enables support for viewing files (such as docx or epub files)
via conversions using pandoc (by converting them to org files)"
(interactive "fEnter name of file to be converted to org file for viewing: ")
;; (print (concat "fname: " fname))
(let* ((base-file-name (file-name-base fname))
(output-file-name (concat (make-temp-file base-file-name t) "/" base-file-name ".org"))
(pandoc-conversion-command (concat "pandoc \""
fname
"\" -t org -o \""
@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,