Skip to content

Instantly share code, notes, and snippets.

require 'openssl'
require 'base64'
# calibrate numbers to get 1s or 10s in solo
N = 48
DATA_SIZE = 600_000
workers_N = 2
# prepare static data set
DATA_ARR = N.times.map do |n|
@dsisnero
dsisnero / spotify-now-playing.js
Created October 27, 2020 04:56 — forked from marco79cgn/spotify-now-playing.js
A Scriptable iOS widget that shows what‘s playing on Spotify
let spotifyCredentials
let widget = await createWidget()
Script.setWidget(widget)
Script.complete()
async function createWidget() {
let widget = new ListWidget()
let spotifyIcon = await getImage("spotify-icon.png")
widget.backgroundColor = new Color("1e2040")
@dsisnero
dsisnero / README.md
Created January 10, 2020 17:34 — forked from savetheclocktower/README.md
Using a rotary encoder as a volume control for the Raspberry Pi

Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.

I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.

@dsisnero
dsisnero / Import Contacts from Slack.js
Created August 2, 2019 18:27 — forked from simonbs/Import Contacts from Slack.js
Scriptable script that imports contacts from Slack. Existing contacts will also have their avatar and social profiles updated. The contacts must have their phone number set in Slack.
// In order to use the script,
// you must create a Slack bot
// with the user:read scope and
// generate an accesss token.
// The script will prompt you
// to copy the access token in.
// The token is stored securely
// in the keychain.
let containers = await ContactsContainer.all()
let contacts = await Contact.all(containers)
@dsisnero
dsisnero / Water Reminder.js
Created August 2, 2019 18:22 — forked from schl3ck/Water Reminder.js
A scriptable script to remind you to drink water and record it. The data gets overridden after 2 days and is lost forever. Features: • Highly customiseable (interval of notifications, repeated notifications if I haven't responded, sound, preset list of how much you want to write down,...) • Works completely in notifications, no need to open the …
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: tint;
/*******************************************
* *
* __ __ _ *
* \ \ / /_ _| |_ ___ _ _ *
* \ \/\/ / _` | _/ -_) '_| *
* ___ \_/\_/\__,_|\__\___|_| *
* | _ \___ _ __ (_)_ _ __| |___ _ _ *
@dsisnero
dsisnero / mdbanalyzer.rb
Created October 16, 2018 23:00 — forked from kinumi/mdbanalyzer.rb
MS-AccessのMDBファイルを解析して適当な相関図を作成します。 (ソーステーブル) => (選択クエリ) => (更新系クエリ) => (ディスティネーションテーブル) ※ソーステーブルとディスティネーションテーブルには同じテーブルが登場する場合があります。
#!ruby -Ku
#coding: utf-8
#
# mdbanalyzer.rb
#
# なにこれ?
# MS-AccessのMDBファイルを解析して適当な相関図を作成します。
#
# (ソーステーブル) => (選択クエリ) => (更新系クエリ) => (ディスティネーションテーブル)
@dsisnero
dsisnero / OCRtoInteract.py
Created October 5, 2018 02:50 — forked from philgruneich/OCRtoInteract.py
Requires Pythonista for iOS and Interact for iOS. Sends image and returns OCR'd text. Opens text in Interact unless used from action extension, then adds to clipboard.
# coding: utf-8
import requests
import photos
from PIL import Image, ImageEnhance
import StringIO
import appex
import console
import json
import keychain
@dsisnero
dsisnero / OCRtoInteract.py
Created October 5, 2018 02:50 — forked from philgruneich/OCRtoInteract.py
Requires Pythonista for iOS and Interact for iOS. Sends image and returns OCR'd text. Opens text in Interact unless used from action extension, then adds to clipboard.
# coding: utf-8
import requests
import photos
from PIL import Image, ImageEnhance
import StringIO
import appex
import console
import json
import keychain
@dsisnero
dsisnero / coroutine_scheduler.lua
Created May 4, 2018 02:18 — forked from Deco/coroutine_scheduler.lua
Lua Coroutine Scheduler
pcall(require,"socket")
local coroutine_scheduler = {
_NAME = "coroutine_scheduler.lua"
_VERSION = "1.0.0",
}
local Scheduler
do Scheduler = setmetatable({}, {
__call = function(class)
require 'tk'
class Pendulum
def initialize
setup
show
@after_id = @root.after(500) {animate}
@canvas.bind('<Destroy>') do
@root.after_cancel(@after_id)