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 / 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
repository available at: https://github.com/raorao/ar-student-schema
For this challenge, I created a simple Students table using AR migration, populated a student object with basic methods and validations.
@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 {
<html>
<head>
</head>
<body>
<script src="jquery.js" type=text/javascript></script>
<script type=text/javascript>
$(document).ready(function() {
addKISSmetricsToButtons();
<?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);
GroceryList.start
GroceryList.next
# nil
GroceryList.add("a gallon of milk")
# :ok
GroceryList.next
# "a gallon of milk"
<html>
<body>
<style>
td {
border: 1px solid black;
width: 40px;
height: 40px;
}
</style>
@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 / 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 / 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