Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
tuxmartin / iscsi.md
Last active March 27, 2016 17:44
Debian iSCSI target

Nastaveni serveru

Testovano na:

# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.3 (jessie)
Release:        8.3
Codename:       jessie
@tuxmartin
tuxmartin / README.md
Last active April 4, 2016 11:09
Secure Apache 2.4 with Let's Encrypt on Debian 8.4

Stazeni Let's Encrypt ACME klienta

sudo -s
apt-get install git 
cd /opt
git clone https://github.com/letsencrypt/letsencrypt
cd /opt/letsencrypt
./letsencrypt-auto --apache -d example.com
@tuxmartin
tuxmartin / insert_update.sql
Last active April 4, 2016 12:25
Pokud je nove vkladane cislo vetsi, nez minule, misto INSERT udela UPDATE.
DROP TABLE IF EXISTS test;
CREATE TABLE test (
id int(11) NOT NULL AUTO_INCREMENT,
uptime bigint NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
DELIMITER $$
martin@martin:/tmp$ vim soucet.pyx
martin@martin:/tmp$ cython --embed soucet.pyx
martin@martin:/tmp$ gcc soucet.c -I/usr/include/python2.7 -lpython2.7 -o soucet
martin@martin:/tmp$ strip soucet
martin@martin:/tmp$ ls -lh | grep soucet
-rwxrwxr-x 1 martin martin 23K dub 7 10:07 soucet
-rw-rw-r-- 1 martin martin 89K dub 7 10:07 soucet.c
-rw-rw-r-- 1 martin martin 180 dub 7 10:06 soucet.pyx
martin@martin:/tmp$
martin@martin:/tmp$ ./soucet 5 10
@tuxmartin
tuxmartin / firewall.sh
Created April 7, 2016 12:14
Linux router - NAT
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
@tuxmartin
tuxmartin / busybox_telnet_send_http_post.sh
Last active April 13, 2016 09:31
busybox_telnet_send_http_post
#!/bin/sh
host=10.123.1.1
port=80
ubnt_ifstats=`ubntbox ifstats.cgi`
# nesmi obsahovat binarni data!!!
(
echo open
@tuxmartin
tuxmartin / example.txt
Last active April 13, 2016 12:18
Raspberry Pi - expand partion and filesystem
root@martin:~# fdisk -l /dev/sdb
Disk /dev/sdb: 14.5 GiB, 15523119104 bytes, 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9ed9cab6
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 133119 131072 64M c W95 FAT32 (LBA)
// Kompilace: gcc -o test test.c
#include <stdio.h>
#include <string.h>
int main(void) {
int i;
char nazev[] = "test_";
for (i = 0; i < 5; i++) {

screenshot

Soubor gtkrc.conf ulozit do /home/USER/gtkrc.conf

V ikone Eclipse zmenit prikaz, ktery bude neco jako /home/martin/app/eclipse/cpp-mars/eclipse/eclipse na env GTK2_RC_FILES=/home/martin/gtkrc.conf /home/martin/app/eclipse/cpp-mars/eclipse/eclipse

[Enable suspend and hibernate]
Identity=unix-user:*
#Identity=unix-user:martin
#Identity=unix-user:martin;unix-group:admin
Action=org.freedesktop.upower.hibernate
ResultInactive=no
ResultActive=yes
AllowAny=yes
# /etc/polkit-1/localauthority/50-local.d/allow_all_users_to_upower.pkla