Skip to content

Instantly share code, notes, and snippets.

View Stefan-Code's full-sized avatar

Stefan Kuntz Stefan-Code

View GitHub Profile
@avalonalex
avalonalex / RSA.py
Last active March 6, 2021 10:46
A implementation of RSA public key encryption algorithms in python, this implementation is for educational purpose, and is not intended for real world use. Hope any one want to do computation like (a^b mode n) effectively find it useful.
#!/usr/bin/env python
import argparse
import copy
import math
import pickle
import random
from itertools import combinations
@zhpengg
zhpengg / skip_list.c
Created June 5, 2012 07:52
skiplist implementation in c
/* Skip Lists: A Probabilistic Alternative to Balanced Trees */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#define SKIPLIST_MAX_LEVEL 6
typedef struct snode {
int key;
@KartikTalwar
KartikTalwar / Documentation.md
Last active February 28, 2025 10:57
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@drawveloper
drawveloper / nodejs-ubuntu-bind-port-80.md
Last active September 19, 2024 01:07
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

@avh4
avh4 / btsync.sh
Created October 30, 2013 04:51
startup script for running BitTorrent Sync on Synology NAS
#!/bin/sh
#
# Put this file in /usr/local/etc/rc.d/btsync.sh
case "$1" in
stop)
echo "Stop BitTorrent Sync..."
kill "`cat /volume1/homes/btsync/bin/.sync/sync.pid`"
kill "`cat /volume1/homes/btsync/bin/.sync/sync.pid`"
@sordina
sordina / ocr.sh
Last active September 17, 2018 06:09
Wrapper script for tesseract to output to STDOUT.
#!/bin/sh
if [ ! "$1" ]
then
echo "Usage: ocr <image-file>"
exit
fi
if [ "x$1" = "x-h" ]
then
@internetimagery
internetimagery / dupe.py
Created January 12, 2016 12:54
Move duplicate files into a folder
# put in shebang here
from __future__ import print_function, division
"""
Take all duplicate files from decending directories and move
them into a new folder "Duplicates" in the working directory.
"""
import os
import sys
@stecman
stecman / _readme.md
Last active January 18, 2025 14:31
Brother P-Touch PT-P300BT bluetooth driver python

Controlling the Brother P-Touch Cube label maker from a computer

The Brother PTP300BT label maker is intended to be controlled using the official Brother P-Touch Design & Print iOS/Android app. The app has arbitrary limits on what you can print (1 text object and up to 3 preset icons), so I thought it would be a fun challenge to reverse engineer the protocol to print whatever I wanted.

Python code at the bottom if you want to skip the fine details.

Process

Intitially I had a quick peek at the Android APK to see if there was any useful information inside. The code that handles the communication with the printer in Print&Design turned out to be a native library, but the app clearly prepares a bitmap image and passes it to this native library for printing. Bitmaps are definitely something we can work with.