Skip to content

Instantly share code, notes, and snippets.

View lunhg's full-sized avatar

Guilherme Lunhani lunhg

  • SP
View GitHub Profile
n = 19
points = {x:[],y:[]} for i in [0..n-1]
update = (a, fn) ->
for _n in [0..a.length-1]
for key,val of a[_n]
fn(_n,key,val)
@text a[_n], 10, (_n+1)*(n/@width)
callback = (n, k, v) ->
@lunhg
lunhg / passport-firebase-admin-sdk.coffee
Last active July 11, 2017 17:34
Given a firebase, and populated users, you can start a login request creating a custom token for that access, and then checkout it on client side with web SDK
passport = require('passport')
passport_custom = require('passport-custom')
getAuth = (req) -> new Promise (resolve, reject) -> resolve req.query['email']
passport.use 'firebase-admin-login', new passport_custom (req, done) ->
onErr = (error) ->
console.log error
done error.code, null, message: error.message
@lunhg
lunhg / users.model.js
Last active July 9, 2018 14:47
O problema atual de, ao adicionar um usuário, procurar se ele existe na base de dados. Se não, criar um. Este usuário será administrador se estiver na whitelist de configuração em `config/<config>.json`. Após isso, procuraremos seus dados no id.org, com um cliente OpenId
// users-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
const uuid = require('uuid');
const { Issuer } = require('openid-client');
module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
let table = {
@lunhg
lunhg / index.html
Last active July 16, 2018 16:25
feathers client service + telegram promised bot service
<main class="container">
<h2 class="center-text">Bot</h2>
<script async src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="<Bot username terminated with 'bot'>" data-size="large" data-onauth="onTelegramAuth(user).then(function(res){console.log(res)})" data-request-access="write"></script>
<footer>
</main>
<script type="text/javascript">
console.log("Loading feathers client...")
var app = window.app = feathers();
var rest = feathers.rest('http://<my registered bot domain that must not be you localhost machine but a DNS one>');
app.configure(rest.fetch(window.fetch));
@lunhg
lunhg / Exercicio_1_1.md
Last active March 12, 2020 13:43
Resolução do execício 1.1 do livro Lógica de Programação: a construção de algoritmos e estruturas de dados

Se

Lógica descritiva Lógica Proposicional
Dona branca usa Rosa ou violeta Rosa || Violeta
Dona Rosa usa Branco ou violeta Branco || Violeta
Dona Violeta usa Branco ou Rosa Branco || Rosa

Logo:

@lunhg
lunhg / Exercício 10
Created March 22, 2020 14:28
Script para Exercício 10 da atividade da semana 3 - Univesp
#!/usr/bin/python
from optparse import OptionParser
# PROGRAMA PRINCIPAL
PROG = "fluxograma-10"
VERSION = "0.0.1"
description = "Calcula o fluxograma do exercício 10 da atividade da semana 3"
parser = OptionParser(usage='usage: %prog [OPTIONS, [ARGS]]',
version='%s %s' % (PROG, VERSION),
@lunhg
lunhg / appinventor-install-archlinux.md
Last active May 13, 2024 22:21
Install App-inventor in ArchLinux

Appinventor

Download dependencies

If you use a x86_64 operating system, you will need to install lib32-* packages. For do this you must add multilib sources at /etc/pacman.conf and uncomment these lines:

#[multilib]
#Include = /etc/pacman.d/mirrorlist
@lunhg
lunhg / converte-binario.py
Created March 31, 2020 20:07
Exercicio para converter numero decimal em binário
# Usage: converte-binario.py [OPTIONS, [ARGS]]
# converte um valor decimal para binario
#
# Options:
# --version show program's version number and exit
# -h, --help show this help message and exit
# -d DECIMAL, --decimal=DECIMAL
# PROGRAMA PRINCIPAL
PROG = "converte-binario"
@lunhg
lunhg / iching.py
Created April 2, 2020 21:41
CLI for consult iching's hexagrams and its mutations with a simulation of coin method
from optparse import OptionParser
import os
import datetime
import hashlib
import base58
import binascii
import hmac
# PROGRAMA PRINCIPAL
PROG = "iching"
#!/bin/bash
# @about: Este script é um exemplo didático para observar como é carregada uma variável de ambiente.
# @usage: Existe o uso correto e incorreto. Para fins didáticos, use primeiro o incorreto e depois o correto
# @incorrect_usage:
# $> ./env_var_script_visibility.sh
# @correct_usage:
# $> TESTE=valor
# $> export TESTE
# $> ./env_var_script_visility.sh