Skip to content

Instantly share code, notes, and snippets.

View juandesant's full-sized avatar

Juande Santander-Vela juandesant

View GitHub Profile
@juandesant
juandesant / einstein.pl
Created December 10, 2022 20:33 — forked from jgilchrist/einstein.pl
A Prolog solution to Einstein's Riddle
right_of(X, Y) :- X is Y+1.
left_of(X, Y) :- right_of(Y, X).
next_to(X, Y) :- right_of(X, Y).
next_to(X, Y) :- left_of(X, Y).
solution(Street, FishOwner) :-
Street = [
house(1, Nationality1, Color1, Pet1, Drinks1, Smokes1),
house(2, Nationality2, Color2, Pet2, Drinks2, Smokes2),
@juandesant
juandesant / gource-multirepo.sh
Last active August 27, 2021 14:10 — forked from derEremit/gource-multiple-repositories.sh
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:
# <gource-multirepo.sh> /path/to/repo1 /path/to/repo2
RESOLUTION="1600x1080"
outfile="gource.mp4"
i=0
#!/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 / 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
@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.
"""
@juandesant
juandesant / Slack Status.js
Created May 13, 2020 19:55 — forked from simonbs/Slack Status.js
Peforms OAuth flow against Slack and sets a Slack Status. Meant to be used with Shortcuts.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: pink; icon-glyph: user;
// In order to use the script, you must create a Slack app and install it on your workspace. Go here to create your app: api.slack.com/apps
// There's two important configurations you must make to the app:
// 1. Add the users.profile:write scope to the app. This scope is necessary to set a Slack status.
// 2. Add the following redirect URL, so Slack will redirect to Scriptable after authorizing.
// https://open.scriptable.app
// Run the script to grant your newly created app authorization to access your Slack account. After you've done this, you can use the script in Shortcuts.
@juandesant
juandesant / MemoizationWithGenerics.swift
Last active April 24, 2020 09:28 — forked from sforteln/MemoizationWithGenerics
Simple Swift Function to memoize generic functions of the form T -> U
func memoized<Input:Hashable,Output>(fn : @escaping (Input) -> Output) -> (Input)->Output {
var cache = [Input:Output]()
let function = fn
let closure = {
(val : Input) -> Output in
let value = cache[val]
if value != nil {
return value!
} else {
let newValue = function(val)
@juandesant
juandesant / wheeler.md
Created March 13, 2020 16:00 — forked from kimsk/wheeler.md
THE USE OF SUB-ROUTINES IN PROGRAMMES

D. J. Wheeler

Cambridge & Illinois Universities

A sub-routine may perhaps best be described as a self-contained part of a programme, which is capable of being used in different programmes. It is an entity of its own within a programme. There is no necessity to compose a programme of a set of distinct sub-routines; for the programme can be written as a complete unit, with no divisions into smaller parts. However it is usually advantageous to arrange that a programme is comprised of a set of subroutines, some of which have been made specially for the particular programme while others are available from a library of standard sub-routines. The reasons for this will be discussed below.

When a programme has been made from a set of sub-routines the breakdown of the code is more complete than it would otherwise be. This allows the coder to concentrate on one section of a programme at a time without the overall detai

@juandesant
juandesant / every
Created September 12, 2019 17:29 — forked from sorbits/every
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}