This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Finder" | |
try | |
make new alias to POSIX file "/System/Applications/Automator.app" at POSIX file "/System/Applications/Automator.app" with properties {name:"Alias to Automator"} | |
on error errorMsg | |
make new alias to POSIX file "/System/Applications/Automator.app" at (path to downloads folder) with properties {name:"Alias to Automator.app"} | |
end try | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires atlassian-python-api PyPI module | |
from atlassian import Confluence | |
# You should read your secret information some other way | |
your_confluence_url = "https://confluence.domain.tld" | |
your_username = "your_username" | |
your_password = "your_password" | |
# cf becomes the Confluence instance with the user logged in | |
cf = Confluence( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
from functools import reduce | |
from collections import Counter | |
# Iterative product for factorial | |
def factorial(x): return reduce(lambda x,y: x*y , range(1,x+1)) | |
words_file_path = "/usr/share/dict/words" | |
words_file = open(words_file_path, "r") # Valid for macOS; change for Linux, other UNIXes | |
words = { x.rstrip("\n").lower() for x in words_file.readlines() } # create a set for faster membership tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"* ]] | |
then | |
# for HTTP-based URLs, nothing to do but report it | |
echo $git_url | |
else | |
# for SSH based URLs, remake git_url so that the user is removed, and the server separator changed to a slash |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Generates gource video (h.264) out of multiple repositories. | |
# Pass the repositories in command line arguments. | |
# Example: | |
# <gource-multirepo.sh> /path/to/repo1 /path/to/repo2 | |
RESOLUTION="1600x1080" | |
outfile="gource.mp4" | |
i=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def next_collatz(n): | |
if n%2 == 0: | |
return n//2 | |
else: | |
return 3*n+1 | |
def collatz(n): | |
yield n | |
result = next_collatz(n) | |
while result != 1 and result : |