Skip to content

Instantly share code, notes, and snippets.

View lucis's full-sized avatar
🇧🇷
I can't describe what's happening

Lucis lucis

🇧🇷
I can't describe what's happening
View GitHub Profile
package adt.splaytree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import adt.bt.BTNode;
public class TreePrinter {
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BTreePrinterTest {
private static Node<Integer> test1() {
Node<Integer> root = new Node<Integer>(2);
Node<Integer> n11 = new Node<Integer>(7);
Node<Integer> n12 = new Node<Integer>(5);
@lucis
lucis / CRNparaWAR.js
Last active July 5, 2018 21:46
Converte relatórios do SisDM para o War (quase)
if (!window.jsPDF) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://unpkg.com/jspdf@latest/dist/jspdf.min.js";
document.head.appendChild(script);
}
function arrayBufferToBase64(buffer) {
var binary = "";
var bytes = [].slice.call(new Uint8Array(buffer));
@lucis
lucis / PopulaHorarioCCC.js
Created July 31, 2018 16:38
Script para Google Planilhas para processar um CSV sobre dados de aulas e popular uma planilha personalizada da coordenação
// Google Scripts não suporta ES6 ;(
/**
* Script para preenchimento da planilha de Horários para o curso de Computação na UFCG, a partir de um CSV com os dados.
*
* Abaixo devem se colocados os nomes das planilhas onde estão os dados e onde deverá ficar o horário processado.
* Também o range de celúlas que o script irá limpar antes de realizar o processamento.
*
* Modelo da planilha: bit.ly/horario20182
*
@lucis
lucis / prova.MD
Created June 27, 2019 01:07
3a Prova de Compila
  1. Transformar para Assembly. Ele informa que o tamanho do main tá numa "variável" chamada mainsize e do método m1 no m1size, se não me engano. Seguinte código (a da outra turma era um if else ao invés do Switch) :
//main
int dia = 0
call m1

switch (dia) {
@lucis
lucis / fetch-and-parse.js
Created August 13, 2019 19:56
Fetchs a ISO-8859-1 HTML page and parse it
const fetchAndParse = url => fetch(url)
.then(response => response.arrayBuffer())
.then(buffer => { const decoder = new TextDecoder("ISO-8859-1"); return decoder.decode(buffer) })
.then(content => { const parser = new DOMParser(); return parser.parseFromString(content, 'text/html') })
// I'll probably improve it later in the matter of compatibility
// WORK IN PROGRESS
{
const testTable = document.querySelector('table');
const table2json = (table,config)=>{
const ths = table.querySelectorAll('th')
if (!ths || !ths.length && !config.headers){
throw new Error('Please provide header values if not in the table')
}
@lucis
lucis / random.c
Created September 20, 2019 14:54
Random in clang
// This function generates a random number between 0 and `max`
// Original method: http://goo.gl/At4AIC
int
random(int max) {
if (max <= 0) {
return 1;
}
static int z1 = 12345; // 12345 for rest of zx
static int z2 = 12345; // 12345 for rest of zx
@lucis
lucis / migration.md
Created October 15, 2019 18:08
Oracle to Postgres migration path

replace nvl with coalesce

replace rownum <= 1 with LIMIT 1

replace listagg with string_agg

replace recursive hierarchy (start with/connect by/prior) with recursive

replace minus with except

@lucis
lucis / notasParaCSV.js
Created October 23, 2019 23:17
Gera CSV a partir da tabela de notas de uma turma do Controle Acadêmico na UFCG
const getCSVNotas = table=>{
const SEP = ';'
const quantasNotas = row=>[...row.querySelectorAll('th')].map(th=>th.innerText).reduce((count,text)=>count + (text.includes('Nota') ? 1 : 0), 0)
const arrayOf = n=>[...Array(n).keys()]
const getLinhaAluno = (row,notas)=>{
const tds = row.querySelectorAll('td');
const it = el=>el.innerText