Skip to content

Instantly share code, notes, and snippets.

@samuelreh
samuelreh / FPinRuby.rb
Created January 26, 2015 05:26
Mary Rose Cook's Practical Intro to FP ported to Ruby
#
# Squares
#
squares = lambda do |nums|
nums.map do |num|
num * num
end
end
class Display(object):
HEIGHT = 8
WIDTH = 8
def __init__(self):
self.array = [0x00] * (self.width() / 8) * self.height()
def height(self):
""" Get the height of the display """
package forcomp
object Anagrams {
/** A word is simply a `String`. */
type Word = String
/** A sentence is a `List` of words. */
type Sentence = List[Word]
import com.scalakata._
@instrument class Playground {
/* Tail Recursion:
*
* The following recursive function calculates the fibonocci number for the given index. With a large enough index,
* the program will throw a StackOverflowError.
*/
def fib(n: Int): Int = {
@samuelreh
samuelreh / PGMaterializedViewRefresh.md
Last active November 28, 2023 12:06
Refresh Materialized View Concurrently(ish) in Postgres 9.3

Refresh Materialized View Concurrently(ish) in Postgres 9.3

Recenlty at Attribution, we've been implementing materiazlied views to speed up slow queries. Although the concept is nothing new, and Materialized Views have been a feature of Oracle for years. They're a new feature in Postgres 9.3.

One missing piece in 9.3 is the ability to refresh views concurrantly, without exclusivly locking the whole view. Postgres 9.4 introduces this feature, which is great if you manage your own DB. However, those of us that use hosted database solutions, such as Amazon RDS, are not so lucky.