I hereby claim:
- I am ameykusurkar on github.
- I am ameykusurkar_gc (https://keybase.io/ameykusurkar_gc) on keybase.
- I have a public key ASAi2oE6mP5YQdgZfHtP9ZM8iVVEotNCcXWgOtxNNhOGTAo
To claim this, I am signing this object:
# `items` table pre-populated with millions or rows | |
class Item < ApplicationRecord; end | |
# Worker loop finds rows and deletes them | |
def consume(n) | |
loop do | |
start = ::Utils::Timing.monotonic_now | |
count = Item.transaction do | |
# Lock first N rows | |
items = Item.limit(n).lock("FOR UPDATE SKIP LOCKED").order(:id).to_a |
-- DEMO: TRANSACTIONS | |
-- | |
-- Create table | |
CREATE TABLE messages ( | |
id int PRIMARY KEY, | |
payload text | |
); | |
-- Insert 3 tuples atomically | |
BEGIN; |
module FizzBuzz where | |
import Data.Maybe (fromMaybe) | |
fizzbuzz n = fromMaybe (show n) ((fizz <> buzz) n) | |
where fizz = say 3 "Fizz" | |
buzz = say 5 "Buzz" | |
say :: Int -> String -> Int -> Maybe String | |
say x phrase n = if mod n x == 0 then Just phrase else Nothing |
import itertools | |
from math import sqrt | |
def estimate_root(x: int) -> int: | |
return next(i for i in itertools.count() if i * i > x) | |
def root(x: int) -> float: | |
guess = estimate_root(x) | |
return narrow_guess(x, lower=guess-1, upper=guess) |
I hereby claim:
To claim this, I am signing this object:
<canvas id="bounce" width="800" height="400" style="border:1px solid"></canvas> | |
<script> | |
const frameRate = 60; | |
window.onload = function() { | |
canvas = document.getElementById("bounce"); | |
ctx = canvas.getContext("2d"); | |
document.addEventListener("keydown", keyPressed); | |
setInterval(game, 1000/frameRate); |
#include <stdio.h> | |
int min(int a, int b) | |
{ | |
if (a < b) return a; | |
else return b; | |
} | |
int max(int a, int b) | |
{ |