This file contains hidden or 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 node | |
// =========== REPLACE YOUR USERNAME HERE =========== | |
// Must be lowercase; package will be listed as @username/package-name on GHPM | |
const GITHUB_USERNAME = "username"; | |
// =========== REPLACE YOUR USERNAME HERE =========== | |
// Performs the changes needed to publish an npm package to GitHub package | |
// manager, then publishes it, then undoes those changes (to be a regular npm | |
// package). Assumes package.json exists in cwd. |
This file contains hidden or 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/local/bin/node | |
// Get wake-up times based on sleep cycles if going to sleep now | |
// Code adapted from sleepyti.me source (surprisingly not minified) | |
const N_TIMES = 6; // Number of wake-up times to provide | |
let dates = [new Date(new Date().getTime() + 104 * 60000)]; | |
for (let i = 1; i < N_TIMES; i++) { | |
dates.push(new Date(dates[i - 1].getTime() + 90 * 60000)); |
This file contains hidden or 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
// Button to mark all posts as read | |
function makeButton() { | |
let button = document.createElement("button"); | |
button.setAttribute("id", "new_post_button"); | |
button.setAttribute("class", "btn-primary left btn-small"); | |
button.addEventListener("click", _ => { | |
// Clear unread posts and reload page | |
document.querySelectorAll(".unread").forEach(b => b.click()); | |
window.location.reload(); | |
}); |
This file contains hidden or 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
// ==UserScript== | |
// @name xkcdBot | |
// @author Cameron Bernhardt (AstroCB) | |
// @description A chat bot that spurts bits of wisdom and/or snark. Oh, and xkcd cartoons. | |
// @version 1.3.27 (last updated 02/02/2016) | |
// @namespace http://github.com/AstroCB | |
// @downloadURL https://cameronbernhardt.com/projects/xkcdBot/xkcdBot.user.js | |
// @include *://chat.meta.stackexchange.com/rooms/* | |
// @include *://chat.stackexchange.com/rooms/* | |
// @include *://chat.stackoverflow.com/rooms/* |
This file contains hidden or 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
var web = require("webpage"), | |
numPages = 819; | |
function load(pageNum) { | |
var url = "https://mediaserver.123library.org/9781292152578/svg/" + pageNum + "/206298/1485375389/907fbc6e4ef67c6e160a3d198b836551/"; | |
var page = web.create(); | |
page.open(url, function(status) { | |
if (status === "success") { | |
console.log("Writing page " + pageNum); | |
page.render("Pages/" + pageNum + ".pdf"); |
This file contains hidden or 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
const page = require("webpage").create(); | |
page.open("https://classes.cornell.edu/shared/schedule/SP17/f2447538c565d8b0821840d825a50430", function(status) { | |
console.log("Loaded with status " + status); | |
if (status == "success") { | |
var doc = page.evaluate(function(parse) { | |
parse(document); | |
}, parse); | |
phantom.exit(); | |
} | |
}); |
This file contains hidden or 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
/** | |
Handles JSON in an OO/JavaScript-y fashion | |
# Example usage | |
`let json: JSON = JSON(url: "https://me.com/me.json")` | |
`print(JSON.parse(json.load()))` | |
*/ | |
public struct JSON { |
This file contains hidden or 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 "Spotify" | |
set currentArtist to artist of current track as string | |
set currentTrack to name of current track as string | |
display notification "\"" & currentTrack & "\" by " & currentArtist with title "Now Playing" | |
delay 1 | |
end tell |
This file contains hidden or 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
// This will cause the LED in port D0 to blink softly ("breathe") like the built-in status indicator does when connected to the Internet. | |
// I used a 20 second delay between increments, which seems to be sufficient for a smooth increase or decrease in brightness. | |
// To modify the speed at which the light blinks, change the increment and decrement of output (lines 16 and 24); default is 3 for both. | |
int led = D0; // Attached light | |
int output = 0; // Power to light | |
bool increasing = true; // Decides whether to increase or decrease power to the light | |
void setup() { | |
pinMode(led, OUTPUT); // LED will be used for output (light) |
This file contains hidden or 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
// ==UserScript== | |
// @name Smallcaps.SE | |
// @author Cameron Bernhardt (AstroCB) | |
// @description Automatically changes your Stack Exchange chat messages to Sᴍᴀʟʟᴄᴀᴘs | |
// @version 1.1 | |
// @namespace http://github.com/AstroCB | |
// @include *://chat.meta.stackexchange.com/rooms/* | |
// @include *://chat.stackexchange.com/rooms/* | |
// @include *://chat.stackoverflow.com/rooms/* | |
// ==/UserScript== |
NewerOlder