Skip to content

Instantly share code, notes, and snippets.

View AstroCB's full-sized avatar
👀

Cameron Bernhardt AstroCB

👀
View GitHub Profile
@AstroCB
AstroCB / LinkFormatter.js
Created November 1, 2014 18:32
Puts links in the format "-hyperlinked_title (source)" and outputs HTML source
var title = "empty";
var url = "empty";
var source = "";
var i = 0;
var j = 0;
var webData = {};
var sources = [];
var finalData = "";
@AstroCB
AstroCB / CleanYourListen.user.js
Last active June 4, 2020 08:06
Clean up YourListen podcast service
// ==UserScript==
// @name Clean Up YourListen
// @namespace http://greasyfork.org/
// @include http://yourlisten.com/*
// @description Remove YourListen cruft
// ==/UserScript==
window.addEventListener("load", function () {
var classes = ["a_tabs", "ad-trackeable", "fbLeft", "navbar-inner", "ad-pad-sm"];
var ids = ["social", "audio_sdb", "f"];
@AstroCB
AstroCB / showGrades.user.js
Created May 10, 2015 22:33
Show numerical grades that teachers have hidden on BCPS One
// ==UserScript==
// @name Show Hidden Grades
// @namespace http://github.com/AstroCB
// @author Cameron Bernhardt
// @description Show numerical grades that teachers have hidden on BCPS One
// @version 1.0
// @include *://bcpsone.bcps.org/student/?*
// ==/UserScript==
var grades = document.querySelectorAll("a .hidden");
for (var i = 0; i < grades.length; i++) {
@AstroCB
AstroCB / smallcaps.user.js
Last active June 4, 2020 08:05
Automatically changes your Stack Exchange chat messages to Sᴍᴀʟʟᴄᴀᴘs
// ==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==
@AstroCB
AstroCB / softblink.ino
Last active August 29, 2015 14:23
Blinks a light softly by scaling analog values (demo at http://i.imgur.com/dz3ZJUF.gif)
@AstroCB
AstroCB / SpotifyInfo.scpt
Created July 23, 2016 03:21
Displays a notification containing information about the currently playing Spotify track (works best when assigned to a keyboard shortcut)
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
@AstroCB
AstroCB / json.swift
Created September 5, 2016 20:19
A snippet that makes working with JSON in Swift a little less painful using JS-like syntax.
/**
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 {
@AstroCB
AstroCB / classes.js
Created January 12, 2017 06:29
An example PhantomJS script for pulling class data from a schedule webpage.
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();
}
});
@AstroCB
AstroCB / loadBook.js
Last active June 4, 2020 08:02
Scrapes public book pages and converts them to PDF.
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");
@AstroCB
AstroCB / xkcdBot.user.js
Created April 5, 2017 21:54
A bot in the form of a userscript that runs in Stack Exchange chat rooms.
// ==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/*