Skip to content

Instantly share code, notes, and snippets.

def append_range(ranges, current_range_start, current_range_end):
if current_range_start == current_range_end:
ranges.append(current_range_start)
else:
ranges.append((current_range_start, current_range_end))
def compress_list_of_integers(ints):
if len(ints) == 0:
return []
ranges = []
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 5 columns, instead of 2. in line 3.
77,R338O7kqll/vLZD6UeiHxEJ8Za6D50r2VlZGGTk+eYvABb3K8RB4hKZiYP6RSuLh5HhrjsvuEHHtODZM1yUeCw==,"{""file"": {}, ""type"": ""FILE_UPLOAD_START"", ""uploader"": {""req"": {}, ""file"": {}, ""_callbacks"": {""$end"": [null], ""$error"": [null], ""$progress"": [null]}}}",https://localhost/dataset/Wut-is-going-on/nivb-z524,1475114093197
78,R338O7kqll/vLZD6UeiHxEJ8Za6D50r2VlZGGTk+eYvABb3K8RB4hKZiYP6RSuLh5HhrjsvuEHHtODZM1yUeCw==,"{""type"": ""FILE_UPLOAD_PROGRESS"", ""percent"": 29.66360845195578, ""uploader"": {""req"": {}, ""file"": {}, ""_callbacks"": {""$end"": [null], ""$error"": [null], ""$progress"": [null]}}}",https://localhost/dataset/Wut-is-going-on/nivb-z524,1475114093231
79,R338O7kqll/vLZD6UeiHxEJ8Za6D50r2VlZGGTk+eYvABb3K8RB4hKZiYP6RSuLh5HhrjsvuEHHtODZM1yUeCw==,"{""type"": ""FILE_UPLOAD_ANALYZING"", ""uploader"": {""req"": {}, ""file"": {}, ""_callbacks"": {""$end"": [null], ""$error"": [null], ""$progress"": [null]}}}",https://localhost/dataset/Wut-is-going-on/nivb-z524,1475114093249
80,R338O7kqll/vLZD6UeiH
module Joins exposing (..)
import Dict exposing (..)
join : List a -> List b -> (a -> b -> Bool) -> List (a, List b)
join left right joinTest =
left
|> List.map (\leftItem ->
right
module ElmAST where
import Json.Decode
import Json.Decode exposing ((:=))
import Json.Encode exposing (Value)
-- The following module comes from bartavelle/json-helpers
import Json.Helpers exposing (..)
import Dict
import Set
peterv@vilterp-mbp:flow-test$ flow version
Flow, a static type checker for JavaScript, version 0.25.0
peterv@vilterp-mbp:flow-test$ flow
flowTest.js:7
7: var y: Foo = {...x, a: 5};
^^^^^^^^^^^^ object literal. This type is incompatible with
7: var y: Foo = {...x, a: 5};
^^^ union: object type(s)
Member 1:
3: type Foo = { type: 'foo', a: number, b: number } | { type: 'bar', c: string };
module AST where
import Dict exposing (Dict)
type alias Module =
{ name : List String
, exports : List Exposable
, imports : Import
, declarations : List Declaration

I18n with Records

Goals:

  1. Elm's typechecker enforces that
  • each localization has all the same messages.
  • the messages you are referring to in your view code exist.
  1. Only the localized strings for the current locale are sent across the wire
  2. Messages which have interpolations are typechecked as well
@vilterp
vilterp / id_rsa.pub
Last active December 14, 2015 18:55
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCguoAax3oAZjCdoDenwDDtVIFHLDVZCKSPX1lDLHUsBaphArtL2f0am50tq8hkiZulap6eRFKgQupSpD42g12eM7cXoaijUi05allxKwdnlm54rkFpQ+mDpgElgCl8T4c16TzlyVEXuxxsRZF9iprOkfdp1fskc2qiJdOHEcY8fAQpnfruKAyyd+9ZmpYWHHM+agZNet1iS2ypHRtBFhlQDyRoFIRHD63KaKx2klrXPgnrlfLPWbiKD87QK2Wa/mkp8yosZNrXtTfP0sLaaYQXOBlG5z2G6RzPoNREYV50RK73ux5vtvqHeJCil7QJI2FvzZVD7UEhXnSGWFKlX/gF peterv@C02Q10NEG8WM-MBA.local
#!/usr/bin/osascript
display notification "is done" with title "Your Shit"
@vilterp
vilterp / TaskfulHtmlLayout.md
Last active May 11, 2016 08:27
Html layout as a taskful API

A problem that comes up periodically is that people want to know the position of Html elements on the page after they've been laid out, for example so they can:

  1. Absolutely position an element based on the position of one or more relatively-positioned elements. E.g:
    1. make a popup seem to "come out of" a certain element (this could be done by adding a child of the div which is positioned relative to it, but is easier if you can just get the laid-out coordinates of the div and position the popup relative to that)
    2. draw a circle around an element, to highlight it (e.g. for a first-time app walkthrough tutorial). Again, maybe possible to do with purely relative layout, but much easier if you can get element position.
    3. draw a line between two page elements
  2. know whether an element is visible, given the current scroll window
  3. get mouse events on an element which are relative to that element's top-left origin (e.g. for a mouse-interactive Graphics.Collage embedded in HTML)

Elm-html cannot t