Skip to content

Instantly share code, notes, and snippets.

View hiszpanski's full-sized avatar
🤔
Thinking deeply

Chris Hiszpanski hiszpanski

🤔
Thinking deeply
View GitHub Profile
@hiszpanski
hiszpanski / gambler.py
Created August 17, 2022 07:21
Sutton & Barto Gambler Problem
from decimal import *
import matplotlib.pyplot as plt
"""
Curiously, the policy does not match the textbook. This may be due to
numerical precision, or ties.
"""
p = Decimal('0.4')
θ = Decimal('1e-50')
<html>
<body>
<video id="remoteVideo" autoplay muted playsinline></video>
<script src="alohasdk.js"></script>
<script>
alohasdk.Call({
deviceId: "xxxxxxxx",
authToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
remoteVideo: remoteVideo,
}).then((pc) => {
@hiszpanski
hiszpanski / asound.state
Created February 24, 2019 09:28
alsamixer settings for Google AIY Voice Bonnet. Place in /var/lib/alsa/
state.ALSA {
control.1 {
iface MIXER
name 'PCM Playback Volume'
value -2000
comment {
access 'read write'
type INTEGER
count 1
range '-10239 - 400'
@hiszpanski
hiszpanski / sighttool.py
Last active March 2, 2017 02:13
Simple tool for pulling images from an S3 bucket and cropping them
"""
Tool for fetching and cropping sight images
"""
import boto3
import os
import sys
# S3 client
s3 = boto3.client('s3')
@hiszpanski
hiszpanski / rdsfetch.py
Last active February 9, 2017 22:36
Fetch RDS log files via command line
"""Fetch RDS log file via command line
AWS deprecated their RDS command-line utility, and the AWS CLI only includes
a subcommand for downloading portion of log file. This downloads full log
file, so that it may be analyzed in say pgbadger, for example:
pgbadger -A 1 -a 1 -j 4 --prefix '%t:%r:%u@%d:[%p]:' \
--log-duration --outfile postgresql.log-2017-02-09-07.html \
postgresql.log.2017-02-09-07
"""
@hiszpanski
hiszpanski / cameo.tcl
Last active September 15, 2020 04:49
Expect script, run by udev, to get camera serial number
#!/usr/bin/expect -f
##############################################################################
#
# cameo.tcl
# Expect script. Queries camera serial number via serial port and returns it.
#
# When a camera is connected, it enumerates as a serial device on the machine,
# for example /dev/ttyACM0. This is dependent on the order in which cameras
# connect, and as there is no identifying information in the USB descriptors,
@hiszpanski
hiszpanski / transcode.py
Created September 25, 2014 04:38
Transcoding boto example
#!/usr/bin/env python
#
# transcoder.py
#
# Transcodes .ts into .mp4
#
# Copyright 2014 Kuna Systems Corporation. All rights reserved.
#
@hiszpanski
hiszpanski / usblog.c
Created August 2, 2014 10:45
Prints vendor and product ids of USB devices as they are added
//
// main.c
// usblog
//
#include <assert.h>
#include <stdio.h>
#import <IOKit/usb/IOUSBLib.h>
@hiszpanski
hiszpanski / twentyfour.py
Last active February 27, 2022 07:48
Solver for the game 24
#!/usr/bin/env python
#
# Plays the game 24: Given 4 numbers that must each be used exactly once, and
# the four basic arithmetic operators (addition, subtraction, multiplication,
# division) than may be used any number of times, finds an expression that
# evaluates to 24.
#
# Copyright 2012 Chris Hiszpanski. All rights reserved.
#
# History:
@hiszpanski
hiszpanski / convert_to_mp3.py
Created October 29, 2012 22:26
Bulk transcoding of files to MP3 using multiple cores and FFMPEG
#!/usr/bin/env python
"""
Transcodes list of audio files specified as command-line arguments into
standard MP3s.
Actual transcoding is done via a subprocess call to ffmpeg. If multiple
cores are available, transcoding is parallelized via a pool of workers, each
of which transcodes one file at a time.
"""