Skip to content

Instantly share code, notes, and snippets.

View joaocarmo's full-sized avatar
🍺
Beer

João Carmo joaocarmo

🍺
Beer
View GitHub Profile
@joaocarmo
joaocarmo / csv-to-keychain.applescript
Last active February 25, 2021 00:44
Imports Website Credentials from a CSV file into Apple's Keychain using macOS and Safari
#!/usr/bin/osascript
-- Adapted from https://github.com/PaperKup/csv-toicloudkeychain
-- For macOS Big Sur
-- Select the csv to import to iCloud keychain
-- Expects a CSV without headers and the following format:
-- WEBSITE,USERNAME,PASSWORD
set theFile to (choose file with prompt "Select the CSV file")
-- Read csv file
@joaocarmo
joaocarmo / pi-hole.conf
Created February 3, 2021 00:25
Unbound configuration for Pi-hole + DoT (DNS over TLS)
# /etc/unbound/unbound.conf.d/pi-hole.conf
server:
# If no logfile is specified, syslog is used
# logfile: "/var/log/unbound/unbound.log"
verbosity: 0
interface: 127.0.0.1
port: 5335
do-ip4: yes
@joaocarmo
joaocarmo / startCiscoVPN.applescript
Created September 14, 2020 12:44
Automate the authentication of Cisco AnyConnect Secure Mobility Client in macOS
#!/usr/bin/osascript
--Variables
set vpnServer to "vpn.mydomain.com"
set vpnPassword to "myb64pwd"
set vpnAppBundleName to "Cisco AnyConnect Secure Mobility Client"
set vpnAppBundleId to "com.cisco.anyconnect.gui"
set keyCodeDelete to 51
set keyCodeReturn to 36
set tinyDelay to 1
set smallDelay to 3
@joaocarmo
joaocarmo / _browser_hacks_for.scss
Created February 25, 2020 12:17
Browser hacks mixing for SASS
/// Browser hacks
/// Source: browser strangeness
/// https://browserstrangeness.github.io/css_hacks.html
/// Jeff Clayton
/// @access public
/// @param {String} $browser
/// @param {String} $selector
/// @param {String} $property
/// @param {*} $value
///
@joaocarmo
joaocarmo / parseUrl.js
Created February 21, 2020 15:06
A URL parsing function mostly compatible with the URL() constructor for browser's that don't support it
function parseUrl(url = '') {
// Make it compatible with the URL() constructor
const parsed = {
href: '',
origin: '',
protocol: '',
username: '',
password: '',
host: '',
hostname: '',
@joaocarmo
joaocarmo / git-checkout-interactive-local-branch.sh
Last active September 13, 2021 12:13
Interactively checkout local branches (git)
#!/bin/bash
################################################################################
# Interactive Git Checkout
# ------------------------------------------------------------------------------
# Author: Joao Carmo
# License: MIT
# ------------------------------------------------------------------------------
# This script will list all available local branches and you can select one to
# checkout using a number (on the list).
@joaocarmo
joaocarmo / git-delete-interactive-local-branch.sh
Last active September 13, 2021 12:14
Interactively delete local branches (git)
#!/bin/bash
################################################################################
# Interactive Git Delete
# ------------------------------------------------------------------------------
# Author: Joao Carmo
# License: MIT
# ------------------------------------------------------------------------------
# This script will list all available local branches and you can select one or
# more to delete using numbers (from the list).
@joaocarmo
joaocarmo / tasks.json
Last active January 10, 2020 10:26
VSCode Custom Task: Preview as HTML in Chrome
{
"version": "2.0.0",
"tasks": [
{
"label": "Preview as HTML in Chrome",
"type": "shell",
"osx": {
"command": "cp ${file} /tmp/${fileBasename}_preview.html && /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome /tmp/${fileBasename}_preview.html && sleep 5 && rm -f /tmp/${fileBasename}_preview.html",
}
}
@joaocarmo
joaocarmo / python.sh
Last active July 31, 2019 12:27
Python wrapper to select the best interpreter available in the system
#!/usr/bin/env bash
################################################################################
# Python Wrapper
# ------------------------------------------------------------------------------
# Author: Joao Carmo
# License: MIT
# ------------------------------------------------------------------------------
# This wrapper script will test each available Python interpreter in the system
# to find the one which has the most critical modules installed and then execute
@joaocarmo
joaocarmo / setNestedValue.js
Created July 1, 2019 11:19
Set an object's nested value
/*
Usage: setNestedValue(<object>, <array>, <value>)
const object = {
key1: {
key11: 'nested-value'
}
}
const newObject = setNestedValue(object, ['key1', 'key12'], 'another-nested-value')