Skip to content

Instantly share code, notes, and snippets.

View tiagopotencia's full-sized avatar

Tiago Brandão tiagopotencia

View GitHub Profile
sudo apt install python3
sudo apt install python3-pip -y
sudo pip3 install elastalert
cd ~/
git clone https://github.com/Yelp/elastalert.git
sudo pip3 install "setuptools>=11.3"
cd elastalert
sudo python3 setup.py install
sudo pip3 install "elasticsearch>=5.0.0"
cp config.yaml.example config.yaml
@tiagopotencia
tiagopotencia / goodfriday.ts
Created April 10, 2020 20:11
Uma representação em typescript sobre um dos dias mais importantes da humanidade! Jesus está vivo! Boa Páscoa!
import {SonOfGod} from "heaven";
class Human{
sins: Sin[];
guilts: Guilt[];
forgiven: Boolean;
constructor() {
this.forgiven = false;
}
var json = []
var fields = Object.keys(json[0])
var replacer = function(key, value) { return value === null ? '' : value }
var csv = json.map(function(row){
return fields.map(function(fieldName){
return JSON.stringify(row[fieldName], replacer)
}).join(',')
})
csv.unshift(fields.join(',')) // add header column
var videoElement = undefined;
var videoSelect = undefined;
var cameras = [];
jQuery(document).ready(function(){
jQuery('#btn-change-camera').on('click', function(){
changeCamera(cameras);
})
@tiagopotencia
tiagopotencia / httplogger.go
Created January 26, 2018 13:53
HttpLoggerMiddleware
package httplogger
import (
"github.com/gin-gonic/gin"
"time"
"fmt"
"log"
)
func LogRequestInfo(notlogged ...string) gin.HandlerFunc {
@tiagopotencia
tiagopotencia / httplogger.go
Created January 26, 2018 13:53
HttpLoggerMiddleware
package httplogger
import (
"github.com/gin-gonic/gin"
"time"
"fmt"
"log"
)
func LogRequestInfo(notlogged ...string) gin.HandlerFunc {
@tiagopotencia
tiagopotencia / WorkingWithChannels.go
Last active December 12, 2017 21:48
Working with channels in Go
package main
import (
"github.com/gin-gonic/gin"
"fmt"
)
var (
channel chan int
)
@tiagopotencia
tiagopotencia / Convert interface{} to []string
Created August 1, 2017 14:12
Using type assertion we can get the type of an interface{}. Go's already knows that value and says it if you try to make a wrong convertion.
package main
import (
"fmt"
)
func main() {
type interfaceToStringSliceStruct struct {
interfaceToStringSlice interface{}
}
@tiagopotencia
tiagopotencia / GoCDVEnvironmentVariables.js
Last active June 28, 2017 17:10
Fill the Environment variables Form
jQuery("#add_variables").click();
var environmentVariablesDiv = jQuery(".form_content")[0];
var paramList =[
["SETPARAM_param", "value"],
];
var secureList =[
["SETPARAM_param", "value"],
@tiagopotencia
tiagopotencia / detect android or ios
Last active March 27, 2017 16:54
Detects if is Android or IOS. This code is very useful and i don't want to go Stackoverflow every time i need it LOL. Code from: http://stackoverflow.com/a/21742107
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
return "Android";
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return "iOS";