Skip to content

Instantly share code, notes, and snippets.

View Chak10's full-sized avatar
🏠
Working from home

Chak10

🏠
Working from home
View GitHub Profile
@Chak10
Chak10 / led.txt
Created September 5, 2020 10:19
LED RESISTOR
GIALLO -> 2.2K
VERDE -> 20K
ROSSO -> 3.3K
from decimal import *
n = 1e4
def factorial(n):
fact = 1
for i in range(1, int(n) + 1):
fact = fact * i
return fact
@Chak10
Chak10 / sodium_encrypt.php
Created June 13, 2019 17:41
Encrypt-decrypt string with Sodium
<?php
function encrypt($message, $pass)
{
$alg = SODIUM_CRYPTO_PWHASH_ALG_DEFAULT;
$opslimit = SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE;
$memlimit = SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE;
$final = $salt = openssl_random_pseudo_bytes(SODIUM_CRYPTO_PWHASH_SALTBYTES);
$secret_key = sodium_crypto_pwhash(SODIUM_CRYPTO_SECRETBOX_KEYBYTES, $pass, $salt, $opslimit, $memlimit, $alg);
$final .= hash_hmac('sha3-256', $message, $secret_key, true);
@Chak10
Chak10 / openweatherapi.php
Last active August 17, 2018 13:37
Current condition
<?php
class OpenWeatherMap
{
var $api;
/**
* OpenWeatherMap constructor.
* @param $a
*/
@Chak10
Chak10 / altitude.py
Last active June 27, 2018 13:55
BMP280 + example
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests
from bmp280 import *
geo = "" #coordin sea
d_api = "" #api darksky
@Chak10
Chak10 / rapidgator_api.php
Last active October 26, 2023 11:39
Class based on Rapidgator Api
<?php
class Rg {
/*
Based on Rapidgator Api
https://support.rapidgator.net/index.php?/Knowledgebase/Article/View/89/9/do-you-have-api
*/
@Chak10
Chak10 / bme280.py
Last active June 21, 2017 07:49
Weather Python
#!/usr/bin/python
#--------------------------------------
# ___ ___ _ ____
# / _ \/ _ \(_) __/__ __ __
# / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/ /_/___/ .__/\_, /
# /_/ /___/
#
# bme280.py
#
@Chak10
Chak10 / curl.php
Last active June 9, 2017 21:04
CURL MEGA CLASS PHP
<?php
namespace Curl;
class Curl {
const VERSION = '7.3.0';
const DEFAULT_TIMEOUT = 30;
public $curl;
public $id = null;
@Chak10
Chak10 / cookie.js
Last active June 5, 2017 19:07
Gestione Cookie Javascript
@Chak10
Chak10 / randomDarkColor.js
Last active December 9, 2023 06:04
Javascript Random Dark Color
function randDarkColor() {
var lum = -0.25;
var hex = String('#' + Math.random().toString(16).slice(2, 8).toUpperCase()).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
var rgb = "#",
c, i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);