Skip to content

Instantly share code, notes, and snippets.

@ebrensi
ebrensi / README.md
Last active December 21, 2023 07:43
Sublime Text 3 plugin to select a color scheme for the current tab only

Installation

Put change_tab_color_scheme.py in the folder that opens up when you select Preferences > Browse Packages...

Now you have a command called change_tab_color_scheme that you can access from the command window. You can set a key binding by going to Preferences > Key Bindings

I personally like the "ctrl+k", "ctrl+c" sequence.

@ebrensi
ebrensi / dev-start.sh
Created June 9, 2022 20:46
Bash script to start tmux with
#!/bin/bash
# open a split-window tmux session with
# backend server in one pane and
# parcel watch frontend builder in the other
session="geminae-webdev"
root="~/dev/geminae"
sessionexists=$(tmux list-sessions | grep $session)
@ebrensi
ebrensi / LiveParams.ts
Last active April 15, 2022 19:53
JavaScript (TypeScript) Object extended with onChange method
/**
* An Object with an onChange method and debounced callbacks.
* Example:
* ```
* type P = {name: string, age: number, birthday: Date}
* const live_obj = const watch<P>({ name: "Doctor Foo", age: 43 })
* live_obj.onChange("name", (newVal: string) => { console.log("yo! name=${newVal} now!") })
* ```
* !!! In order for types to work correctly, instantiate a LiveParams object using the `watch<P>()`
* factory function rather than `new LiveParams<P>()`.
@ebrensi
ebrensi / hide-trolls.js
Created September 1, 2021 18:13
Hide posts from certain authors on letsrun.com message forum (https://www.letsrun.com/forum)
/*
* Run this in your browser when you're at https://www.letsrun.com/forum,
* either directly in the console (ctrl-shift-i)
* or via a userscript extension like Tampermonkey
*/
// Author names of trolls you want to hide
toHide = ["troll guy", "other troll"]
document.querySelectorAll(".author-name").forEach(el => {
@ebrensi
ebrensi / README.md
Last active October 29, 2020 19:02
Some mods to jakearchibald/idb-keyval that make it faster

idb-keyval

idb-keyval is a tiny TypeScript library by Jake Archibald that simplifies usage of IndexedDB as a client-side key-value store. His repo includes a few JavaScript builds for different use cases.

idb-keyval-alt.js

I submitted this as a pull-request (see #91) but it appears not much is happening with that repo right now, so here is the essential part of my pull request for anyone to use.

The original idb-keyval opens a new transaction for every (get, set, or del) operation, which is inefficient for performing lots of opertations. One alternative is to use a more full-featured library like IDB or Dexie, which feature batch operations that perform several in the same transaction. This mod maintains the original i

@ebrensi
ebrensi / stylus-rotate.sh
Created May 2, 2019 19:19
Automatic Stylus (Pen) Rotate Orientation
#!/bin/sh
# Automatic stylus (pen) orientation for HP Spectre x360
# adapted by Efrem Rensi
# This is a fix for an apparent bug in Cinnamon whereby System Settings >> General >> Automatic Screen Rotation
# Rotates the screen and touch functionality, but the pen orientation does not rotate
# Based on chadm's script at https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu.
# Receives input from monitor-sensor (part of iio-sensor-proxy package) and sets the touchscreen
# orientation based on the accellerometer positionn. We assume that the display rotation is
@ebrensi
ebrensi / L.Control.fps.js
Created February 20, 2017 07:23
fps display control for leaflet.js
/* fps display control for leaflet*/
/* Efrem Rensi 2017/2/19 */
L.Control.fps = L.Control.extend({
lastCalledTime: 1,
options: {
position: "topright"
},
@ebrensi
ebrensi / extensions.py
Last active June 10, 2016 01:18
Scrapy extension to keep Heroku awake when running scrapyd
import logging
from twisted.internet import task
from twisted.web.client import getPage
from scrapy import signals
from scrapy.exceptions import NotConfigured
logger = logging.getLogger(__name__)