Skip to content

Instantly share code, notes, and snippets.

@jeffeb3
jeffeb3 / gist:c12db4e4c2646ec68ac9
Created January 16, 2015 23:20
How to print the time in python.
#!/usr/bin/env python
import time
print time.time()
@jeffeb3
jeffeb3 / .Xmodmap
Created January 29, 2016 00:08
Xmodmap for mimicking pok3r keyboard layer.
! Trying to F*** with my keyboard.
!
! The theory is that if I make the caps lock be the "Mode_switch" key,
! then I can change what happens for each key when I press the "Mode_switch" key.
!
! I'm not using the "Mode_switch" key anyway...
!
! This will make the caps lock be the "Mode_switch" key.
clear Lock
@jeffeb3
jeffeb3 / slack_utils.py
Created September 29, 2016 21:48
Post to slack from a MicroPython (esp 8266, version 1.8.4)
def slack_it(msg):
''' Send a message to a predefined slack channel.'''
import urequests
# Get an "incoming-webhook" URL from your slack account. @see https://api.slack.com/incoming-webhooks
URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
headers = {'content-type': 'application/json'}
data = '{"text":"%s"}' % msg
@jeffeb3
jeffeb3 / AnalogMqtt.cpp
Created November 9, 2017 17:58
Example for the ESPBackBone library I'm writing
#include <ESP32BackBone.h>
double value1(0.0);
double value2(0.0);
// Converts the voltage value to 0-100 (used in the display code)
double progress(double inValue)
{
const double MIN = 0.0;
const double MAX = 3.3;
@jeffeb3
jeffeb3 / rpm_test.ino
Last active February 16, 2018 03:53
Measure RPM from a piece of tape spinning on a fast thing.
// These aren't special, just use ints.
const int IR = 4;
const int PHOTO = 2;
// These are coming from the "micros()" function, so that dictates an unsigned long
volatile unsigned long rpm_value;
volatile unsigned long prev_rpm_time = 0;
volatile unsigned long current_rpm_time = 0;
float rpmmath;
float smooth_rpm = 0.0; // Be sure you initialize this.
@jeffeb3
jeffeb3 / median.cpp
Created June 2, 2018 20:29
Simple functions to calculate medians from doubles.
#include "median.h"
#include <string.h>
// Storage for the input to the median filter.
double data[MEDIAN_FILTER_SIZE];
double median_data[MEDIAN_FILTER_SIZE];
// Pointer to the next element in the median filter. Not very safe programming!
double* pNextDataInput = data;
@jeffeb3
jeffeb3 / winer.html
Last active December 31, 2018 23:24
Trying out a wine scoring thing using react and boostrap but not using npm...
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Flask React</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- styles -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
#!/bin/python3
#
# A little python script that can act enough like a Marlin printer to test out a UART screen.
# I connected it to the screen with an FTDI. It connects at /dev/ttyUSB0
import serial
import time
class Screen(object):
def __init__(self, port, speed):
@jeffeb3
jeffeb3 / screen-test.py
Created December 28, 2020 06:55
TFT Marlin Simulator
#!/bin/python3
import serial
import time
class Screen(object):
def __init__(self, port, speed):
self.serial = serial.Serial(port, speed, timeout=0.05)
print("Opened on port: {}".format(self.serial.name))
self.x = 10.0
#!/bin/sh
#
# Write/remove a task to do later.
#
# Select an existing entry to remove it from the file, or type a new entry to
# add it.
#
file="$HOME/.todo"
touch "$file"