Skip to content

Instantly share code, notes, and snippets.

View robertberry-zz's full-sized avatar

Rob Berry robertberry-zz

View GitHub Profile
<!doctype html>
<html>
<head>
<style type="text/css">
body {
background-color: #f0f0f0;
}
.Page {
left: 50%;
function subsequenceWithLargestSum(xs) {
var n = xs.length;
var start = 0;
var runningSum = 0;
var largestStart = 0;
var largestEnd = 0;
var largestSum = 0;
for (var i = 0; i < n; i++) {
@robertberry-zz
robertberry-zz / test.html
Created September 5, 2016 11:11
testymctest
<!doctype html>
<html>
<head>
<title>Goodbye cruel world</title>
</head>
<body>
<p>Hello cruel world</p>
<iframe src="https://twitter.com/i/videos/live_video/738315305816248320?embed_source=clientlib&amp;player_id=0&amp;rpc_init=1&amp;conviva_environment=production" allowfullscreen="" id="player_live_video_738315305816248320" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0;"></iframe>
</body>
@robertberry-zz
robertberry-zz / countPermutations.js
Created September 4, 2016 18:38
O(n) algorithm for counting permutations of a string in another string
function countChars(word) {
var counts = {};
for (var i = 0; i < word.length; i++) {
var letter = word[i];
if (letter in counts && counts.hasOwnProperty(letter)) {
counts[letter]++;
} else {
counts[letter] = 1;
function countChars(word) {
var counts = {};
for (var i = 0; i < word.length; i++) {
var letter = word[i];
if (letter in counts && counts.hasOwnProperty(letter)) {
counts[letter]++;
} else {
counts[letter] = 1;
case class Position(x: Int, y: Int)
object Grid {
val Width = 10
val Height = 10
val grid = Map(
Position(0, 0) -> true
)
import Data.List (groupBy)
import Data.Function (on)
section :: String -> String
section = takeWhile (/= ',')
groupBySection :: [String] -> [[String]]
groupBySection = groupBy ((==) `on` section)
top15 :: [String] -> [String]
SELECT MAX(c.section_id) section_id, MAX(t.tag_web_title) contributor_name, COUNT(DISTINCT c.id) articles_published
FROM content_dim c RIGHT JOIN content_tag_lookup t ON c.content_key = t.content_key
WHERE t.tag_type = 'contributor'
GROUP BY tag_id, section_id
ORDER BY section_id ASC, articles_published DESC;
case class Front(containers: Seq[Container])
case class Container(slices: Seq[Slice])
case class Slice(columns: Seq[Column])
case class Column(cards: Seq[Card])
sealed trait Foo
case class Bar(a: Int) extends Foo
case class Baz(b: Int) extends Foo
object FooJson {
def fromFoo(foo: Foo) = foo match {
case Bar(a) => FooJson("bar", Some(a), None)
case Baz(b) => FooJson("baz", None, Some(b))
}