Skip to content

Instantly share code, notes, and snippets.

@vishesh
vishesh / .emacs
Last active February 22, 2023 09:13
Leanest usable emacs config, without using any external packages in emacs29
;;; init.el --- Emacs configuration. -*- lexical-binding: t -*-
;;; Copyright (C) 2023 Vishesh Yadav
;;; Author: Vishesh Yadav <visehsh3y@gmail.com>
;;
;; Leanest usable emacs config, without using any external packages in emacs29.
;;;----------------------------------------------------------------------------
;;; Personal
;;;----------------------------------------------------------------------------
@vishesh
vishesh / crystal-disk-mark-fio-bench.sh
Created January 12, 2023 21:05 — forked from O1ahmad/crystal-disk-mark-fio-bench.sh
CrystalDiskMark-esque Disk Benchmark (using fio)
#!/bin/bash
LOOPS=5 #How many times to run each test
SIZE=1024 #Size of each test, multiples of 32 recommended for Q32 tests to give the most accurate results.
WRITEZERO=0 #Set whether to write zeroes or randoms to testfile (random is the default for both fio and crystaldiskmark); dd benchmarks typically only write zeroes which is why there can be a speed difference.
QSIZE=$(($SIZE / 32)) #Size of Q32Seq tests
SIZE+=m
QSIZE+=m
var emojis = [
'😄','😃','😀','😊','☺','😉','😍','😘','😚','😗','😙','😜','😝','😛','😳','😁','😔','😌','😒','😞','😣','😢','😂','😭','😪','😥','😰','😅','😓','😩','😫','😨','😱','😠','😡','😤','😖','😆','😋','😷','😎','😴','😵','😲','😟','😦','😧','😈','👿','😮','😬','😐','😕','😯','😶','😇','😏','😑','👲','👳','👮','👷','💂','👶','👦','👧','👨','👩','👴','👵','👱','👼','👸','😺','😸','😻','😽','😼','🙀','😿','😹','😾','👹','👺','🙈','🙉','🙊','💀','👽','💩','🔥','✨','🌟','💫','💥','💢','💦','💧','💤','💨','👂','👀','👃','👅','👄','👍','👎','👌','👊','✊','✌','👋','✋','👐','👆','👇','👉','👈','🙌','🙏','☝','👏','💪','🚶','🏃','💃','👫','👪','👬','👭','💏','💑','👯','🙆','🙅','💁','🙋','💆','💇','💅','👰','🙎','🙍','🙇','🎩','👑','👒','👟','👞','👡','👠','👢','👕','👔','👚','👗','🎽','👖','👘','👙','💼','👜','👝','👛','👓','🎀','🌂','💄','💛','💙','💜','💚','❤','💔','💗','💓','💕','💖','💞','💘','💌','💋','💍','💎','👤','👥','💬','👣','💭','🐶','🐺','🐱','🐭','🐹','🐰','🐸','🐯','🐨','🐻','🐷','🐽','🐮','🐗','🐵','🐒','🐴','🐑','🐘','🐼','🐧','🐦','🐤','🐥','🐣','🐔','🐍','🐢','🐛','🐝','🐜','🐞','🐌','🐙','🐚','🐠','🐟','🐬','🐳','🐋','🐄','🐏','🐀','🐃','🐅','🐇','🐉','🐎','🐐','🐓','🐕','🐖','🐁','🐂','🐲','🐡','🐊','🐫','🐪','🐆','🐈','🐩','🐾',
;;;----------------------------------------------------------------------------
;;; Large files
;;;----------------------------------------------------------------------------
(defun fast-file-view-mode ()
"Makes the buffer readonly and disables fontlock and other bells and whistles for faster viewing"
(interactive)
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode)
@vishesh
vishesh / gist:447b5faf37a89aec4da320978cd43499
Created February 5, 2021 04:02
Userscript: Github sensible tab-width
/* ==UserStyle==
@name GitHub Tabs
@description Set sensible tabs on GitHub
@match *://github.com/*
==/UserStyle== */
.tab-size /* override GitHub’s guesses of correct tab size */ {
-moz-tab-size: 4 !important;
tab-size: 4 !important;
}
@vishesh
vishesh / source.rkt
Created July 26, 2018 00:05
Random stupid conversation
#lang racket
(define (conversation person-a person-b until)
(let loop ([until until]
[last-message-a ""]
[last-message-b ""]
[person-a person-a]
[person-b person-b])
(let ([next-message-a (string-append "I didnt know that " last-message-a)]
[next-message-b (string-append "you didnt know that " last-message-b)])
@vishesh
vishesh / bing.rkt
Created March 6, 2017 10:24
Set Bing's `Photo of the Day` as current wallpaper.
#lang racket/base
;; bing.rkt
;;
;; Download Bing's Photo of the Day and set it as current
;; wallpaper. Uses hsetroot on Linux.
(require net/url
racket/file
racket/format
@vishesh
vishesh / longestpalin.ml
Created December 24, 2015 22:20
Longest palindrome subsequence
(* hacker rank longest palindrome subsequence *)
open Core.Std
open Option
let lcs_palin_naive str =
let rec find i j =
match (i, j) with
| (x, y) when x = y -> 1
@vishesh
vishesh / largest_bst.ml
Last active November 28, 2015 05:04
Largest BST subtree in a given Binary Tree
open Core.Std
type tree = Empty | Node of int * tree * tree
let rec largest_bst t =
let min_exn (lst:int list) : int =
Option.value_exn (List.min_elt lst ~cmp:Int.compare)
and max_exn (lst:int list) : int =
Option.value_exn (List.max_elt lst ~cmp:Int.compare)
in
@vishesh
vishesh / lis.ss
Created March 17, 2015 01:39
longest increasing subsequence
(define (seq lst last)
(if (empty? lst)
0
(if (< last (first lst))
(max (add1 (seq (rest lst) (first lst)))
(seq (rest lst) last))
(seq (rest lst) last))))