Skip to content

Instantly share code, notes, and snippets.

View juanplopes's full-sized avatar
🌲
Is that a Segment Tree problem?

Juan Lopes juanplopes

🌲
Is that a Segment Tree problem?
View GitHub Profile
#!/bin/bash
set -e
mkdir -p ~/Library/KeyBindings
cat > ~/Library/KeyBindings/DefaultKeyBinding.dict << EOF
{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
# -*- 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()
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
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)
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 };
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 December 5, 2019 19:40
Update tzdata
# 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/
@juanplopes
juanplopes / TestSizeUtils.java
Last active November 27, 2019 15:10
TestSizeUtils
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 November 7, 2019 17:36
Codeforces Round #595 (Div. 3)
#include <iostream>
#include <algorithm>
using namespace std;
int T[200];
int main() {
ios_base::sync_with_stdio(false);
int test; cin >> test;
int N;
(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;