Skip to content

Instantly share code, notes, and snippets.

View ggrandes's full-sized avatar
🛠️
I may be slow to respond.

G.Grandes ggrandes

🛠️
I may be slow to respond.
View GitHub Profile
/*
* This file is an MPU6050 demonstration.
* https://openest.io/en/2020/01/21/mpu6050-accelerometer-on-raspberry-pi/
* Copyright (c) 2020 Julien Grossholtz - https://openest.io.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
import datetime
from telethon import TelegramClient
api_id = 123456789
api_hash = 'abcdef123456789'
client = TelegramClient('session_name', api_id, api_hash)
client.session.report_errors = True
client.start()
@zoilomora
zoilomora / README.md
Last active April 25, 2024 08:17
How to disable systemd-resolved in Ubuntu

How to disable systemd-resolved in Ubuntu

Stages

  • Disable and stop the systemd-resolved service:

      sudo systemctl disable systemd-resolved.service
      sudo systemctl stop systemd-resolved
    
  • Then put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf:

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r <session_name>
@jesusbmx
jesusbmx / java-exe.md
Last active January 15, 2022 16:12
Crear exe de java

Crear un instalador de java

Estructura de archivos:

  1. Carpeta [NombreApp] carpeta raíz.
    • Carpeta app contiene todos los archivos de la aplicación.
      • Carpeta bin/jre1.8.0_161 contiene el JDK de Java
    • Carpeta res contiene todos los recursos.
      • Carpeta Output contiene el futuro instalador.
      • Archivo launch4j.manifest archivo manifiesto de launch4j.
  • Archivo Setup.iss Configuración del programa Inno setup.
# Custom history configuration
# Run script using:
# chmod u+x better_history.sh
# sudo su
# ./better_history.sh
echo ">>> Starting"
echo ">>> Loading configuration into /etc/bash.bashrc"
echo "HISTTIMEFORMAT='%F %T '" >> /etc/bash.bashrc
echo 'HISTFILESIZE=-1' >> /etc/bash.bashrc
@judepereira
judepereira / CcsClient.java
Created March 31, 2017 09:28
XMPP/CCS client for FCM/GCM, using Smack 4.2
import com.mongodb.BasicDBObject;
import com.mongodb.util.JSON;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.StandardExtensionElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.Roster;
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active May 2, 2024 06:51
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@chrisveness
chrisveness / crypto-pbkdf2.js
Last active December 21, 2023 19:20
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*