Skip to content

Instantly share code, notes, and snippets.

View raorao's full-sized avatar

Srinivas Rao-Mouw raorao

  • San Francisco, CA
View GitHub Profile
@raorao
raorao / pr-comment-emojis.md
Last active March 27, 2024 23:21
PR Comment Emojis

Any top-level comment on pull request ought be tagged with one of four emojis:

  • for a non-blocking comment that asks for clarification. The pull request author must answer the question before the pull request is merged, but does not have to wait for the comment author to re-review before merging.

  • 🎨 for a non-blocking comment that proposes a refactor or cleanup. The pull request author does not have to address the comment for the pull request to merge.

  • ⚠️ for a blocking comment that must be addressed before the pull request can merge. The comment's author should leave a Request Changes review, and is responsible for re-reviewing once the pull request author has addressed the issue.

  • 😻 for a comment that compliments the author for their work.

@raorao
raorao / ets_cache.ex
Last active August 25, 2022 20:14
Simple ETS based cache with TTL
defmodule RequestCache do
@moduledoc """
Simple ETS-based cache.
"""
use GenServer
@type t :: %{ttl: integer, invalidators: %{}}
@type cache_key :: any
@type cache_value :: any
@raorao
raorao / large_changes.md
Last active October 10, 2019 20:16
Applying large changes to co-owned repos

Prerequisties

  • a script that can make all necessary changes, with no manual intervention.

Steps for Implementer

  1. check out master, run the script, commit the result
git fetch origin
git checkout master
@raorao
raorao / hackery.md
Last active July 5, 2018 18:51
valueOf hackery.
obj = (function() {
  currentValue = 7
  return {
    valueOf: function() { return currentValue = currentValue+2 }
  }
})()

(obj < 10) && (obj > 10) //true
@raorao
raorao / gen_server_cache.ex
Created May 12, 2017 04:30
Simple Process cache in Elixir.
defmodule RequestCache do
@moduledoc """
Simple GenServer-based cache.
"""
use GenServer
@type t :: %{cache: %{optional(cache_key) => cache_value}, interval: integer}
@typep cache_key :: any
@typep cache_value :: any
<html>
<body>
<style>
td {
border: 1px solid black;
width: 40px;
height: 40px;
}
</style>
GroceryList.start
GroceryList.next
# nil
GroceryList.add("a gallon of milk")
# :ok
GroceryList.next
# "a gallon of milk"
<?php
function slowApiLookup() {
try {
$url = "http://slowapi.com/delay/5.0";
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curlSession, CURLOPT_TIMEOUT,1);
$response = curl_exec($curlSession);
<html>
<head>
</head>
<body>
<script src="jquery.js" type=text/javascript></script>
<script type=text/javascript>
$(document).ready(function() {
addKISSmetricsToButtons();
@raorao
raorao / closures.js
Last active December 28, 2015 06:09
Here's my attempt at explaining closures in JavaScript.
// As I've been know to yell, JavaScript is a stupid language, and I don’t mean that as an insult.
// For example, where Ruby has 50-ish enumerable methods to iterate over collections,
// JS has, basically, two. But that’s okay! That just means you have to build any complicated
// logical structures yourself in JavaScript, which makes your code more transparent and flexible.
// One important structure you often find yourself building from scratch is private functionality
// in object oriented programming. JavaScript closures are one way to achieve that goal.
var counter = (function() {
var currentCount = 0;
return {