This document copied from https://gist.github.com/abdallahokasha/37911a64ad289487387e2d1a144604ae
here.
Download the package form Robo3t or using wget
declare global { | |
interface SubtleCrypto { | |
timingSafeEqual(a: ArrayBuffer, b: ArrayBuffer): boolean // cloudflare workers has a timingSafeEqual method | |
} | |
} | |
export const generateTOTP = async (secret: string): Promise<string> => { | |
const time = Math.floor(Date.now() / 1000) // get the current time in seconds | |
const timeWindow = 15 * 60 // 15-minute time window | |
const timeStep = Math.floor(time / timeWindow) // calculate the time step |
This document copied from https://gist.github.com/abdallahokasha/37911a64ad289487387e2d1a144604ae
here.
wget
async function getToken(key, options) { | |
let { default: JsSHA } = await import( | |
"https://cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/jssha.js" | |
); | |
options = { | |
period: 30, | |
algorithm: "SHA-1", | |
digits: 6, | |
timestamp: Date.now(), | |
...options, |
__author__ = "Vycktor Stark" | |
""" | |
This is a simple project to run a bot on the telegram via polling (webscraping) without using a module or lib | |
to start the code, after the download, just first insert your bot key to it and run as follows: `python3 main.py` | |
Note: I am aware that it is much more practical to use the / lib module to create the code faster, | |
but the goal of this snippet is to demonstrate an alternative for you to create the code your way | |
""" | |
from threading import Thread | |
import json, requests, re, time |
__author__ = "Vycktor Stark" | |
""" | |
This is a simple project to run your bot on Telegram and receive requests for new events via webhook on your server | |
To be very practical, I am using the / lib flask module to create this project! | |
Where you just need to declare your bot's token and the code itself will import other things, like your host, Instructions: | |
- Declare your bot's token here; | |
- Run the script on your server; | |
- Access your host + webhookstart (example: https://mysite.com/webhookstart) |
<?php session_start(); | |
$siteprot = $_SERVER['REQUEST_SCHEME'] . '://'; | |
$sitehost = $_SERVER['HTTP_HOST']; | |
$siteuri = $_SERVER['REQUEST_URI']; | |
if(!$_COOKIE['SITEINDEX']) { | |
setcookie('SITEINDEX', max(explode('/', dirname($_SERVER['PHP_SELF'])))); | |
$siteindex = '/' . max(explode('/', dirname($_SERVER['PHP_SELF']))) . '/'; | |
} else { |
If you're trying to do this, you came to the right place!
Watch this code work in real time: https://twitter.com/CodingDoug/status/945035556555186176
These instructions assume that you already have a Firebase project, and billing is enabled. Billing is required to use the Vision API.
If your EC2 instances in AWS are managed through Auto Scaling Groups, it is easy to schedule startup and shutdown of those instances, e.g. to save money.
This tutorial walks you through setting up an AWS Lambda function that is triggered by CloudWatch Events and automatically changes the min, max and desired instances in your Auto Scaling Group(s).
The idea is to toggle between 0 (stop
) and a specifed min, max and desired amount of instances (start
), so you only need a single Lambda function. The premise is that you do not touch these Auto Scaling Group settings manually, or you might make your EC2 instances nocturnal.
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) |
module.exports = { | |
config: { | |
// default font size in pixels for all tabs | |
fontSize: 12, | |
// font family with optional fallbacks | |
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace', | |
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk) | |
cursorColor: 'rgba(248,28,229,0.8)', |