Skip to content

Instantly share code, notes, and snippets.

View hgouveia's full-sized avatar

Jose De Gouveia hgouveia

View GitHub Profile
@hgouveia
hgouveia / gw2.telegram.php
Last active December 10, 2022 17:07
GW2 Trading Post Telegram Notifier
<?php
$GW2_API_KEY = ""; // Get it from https://account.arena.net/applications with 'account', 'tradingpost' scopes
$GW2_API_LANG = "en"; // en, es, de, fr and zh: https://wiki.guildwars2.com/wiki/API:2#Localisation
$TELEGRAM_API_KEY = ""; // Get this from telegram using @BotFather
$TELEGRAM_CHAT_ID = ""; // Search how to get the chatId of your username or use @RawDataBot
$SKIP_IF_ONLINE = true; // if the player is online, wont notify
// Get previous time of check
$CURRENT_TIME = time(); // UTC Time
$LAST_TIME_FILE = "last_check.log";
@hgouveia
hgouveia / number_format.js
Created March 12, 2021 10:59
number_format like is php in javascript
function number_format(value, decimals = 0, decPoint = '.', thousandsSep: string = ',') {
let formatted: string = '';
const formatter = new Intl.NumberFormat(
'de', // this will be ignored
{
style: 'currency',
currency: 'eur', // this will be ignored
minimumFractionDigits: decimals,
maximumFractionDigits: decimals
}
@hgouveia
hgouveia / publisher.js
Last active December 2, 2020 11:13
electron-builder s3 publisher, to be able to triggered it manually reusing a preexisting file
'use strict';
// Alternative version
const { PublishManager } = require('app-builder-lib/out/publish/PublishManager');
const { normalizeOptions } = require('electron-builder/out/builder');
const { Packager } = require('app-builder-lib/out/packager');
const pkg = require('../package.json');
const argv = require('yargs').argv;
const buildFile = argv.file.replace('${version}', pkg.version);
const buildDir = argv.buildDir || './build/';
@hgouveia
hgouveia / profiles.json
Created December 20, 2019 09:05
Cmdr in the new Windows Terminal
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{577c6bb9-9c1a-42b3-93ff-613621d0072a}",
"profiles":
[
{
"guid": "{577c6bb9-9c1a-42b3-93ff-613621d0072a}",
"name": "cmder",
"icon": "G:\\data\\Programs\\cmder\\icons\\cmder.ico",
"commandline": "cmd.exe /K \"G:\\data\\Programs\\cmder\\vendor\\init.bat\" -new_console:d:%USERPROFILE%",
@hgouveia
hgouveia / JWT.server.js
Last active July 25, 2018 09:04
JWT nodejs very simple impl
/**
* Usage:
* const JWT = require('./JWT');
* const payload = {
* 'sub': 1234, // userid
* 'iat': Date().now(), // issued at
* 'exp': Math.floor(Date.now() / 1000) + 86400 // expiration time (1day = 86400)
* };
* const token = JWT.encode(payload, 'my_secret');
* console.log(token);
@hgouveia
hgouveia / Vagrantfile
Created July 20, 2018 09:40
Gitlab vagrantfile with docker
Vagrant.configure("2") do |config|
config.vm.box = "minimal/xenial64"
config.vm.hostname = "gitlab.local"
config.vm.network :private_network, ip: "192.168.10.20"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.network :forwarded_port, guest: 2222, host: 2222
config.vm.provision :docker
config.vm.provision "shell", inline: <<-SHELL
apt-get update
@hgouveia
hgouveia / Vagrantfile
Created June 27, 2018 09:20
Vagrant: Ubuntu GUI Virtualbox
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", 1024, "--cpus", 1, "--vram", 256, "--accelerate3d", "on"]
vb.customize ["setextradata", :id, "GUI/MaxGuestResolution", "any" ]
vb.customize ["setextradata", :id, "CustomVideoMode1", "1024x768x32" ]
vb.customize ["setextradata", :id, "GUI/CustomVideoMode1", "1024x768x32" ]
vb.gui = true
end
config.vm.provision "shell", inline: <<-SHELL
@hgouveia
hgouveia / JWTHelper.js
Last active July 25, 2018 09:04
Very simple helper class to decode JWT token on javscript
"use strict";
export class JWTHelper {
/**
* Decode a JWT token
*
* @static
* @param {string} token
* @throws Error
* @returns object|boolean
@hgouveia
hgouveia / tasks.json
Created February 4, 2018 08:11
Vscode task configuration for Godot 3.0 C#, for running and compiling
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "run",
"type": "shell",
"command": "D:/Godot/bin/Godot.exe --path \"${workspaceRoot}\""
},
@hgouveia
hgouveia / fix_normals.py
Created May 26, 2017 17:52
Blender script for fix normals on selected objects
# Usage:
# 1. Select the objects in blender
# 2. Open a Text Editor view in Blender.
# 3. Press Alt + O, or go to Text>Open Text Block and open the .py file
# 4. Then simply press Run script
import bpy
if bpy.context.selected_objects != []:
for obj in bpy.context.selected_objects:
if obj.type == 'MESH':