Skip to content

Instantly share code, notes, and snippets.

@tinti
tinti / guide.md
Created November 24, 2017 20:22 — forked from mikkeloscar/guide.md
Setup armv7h chroot under x86_64 host (Archlinux/Archlinuxarm biased)

Setup armv7h chroot under x86_64 host (Archlinux/Archlinuxarm biased)

Simple way to setup an arm chroot for building packages for your arm devices. This is an alternative to cross-compiling where you are limited to only linking against the libs in your toolchain.

Setup chroot-fs

You can store the chroot wherever you like. I choose to store it in a disk-image which I mount to my filesystem.

umount: device is busy. Why?
There are several reasons why a file system cannot be unmounted. Here are a few of the reasons.
Working directory or file open of a running process
# umount /mnt/test
umount: /mnt/test: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
# lsof /mnt/test/
@tinti
tinti / sshd.go
Created June 20, 2017 22:29 — forked from nictuku/sshd.go
Go SSH server complete example
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/terminal"
@tinti
tinti / capture3_with_timeout.rb
Created June 20, 2017 22:29 — forked from pasela/capture3_with_timeout.rb
[ruby] capture3_with_timeout
# encoding: utf-8
require "timeout"
# Capture the standard output and the standard error of a command.
# Almost same as Open3.capture3 method except for timeout handling and return value.
# See Open3.capture3.
#
# result = capture3_with_timeout([env,] cmd... [, opts])
#
@tinti
tinti / procps-ng-red-text.md
Created May 21, 2017 03:26 — forked from ferdinandhuebner/procps-ng-red-text.md
make the red top from procps-ng display like the old top
@tinti
tinti / main.go
Created March 15, 2017 13:23 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@tinti
tinti / golang-tls.md
Created January 18, 2017 17:48 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@tinti
tinti / ssh-hp1920-enable-cmdline-mode.exp
Created September 16, 2016 16:04 — forked from leonroy/ssh-hp1920-enable-cmdline-mode.exp
SSH to HP 1920 and enable cmdline-mode
#!/usr/bin/expect -f
set timeout 60
set host [lindex $argv 0]
stty -echo
send_user -- "Password for $host: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set password $expect_out(1,string)
@tinti
tinti / expecting.md
Created June 30, 2016 16:13 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@tinti
tinti / js_linux.py
Created April 14, 2016 18:38 — forked from rdb/js_linux.py
Access joysticks/game controllers from Python in Linux via the joystick driver. See https://www.panda3d.org/forums/viewtopic.php?f=8&t=16767
# Released by rdb under the Unlicense (unlicense.org)
# Based on information from:
# https://www.kernel.org/doc/Documentation/input/joystick-api.txt
import os, struct, array
from fcntl import ioctl
# Iterate over the joystick devices.
print('Available devices:')