Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#!python
# -*- coding: utf-8 -*-
import sys, unicodedata, logging, re, os.path
basepath = os.path.dirname( sys.argv[0] )
sys.path.append( os.path.join( basepath, "pyexcelerator-0.6.4.1.zip") ) # http://sourceforge.net/projects/pyexcelerator/
import pyExcelerator
#!/usr/bin/env ruby
# coding: utf-8
def grep_packages(grep_word)
package_list = `adb shell pm list package`
grep_package_list = package_list.split(/\s+/).map { |line| line.sub(/^package:/, '') }.select { |line| line.include?(grep_word) }
if grep_package_list.size == 1
return grep_package_list[0]
elsif grep_package_list.size > 1
@kamawanu
kamawanu / enc_dec_test.py
Created November 19, 2017 17:32 — forked from justinfx/enc_dec_test.py
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson python-cjson ujson yajl msgpack-python
"""
from timeit import timeit
from tabulate import tabulate
@kamawanu
kamawanu / android.headless.sh
Created January 11, 2018 14:17 — forked from francisdb/android.headless.sh
Android headless sdk update
./android list sdk --all
./android update sdk --no-ui --all --filter 87,81,1,2,3,82,tool,platform-tool

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@kamawanu
kamawanu / ariblib-ubuntu.sh
Last active April 29, 2018 15:18 — forked from youzaka/captiondumper.py
字幕ダンプ
sudo apt install python3-pip
sudo pip3 install ariblib
@kamawanu
kamawanu / ISO3166.py
Created August 10, 2020 20:00 — forked from carlopires/ISO3166.py
Python dict for ISO3166 country codes
# -o- coding: utf-8 -o-
# ISO3166 python dict
# oficial list in http://www.iso.org/iso/iso_3166_code_lists
ISO3166 = {
'AF': 'AFGHANISTAN',
'AX': 'ÅLAND ISLANDS',
'AL': 'ALBANIA',
'DZ': 'ALGERIA',
'AS': 'AMERICAN SAMOA',
@kamawanu
kamawanu / countries_codes_and_coordinates.csv
Created August 12, 2020 14:39 — forked from tadast/countries_codes_and_coordinates.csv
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude
Country Alpha-2 code Alpha-3 code Numeric code Latitude (average) Longitude (average)
Afghanistan AF AFG 4 33 65
Albania AL ALB 8 41 20
Algeria DZ DZA 12 28 3
American Samoa AS ASM 16 -14.3333 -170
Andorra AD AND 20 42.5 1.6
Angola AO AGO 24 -12.5 18.5
Anguilla AI AIA 660 18.25 -63.1667
Antarctica AQ ATA 10 -90 0
Antigua and Barbuda AG ATG 28 17.05 -61.8
@kamawanu
kamawanu / _readme.md
Created December 19, 2020 18:26 — forked from stecman/_readme.md
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.