Skip to content

Instantly share code, notes, and snippets.

View edrdo's full-sized avatar

Eduardo R. B. Marques edrdo

View GitHub Profile
@edrdo
edrdo / _jsonPuller.md
Created September 17, 2022 09:06 — forked from jalcantarab/_jsonPuller.md
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

import shutil
import tempfile
from collections import defaultdict
import hypothesis.strategies as st
from hypothesis.database import DirectoryBasedExampleDatabase
from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule
from hypothesis import settings
from hypothesis import Phase
from hypothesis import Verbosity
@edrdo
edrdo / Shell.java
Created April 4, 2020 18:48
Shell command execution in Java
package something;
import java.io.IOException;
/**
* Utility class for executing shell commands.
*/
public final class Shell {
@SafeVarargs
@edrdo
edrdo / TEA.java
Created November 27, 2019 21:25
Tiny Encryption Algorithm
package qses.tea;
/**
* Implementation of the Tiny Encryption Algorithm (TEA).
* The Tiny Encryption Algorithm is one of the fastest and most efficient
* cryptographic algorithms in existence. It was developed by David Wheeler and
* Roger Needham at the Computer Laboratory of Cambridge University.
*
* See http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps
*
@edrdo
edrdo / string_split.sql
Created May 4, 2019 23:40
string_split (MySQL)
DROP PROCEDURE IF EXISTS string_split;
DELIMITER $
CREATE PROCEDURE string_split
(IN string TEXT, IN sep CHAR(1), OUT num INT)
BEGIN
DECLARE pos INT;
DECLARE aux TEXT;
DECLARE str text;
@edrdo
edrdo / pthread_barrier.c
Last active December 2, 2023 11:36
Pthread barriers using condition variables
/**
* Eduardo R. B. Marques.
*
* Basic pthread_barrier_XXX functionality (not part of the standard Pthreads library).
*
* Note: no error checking for now.
*/
typedef struct {
unsigned size; // threads that should join barrier
@edrdo
edrdo / EDFQueue.py
Created August 31, 2018 10:31
EDF task queue in Python
import heapq
import time
import os
class EDFQueue(object):
def __init__(self):
self.heap = []
def count(self):
return len(self.heap)
@edrdo
edrdo / poisson.py
Created June 15, 2018 13:03
Poisson process - interarrival times (Pyhton)
import random
class PoissonProcess(object):
def __init__(self, rate, seed=None):
self.prng = random.Random(seed)
self.rate = rate
def timeTillNextEvent(self):
return self.prng.expovariate(self.rate)
@edrdo
edrdo / .gitignore
Created June 6, 2018 08:52
.gitignore entries for LaTeX generated files
*.aux
*.toc
*.out
*.bbl
*.blg
*.log
*.synctex.gz
@edrdo
edrdo / whittakerSmoother.m
Last active March 14, 2021 09:23
Whittaker smoothing algoritm in Matlab
% Reference: "A perfect smoother", PHC Eilers - Analytical chemistry, 2003
% This is the simplest formulation - check Eilers' article for an alternative implementation making use of sparse matrixes.
function z = whittakerSmoother(y,lambda)
m = length(y);
I = eye(m);
D = diff(I);
z = (I + lambda * D' * D)\y;
end
% Test