Skip to content

Instantly share code, notes, and snippets.

import json
import urllib.request
# Chrome's debugging protocol is accessible on localhost port 9222
url = "http://localhost:9222/json"
try:
with urllib.request.urlopen(url) as response:
tabs = json.loads(response.read().decode())
for tab in tabs:
@rcy
rcy / rcirc-pending.el
Last active February 7, 2023 08:14
allow editing messages after they are submitted in rcirc
;;; rcirc-pending.el --- allow editing messages after they are submitted
;; Author: Ryan Yeske <[email protected]>
;; Keywords: comm
;;; annotate.el --- mark up foreign language buffers according to anki deck
;; Copyright (C) 2009 Ryan Yeske
;; Author: Ryan Yeske <[email protected]>
;; Keywords: languages
;; Version: 2009-03-17 23:04:03
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@rcy
rcy / machine.js
Created May 10, 2021 19:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rcy
rcy / machine.js
Last active March 30, 2021 23:29
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@rcy
rcy / rehash.sh
Created August 29, 2020 18:02
Recompute hashes for graphile-migrate migration files
#!/bin/bash
#
# usage: rehash.sh committed/*.sql
#
# This will update each file's Previous and Hash values
#
function sum {
sha1sum | cut -d' ' -f1
}
(defun rcirc-reposition-to-bottom (orig-fun &rest args)
"Reposition the window to put point at bottom line."
(when (and (eq major-mode 'rcirc-mode)
(eq (point) (point-max))
(recenter -1))))
(advice-add 'text-scale-adjust :after #'rcirc-reposition-to-bottom)
(progn
(condition-case nil
(scroll-down 1)
(error nil))
(message "got here"))
;; simpler version of above
(progn
(ignore-errors (scroll-down 1))
(message "got here"))
@rcy
rcy / graphcool.subtest.js
Last active July 20, 2017 17:19
component to test mutation updates and subscriptions on graphql/graphcool
import React, { Component } from 'react';
import { gql, graphql, withApollo, compose } from 'react-apollo';
class Box extends Component {
state = {
mutateCount: 0, // the number of times we have called mutate()
subCount: 0, // the number of times we have received subscription event
};
componentWillMount() {
@rcy
rcy / apolloclient.js
Created May 18, 2017 23:51
apollo client setup for meteor
import { createMeteorNetworkInterface, meteorClientConfig } from 'meteor/apollo';
import { ApolloClient } from 'react-apollo';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
const wsClient = new SubscriptionClient('ws://localhost:5000/', {
reconnect: true,
});
// Create a normal network interface: