Skip to content

Instantly share code, notes, and snippets.

@cmur2
cmur2 / TTN Decoder TrackerD 1.4.3.js
Last active June 7, 2023 21:14
TTN Decoder for Dragino TrackerD (reformatted)
function decodeUplink(input) {
var bytes = input.bytes;
var port = input.fPort;
function getLatitude() {
return (bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3])/1000000; // gps latitude,unit: °
}
function getLongitude() {
return (bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7])/1000000; // gps longitude,unit: °
@cmur2
cmur2 / tfsec-ignore.py
Last active February 3, 2022 13:09
Automatically add TFSec ignore comments to onboard new Terraform code bases gracefully.
#!/usr/bin/env python3
# A script that processes TFSec JSON output (via stdin) and automatically adds
# TFSec ignore comments to all affected locations. This allows to onboard a new
# Terraform code base to TFSec gracefully:
#
# 1. run tfsec-ignore.py to quickly add ignore comments for existing problems
# 2. integrate TFSec into your CI pipeline to avoid introducing new problems
# 3. over time fix existing problems in the code base
#
@cmur2
cmur2 / my-npt-dhcp6c-script
Last active September 1, 2021 13:51
Script for dhcp6c to handle IPv6 network prefix translation as described in https://blog.altimos.de/2016/11/isolating-your-home-ipv6-network-with-nptv6-on-edgerouter-lite/
#!/bin/bash
INSIDE_PREFIX="fdxx::/64"
OUTSIDE_INTERFACE="eth2"
DUMMY_INTERFACE="dummypd0"
OUTSIDE_PREFIX_FILE="/var/run/my-npt-outside-prefix"
logger -p info -t my-npt "my-npt-dhcp6c-script invoked"
OLD_OUTSIDE_PREFIX=""
#!/usr/bin/expect
set timeout 20
set name [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
spawn telnet $name
expect "login: "
send "$user\n"
@cmur2
cmur2 / gist:4356018
Created December 21, 2012 21:40
anti-NoScript XSS entry for printfriendly.com
^http://pdf\.printfriendly\.com/pdfs/make
@cmur2
cmur2 / material_renamer.rb
Created August 25, 2012 13:09
Sketchup MaterialRenamer
# License: 2-clause BSD
require 'sketchup.rb'
class MaterialRenamer
def initialize
am = Sketchup.active_model
sel_faces = am.selection.select { |e| e.typename == 'Face' }
sel_materials = sel_faces.collect { |f| f.material }.uniq
@cmur2
cmur2 / point2coords.rb
Created August 25, 2012 13:08
Sketchup PointCoordinates tool
# License: 2-clause BSD
require 'sketchup.rb'
class PointCoordinatesTool
def initialize
end
def activate
@last_pos = Sketchup::InputPoint.new
@cmur2
cmur2 / diff.rb
Created October 9, 2011 20:06
Ruby command line diff based on Diff::LCS
#!/usr/bin/ruby -Ku
DEBUG = false
require 'rubygems'
require 'diff/lcs'
class OO
def green; "\e[42m\e[1;37m" end
def red; "\e[41m\e[1;37m" end
@cmur2
cmur2 / options.md
Created October 4, 2011 18:33
Firefox options

browser.urlbar.formatting.enabled = false

browser.urlbar.maxRichResults

browser.urlbar.trimURLs = false

gfx.font_rendering.cleartype_params.rendering_mode = 0

0 = default, 1 = aliased, 2 = GDI Classic, 3 = GDI Natural, 4 = Natural, 5 = Natural Symmetric