Skip to content

Instantly share code, notes, and snippets.

@bf4648
bf4648 / cryptography.md
Created January 26, 2023 17:26 — forked from gauravchl/cryptography.md
Useful commands for cryptography need
View cryptography.md

sha256 of a file

openssl sha -sha256 ws-test.js

sha256 of string

echo -n 'your string' | opsnssl sha -sha256

Random password 192 character

openssl rand 192

Random password in file

@bf4648
bf4648 / display-previous-and-next-links.js
Last active December 14, 2022 19:05
Display links at the top of an obsidian page for the previous and next files
View display-previous-and-next-links.js
@bf4648
bf4648 / venv.fish
Created October 10, 2022 16:31 — forked from tommyip/venv.fish
Automatically activate/deactivate virtualenv in fish shell
View venv.fish
# Based on https://gist.github.com/bastibe/c0950e463ffdfdfada7adf149ae77c6f
# Changes:
# * Instead of overriding cd, we detect directory change. This allows the script to work
# for other means of cd, such as z.
# * Update syntax to work with new versions of fish.
function __auto_source_venv --on-variable PWD --description "Activate/Deactivate virtualenv on directory change"
status --is-command-substitution; and return
# Check if we are inside a git directory
@bf4648
bf4648 / venv.fish
Created October 10, 2022 16:31 — forked from tommyip/venv.fish
Automatically activate/deactivate virtualenv in fish shell
View venv.fish
# Based on https://gist.github.com/bastibe/c0950e463ffdfdfada7adf149ae77c6f
# Changes:
# * Instead of overriding cd, we detect directory change. This allows the script to work
# for other means of cd, such as z.
# * Update syntax to work with new versions of fish.
function __auto_source_venv --on-variable PWD --description "Activate/Deactivate virtualenv on directory change"
status --is-command-substitution; and return
# Check if we are inside a git directory
@bf4648
bf4648 / macOS_SytemPrefs.md
Created September 16, 2022 14:25 — forked from rmcdongit/macOS_SytemPrefs.md
Apple System Preferences URL Schemes
View macOS_SytemPrefs.md

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@bf4648
bf4648 / gist:24f4a14cf9f0c9447d1f8e12055ef57c
Created June 3, 2022 17:47 — forked from tyru/gist:984296
s:substring() and s:substring_once() in vital.vim
View gist:24f4a14cf9f0c9447d1f8e12055ef57c
" Substitute a:from => a:to by string.
" To substitute by pattern, use substitute() instead.
function! s:substring(str, from, to)
if a:str ==# '' || a:from ==# ''
return a:str
endif
let str = a:str
let idx = stridx(str, a:from)
while idx !=# -1
@bf4648
bf4648 / handbrake.sh
Created September 19, 2021 22:39 — forked from ralphcrisostomo/handbrake.sh
Batch convert videos with HandBrake CLI
View handbrake.sh
#!/bin/bash
# Batch convert videos with HandBrake CLI
# By Ralph Crisostomo - 2016.04.17
#
# Usage :
# 'sudo ./handbrake.sh /source /destination'
#
# Reference :
# https://forum.handbrake.fr/viewtopic.php?f=6&t=19426
# https://gist.github.com/czj/1263872
@bf4648
bf4648 / .gdbinit
Created August 12, 2021 00:14 — forked from thobbs/.gdbinit
A version of .gdbinit that provides a pystack and pystackv command that does not hang forever. The problem appeared to be an infinite loop, so to fix it I just added a basic counter that breaks the while loop after 200 iterations.
View .gdbinit
# -*- ksh -*-
#
# If you use the GNU debugger gdb to debug the Python C runtime, you
# might find some of the following commands useful. Copy this to your
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
# start it up. Then, at the gdb prompt you can do things like:
#
# (gdb) pyo apyobjectptr
# <module 'foobar' (built-in)>
# refcounts: 1
@bf4648
bf4648 / vim find
Created June 26, 2021 18:52 — forked from jinzhubaofu/vim find
vim find from hades
View vim find
'Find' : 'find')<CR>
" Find file in current directory and edit it.
function! Find(name)
let l:list=system("find . -type f | grep -i '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
" let l:list=system("find . -iname '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
" replace above line with below one for gvim on windows
" let l:list=system("find . -name ".a:name." | perl -ne \"print qq{$.\\t$_}\"")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
@bf4648
bf4648 / helpers.py
Created June 25, 2021 15:15 — forked from kennethreitz/helpers.py
Various Python helper functions
View helpers.py
# encoding: utf-8
""" Python General Helpers
Copyright (c) 2010 Kenneth Reitz. Creative Commons Attribution 3.0 License.
"""
import urllib, re, time, sys
import paramiko