Skip to content

Instantly share code, notes, and snippets.

View karnauskas's full-sized avatar
🏠
Working from home

Marius Karnauskas karnauskas

🏠
Working from home
View GitHub Profile
@karnauskas
karnauskas / dhcp_server.py
Created June 22, 2023 05:00 — forked from yosshy/dhcp_server.py
DHCP Server with Python Scapy
from scapy.all import DHCP_am
from scapy.base_classes import Net
dhcp_server = DHCP_am(iface='eth1', domain='example.com',
pool=Net('192.168.10.0/24'),
network='192.168.10.0/24',
gw='192.168.10.254',
renewal_time=600, lease_time=3600)
dhcp_server()
diff --exclude .git -Naur the-algorithm/README.md the-algorithm-2/README.md
--- the-algorithm/README.md 2023-03-31 20:33:20
+++ the-algorithm-2/README.md 2023-04-02 03:56:31
@@ -10,7 +10,7 @@
| Type | Component | Description |
|------------|------------|------------|
-| Feature | [simclusters-ann](simclusters-ann/README.md) | Community detection and sparse embeddings into those communities. |
+| Feature | [SimClusters](src/scala/com/twitter/simclusters_v2/README.md) | Community detection and sparse embeddings into those communities. |
| | [TwHIN](https://github.com/twitter/the-algorithm-ml/blob/main/projects/twhin/README.md) | Dense knowledge graph embeddings for Users and Tweets. |
@karnauskas
karnauskas / init.c
Created March 20, 2023 10:40 — forked from rofl0r/init.c
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@karnauskas
karnauskas / cleanup_swap.md
Created March 16, 2023 14:57 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@karnauskas
karnauskas / now_tv_hg_612_openwrt.md
Created February 27, 2023 03:08 — forked from gzzsound/now_tv_hg_612_openwrt.md
NOW TV configuration for Openreach HG612 + OpenWRT router

I am hoping to save a few hours for people like me who have a modem + router setup and switched to NOW TV ISP.

Extract Client ID and Vendor Class ID from DHCP handshake

  • Connect to the NOW TV router and select "WANOE only" from advanced > router mode
  • With a computer connected to LAN 2, using Wireshark, collect DHCP Client ID and Vendor Class ID (options 60 and 61) (1)
  • Convert those two values to hexadecimal

Configuration for HG 612

@karnauskas
karnauskas / deskew.py
Created December 13, 2021 22:32 — forked from russss/deskew.py
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
/*****************************************
* Read QSee/Zmodo cameras *
* Forward stream to FIFO pipe *
* Author: Daniel Osborne *
* Based on IP Cam Viewer by Robert Chou *
* License: Public Domain *
*****************************************/
/* Version history
* 0.41 - 2013-05-03
@karnauskas
karnauskas / 00README.md
Created November 27, 2021 16:36 — forked from smarek/00README.md
E3372s-153 from Stick mode to HiLink mode automatic installer

E3372s from STICK to HiLink mode installer

You need

  • curl, usb-modeswitch, grep, awk, sudo (not necessary, last step can fail safely)
  • balong_flash in $PATH ( https://github.com/forth32/balongflash.git )
  • atinout in $PATH ( https://github.com/beralt/atinout.git will work fine )
  • 2 files we flash (core sw update version 22.x, WebUI installer), we use these (you can probably use different balong-compatible):
    • core sw: "E3372sUpdate_22.298.03.02.965.BIN" / "E3372sUpdate_22.298.03.02.965.exe"
    • webui: "Update_WEBUI_17.100.06.00.03_Hilink_V7R2_9x25_CPIO.exe"
@karnauskas
karnauskas / androidManifestDecompress.py
Created November 24, 2021 01:14 — forked from i64/androidManifestDecompress.py
decompress androidmanifest file in python
class AndroidXMLDecompress():
endDocTag = 0x00100101
startTag = 0x00100102
endTag = 0x00100103
def decompressXML(self, xml: bytearray) -> str:
finalXml = str()
numbStrings = self.LEW(xml, 4*4)
Mem: 91808K used, 30084K free, 84K shrd, 4692K buff, 24628K cached
CPU: 4% usr 8% sys 0% nic 88% idle 0% io 0% irq 0% sirq
Load average: 0.00 0.00 0.00 2/77 3643
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
3642 3634 root R 1260 1% 8% top
3409 1 root S 668m 561% 0% /root/cloudflared -config /etc/cloudfl
^C