Skip to content

Instantly share code, notes, and snippets.

View rtfeldman's full-sized avatar

Richard Feldman rtfeldman

View GitHub Profile
@rtfeldman
rtfeldman / gist:2433334
Created April 21, 2012 02:25
Replaces netflix.com's painful scrolling behavior with normal scroll bars using the Stylebot Chrome extension: http://bit.ly/fNacLp
/*
* Paste this CSS into the Stylebot Chrome Extension ( http://bit.ly/fNacLp )
* to get normal horizontal scroll bars on netflix.com instead of its current
* eye-searing nausea-inducing hover-to-scroll monstrosity.
*
* Sweet relief!
*
* Released to the public domain by Richard Feldman - @rtfeldman on Twitter
*/
inc x = x + 1
log str = console.log str
console.log (inc 5)
log 500
// Output:
var inc = function (x) {
return x + 1;
};
@rtfeldman
rtfeldman / gist:a66135b8ad0a446473ba
Created July 9, 2014 18:18
Fibonacci in Haskell
fibonacci 0 = 0
fibonacci 1 = 1
fibonacci n = fibonacci (n - 1) + fibonacci (n - 2)
@rtfeldman
rtfeldman / keybase.md
Created June 2, 2015 19:17
keybase.io identity proof

Keybase proof

I hereby claim:

  • I am rtfeldman on github.
  • I am rtfeldman (https://keybase.io/rtfeldman) on keybase.
  • I have a public key whose fingerprint is 0739 55F3 77B6 314B 8D74 7443 CB96 9B2A 26E7 5548

To claim this, I am signing this object:

# Elm Sprockets Integration for Rails 3
#
# I'm working on turning this into a Gem - see https://github.com/NoRedInk/sprockets-elm - but
# I know a lot more about Elm than I do Rails, and haven't gotten that version working yet.
# If you know how to help Gemify this, by all means please hit me up! https://twitter.com/rtfeldman
# I could definitely use the help.
#
# Anyway, in the meantime, this is what we're using at NoRedInk to integrate Elm into our asset
# pipeline, and it works like a charm. Just copy this into config/initializers/elm_sprockets.rb
#
  1. Enable developer options on your phone and turn on USB debugging.
  2. Connect the phone to a computer with a USB cable.
  3. Do this (on OS X):
brew install android-platform-tools
adb shell
pm hide com.sec.android.inputmethod
@rtfeldman
rtfeldman / Signal.create.md
Last active October 7, 2015 22:32 — forked from mgold/proposal.elm
Elm mailbox revamp

This is proposed as a simplified alternative to https://gist.github.com/mgold/f3527359996fdf295843 - what if instead of renaming Mailbox, we just didn't have a name for that thing?

Rationale:

  1. From an API perspective, it's important that the function for instantiating a Signal returns two distinct values: the Signal and a way to send a Message to it.
  2. Mailbox (and alternatively Dispatcher) give a type alias to that return value.
  3. In practice, we never compose Mailboxes or Dispatchers directly; we simply read the two values out of them and then immediately discard them.
  4. Despite this, I hear people saying things like "Do I need a Mailbox for that?" when the real question is "I want to create a Signal; how do I do that?" The type alias seems to be a red herring that leads people down the wrong path.
  5. I've gotten the best results from telling people "Focus on the Signal. Do you need to create a new Signal out of thin air? If so, here's the function that does that." (Currently that fun
@rtfeldman
rtfeldman / elm_sprockets.rb
Created March 22, 2016 01:58
Elm Sprockets
require 'open3'
require 'tempfile'
class ElmCompiler < Sprockets::Processor
def self.default_mime_type
'text/x-elm'
end
def evaluate(context, _locals)
pathname = context.pathname.to_s
module Script exposing (spec) --where
import ElmTest as Test exposing (onFail, test)
import Component.Util exposing (..)
import Html exposing (span, text)
import Dom exposing (htmlToString)
{-

Elm Style Guide

Purpose

The goal of the style guide is foremost to promote consistency and reuse of pattern from other languages in order to improve readability and make Elm easier for beginners. This includes moving Elm away from Haskell’s indentation style and even making some parts look closer to JavaScript. These decisions are intentional.

We would like Elm to look friendly and familiar to users of any language — especially JavaScript — so they can discover Elm’s powerful features without being overwhelmed. This does not intend to weaken or discourage any features of Elm, but instead to make them more accessible.

A secondary goal of the style guide is to encourage short diffs when changes are made. This makes changes more clear, and helps when multiple people are collaborating.

Whitespace