Skip to content

Instantly share code, notes, and snippets.

View flourigh's full-sized avatar
🎯
Focusing

Roberto Monteiro flourigh

🎯
Focusing
View GitHub Profile
@VycktorStark
VycktorStark / main.py
Last active August 13, 2020 15:28
Simple bot with polling - TELEGRAM BOT
__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
@VycktorStark
VycktorStark / main.py
Last active June 15, 2020 10:26
Simple bot with webhook - TELEGRAM BOT
__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)
@flourigh
flourigh / logout.php
Created January 25, 2018 16:37
The best logout page for real security for your user.
<?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 {
@CodingDoug
CodingDoug / README.md
Last active October 3, 2020 20:18
Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

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

Setup

These instructions assume that you already have a Firebase project, and billing is enabled. Billing is required to use the Vision API.

@veuncent
veuncent / toggleAutoScalingGroup.md
Last active September 29, 2023 15:56
AWS Auto Scaling Groups: scheduled start/stop

Tutorial: scheduled start/stop of EC2 instances managed by Auto Scaling Groups

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.

Create new Lambda function and Start Event

@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# 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)
@coco-napky
coco-napky / hyper.js
Created March 8, 2017 23:21
Hyper config for git bash in Windows
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)',
@vlucas
vlucas / encryption.js
Last active June 7, 2024 04:27
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@bennadel
bennadel / reduce.js
Created August 18, 2016 11:00
Code Kata: Using Array Reduce() To Navigate An Object Graph In JavaScript
// I am just an arbitrarily non-trivial object to query.
var config = {
tasks: {
interval: {
//...
},
daily: {
backupFilesToS3: {
dayOfWeek: "Saturday",
hour: 22
@krschmidt
krschmidt / head.html
Last active March 2, 2024 20:57
Set Canonical URL via Javascript
<script type='text/javascript'>
var link = !!document.querySelector("link[rel='canonical']") ? document.querySelector("link[rel='canonical']") : document.createElement('link');
link.setAttribute('rel', 'canonical');
link.setAttribute('href', location.protocol + '//' + location.host + location.pathname);
document.head.appendChild(link);
</script>