Skip to content

Instantly share code, notes, and snippets.

.flair {
padding: 0px;
margin: 0;
line-height: 26px;
vertical-align: middle;
text-align: right;
color: #FFF;
background: url(%%brandflairs%%) top left no-repeat #000;
min-width: 40px;
padding-right: 10px;
package com.mingweisamuel.zyra.util;
import java.util.Arrays;
import java.util.function.Supplier;
/**
* <p>This class represents a token bucket system. One instance represents one recurring bucket with a certain
* limit of tokens per timespan.</p>
*
* <p>A circular buffer keeps track of tokens. The index of each bucket represents the number of requests sent
function test() {
for (let i = 0; i < 20; i++) {
let problem = generateProblem();
console.log('Problem:', problem);
let ansFast = roadTripFast(...problem);
let ansKey = roadTripKey(...problem);
console.log(ansFast, ansKey);
if (ansFast === ansKey)
console.log('%cPASS', 'color: #0A0');
else
50
Itoshima Tokushima Tamana Joetsu Higashiyamato Tsubame Shisou Shimabara Hanno Wakayama Sango Kashihara Kani Sumoto Maibara Asahikawa Kasaoka Komae Kitakami Odo Sanuki Kitahiroshima Tagawa Miyakonojo Kiryu Fujisawa Gotenba Zama Naka Tsuruoka Hiroshima Koshigaya Narita Kyoto Morui Tokorozawa Akita Miyama Annaka Matsuura Tagajo Fujiyoshida Kadoma Kurume Yawata Abiko Kobayashi Seiyo Fukuroi Satsumasendai
169.80381765787627 662.5432691383742 x x x 536.0733799309679 268.74063261977864 x x x x x 655.3609599975988 x 186.03350816135605 x x x 720.5420452360715 x 191.74336022679694 146.47419127719863 x x 396.6497899938318 417.3048090136152 x 223.92533606928922 862.6583032692702 683.5657590614952 x x 767.7234916126935 x 116.10788282009865 947.9276455536063 38.75192912277514 38.76354433712656 x x 989.7381973884163 200.06147840542468 505.50317204811887 x 586.0996505310661 27.690748018022358 x x x x
662.5432691383742 93.50239786834088 26.36887333545462 409.8430510675028 40.456863850201984 568.9825549044463 481.8842142241
from azure.common.exceptions import CloudError
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
SSH_USERNAME = 'ubuntu'
// DAY 3
(function(rows) {
let claims = Array.from(Array(1000).keys()).map(() => Array(1000).fill(0));
for (let row of rows) {
let [ , , loc, size ] = row;
loc = loc.split(',').map(Number);
size = size.split('x').map(Number);
for (let i = 0; i < size[0]; i++) {
let claimRow = claims[loc[0] + i];
for (let j = 0; j < size[1]; j++) {
function onOpen() {
const ui = DocumentApp.getUi();
// Or DocumentApp or FormApp.
ui.createAddonMenu()
.addItem('Invert Selected', 'doInvertSelected')
.addToUi();
}
function invertColor(val) {
return '#' + ('00000' + (0xFFFFFF - parseInt(val.substr(1), 16)).toString(16)).substr(-6);
@MingweiSamuel
MingweiSamuel / semaphore.js
Last active December 6, 2019 02:35
Tiny Javascript Semaphore
function Semaphore(count) {
this.permits = count;
this.queue = [];
}
Semaphore.prototype.acquire = function() {
return new Promise(resolve => {
if (0 === this.permits)
this.queue.push(resolve);
else {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
macro_rules! arr {
(
$( #[$attr:meta] )*
$v:vis $id:ident $name:ident: [$ty:ty; _] = $value:expr
) => {
$( #[$attr] )*
$v $id $name: [$ty; $value.len()] = $value;
}
}