Skip to content

Instantly share code, notes, and snippets.

View hypernova7's full-sized avatar
🦀
I love Rust

Eddy Otsutsuki hypernova7

🦀
I love Rust
  • WWW
  • México
View GitHub Profile
Verifying my Blockstack ID is secured with the address 14WhSm3S7GGHWnyY4Y7UNE5YKovppKMUr3 https://explorer.blockstack.org/address/14WhSm3S7GGHWnyY4Y7UNE5YKovppKMUr3
@hypernova7
hypernova7 / build.gradle
Created October 12, 2021 11:28
Build and sign Flutter app with Github Actions
// android/app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
@hypernova7
hypernova7 / index.js
Last active November 7, 2021 21:39
Checking telegram authorization with ExpressJS
const app = require('express')();
const consola = require('consola');
const logger = consola.withTag('tg-check-auth')
app.listen(process.env.PORT)
app.get('/auth', auth)
function auth (req, res) {
let status = 200 // OK code
@hypernova7
hypernova7 / battery-monitor
Created February 20, 2022 05:51
Battery monitor with dunst
#!/bin/bash
# Original source: https://paste.pound-python.org/raw/QHM2XBftWwSti7Pc63JN/
# Batterry monitor with dunst
battery_level=$(acpi -b | sed -n 's/.*\ \([[:digit:]]\{1,3\}\)\%.*/\1/;p')
battery_state=$(acpi -b | awk '{print $3}' | tr -d ",")
battery_remaining=$(acpi -b | sed -n '/Discharging/{s/^.*\ \([[:digit:]]\{2\}\)\:\([[:digit:]]\{2\}\).*/\1h \2min/;p}')
backlight_cmd=$(which light)
_battery_threshold_level="35"
_battery_critical_level="30"
@hypernova7
hypernova7 / parse-md.js
Created June 7, 2022 23:23
Convert Telegram message entities to MarkdownV2
/*
@parseMD function: convert Telegram message entities to MarkdownV2
Based on: https://github.com/butthx/duckbot/blob/036b1681c1a55132490a59a5cc9dea53006d0c99/src/modules/misc.ts#L1456
Especial thanks ♥ to: https://github.com/butthx
*/
function parseMD (text = '', entities = []) {
if (entities.length === 0) return text;
let cache = [];
const res = [];
const styles = {
@hypernova7
hypernova7 / pagination-bot.js
Last active September 11, 2023 05:16
Telegraf pagination bot example
/*
Telegraf pagination bot example
by @hypernova7
Dependencies to install: npm i consola telegraf
*/
import consola from 'consola'
import { Telegraf, Markup, session } from 'telegraf'
@hypernova7
hypernova7 / bot-login.js
Created August 18, 2022 08:32
Telegram bot login example using Telegraf v4 and Express
import 'dotenv/config';
import crypto from 'node:crypto';
import express from 'express';
import cookieSession from 'cookie-session';
import { Markup, session, Telegraf } from 'telegraf';
import consola from 'consola';
const logger = consola.withTag('tg-check-auth');
const bot = new Telegraf(process.env.BOT_TOKEN);
const app = express();
@hypernova7
hypernova7 / bot.js
Last active October 16, 2022 21:52
Telegram OCR Bot
import { Telegraf } from 'telegraf'
import { getTextFromImage, langs } from './ocr'
const bot = new Telegraf(process.env.BOT_TOKEN)
bot.command('ocr', async ctx => {
const reply_to = ctx.message.reply_to_message
const query = ctx.message.text.replce('/ocr', '').trim()
if (query === 'langs') {
@hypernova7
hypernova7 / script.sh
Created December 31, 2022 00:49
Check image updates from Docker Hub
#!/usr/bin/env sh
# Check image updates from Docker Hub
# Credits: Eddy Otsutsuki <https://github.com/hypernova7>
get_image_data() {
curl \
--silent \
"https://registry.hub.docker.com/v2/repositories/$1/tags?page_size=100&ordering=last_updated" | jq \
-r "$2"
}
@hypernova7
hypernova7 / bot.js
Last active September 19, 2023 23:34
telegraf + webhook + ngrok + express
import bot from './setup-bot'
bot.hears('Hi', ctx => {
ctx.reply('Hi there!')
})
export default bot