Skip to content

Instantly share code, notes, and snippets.

Avatar
☺️

Bruno Alexandre balexandre

☺️
View GitHub Profile
@balexandre
balexandre / docker_setup.md
Last active Sep 23, 2020
Docker services setup
View docker_setup.md

MySQL/mariaDB with password

docker run -d -p 3306:3306 --name mariadb-pwd -e MYSQL_ROOT_PASSWORD=i-am-root -e MYSQL_USER=db-user -e MYSQL_PASSWORD=db-pass mariadb:latest

MySQL/mariaDB without password

docker run -d -p 3306:3306 --name mariadb -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mariadb:latest
@balexandre
balexandre / f1_viewer_config.json
Created Aug 28, 2020
My F1Viewer configuration
View f1_viewer_config.json
{
"live_retry_timeout": 60,
"preferred_language": "en",
"check_updates": true,
"save_logs": true,
"log_location": "",
"horizontal_layout": false,
"theme": {
"background_color": "#000000",
"border_color": "#0CA597",
View anwser.md

if a website does not provide an API to fetch such information, you need to parse the website HTML and put that data into a file/database somewhere, so in your own website, you can use that data...

for that, you need to create a web scraper to parse the HTML you get from the website ... look at puppeteer and cheerio packages if you want to go with NodeJs

it will end up being something like

const puppeteer = require("puppeteer");
const cheerio = require("cheerio");
@balexandre
balexandre / user.js
Created Apr 9, 2020
A simple Request parser to get user data for auditing
View user.js
const uaParser = require('ua-parser-js');
const requestIp = require('request-ip');
const getUserIpAddress = req => requestIp.getClientIp(req);
const getUserAgent = req => (req && req.headers && req.headers['user-agent'] ? req.headers['user-agent'] : '');
const extractUaData = ua => `${ua.browser.name} | ${ua.browser.major} | ${ua.os.name} | ${ua.os.version}`;
const parseUserAgent = req => {
@balexandre
balexandre / logger.api.js
Created Apr 9, 2020
A simple audit logger
View logger.api.js
const db = require('./../../models');
const logger = require('./../logger');
const utilities = require('./../../utilities');
const logApiCall = (campaignId, engine, options, req, res) => {
try {
const reqInfo = utilities.user.extractRequest(req);
let responseBody = null;
if (res.body) responseBody = JSON.stringify(res.body);
@balexandre
balexandre / auth-aws-cognito.js
Created Mar 20, 2020
AWS Cognito Authentication routes for NodeJs
View auth-aws-cognito.js
const router = require('express').Router()
const AmazonCognitoIdentity = require('amazon-cognito-identity-js')
const cookieParser = require('cookieparser')
const gravatarUrl = require('gravatar-url')
global.fetch = require('node-fetch')
const userPool = new AmazonCognitoIdentity.CognitoUserPool({
UserPoolId: process.env.AWS_COG_USER_POOL_ID, // Pool Id
ClientId: process.env.AWS_COG_CLIENT_ID, // App client id
@balexandre
balexandre / jira.linq
Last active May 26, 2020 — forked from Tempest1000/jira.linq
Jira report with custom fields and hours, html and csv output
View jira.linq
void Main()
{
// -------------------------
// To use this application you must download a copy of Newtonsoft.Json.dll, which by default is not bundled with LINQPad.
// This DLL can be sourced from the NuGet package manager here: https://www.nuget.org/packages/Newtonsoft.Json
// Note the hardcoded path above, this can be changed to the location of the DLL on your hard drive.
// To do this: F4 > browse > choose Newtonsoft.Json.dll
// The password for JIRA shouldn't be stored in plaintext in the script, so add this value to the LINQPad password manager.
// In the password manager give the password the name "Jira Password".
// -------------------------
@balexandre
balexandre / index.js
Created May 9, 2018
AWS Lamdba, node 8.10, add public-read and custom headers to uploaded files on S3 bucket
View index.js
/*
AWS Lambda function: updateS3FilesWithCustomProperties
Runtime: Node.js 8.10
Trigger: S3, Event type: ObjectCreated, "arn:aws:s3:::<your_bucket>
Resources: CloudWatch | Resource: arn:aws:logs:*:*:* | Actions: Allow: logs:CreateLogGroup
Allow: logs:CreateLogStream
@balexandre
balexandre / HttpRequestExtension.cs
Last active Jun 30, 2016
Get real user IP address and browser information (CloudFlare aware)
View HttpRequestExtension.cs
using System.Linq;
using System.Web;
using ServiceStack;
namespace GKO.Library.Extensions
{
public static class HttpRequestExtension
{
// #################################################################
// # Important Note:
@balexandre
balexandre / JsonSchemaToPocos.cs
Last active May 11, 2016 — forked from rushfrisby/JsonSchemaToPocos.cs
Converts a JSON schema to C# POCO classes
View JsonSchemaToPocos.cs
using Newtonsoft.Json.Schema; // nuget: Newtonsoft.Json.Schema (http://www.newtonsoft.com/jsonschema)
class Program
{
private const string Cyrillic = "Cyrillic";
private const string Nullable = "?";
private const string PocoClassPrefix = "MailChimp_";
static void Main()
{
You can’t perform that action at this time.