Skip to content

Instantly share code, notes, and snippets.

View n8henrie's full-sized avatar

Nathan Henrie n8henrie

View GitHub Profile
@n8henrie
n8henrie / crashplan_setup.sh
Last active March 15, 2024 21:36
Set up CrashPlan on Raspberry Pi (Raspbian Jessie)
#!/bin/bash
#############
# n8henrie's Raspberry Pi CrashPlan installer script
# v0.1.0 :: 20160530
#############
set -e
CP_VERSION="4.8.0"
@n8henrie
n8henrie / txt_to_reminders.applescript
Last active March 11, 2024 17:04
Demonstration of using AppleScript with Reminders.app
--taken from http://benguild.com/2012/04/11/how-to-import-tasks-to-do-items-into-ios-reminders/#comment-1346894559
--set theFileContents to (read file "Users:n8henrie:Desktop:Reminders.txt") -- Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder
--set theLines to paragraphs of theFileContents
set theLines to {"task name 1", "task name 2"}
repeat with eachLine in theLines
tell application "Reminders"
set mylist to list "Your List Name"
tell mylist
make new reminder at end with properties {name:eachLine, due date:date "7/10/2014 3:00 PM"}
@n8henrie
n8henrie / Open in Editor.js
Last active February 21, 2024 21:26
JXA to open finder selection in MacVim, or default to an empty buffer
#!/usr/bin/osascript -l JavaScript
// For use in Hammerspoon via hs.osascript.javascriptFromFile
//
// Debugging:
// 1. Add a `delay` to the beginning
// 2. Add some `console.log`s
// 3. Run from console as `osascript Open\ in\ MacVim.js`
// 4. Switch to a Finder window before the sleep is done
'use strict';
@n8henrie
n8henrie / alexa-skills-kit-color-expert-python.py
Created March 23, 2016 03:20
Amazon's example Alexa Skills lambda function
"""
This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit.
The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well
as testing instructions are located at http://amzn.to/1LzFrj6
For additional samples, visit the Alexa Skills Kit Getting Started guide at
http://amzn.to/1LGWsLG
"""
from __future__ import print_function
#! /usr/bin/env python3
'''pyCookieCheat.py
2015022 Now its own GitHub repo, and in PyPi.
- For most recent version: https://github.com/n8henrie/pycookiecheat
- This gist unlikely to be maintained further for that reason.
20150221 v2.0.1: Now should find cookies for base domain and all subs.
20140518 v2.0: Now works with Chrome's new encrypted cookies.
See relevant post at http://n8h.me/HufI1w
@n8henrie
n8henrie / chrome_se_export.py
Created November 4, 2015 22:50
Export your Chrome search engines to JSON.
"""chrome_se_export.py
Export your Chrome search engines to JSON.
"""
import os.path
import sqlite3
import re
import json
import click
@n8henrie
n8henrie / nix-darwin-linux-builder-example.nix
Created September 25, 2023 21:33
How to use darwin-builder to build linux nix packages on darwin
{
description = "Example use of nixpkgs#darwin-builder";
# First, read through https://github.com/NixOS/nixpkgs/blob/master/doc/builders/special/darwin-builder.section.md#sec-darwin-builder-example-flake
# and add yourself to `extra-trusted-users`, verify with `nix show-config | grep -i trusted-users`
#
# Copy this flake somewhere and run:
#
# ```console
# $ nix build --builders '' .#packages.aarch64-darwin.default
@n8henrie
n8henrie / cheat_downloader.py
Last active November 1, 2023 07:03
I got tired of figuring out complex POST requests with tons of hidden fields to automate grabbing content with Python Requests (http://www.python-requests.org). I figured out that I could just log into the site normally in Chrome, then grab the cookies from Chrome and use those in Requests. Worked for my purposes, so I thought I'd share.
#! /usr/bin/env python3
"""cheat_downloader.py
Loads Chrome's cookies into Python Requests for bulk downloading.
http://n8henrie.com/2013/11/use-chromes-cookies-for-easier-downloading-with-python-requests/
Working with:
- Python 3.3.2
- BeautifulSoup 4.3.1
- Requests 2.0.0
- Chrome 30.0.1599.101
@n8henrie
n8henrie / iphone_cannot_be_played.js
Last active October 17, 2023 22:50
Automatically click "ok" on the dozens of error notifications I get when syncing with MacOS
#!/usr/bin/osascript -l JavaScript
function click_ok() {
const sys = Application('System Events')
const finder = sys.processes["Finder"]
try {
let sheets = finder.windows.whose({name: "NatePhone"}).sheets().flat()
let message = "cannot be played on this iPhone."
let error_sheet = sheets.filter(sheet => {
@n8henrie
n8henrie / .gitignore
Last active October 6, 2023 18:32
Download and install Golang for Raspberry Pi
go*.linux-armv6l.tar.gz