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
/ invalid
%div
%span
%span
%span{ |
"foo" => "bar", |
"baz" => 'quz' }
/ valid
%div
@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
Query = {}
Query.new = function() {
var queryAttributes = {
filters: [],
beginDate: null,
endDate: null,
attribute: null
}
@raorao
raorao / foo.md
Last active August 29, 2015 14:18

bar foo

Keybase proof

I hereby claim:

  • I am raorao on github.
  • I am raorao (https://keybase.io/raorao) on keybase.
  • I have a public key whose fingerprint is 2B05 C1E8 A751 C8FF DE93 20B6 CC2B F1A1 2EC2 F87E

To claim this, I am signing this object:

@raorao
raorao / progress.sass
Last active September 4, 2015 20:00
how I used to write sass --> how i write it now.
// how I used to write sass!
// -----------------------
// its short, sure, but short doesn't necessarily mean simple. Its very difficult for me
// to tell how a given element gets its styles -- element-1 is getting inherited styles
// from its container, and then has two different explicit selectors. At scale,
// its even harder to tell what overrides what, and file ordering begins to actually
// matter. Whenever I see code like this now, I refactor it asap -- before
// it gets too unwieldy and brittle to change.
.container-element
font: 15px verdana
GroceryList.start
GroceryList.next
# nil
GroceryList.add("a gallon of milk")
# :ok
GroceryList.next
# "a gallon of milk"
@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
@raorao
raorao / ets_cache.ex
Last active October 21, 2024 19:20
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
<html>
<body>
<style>
td {
border: 1px solid black;
width: 40px;
height: 40px;
}
</style>