Skip to content

Instantly share code, notes, and snippets.

View hvalls's full-sized avatar

Héctor Valls hvalls

View GitHub Profile
@hvalls
hvalls / auth.go
Created June 5, 2023 11:27
Google token server validation
package auth
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"github.com/golang-jwt/jwt"
const nodemailer = require("nodemailer");
const { google } = require("googleapis");
const OAuth2 = google.auth.OAuth2;
const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;
const refreshToken = process.env.REFRESH_TOKEN;
const from = process.env.FROM;
const to = process.env.TO;
@hvalls
hvalls / books.json
Last active January 11, 2022 16:11
My books
[
{
"title": "Zero Trust Networks: Building Secure Systems in Untrusted Networks",
"authors": "Evan Gilman, Doug Barth",
"picture": "https://images-na.ssl-images-amazon.com/images/I/51FEu6AhMfL._SX379_BO1,204,203,200_.jpg",
"link": "https://www.amazon.com/Zero-Trust-Networks-Building-Untrusted/dp/1491962194/"
},
{
"title": "Defensive Security Handbook: Best Practices for Securing Infrastructure",
"authors": "Lee Brotherston, Amanda Berlin",
@hvalls
hvalls / google_forms.js
Created June 16, 2019 18:22
Get last form response and call webhook
function onFormSubmit(e) {
var url = //TODO;
var formId = //TODO;
var form = FormApp.openById(formId);
var formResponses = form.getResponses();
var formResponse = formResponses[formResponses.length - 1];
var itemResponses = formResponse.getItemResponses();
var data = itemResponses.map(function(item) {
return { id: item.getItem().getId(), text: item.getItem().getTitle(), response: item.getResponse()};
@hvalls
hvalls / add_safari_bookmark.sh
Last active November 23, 2022 07:54
Add Safari bookmark
#!/bin/bash
cd /Users/{user}/Library/Safari
while IFS='#' read -r title url
do
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0 dict"
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary dict"
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary:title string ${title}"
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URLString string ${url}"
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:WebBookmarkType string WebBookmarkTypeLeaf"
@hvalls
hvalls / .gitlab-ci.yml
Created May 2, 2019 14:06
Gitlab CI + Heroku container deploy
#Environment variables: HEROKU_API_KEY, HEROKU_APP
image: ubuntu:bionic
stages:
- deploy
before_script:
# OS dependencies
- apt-get update
@hvalls
hvalls / vault.service
Last active August 9, 2018 07:04
Terraform Configuration: Hashicorp Vault dev server on AWS EC2 instance
[Unit]
Description=Vault dev server
[Service]
Type=simple
ExecStart=/home/ec2-user/vault server -dev -dev-listen-address=0.0.0.0:8200
@hvalls
hvalls / docker-compose.yml
Last active November 23, 2016 09:27
Docker: MariaDB and phpMyAdmin
version: '2'
services:
db:
environment:
- MYSQL_ROOT_PASSWORD=pass
image: mariadb
admin:
links:
- db
ports:
/*
* This is the source code of Telegram for Android v. 3.x.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@hvalls
hvalls / Md5.java
Created April 13, 2016 07:28
MD5 encryption in Android
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
class MD5 {
public String encrypt(String token) {
int RESULT_LENGTH = 16;