Skip to content

Instantly share code, notes, and snippets.

View zentala's full-sized avatar

Paweł Żentała zentala

View GitHub Profile
@zentala
zentala / README.md
Last active November 28, 2023 06:57
@zentala
zentala / TeamViewer-CLI.md
Last active November 28, 2023 05:57
TeamViewer in console (CLI), without GUI

Use TeamViewer without GUI, in pure console mode. That may be helpfull if you need to get easy access to a remote Linux server, that is located behind NAT.

$ cd ~/Downloads/ 
$ wget https://download.teamviewer.com/download/linux/teamviewer_i386.deb 
$ sudo dpkg -i teamviewer_i386.deb 
$ teamviewer help # list of commands, but not all of them, I don't know why 
$ teamviewer info # check TV daemon status and get TV ID $ sudo teamviewer passwd [password] # set new password
@zentala
zentala / 60-i2c-tools.rules
Last active February 21, 2021 03:19
Make I2C acccesible without sudo & preserve that setting
# $ sudo addgroup i2c && sudo usermod -G i2c "$USER"
# $ sudo vim /lib/udev/rules.d/60-i2c-tools.rules
KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
# Device restart required.
# Tested with Ubuntu 20.04 on Raspberry Pi.
#
# https://lexruee.ch/setting-i2c-permissions-for-non-root-users.html
# https://www.raspberrypi.org/forums/viewtopic.php?t=26212
@zentala
zentala / .editorconfig
Created February 3, 2020 10:02
Example editor config file
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
@zentala
zentala / package.json
Last active February 21, 2021 03:20
Node.js HTTP server without coding
{
"name": "simple-server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "node node_modules/http-server/bin/http-server ./public/"
},
"dependencies": {
"http-server": "^0.11.1"
@zentala
zentala / lxc_create_container.sh
Last active February 15, 2024 19:11
Create LXC Ubuntu Bionic privileged container, with SSH server, new passwordless sudo user, with ZSH and oh-my-zsh
#!/bin/bash
# Usage:
# $ chmod +x lxc_create_container.sh
# $ ./lxc_create_container.sh <container-name>
# What this script is doing?
# * Creating new LXC container
# * Making it privileged (giving root permissions)
# * Creating new user (you can configure login and pass below)
@zentala
zentala / simpleDownloadServer.js
Last active January 1, 2023 19:21
Node & Express file downloading in 4 lines!
const app = require('express')()
const path = require('path')
const filePath = path.join(__dirname, 'raport.csv')
app.get('/', (req, res) => res.download(filePath))
app.listen(3000, () => console.log(`Server listening on port 3000!`))
// 1) Locate `node simpleDownloadServer.js` and `raport.csv` in the same directory
// 2) Execute in console `npm init && npm install express`, and then `node simpleDownloadServer.js`
// 3) Open in browser `http://localhost:3000/` in order to download `raport.csv`
@zentala
zentala / formatBytes.js
Created September 27, 2017 11:57
Convert size in bytes to human readable format (JavaScript)
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Usage: