Skip to content

Instantly share code, notes, and snippets.

View maltzsama's full-sized avatar
💭
Göteborgs

maltzsama

💭
Göteborgs
View GitHub Profile
yum install tftp-server
vi /etc/xinetd.d/tftp
#Encontre a linha:
disable = yes
#Mude-a para:
disable = no
#Levante o serviço:
/sbin/chkconfig tftp on
@maltzsama
maltzsama / nfsserver.sh
Created April 16, 2013 16:17
Setup of NFS server to work with Mini2440 and Micro2440
#Primeiramente instale os seguintes pacotes necessários para o NFS
yum -y install nfs-utils rpcbind
#Verifique a configuração do arquivo /etc/hosts, ele deverá estar mais ou menos assim:
127.0.0.1 localhost.localdomain magrathea
192.168.0.100 magrathea
#Modifique o arquivo /etc/hosts.denny para o seguinte conteudo
portmap mountd nfsd statd lockd rquotad : ALL
@maltzsama
maltzsama / pyserialsetup.sh
Last active December 16, 2015 07:19
Install pyserial arch linux or ubuntu/debian
#!/bin/bash
x=$(lsb_release -a | grep "Distributor ID:")
if [ ${x:16:6} = "Ubuntu" ] || [ ${x:16:6} = "Debian" ]; then
#Instalar a pyserial no ubuntu/debian
echo "Ubuntu ou debian"
apt-get install python-pyserial
elif [ ${x:16:4} = "arch" ]; then
#Instalar a pyserial no Arch Linux
echo "Arch linux"
pacman -S python-pyserial
@maltzsama
maltzsama / serloop.py
Last active December 16, 2015 07:19
Loopback serial python script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import serial
ser=serial.Serial()
ser.open()
ser.write('test\n')
ser.close()
ser2=serial.Serial('/dev/ttyS0', 19200, timeout=10)
info=ser2.readline()
@maltzsama
maltzsama / macaddress.py
Created April 16, 2013 17:35
mac address python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
fd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
fd.bind(('eth0', 9999))
mac = fd.getsockname()[-1]
print ':'.join(['%02x' % ord(n) for n in mac])
@maltzsama
maltzsama / sqlserverdrive.sh
Last active December 16, 2015 07:19
SqlServer from python with pymssql using Debian or Arch Linux
#!/bin/bash
#Packages
#python, freetds e pymssql
distro=$(lsb_release -a | grep "Distributor ID:")
if [ ${distro:16:6} = "Debian" ]; then
#Install Debian packages
echo "Debian"
apt-get install python freetds-common
apt-get install python-pymssql
@maltzsama
maltzsama / mysqlbkp.py
Created April 16, 2013 19:01
MySQL Backup scrip
#!/usr/bin/env python
#-*- coding:utf-8 -*-
###########################################
# mysqlbkp.py
# Desc: backup script writting python to backup all MySQL databases.
# Autor: Demetrius Albuquerque
# email: [email protected]
# versão: 0.1 data: 08/11/2012
###########################################
@maltzsama
maltzsama / xensnapshot.py
Last active December 16, 2015 07:29
Creation of snapshot on xenserver using python script.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
###########################################
# xensnapshot.py
# Desc: xenserver snapshots
# Author: Demetrius Albuquerque
# mail: [email protected]
# version: 0.1 data: 02/01/2013
###########################################
@maltzsama
maltzsama / MyLiPhpDeb.sh
Last active December 16, 2015 08:19
Setup MySQL + Lighttpd + PHP5 + Debian Squeeze (6.0.5)
sudo su
#1 - Instalacao básica do MySQL
apt-get install mysql-server mysql-client
#Informe uma senha para o usuário root do MySQL
#Password - PASSWORD
#2 - Instalar Lighttpd
apt-get install lighttpd
#As páginas do lighttp devem ficar no /var/www
@maltzsama
maltzsama / user.sql
Created April 17, 2013 14:40
User list of MySQL
SHOW PROCESSLIST;
+----+-------------+----------------------+---------------------+---------+-------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+----------------------+---------------------+---------+-------+-------+------------------+
| 12 | root | 192.168.1.1:52451 | NULL | Query | 0 | NULL | SHOW PROCESSLIST |
+----+-------------+----------------------+---------------------+---------+-------+-------+------------------+
8 rows in set (0.01 sec)
SELECT LEFT(host, IF(LOCATE(':', host), LOCATE(':', host), LENGTH(host) + 1) - 1) AS
host_short,GROUP_CONCAT(DISTINCT USER) AS users,COUNT(*)