Skip to content

Instantly share code, notes, and snippets.

@russellbeattie
russellbeattie / get-links.js
Created August 14, 2023 21:30
Grab bookmarks and export as JSON
const https = require('https');
main();
async function main() {
let args = process.argv.slice(2);
let days = parseInt(args[0]) || 14;
let urlStr = 'https://www.cdc.gov/coronavirus/2019-ncov/json/new-cases-chart-data.json';
export default class Router {
constructor(){
this.routes = [];
this.current = null;
}
add(route, handler) {
let re = new RegExp(route + '$');
@russellbeattie
russellbeattie / dwitterish.html
Last active February 22, 2017 03:30
Dwitter.net practice page
<!DOCTYPE html>
<html>
<head>
<title>Dwitterish</title>
<style>
body{
background-color: #fff;
font-family: sans-serif;
}
.container{
@russellbeattie
russellbeattie / throttle.js
Last active August 18, 2016 01:47
A better, self-contained, JavaScript function throttle
function throttle(fn, limit, scope) {
var last;
var deferTimer;
return function() {
var context = scope || this;
var args = arguments;
@russellbeattie
russellbeattie / search-apple-mail-body.js
Created June 1, 2016 01:11
Searches Apple mail Inbox for your name (if your name is Russ - otherwise change that bit) in the latest message and logs out/marks yellow.
#!/usr/bin/env osascript -l JavaScript
function run(argv) {
var Mail = new Application("Mail");
var inbox = Mail.inbox();
var messages = inbox.messages();
@russellbeattie
russellbeattie / getfeed-nolibs.js
Created December 9, 2015 10:09
Just a quick library-free script to grab a feed and parse it
var https = require('https');
var http = require('http');
var url = require('url');
var feedUrl = 'http://www.techmeme.com/feed.xml';
main();
function main(){
@russellbeattie
russellbeattie / aws-twitter-search-bot.js
Last active January 19, 2016 00:42
AWS Lambda Twitter Search Bot... uses S3 for persistence and SNS to send out messages.
var querystring = require('querystring');
var https = require('https');
var aws = require('aws-sdk');
var s3 = new aws.S3();
var sns = new aws.SNS({
region: 'us-east-1'
});
var query = '#SEARCH TERM HERE';
@russellbeattie
russellbeattie / Dispatcher.js
Last active November 5, 2015 06:26
Clean version of Flux Dispatcher
/**
* Copyright (c) 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in
* https://github.com/facebook/flux/blob/master/LICENSE. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
@russellbeattie
russellbeattie / gist:11205288
Created April 23, 2014 07:10
Enabling remote debugging in apps using Cordova targeting Amazon Fire OS
package com.example.helloworld;
import android.os.Bundle;
import org.apache.cordova.*;
public class HelloActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{