Skip to content

Instantly share code, notes, and snippets.

View lf-'s full-sized avatar
💭
GitHub 💧🧊

jade lf-

💭
GitHub 💧🧊
View GitHub Profile
#include <SoftwareSerial.h>
const int MD49_RX = 8;
const int MD49_TX = 9;
const int SABER_TX = 10;
const int SABER_UNUSED = 11;
const int CMD_MD49 = 0x01;
const int CMD_SABER = 0x02;
SoftwareSerial md49(MD49_RX, MD49_TX);
#include <SoftwareSerial.h>
const int MD49_RX = 8;
const int MD49_TX = 9;
SoftwareSerial md49(MD49_RX, MD49_TX);
void setup() {
// put your setup code here, to run once:
@lf-
lf- / leftpad.py
Last active October 21, 2024 18:48
leftpad.py
class left_pad:
def __init__(this,PadChar=' ',width=4):
this.PadChar=PadChar
this.width = width
def LeftPad(this,stringToPadWithChar):
charsToPad=this.width-len(stringToPadWithChar)
OutStr=''
if(charsToPad>0):
for i in range(0,charsToPad):
OutStr=OutStr+this.PadChar
import json
import os
import os.path
import platform
import requests
import shutil
import subprocess
import time
@lf-
lf- / fuposix.c
Created April 20, 2017 06:43
Because POSIX behaviour is obnoxious sometimes. A super thin syscall wrapper so posix will never bother us again.
#include <stdio.h>
#include <unistd.h>
#include <string.h>
typedef int (*scfunc)(const char *, const char *);
struct SysCall {
char* name;
scfunc func;
127.0.0.1: =====================================================
127.0.0.1: IPMI 1.5 Get Channel Authentication Capabilities Request
127.0.0.1: =====================================================
127.0.0.1: RMCP Header:
127.0.0.1: ------------
127.0.0.1: [ 6h] = version[ 8b]
127.0.0.1: [ 0h] = reserved[ 8b]
127.0.0.1: [ FFh] = sequence_number[ 8b]
127.0.0.1: [ 7h] = message_class.class[ 5b]
127.0.0.1: [ 0h] = message_class.reserved[ 2b]
@lf-
lf- / screw_dbus.py
Created June 24, 2017 05:30
A hack to get async dbus working (ironically it works with dbus-python, but not pydbus)
# <hack>
# our D-Bus library is missing async :(
# source: https://github.com/LEW21/pydbus/issues/58
def _async_result_handler(obj, result, user_data):
"""Generic callback dispatcher called from glib loop when an async method
call has returned. This callback is set up by method dbus_async_call."""
(result_callback, error_callback, real_user_data) = user_data
try:
ret = obj.call_finish(result)
@lf-
lf- / with_lennyface.py
Created June 28, 2017 20:10
I blame @parrottq for this
import contextlib
@contextlib.contextmanager
def lennyface():
global print
oldprint = print
def new_print(*args, **kwargs):
#newargs = [a.replace(' ', '( ͡° ͜ʖ ͡°)') for a in args]
args = list(args)
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"
a = [1, 2, 3]
%clip a
# will store "[1, 2, 3]"
@lf-
lf- / catanrandom.py
Created July 15, 2017 18:24
A little randomizer script for Settlers of Catan
from __future__ import print_function
import random
board = ['wheat', 'wood', 'sheep'] * 4 + ['rock', 'brick'] * 3 + ['desert']
random.shuffle(board)
slices = [
board[0:3],
board[3:7],
board[7:12],