Skip to content

Instantly share code, notes, and snippets.

@fvisin
fvisin / tensorflow_rename_variables.py
Last active May 2, 2024 11:51 — forked from batzner/tensorflow_rename_variables.py
Small python script to rename variables in a TensorFlow checkpoint
# Adapted from https://gist.github.com/batzner/7c24802dd9c5e15870b4b56e22135c96
import getopt
import sys
import tensorflow as tf
usage_str = ('python tensorflow_rename_variables.py '
'--checkpoint_dir=path/to/dir/ --replace_from=substr '
'--replace_to=substr --add_prefix=abc --dry_run')
find_usage_str = ('python tensorflow_rename_variables.py '
@plmcgrn
plmcgrn / sonos-udm-mutiple-networks.md
Last active May 2, 2024 11:51
Unifi UDM and Sonos home theater with multiple VLAN's

Overview

This goal of this setup is to put the Sonos speakers on an untrusted network to keep all but the required traffic away from the trusted network where devices like personal computers, phones, etc. live. This write-up assumes you already have two networks setup and working.

Important Note on Unifi OS 3.x

UI broke cross-VLAN multicast DNS in this version. See below for steps to install the multicast-relay script to re-enable this. Without it, your Sonos controller app will not be able to discover your speakers on the other VLAN.

System

I have a Sonos Playbar, Sub, and 2 Play:3's as rear surrounds as one home theater setup connected to a UDM (non-Pro, but this should work on Pro too). Some of this setup may be easier for people with non-paired speakers, as Sonos does some shenanigans with which speaker is actively sending traffic to your wifi.

@L3viathan
L3viathan / atomic_contextmanager.py
Last active May 2, 2024 11:49
Go backwards in time when something went wrong
import os
import sys
import inspect
import signal
from contextlib import contextmanager
def _kill_self(signum, frame):
os._exit(0)
@contextmanager
@saulodias
saulodias / stroke2path.sh
Created July 12, 2022 05:10
Converts SVG files from stroke to path
mkdir -p _output
for i in *.svg
do
inkscape --actions="select-all;selection-ungroup;select-all;selection-ungroup;select-all;object-stroke-to-path;" --export-filename=- $i > _output/$i
echo "done with "$i
done

Have you ever wanted to do:

SELECT * FROM www.google.com

With BigQuery you kind of can. But have you ever wanted to do:

SELECT * FROM www.wikipedia.com

With Wikidata Query Service you kind of can (semantic web!, RDF!?, https://www.w3.org/wiki/SparqlImplementations).

@denguir
denguir / cuda_install.md
Last active May 2, 2024 11:43
Installation procedure for CUDA & cuDNN

How to install CUDA & cuDNN on Ubuntu 22.04

Install NVIDIA drivers

Update & upgrade

sudo apt update && sudo apt upgrade

Remove previous NVIDIA installation

EXPERIMENT 1.
Program for encryption and decryption :
def encrypt(text, shift ):
result =””
for char in text:
if char.isalpha():
if char.islower():
result+= chr((ord(char)-ord(“a”)+shift)% 26+ ord (a))
else:
result+=chr((ord(char)-ord(“A”)+shift) % 26 + ord(“A”))
@fnky
fnky / ANSI.md
Last active May 2, 2024 11:42
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@marcouberti
marcouberti / mock_android_context.java
Last active May 2, 2024 11:43
Mock Android Context using Mockito
import org.mockito.Mock;
import static org.mockito.Mockito.when;
@Mock
private Context mockApplicationContext;
@Mock
private Resources mockContextResources;
@Mock
private SharedPreferences mockSharedPreferences;
cd ~/Library/Android/sdk/platform-tools/
# Get the hash of the mitmproxy-ca certificate.
openssl x509 -inform PEM -subject_hash_old -in ~/.mitmproxy/mitmproxy-ca.pem | head -1
# We will use this hash value, append '.0' (dot zero) and use this as the filename for the resulting Android certificate
cat ~/.mitmproxy/mitmproxy-ca.pem > c8750f0d.0
openssl x509 -inform PEM -text -in ~/.mitmproxy/mitmproxy-ca.pem -out /dev/null >> c8750f0d.0
# In an other terminal, we will start the emulator with writable /system volume