Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@gwpl
gwpl / SSH-X11-Forwarding.md
Created December 15, 2011 22:42 — forked from adrianratnapala/SSH-X11-Forwarding.md
A note on X11-Forwarding in SSh.

I used to think that

ssh -X me@some.box

"just bloody worked". However this might not work - ssh must play ball on both sides of the link. On the remote (ssh server, X client) sshd must sit behind some port, tell Xlib to send X11 requests to it and then forward them back to you the X server (where the ssh client is). If the remote box is locked down to prevent this, you will get:

X11 forwarding request failed on channel 0

as part of an otherwise working login. As it happens, I am the admin of the remote box in question, so I followed the ArchWiki and went to /etc/ssh/sshd_config and uncommented

@gwpl
gwpl / LICENSE.The Unlicense
Last active January 24, 2016 14:59
barcodes_labels_test.tex - test of barcodes printing for Emerson 525x25,4mm paper on HP 3525 Ink Advantage. (Before I make repo, let's make it gist. Licence: as it is just LaTeX document, I give it with no warranty to Public Domain, let's use "The Unlicense" license (even more permissive then CC0) following advice on : http://choosealicense.com/…
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
#!/bin/bash
LOGFILE=/home/"${USER?}"/.ssh_last_wrapper_invocation_error.log
SSHHISTORY=/home/"${USER?}"/.ssh_commands_history
ALLOWED_COMMANDS=/etc/ssh/users_configs/"${USER?}"/allowed_commands
if [ "$1" == 'make_files_for_user' ]; then
if [ -z "$2" -o -z "$3" ]; then
echo Usage: $0 make_files_for_user Username Groupname
exit 1
@gwpl
gwpl / only_exec_command.c
Last active April 30, 2016 21:37
It is "pseudo-shell" that will only execute provided -c command. Might be helpful for sshd users configured with "ForcedCommand" and "ChrootDirectory". (example with further references: https://goo.gl/TjhrWd ). License: This is trivial code snippet directly based on documentation and C specification, please consider it public domain.
#include <unistd.h>
// compile with: gcc only_exec_command.c -static -o only_exec_command
// It is "pseudo-shell" that will only execute provided -c command.
// Usage : ./only_exec_command -c /bin/echo This is test
// Please note that this is far from perfect. It should actually parse and split string
// provided in argv[2], like shlex.Split in python. However, it's enought for my application
// of running one binary specified in ForceCommand sshd_config option.
int main(int argc, char **argv){
\documentclass[fontsize=8.5pt]{scrartcl}
% set page size
\usepackage{geometry}
\geometry{
paperwidth = 3.5in,
paperheight = 2in,
margin = 0.15in,
}
@gwpl
gwpl / fstab
Last active May 7, 2016 20:19
sshfs mount config snippets
#/etc/fstab
# remote on remoteY ( remoteY has to be defined in /root/.ssh/config,/home/userX/.ssh/config )
userX@remoteY:/mnt/remoteY/ext4/userX/mount /mnt/remoteY_mount fuse.sshfs noauto,x-systemd.automount,x-systemd.device-timeout=10,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/gwpl/.ssh/id_ecdsa521_sftplenovox230,allow_other,default_permissions,uid=123456789,gid=100,reconnect 0 0
# assuming 123456789 is UID and 100 GID desired of mount
@gwpl
gwpl / standalone_verbatim.tex
Last active May 9, 2016 20:43
standalone_verbatim.tex is parametrized tex template, that genrates cropped pdf containing given text verbatim of given file in monospace. Just compile below, or get some ascii art penguin into penguin.txt (e.g. from: http://chris.com/ascii/index.php?art=logos%20and%20insignias/linux ) and run: $ pdflatex '\def\txtfile{penguin.txt} \input{standa…
% Following standalone configuration: http://tex.stackexchange.com/a/94395/7128
\documentclass[varwidth=\maxdimen]{standalone}
% Usage: pdflatex '\def\txtfile{input.txt} \input{this_document_template.tex}'
% Example pdflatex '\def\txtfile{penguin.txt} \input{standalone_verbatim.tex}'
\usepackage{verbatim}
\begin{document}
% following http://tex.stackexchange.com/a/1495/7128
\ifdefined\txtfile
%
%Specified file: \txtfile
[color]
branch = auto
diff = auto
interactive = auto
status = auto
grep = auto
[alias]
st = status
ci = commit
br = branch
wget -A pdf -c -r -l 1 -nd https://www.raspberrypi.org/magpi-issues/
@gwpl
gwpl / PrintTextFitToLabel.sh
Created August 1, 2016 15:02
# type "My\nmultiline\nlabel" and see it printed on 32x57 mm Dymo 450 via network ;) # based on http://unix.stackexchange.com/a/298020/9689
# type "My\nmultiline\nlabel" and see it printed on 32x57 mm Dymo 450 via network ;)
# based on http://unix.stackexchange.com/a/298020/9689
cd /tmp
read -r -p 'Label:' label && convert -background white -fill black -density 600x600 -size 1346x756 -font 'DejaVu-Sans' -gravity center label:"${label}" label.pdf && xpdf label.pdf && lpr -P DYMO_LabelWriter_450_RPi2_B_1st -o raw -o scaling=100 label.pdf