Sunday, December 26, 2021

dotnet 6 raspbian

basado en  https://mycsharpdeveloper.wordpress.com/2021/09/21/installing-net-6-on-raspberry-pi-4-and-get-cpu-temperature-via-c/


wget https://download.visualstudio.microsoft.com/download/pr/d43345e2-f0d7-4866-b56e-419071f30ebe/68debcece0276e9b25a65ec5798cf07b/dotnet-sdk-6.0.101-linux-arm64.tar.gz


mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.101-linux-arm64.tar.gz -C $HOME/dotnet

export DOTNET_ROOT=$HOME/dotnet

export PATH=$PATH:$HOME/dotnet


# Run nano editor to edit the .bashrc

nano ~/.bashrc

# Copy the commands below to the .bashrc

export DOTNET_ROOT=$HOME/dotnet

export PATH=$PATH:$HOME/dotnet

 

# Run this command so the terminal session will use the new settings

source ~/.bashrc

#Crea una app por consola para validar que funciono la instalacion

mkdir hello-DotNet6

cd hello-DotNet6/

dotnet new console


#para ejecutar el hola Mundo

dotnet run 


Saturday, December 25, 2021

broken packages - The following packages have unmet dependencies - E: Broken packages

para el error:

The following information may help to resolve the situation:  The following packages have unmet dependencies:  vlc-bin : Depends: libvlc-bin (= 3.0.12-0+deb10u1+rpt1+arm64) but 3.0.12-0+deb10u1+rpt3 is to be installed  vlc-plugin-skins2 : Depends: vlc-plugin-qt (= 3.0.12-0+deb10u1+rpt3) but 3.0.12-0+deb10u1+rpt1+arm64 is to be installed E: Broken packages 


sudo apt full-upgrade sudo apt dist-upgrade

Friday, December 3, 2021

SSH no funciona raspbian - Failed to start OpenBSD Secure Shell server.

sudo service sshd restart

Job for ssh.service failed because the control process exited with error code.

See "systemctl status ssh.service" and "journalctl -xe" for details.

-- The unit ssh.service has entered the 'failed' state with result 'exit-code'.

Dec 03 20:28:09 pbeltran.ddns.net systemd[1]: Failed to start OpenBSD Secure Shell server.

-- Subject: A start job for unit ssh.service has failed

-- Defined-By: systemd

ssh -t

ssh: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libgssapi_krb5.so.2: invalid ELF header

sudo apt-get install libgssapi-krb5-2 --reinstall

sudo service smbd stop

sudo systemctl disable smbd

sudo reboot

ssh: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libkrb5.so.3: invalid ELF header

sudo apt-get install libk5crypto3 --reinstall

ssh: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libkrb5.so.3: invalid ELF header

sudo apt-get install -y libkrb5-3 --reinstall


descargar un sitio completo en html - Scrape an entire website

 Scrape an entire website 

#linux

wget --recursive --html-extension --page-requisites --convert-links http://website.com


Consider HTTrack. It's a free and easy-to-use offline browser utility.

http://www.httrack.com/


basado

https://stackoverflow.com/questions/9265172/scrape-an-entire-website

Wednesday, November 17, 2021

Secondary DNS Server for DHCP - PI-Hole

Basado en : 

https://discourse.pi-hole.net/t/secondary-dns-server-for-dhcp/1874/4


sudo nano /etc/dnsmasq.d/02-pihole-dhcp.conf

dhcp-option=6,Pi-holeIP,SecondaryDNSIP

sudo service pihole-FTL restart

ejemplo aplicado : dhcp-option=6,192.168.1.2,8.8.8.8

Friday, November 12, 2021

DNS varios

 

156.154.70.22 DNS Comodo firewall

156.154.71.22 DNS Comodo firewall

200.28.4.130 DNS Movistar

200.28.4.129 DNS Movistar


Saturday, July 24, 2021

Detect HTTP or HTTPS then force HTTPS in JavaScript

necesitaba redireccionar una pagina en http a https


 if (location.protocol !== 'https:') {

    location.replace(`https:${location.href.substring(location.protocol.length)}`);

}


https://stackoverflow.com/questions/4723213/detect-http-or-https-then-force-https-in-javascript

Saturday, June 26, 2021

desintalar paquetes en modo debug huawei - remove package debug mode

 #para buscar packetes

# pm list packages | grep craft

pm uninstall -k --user 0 com.appblockgames.freecraftexploration

pm uninstall -k --user 0 com.google.android.youtube

pm uninstall -k --user 0 com.huawei.health

pm uninstall -k --user 0 com.huawei.videoeditor

pm uninstall -k --user 0 com.google.android.videos

pm uninstall -k --user 0 com.android.gallery3d

pm uninstall -k --user 0 com.huawei.gameassistant

pm uninstall -k --user 0 package:com.huawei.appmarket

pm uninstall -k --user 0 com.android.hwmirror

pm uninstall -k --user 0 com.huawei.himovie.overseas

pm uninstall -k --user 0 com.huawei.android.tips

pm uninstall -k --user 0 com.android.calendar

pm uninstall -k --user 0 com.google.android.apps.photos

pm uninstall -k --user 0 com.google.android.apps.maps

pm uninstall -k --user 0 com.huawei.phoneservice

pm uninstall -k --user 0 com.huawei.android.thememanager

pm uninstall -k --user 0 com.huawei.ridemode

Tuesday, June 1, 2021

Optimizar el consumo en RPI

 sudo nano /boot/config.txt

