Skip to content

Instantly share code, notes, and snippets.

Avatar
This is not a verified profile. Or is it?

Juan Lopes juanplopes

This is not a verified profile. Or is it?
View GitHub Profile
View rex.py
# -*- coding: utf-8 -*-
from collections import deque
from functools import reduce
def rex(pattern):
tokens = deque(pattern)
def walk(chars):
while tokens and tokens[0] in chars:
yield tokens.popleft()
View regression.txt
Crescimento por dia: 36.84%
2020-02-26 0 1
2020-02-27 0 1
2020-02-28 1 1
2020-02-29 1 2
2020-03-01 2 2
2020-03-02 2 2
2020-03-03 3 2
2020-03-04 5 4
2020-03-05 7 4
View regression.py
import datetime, numpy as np
first_day = datetime.date(2020, 2, 26)
y = np.array([1, 1, 1, 2, 2, 2, 2, 4, 4, 13, 13, 20, 25, 31, 38, 52, 151, 151, 162, 200, 321, 372, 621, 793])
x = np.arange(1, len(y)+1)
curve = np.exp(np.polyfit(x, np.log(y), 1))
#y = b*a^x
#log(y) = xlog(a)+log(b)
View performance.js
var performanceReport = function(perf) {
if (perf == null)
return console.log("No storage query was run yet!");
var perc = n => isNaN(n) ? 0 : Math.round(n*1000.0)/10;
var expectedEvents = 0, actualEvents = 0, cacheReads=0, cacheWrites=0, metrics = {};
var count = {'init': 0, 'read': 0, 'flow': 0, 'misc': 0, 'filter': 0 };
var time = {'init': 0, 'read': 0, 'flow': 0, 'misc': 0, 'filter': 0 };
View settings.groovy
import net.intelie.live.*
import net.intelie.live.util.*
import net.intelie.live.queries.*
import net.intelie.live.model.*
import javax.ws.rs.*
import javax.ws.rs.core.*
import javax.servlet.http.*
import org.springframework.security.web.csrf.*
import org.springframework.web.util.*
import com.google.gson.*
@juanplopes
juanplopes / tzdata.sh
Last active Dec 5, 2019
Update tzdata
View tzdata.sh
# On Ubuntu: make sure you have lzip and gawk installed
tmp_dir=$(mktemp -d -t tzdata-XXXXXXXXXX)
cd $tmp_dir
wget https://cdn.azul.com/tools/ziupdater1.0.2.2-jse8+7-any_jvm.tar.gz
wget https://data.iana.org/time-zones/releases/tzdb-2019c.tar.lz
tar zfxv ziupdater*.tar.gz
tar lfxv tzdb-2019c.tar.lz
cd tzdb-2019c/
View TestSizeUtils.java
import net.intelie.introspective.ObjectSizer;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
public class TestSizeUtils {
public static String formatBytes(double value) {
String[] NAMES = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int name = 0;
@juanplopes
juanplopes / A.cpp
Created Nov 7, 2019
Codeforces Round #595 (Div. 3)
View A.cpp
#include <iostream>
#include <algorithm>
using namespace std;
int T[200];
int main() {
ios_base::sync_with_stdio(false);
int test; cin >> test;
int N;
View gist:93e687e65dca1eeb44640c122dbdcb0d
(async () => {
var get = async(url, prop, dataless) => {
var data = (await (await fetch(url)).json());
if (!dataless) data = data.data;
var result = {};
data.forEach(element => {
result[element[prop]] = element;
});
return result;
View 1579.cpp
#include <iostream>
using namespace std;
int X[200];
int trucks(int P, int maximum) {
int count = 0, current = 0;
for(int i=0; i<P; i++) {
if (X[i] > maximum) return 10000000;
if (current + X[i] > maximum) {
You can’t perform that action at this time.