Skip to content

Instantly share code, notes, and snippets.

@nmk
nmk / streams_disappear.ex
Last active March 3, 2023 11:37
Phoenix disappearing streams
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
#!/usr/bin/env stack
-- stack --resolver lts-11.15 script --package text --package yesod
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
#!/usr/bin/env stack
-- stack --resolver lts-11.15 script --package text --package yesod
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
@nmk
nmk / Main.elm
Last active February 1, 2017 13:04
module Main exposing (..)
import Form exposing (..)
import Form.Input as Input
import Form.Validate exposing (..)
import Html exposing (..)
type Color
= Red
@nmk
nmk / Main.elm
Last active October 22, 2016 11:04
Dependent fields validation with elm-simple-form
module Main exposing (..)
import Form exposing (Form, FieldState)
import Form.Input as Input
import Form.Validate exposing (..)
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
@nmk
nmk / gist:ed115b30480a30cc917c
Created February 17, 2016 18:21
Bad Vector dropWhile performance Core
==================== Tidy Core ====================
2016-02-17 18:20:25.680333 UTC
Result size of Tidy Core = {terms: 869, types: 656, coercions: 162}
lvl_rdKT
lvl_rdKT =
case $wshowSignedInt 0 10000000 ([])
of _ { (# ww5_a93C, ww6_a93D #) ->
Debugger entered--Lisp error: (void-function projectile-project-p)
(projectile-project-p)
(if (projectile-project-p) (cons (abbreviate-file-name (projectile-project-root)) (projectile-relevant-known-projects)) projectile-known-projects)
(lambda nil (if (projectile-project-p) (cons (abbreviate-file-name (projectile-project-root)) (projectile-relevant-known-projects)) projectile-known-projects))()
#[0 "\301\302\303\300!\203
\300 \202\300\"\207" [(lambda nil (if (projectile-project-p) (cons (abbreviate-file-name (projectile-project-root)) (projectile-relevant-known-projects)) projectile-known-projects)) helm-init-candidates-in-buffer global functionp] 4 "\n\n(fn)"]()
apply(#[0 "\301\302\303\300!\203
\300 \202\300\"\207" [(lambda nil (if (projectile-project-p) (cons (abbreviate-file-name (projectile-project-root)) (projectile-relevant-known-projects)) projectile-known-projects)) helm-init-candidates-in-buffer global functionp] 4 "\n\n(fn)"] nil)
helm-funcall-with-source(((name . "*Helm Switch Pr
@nmk
nmk / gist:64ad901d7d237a7be925
Created October 19, 2015 12:07
dtrace errors
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): invalid user access in action #11 at DIF offset 24
dtrace: error on enabled probe ID 5 (ID 161: syscall::open:return): inva
@nmk
nmk / gist:75c7ba95917608ba8c69
Last active September 3, 2015 09:04
Stack ghci fails to load Prelude
haskell $ stack new foobar
Downloading template "new-template" to create project "foobar" in foobar/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /Users/nmk/.stack/stack.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
require "minitest/autorun"
class RunningStat
def initialize(opts={})
@nr_of_els = opts.fetch(:nr_of_els, 0)
@old_m = opts.fetch(:old_m, 0.0)
@old_s = opts.fetch(:old_s, 0.0)
end
def push(x)