Skip to content

Instantly share code, notes, and snippets.

View coleww's full-sized avatar

Cole Sea coleww

  • (=^.^=)
  • Seatttle, WA
View GitHub Profile
@coleww
coleww / compute-sizes.js
Created March 1, 2024 00:47
Compute responsive sizes
// 1. Paste the first script into the console
// 2. Slowly resize the browser window, covering full range
// 3. Paste the second script into the console
// This could probably be a browser extension that overlays the data on each image...
// SCRIPT ONE
// breakpoint values that we want to calculate `sizes` for
GRAVITY TEST
# BITSY VERSION 6.4
! ROOM_FORMAT 1
PAL 0
0,82,204
128,159,255
255,255,255
@coleww
coleww / downloadAll.js
Last active May 16, 2022 23:33
bandcamp download all purchases
// for use on https://bandcamp.com/download pages.
// once all the download links on the page are loaded,
// open the javascript console, paste the following code in, and hit enter.
// leave the page open until the downloads stop,
// it'll pause for 30 seconds after every click to ensure the last download has started already.
var secs = 30; // adjust as needed for slower connections.
var intervalTime = secs * 1000
var toDownload = [].slice.call(document.querySelectorAll('.downloads a.item-button'));
var interval;
@coleww
coleww / loopy.html
Created June 22, 2016 01:43
looper buddy
<script>
var the_path_to_your_sound_file = "surf.mp3"
var context = new AudioContext();
var playSound = context.createBufferSource();
var getSound = new XMLHttpRequest();
getSound.open("GET", the_path_to_your_sound_file, true);
getSound.responseType = "arraybuffer";
getSound.onload = function() {
context.decodeAudioData(getSound.response, function(buffer){
playSound.buffer = buffer;
@coleww
coleww / spider.js
Created November 10, 2015 16:34
top one hundo itunes
request('http://lyrics.wikia.com/LyricWiki:Top_100', function (error, response, html) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html);
//handle the 'page not found' page?
$('li b a').each(function(i, element){
pages.push('http://lyrics.wikia.com' + $(element).attr('href'))
//
});
console.log(pages)
@coleww
coleww / oui tube .shhhhhh
Last active November 7, 2015 15:01
youtube url 2 mp3
youtube-dl -o "input" https://www.youtube.com/watch?v=someurl && ffmpeg -i input.mp4 output.mp3
@coleww
coleww / isProbablyAMeme.js
Created October 31, 2015 18:34
isProbablyAMeme.js
function isProbablyAMeme(ctx2, w, h) {
// given a ctx, get it's pixel data
var pixels = ctx2.getImageData(0, 0, w, h)
// threshhold filter the pixels. looking for bright white a la bold impact meme text
for (var i = 0; i < pixels.data.length; i += 4) {
var avg = (pixels.data[i] + pixels.data[i + 1] + pixels.data[i + 2]) / 3
var ne = avg > 240 ? 0 : 255
pixels.data[i] = ne
pixels.data[i + 1] = ne
@coleww
coleww / botstats.js
Last active October 25, 2015 18:36
bot stats
var config = require({CONFIG_IN_THE_TTEZEL/TWIT_MODULE_STYLE})
var Twit = require('twit')
var T = new Twit(config)
var fs = require('fs')
var uname = 'YR-TWITTER-USERNAME'
var listSlug = 'THE-SLUG-TO-YR-BOT-LIST'
var theInterval = 5000
// Requests / 15-min window (user auth) // 180
// if yr list has > 180 members, uhhhhh increase theInterval so that it doesn't break 180 in 15 minutes?
@coleww
coleww / happybirthday.js
Last active October 23, 2015 16:01
automagic birthday greeter server thing
var http = require("http")
var url = require("url")
var MemJS = require("memjs").Client
memjs = MemJS.create();
var server = http.createServer(function (req, res) {
var name = url.parse(req.url).pathname.substr(1)
if(!!name) {
doThatThang(name, function (html) {
res.writeHead(200, {"Content-Type": 'text/html', 'Content-Length': html.length});
res.end(html);
@coleww
coleww / bot.js
Created October 22, 2015 13:19
neko_atsume_alert
var config = require('./config') // yr api keys and stuff
var Twit = require('twit')
var T = new Twit(config)
var fs = require('fs')
var $ = require('cheerio')
var request = require('request')
function doThatThang (link, type) {
request(link, function (err, resp, html) {
if (err) return console.error(err)