# Disable Bluetooth

dtoverlay=pi3-disable-bt

#deshabilitar los servicios de bluetooth

sudo systemctl disable hciuart.service

sudo systemctl disable bluealsa.service

sudo systemctl disable bluetooth.service


#rpi 4

#apagar hdmi 1, para encender cambiar 0 por 1.
vcgencmd display_power 0 2
#apagar hdmi 2
vcgencmd display_power 0 7

#si queremos bajar el consumo a nivel de CPU
sudo nano /boot/config.txt
arm_freq=1400

Saturday, May 29, 2021

SSH sin password - conectar ssh sin contraseña

#Configura conexiones SSH sin password 

#desde el PC de origen creamos la llave 

ssh-keygen -b 4096 -t rsa

#una vez generada la llave 

ssh-copy-id usuario@servidor.ddns.net

#si se requiere agregar otro puerto distinto al 22 se debe agregar -p puerto

ssh-copy-id usuario@servidor.ddns.net -p 23

#posterior a esto 

ssh usuario@servidor.ddns.net -p 23

#para agregar host dinamicos

ssh-keygen -f "/home/user/.ssh/known_hosts" -R "dominio.ddns.net"

Saturday, May 22, 2021

Correo Python con imagen embebida

 # -*- coding: utf-8 -*-

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email import encoders
 
# Iniciamos los parámetros del script
remitente = 'correo@gmail.com'
destinatarios = ['correoDestino@gmail.com']#,'dest2','dest3']
asunto = 'Correo de prueba - Imagen'
#cuerpo = 'Este es el contenido del mensaje'
cuerpo = 'Hola!<br/> <br/> Este es un <b>e-mail</b> enviando desde <b>Python</b>'
ruta_adjunto = '/home/pi/correo.txt'
nombre_adjunto = 'correo.txt'
 
# Creamos el objeto mensaje
mensaje = MIMEMultipart()
 
# Establecemos los atributos del mensaje
mensaje['From'] = 'correo@gmail.com'
mensaje['To'] = ", ".join(destinatarios)
mensaje['Subject'] = asunto
 
# Agregamos el cuerpo del mensaje como objeto MIME de tipo texto
#mensaje.attach(MIMEText(cuerpo, 'html'))
# We reference the image in the IMG SRC attribute by the ID we give it below
msgText = MIMEText('<b>Some <i>HTML</i> text</b> and an image.<br><img 
src="cid:image1"><br><table class="default">  <tr>    <td>Celda 1</td>    
<td>Celda 2</td>    <td>Celda 3</td>  </tr>  <tr>    <td>Celda 4</td>   
 <td>Celda 5</td>    <td>Celda 6</td>  </tr></table>''html')
mensaje.attach(msgText)

# Abrimos el archivo que vamos a adjuntar
archivo_adjunto = open(ruta_adjunto'rb')
 # This example assumes the image is in the current directory
fp = open('test.jpg''rb')
msgImage = MIMEImage(fp.read())
fp.close()
# Define the image's ID as referenced above
msgImage.add_header('Content-ID''<image1>')
mensaje.attach(msgImage)

# Creamos un objeto MIME base
adjunto_MIME = MIMEBase('application''octet-stream')
# Y le cargamos el archivo adjunto
adjunto_MIME.set_payload((archivo_adjunto).read())
# Codificamos el objeto en BASE64
encoders.encode_base64(adjunto_MIME)
# Agregamos una cabecera al objeto
adjunto_MIME.add_header('Content-Disposition'"attachment; 
filename= %s" % nombre_adjunto)
# Y finalmente lo agregamos al mensaje
mensaje.attach(adjunto_MIME)
 
# Creamos la conexión con el servidor
sesion_smtp = smtplib.SMTP('smtp.gmail.com'587)
 
# Ciframos la conexión
sesion_smtp.starttls()
 
# Iniciamos sesión en el servidor
sesion_smtp.login('correo@gmail.c','TuClave')
 
# Convertimos el objeto mensaje a texto
texto = mensaje.as_string()
 
# Enviamos el mensaje
sesion_smtp.sendmail(remitentedestinatariostexto)
 
# Cerramos la conexión
sesion_smtp.quit()

Monday, March 22, 2021

obtener todas las tablas de una base de datos y ademas contar los registros

  SELECT  name ,CONCAT (  'select count (*),''',name,''' from ',name)

 FROM sysobjects WHERE xtype = 'U' order by name

Sunday, February 21, 2021

noip no-ip.com

basado en https://www.realdroid.es/2016/10/29/configurar-no-ip-para-raspberry-pi-y-de-paso-que-es-no-ip/


sudo apt-get update && sudo apt-get upgrade

mkdir noip

cd noip 

wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

tar -zxvf noip-duc-linux.tar.gz

cd noip-2.1.9-1

sudo make 

sudo make install


contrab -e 

#y agregar 

@reboot /usr/local/bin/noip2

Saturday, January 16, 2021

Wednesday, January 6, 2021

Limpieza

sudo nano limpieza.sh

sudo apt-get clean
sudo apt-get autoclean
sudo dpkg --configure -a
sudo apt-get autoremove -y
sudo apt purge & sudo apt clean -y
sudo apt-get update --allow-releaseinfo-change
sudo apt-get update -y && sudo apt-get upgrade -y

sudo chmod +x limpieza.sh

actualizar la version desde buster a bullseye

https://linuxhint.com/upgrade-raspberry-pi-os-buster-to-bullseye/

primero el apt list y despues full upgrade