Skip to content

Instantly share code, notes, and snippets.

@znuh
znuh / mac_eeprom.dts
Created November 19, 2019 18:48
devicetree excerpt for reading a MAC address from an EEPROM
i2c2: i2c@f8024000 {
status = "okay";
id: eeprom@50 {
compatible = "microchip,24c02"; /* actually it's a 24AA025E48 */
pagesize = <16>;
read-only;
reg = <0x50>;
#address-cells = <1>;
@znuh
znuh / gtk_io.lua
Created May 8, 2017 21:10
Gtk with async IO
local lgi = require 'lgi'
local Gtk = lgi.require('Gtk')
local Gio = lgi.require('Gio')
local posix = require "posix"
--Gtk.init()
local window = Gtk.Window {
title = "foo",
Gtk.Label{id="label"}
@znuh
znuh / mk808b.txt
Created May 19, 2016 16:50
MK808B UART
QA5:A;SVN:B72;POC:3FF;STS:0;BOOT:0;INIT:0;READ:0;CHECK:0;PASS:0;
no sdio debug board detected
TE : 24849
BT : 11:27:10 Mar 30 2015
PMU:NONE
##### VDDEE voltage = 0x044c
CPU clock is 792MHz
DDR mode: 32 bit mode
@znuh
znuh / vufine.txt
Created April 30, 2016 17:53
Vufine EDID
get-edid -b 4 | parse-edid
4
This is read-edid version 3.0.2. Prepare for some fun.
Attempting to use i2c interface
Only trying 4 as per your request.
256-byte EDID successfully retrieved from i2c bus 4
Looks like i2c was successful. Have a good day.
Checksum Correct
Section "Monitor"
@znuh
znuh / block_facebook.sh
Created April 7, 2016 15:07
Make Oculus great again
#!/bin/sh
# thanks to koppi!
whois -H -h riswhois.ripe.net -- -F -K -i 32934 | grep -v "^$" | grep -v "^%" | awk '{ print $2 }' | grep -v : | python merge_nets.py > facebook_ranges.txt
cat facebook_ranges.txt
echo "continue?"
read
src="192.168.1.31"
for dst in $(cat facebook_ranges.txt)
do
echo "blocking $src to $dst"
@znuh
znuh / tail_strace.c
Created March 12, 2016 12:17
strace tail -n 200
lseek(3, 0, SEEK_CUR) = 0
lseek(3, 0, SEEK_END) = 410697
lseek(3, 409600, SEEK_SET) = 409600
read(3, "240]: message repeated 3 times: "..., 1097) = 1097
lseek(3, 401408, SEEK_SET) = 401408
read(3, ":08 streator systemd[19120]: Sto"..., 8192) = 8192
lseek(3, 393216, SEEK_SET) = 393216
read(3, ".025488] wlp3s0: authenticate wi"..., 8192) = 8192
lseek(3, 385024, SEEK_SET) = 385024
read(3, " up\nMar 12 08:52:06 streator ker"..., 8192) = 8192
@znuh
znuh / kicad_iogen.lua
Created November 10, 2015 19:21
KiCAD IO generator for schematics symbols
-- example:
--X PA1/LCDDAT1 F6 700 700 200 L 50 50 1 1 I
--X PA0/LCDDAT0/TMS A7 700 800 200 L 50 50 1 1 I
local x_ofs = 900
local y_ofs = 1550
local y_step = -100
local unit = arg[1]
@znuh
znuh / gtofd.c
Created September 11, 2015 20:10
#include <unistd.h>
#include <stdint.h>
#include <sys/time.h>
#include <stdio.h>
int main(int argc, char **argv) {
struct timeval tv1, tv2;
uint64_t t1,t2;
gettimeofday(&tv1, NULL);
@znuh
znuh / gist:8983414
Created February 13, 2014 20:42
list/find function
function list_funcs(p1,p2)
local tbl = _G
local str
if type(p1) == "table" then
tbl = p1
elseif type(p1) == "string" then
str = p1
end
if type(p2) == "string" then
str = p2
@znuh
znuh / ppm_corr.patch
Created March 15, 2013 20:03
ppm correction patch for GQRX
diff --git a/mainwindow.cpp b/mainwindow.cpp
index f1fc9a6..1cacd89 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -307,14 +307,17 @@ bool MainWindow::saveConfig(const QString cfgfile)
*/
void MainWindow::setNewFrequency(qint64 freq)
{
+ double corrected_freq;
+