Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / boot.py
Created December 27, 2019 08:11
実行中のデバイスが M5StickV か UnitV かを調べる
from machine import I2C
i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29)
devices = i2c.scan()
if len(devices)==0:
print("UnitV")
else:
print("StickV")
@HaydenFaulkner
HaydenFaulkner / video_to_frames.py
Last active March 19, 2024 16:37
Fast frame extraction from videos using Python and OpenCV
from concurrent.futures import ProcessPoolExecutor, as_completed
import cv2
import multiprocessing
import os
import sys
def print_progress(iteration, total, prefix='', suffix='', decimals=3, bar_length=100):
"""
Call in a loop to create standard out progress bar
@michimani
michimani / delete_messages.py
Last active April 18, 2022 07:56
Delete old slack messages at a specific channel.
"""Delete old Slack messages at specific channel."""
from datetime import datetime
from time import sleep
import json
import re
import sys
import urllib.parse
import urllib.request
DELETE_URL = "https://slack.com/api/chat.delete"
@lhns
lhns / afterPrintCancelled
Created December 23, 2018 14:44
OctoPrint GCODE Scripts
; disable motors
M84
; disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0
; relative XYZE
@CMCDragonkai
CMCDragonkai / local_https_server_using_stunnel.md
Last active March 8, 2022 04:16
Local HTTPS Server using Stunnel #network #tls

Local HTTPS Server using Stunnel

You want an HTTPS server bound to localhost running in front of a HTTP server. This is pretty much needed if you're working on things that work only in HTTPS, such as HTTPS-only cookies and front end apps dealing with mixed content.

We can do this with Stunnel.

First create a self-signed certificate or acquire one from Let's Encrypt.

@fay59
fay59 / icloud-album-download.sh
Last active November 15, 2024 20:49
Download entire iCloud shared albums
#!/bin/bash
# requires jq
# arg 1: iCloud web album URL
# arg 2: folder to download into (optional)
function curl_post_json {
curl -sH "Content-Type: application/json" -X POST -d "@-" "$@"
}
@sphaero
sphaero / gstreamer-build.sh
Last active February 11, 2023 16:25
Install & build gstreamer from git
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
@abbiekressner
abbiekressner / .octaverc
Created January 29, 2014 02:06
Enable plotting for Octave in iTerm
## The following allows plotting to work within iTerm.app
setenv GNUTERM qt
@ephemeralsnow
ephemeralsnow / gist:6020051
Created July 17, 2013 12:20
fluentd の out_file で出力したファイルを読み込んで in_forward へ投げる
require 'date'
require 'time'
require 'json'
require 'fluent-logger'
logger = Fluent::Logger::FluentLogger.new(nil, :host => '127.0.0.1', :port => 24224)
IO.foreach("fluentd_out_file.log") { |line|
line.scan(/^([^\t]+)\t([^\t]+)\t(.+)$/) { |a|
datetime = DateTime.parse(a[0])
time = datetime.to_time
notify_start_time=0
notify_end_time=0
notify_threshold=10
notify_threshold2=30
notify_prev_command=""
notify_flag=0
function notify_preexec {
notify_flag=1
notify_start_time=`date +'%s'`