Skip to content

Instantly share code, notes, and snippets.

View sr105's full-sized avatar

Harvey Chapman sr105

View GitHub Profile
@sr105
sr105 / excerpt.org
Created July 18, 2021 23:13
Embedded Server Installation - DHCP, TFTP, NFS
Network Booting

It saves time during development to boot the kernel and use a networked rootfs from the developer’s machine. It also allows for editing on the host files used live on the target

Two variants: with/without PXE

The device can be statically configured in the boot loader to know it’s IP address and what files to download and how to boot them. OR you can configure a DHCP server to tell the device those steps. The latter is preferred as it moves more of the configuration to the developer’s machine and requires less interaction with U-Boot on the device over the console.

@sr105
sr105 / README.md
Created February 5, 2019 17:59
Same named network for multiple docker compose files

Same Network for Multiple docker-compose files

The A file creates the network. The B file connects to it.

Run

docker-compose -f docker-compose-A.yaml up -d
docker-compose -f docker-compose-B.yaml up -d

Testing what names Docker puts into DNS:

@sr105
sr105 / atoi_strrev.c
Last active October 11, 2018 23:45
C atoi and strrev (for fun)
/* Test:
* gcc -o atoi atoi.c
* ./atoi 12345 123465
* Output:
* Number: 12345 Reverse: 54321 54321 54321
* Number: 123456 Reverse: 654321 654321 654321
*/
#include <stdio.h>
#include <stdlib.h>
@sr105
sr105 / totp.py
Last active September 28, 2018 17:33
TOTP Authenticator Python Implementation
#!/usr/bin/env python3
import time
import urllib.parse
import base64
import hmac
import types
# https://en.wikipedia.org/wiki/Time-based_One-time_Password_algorithm
@sr105
sr105 / woodLength.js
Last active August 30, 2018 16:41
woodLength Javascript Kata
// https://www.codewars.com/kata/how-much-wood/train/javascript
//
// Written for node v8.1.3
//
// nvm install v8.1.3
// nvm use v8.1.3
// node woodLength.js
//
function woodLength(dimensions) {
@sr105
sr105 / gdb_commands
Created September 27, 2017 15:13
gdb sysroot not working
# set sysroot /opt/poky/2.3.1/sysroots/corei7-64-poky-linux
directory /opt/poky/2.3.1/sysroots/corei7-64-poky-linux
set breakpoint pending on
file /work/build-mxencoder-Poky-Debug/mxencoder-test/mxencoder-test
target remote | ssh -T root@192.168.4.52 gdbserver - /opt/mxencoder-test/bin/mxencoder-test
b mxencoder-test.cpp:67
static GstEncodingProfile* create_encoding_profile()
{
// At some point, we might want to allow multiple formats etc.
// FIXME: hook up Configure() parameters here
GstEncodingContainerProfile *container;
GstEncodingVideoProfile *video;
GstCaps *caps, *restr;
caps = gst_caps_new_simple("video/quicktime", "variant", G_TYPE_STRING, "iso", NULL);
container = gst_encoding_container_profile_new(NULL, NULL, caps, NULL);
@sr105
sr105 / gist:66c8dc0a55f8970ff1efd342f3a6ce98
Created July 17, 2017 18:33
gstreamer encode and watch
gst-launch-1.0 -e v4l2src ! video/x-raw,width=3840,height=2160,format=YV12 \
! vaapih264enc bitrate=20000 rate-control=2 ! queue \
! mpegtsmux ! filesink location=file.mp4
gst-launch-1.0 -e v4l2src ! video/x-raw,width=1280,height=720 ! queue ! xvimagesink
@sr105
sr105 / luhn.py
Last active May 25, 2017 19:07
Luhn algorithm
def luhn(cc, debug=False):
double = True
sum = 0
doubled = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
if debug:
print('{:15}{:15}{:15}{}'.format('digit', 'sum digit', 'sum', 'double'))
for n in (int(c) for c in reversed(cc.replace(' ', ''))):
value = doubled[n] if double else n
if debug:
print('{:<15}{:<15}{:<15}{}'.format(n, value, sum, double))
@sr105
sr105 / remote_emacs.sh
Last active June 16, 2017 14:51
Instructions and script for telling a local emacs to open a remote file via ssh while at the remote prompt using iTerm2 triggers
#!/bin/bash
# Don't forget to read the SECURITY WARNING below, and then don't
# say you didn't know.
#######
## Description
#
# tl;dr -- Type `e filename` on a remote host via ssh and your local
# emacs will open the remote file. Don't have the `e` function