Skip to content

Instantly share code, notes, and snippets.


Juande Santander-Vela juandesant

View GitHub Profile
juandesant / RevealAllFilesInHierarchy.scpt
Created Mar 18, 2022
Uses AppleScript to reveal all files within a hierarchy, using the frontmost folder in the Finder
View RevealAllFilesInHierarchy.scpt
tell application "Finder"
-- get the folder that corresponds to the foremost Finder Window
set theFolder to the folder of the first window
-- alternatively, you could choose a folder with the form below
-- set theFolder to (choose folder)
-- get justTheFiles by using the every item of ... whose ... construct
set justTheFiles to every item of the (entire contents of theFolder) whose kind "Folder"
-- reveal them opens up new folders of each directory and subdirectory in the hierarchy below the current folder
reveal justTheFiles
end tell
juandesant /
Created Mar 18, 2022
Bash/ZSH function that returns the HTTP url for a Git repository
git-url () {
# Use `git config` to get the remote URL
git_url=$(git config --get remote.origin.url)
# Check if it is an HTTP-based URL
if [[ $git_url == *"http"* ]]
# for HTTP-based URLs, nothing to do but report it
echo $git_url
# for SSH based URLs, remake git_url so that the user is removed, and the server separator changed to a slash
juandesant /
Last active Aug 27, 2021 — forked from derEremit/
Generates gource video out of multiple repositories.
#!/usr/bin/env bash
# Generates gource video (h.264) out of multiple repositories.
# Pass the repositories in command line arguments.
# Example:
# <> /path/to/repo1 /path/to/repo2
def dict_diff(dict_a, dict_b, show_value_diff=True):
result = {}
result['added'] = {k: dict_b[k] for k in set(dict_b) - set(dict_a)}
result['removed'] = {k: dict_a[k] for k in set(dict_a) - set(dict_b)}
if show_value_diff:
common_keys = set(first_dict) & set(second_dict)
result['value_diffs'] = {
k:(dict_a[k], dict_b[k])
for k in common_keys
if dict_a[k] != dict_b[k]
juandesant /
Last active Aug 4, 2021
Python implementation of the Collatz series as a generator
def next_collatz(n):
if n%2 == 0:
return n//2
return 3*n+1
def collatz(n):
yield n
result = next_collatz(n)
while result != 1 and result :
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
# 10 May 2008
# Original version by John Gruber:
juandesant / OmniOutliner-SplitRowsInTopics.js
Last active Mar 12, 2021
This script takes selected rows in OmniOutliner, and tries to split topics that have multiple lines into multiple rows, and leaves one-liner items alone.
View OmniOutliner-SplitRowsInTopics.js
// Based on information provided on
// Get selected nodes in foremost window (editors[0])
var nodes = document.editors[0].selectedNodes
// Split all selected topics in paragraphs
function(node) {
// for each individual node
def is_power_of_two(an_int):
# We use the binary representation to work with
bits = bin(an_int)[2:] # truncates the "0b" part of the string
# A power of two only has one bit set, so the sum of all bits needs to be 1
return sum([int(x) for x in list(bits)]) == 1
def is_power_of_two_recursive(an_int):
if an_int < 0:
return is_power_of_two_recursive(-an_int)
elif an_int == 0:
string = input("Which string you want to vowel-reverse?\n> ")
listed_string = list(string)
# Helper function to find whether a character is a vowel
def is_vowel(c):
"""Determines is c is a vowel; returns False if it is not, True if it is."""
result = False
vowel_list = list("aeiou")
position = vowel_list.index(c)
#!/usr/bin/env python
# Based on
import random
dict_file = open('/usr/share/dict/words', 'r') # substitute with the path your /etc/dict/words equivalent
word_list = [x.rstrip('\n') for x in dict_file.readlines()]
capitalise_first_letter = True
capitalise_first_word = False
joiner_character = "-"