Skip to content

Instantly share code, notes, and snippets.

View juandesant's full-sized avatar

Juande Santander-Vela juandesant

View GitHub Profile
#!/usr/bin/perl
# 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
juandesant / OmniOutliner-SplitRowsInTopics.js
Last active March 12, 2021 17:21
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.
// Based on information provided on
// https://omni-automation.com/omnioutliner/item.html
// Get selected nodes in foremost window (editors[0])
var nodes = document.editors[0].selectedNodes
// Split all selected topics in paragraphs
nodes.forEach(
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")
try:
position = vowel_list.index(c)
#!/usr/bin/env python
# Based on https://m.xkcd.com/936/
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 = "-"
@juandesant
juandesant / airquality.scpt
Created August 31, 2020 14:28 — forked from jasonsnell/airquality.scpt
Air Quality AppleScript
-- PurpleAir station ID
set theStationID to "6732"
tell application "JSON Helper"
set theWeather to (fetch JSON from ("https://www.purpleair.com/json?show=" & theStationID) with cleaning feed)
set theStatsA to (read JSON from (Stats of item 1 of results of theWeather))
set theStatsB to (read JSON from (Stats of item 2 of results of theWeather))
set theLocation to Label of item 1 of results of theWeather
set theLat to (Lat of item 1 of results of theWeather)
set theLon to (Lon of item 1 of results of theWeather)
#!/usr/bin/env bash
# ~/.macos — https://mths.be/macos
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# http://www.graphviz.org/content/cluster
digraph G {
graph [fontname = "Handlee"];
node [fontname = "Handlee"];
edge [fontname = "Handlee"];
bgcolor=transparent;
subgraph cluster_0 {
@juandesant
juandesant / Check email from Exchange.py
Created June 10, 2020 15:02
Check email from Exchange with Python
# /usr/bin/env python
# Based on https://chuoi.org/posts/checkexchangeemailandsendemailwithpython/
"""Description
A Python script to check email exchange mailbox, download require attachment and send email to user.
Use:
cd /path/to/file && python3 main.py
"""
import os
@juandesant
juandesant / astropy_speedups.py
Created May 18, 2020 17:10 — forked from StuartLittlefair/astropy_speedups.py
Speedups for astropy coordinate transformations with >1000s of obstimes (works best for roughly regular spaced grid of obstimes)
"""
Contains some faster coordinate transformations than the ones currently used in astropy.
This is based on an idea put forward by @bwinkel in the pull request located at
at https://github.com/astropy/astropy/pull/6068. This may be merged into the astropy
master at some point. If this happens, this module can be removed.
Simply import into code to experience the speedups; the astropy coordinate transforms are
overwritten on modeul import.
"""