Skip to content

Instantly share code, notes, and snippets.

@chicoxyzzy
chicoxyzzy / nvm-node-nightlies.md
Last active February 6, 2024 16:44
Installing Node Nightlies via nvm

You can install Node Nightlies/RCs via nvm using NVM_NODEJS_ORG_MIRROR environment variable.

Install latest Node RC

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc/ nvm i node

Install latest Node.js Nightly

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm i node
@tfausak
tfausak / chrono-legionnaire.hs
Last active October 5, 2017 14:31
Adds the time to every line.
#!/usr/bin/env stack
-- stack --resolver ghc-8.2.1 script --package time
import Data.Time
import Data.IORef
import Text.Printf
main :: IO ()
main = do
start <- getCurrentTime
before <- newIORef start
@aaronlevin
aaronlevin / minimal-http.hs
Last active June 27, 2017 16:37
Minimal Haskell HTTP server written on top of warp via the Web Application Interface (no frameworks)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Wai (pathInfo, Request, requestMethod, Response, responseLBS, ResponseReceived)
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (status200, status401)
-- note: type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
application :: Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
compiler-check: match-exact
resolver: ghc-8.0.1.20161117
setup-info:
ghc:
linux64:
8.0.1.20161117:
url: http://downloads.haskell.org/~ghc/8.0.2-rc1/ghc-8.0.1.20161117-x86_64-deb8-linux.tar.xz
content-length: 112047972
sha1: 6a6e4c9c53c71cc84b6966a9f61948542fd2f15a
macosx:
@mathiasverraes
mathiasverraes / MonoidalFizzBuzz.hs
Created November 16, 2016 16:21
Extensible Monoidal FizzBuzz in Haskell
module MonoidalFizzBuzz where
import Data.Monoid
import Data.Maybe
-- based on @mittie https://twitter.com/mittie/status/798257339736453120
monoidalFizzbuzz = zipWith fromMaybe numbers strings
where
fizzes = cycle [Nothing, Nothing, Just "Fizz"]
buzzes = cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"]
@Dierk
Dierk / Main.purs
Created November 14, 2016 20:11
Monoidal Fizzbuzz in Purescript
module Main where
import Control.Monad.Eff.Console (log)
import Data.List.Lazy (take, zipWith, fromFoldable, cycle, iterate, foldr)
import Data.Monoid (mempty, (<>))
import Data.Maybe (Maybe(..), fromMaybe)
import Prelude ( show, map, ($), (+))
main = do
@ekmett
ekmett / math_constexpr.h
Last active November 2, 2022 21:56
Computing Spherical Harmonics
#pragma once
#include <limits>
#define _USE_MATH_DEFINES
#include <math.h>
namespace framework {
namespace math_constexpr {
int constexpr abs(int x) {
@ekmett
ekmett / MonadHom.hs
Created July 23, 2016 17:06
monad homomorphisms and stuff
{-# language ConstraintKinds #-}
{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language LambdaCase #-}
{-# language MultiParamTypeClasses #-}
{-# language PolyKinds #-}
{-# language RankNTypes #-}
{-# language ScopedTypeVariables #-}
{-# language TupleSections #-}
{-# language TypeFamilies #-}
@slorber
slorber / do notation.js
Last active November 17, 2016 17:10
Use do { } makes React render() method more readable
// FP languages permit to evaluate if/else expressions as values.
// In many cases it permits to avoid using mutable variables (var/let), multiple returns, or nested ternary operators
// This is the do { } notation (stage 0), that permits to write the following right now with Babel.
const Users = ({users}) => (
<div>
{users.map(user =>
<UserCard key={user.id} user={user}/>
@davidchambers
davidchambers / comment.md
Created June 2, 2016 21:34
Quick introduction to chaining monads from a pull request review
var convertPercentage = function(percentage) {
  if (percentage == null) {
    return null;
  } else {
    return parseFloat(percentage.replace(/[^-\d.]/g, ''));
  }
};