Skip to content

Instantly share code, notes, and snippets.

View szabba's full-sized avatar

Karol Marcjan szabba

  • Zielona Góra, Poland
View GitHub Profile
@sch
sch / README.md
Last active September 30, 2018 15:21
Elm as an NPM dependency

Sometimes you may want to have more than one version of Elm installed on your computer.

It could be that you're in the process of upgrading multiple projects, and you'd like to have one in 0.18 and another in 0.19. It could be you want to pin your version of Elm to something specific so you can be sure all the members of your team are using the same one. It could be you're relying on lots of Elm-related tooling, and you want to make sure you have the right combination for a specific project.

One option is to piggy-back on top of the [Node Package Manager][npm], and explicitly declare which version of Elm you'd like to use. The elm binary is wrapped up as a node module with a bit of metadata:

$ npm info elm@latest

elm@0.19.0-bugfix2 | BSD-3-Clause | deps: 1 | versions: 33
@mfeineis
mfeineis / FromReduxToElm.elm
Created March 11, 2018 01:48
A self-contained attempt at explaining The Elm Architecture (TEA) in terms of Redux - https://ellie-app.com/kKcXHF8fJa1/0
port module FromReduxToElm exposing (main)
import Html exposing (Html)
port sayHello : (String -> msg) -> Sub msg
type alias Model =
{ who : String

We don't use that word here

There are some words which carry with them the baggage of sexism and ableism and so they're words we've chosen to avoid using within our community.

We realise that sometimes SlackBot might get a bit over-eager and correct you when you intentionally chose that word and it is appropriate. That's okay, but we find that in most cases, SlackBot's reminders help us choose our words with intention and promote a more inclusive and welcoming space.

There are plenty of other words that you can use which can still convey the meaning you're looking for. Sometimes it might require a bit of creativity, but trust us – it can be done.

We don't assume you were intentionally being sexist or ableist. Our language is littered with the legacy of unfortunate cultural baggage. You might not even believe that there's a problem with the word you used. That's cool, but we don't use that word here.

@wojteklu
wojteklu / clean_code.md
Last active May 13, 2024 02:13
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@ericlagergren
ericlagergren / index.gohtml
Last active December 22, 2023 17:51
Hot-reloading / hot-swapping live template files in Go
My name is {{.Name}} and I'm {{.Age}} years old!!
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@stelleg
stelleg / hm_scott.lhs
Last active July 4, 2016 10:42
Hindley Milner + Scott Encoding Musings
Sometimes it would be nice if a type system could automatically "do it's best"
to restrict what a value will be. For example, the type `Bool` is the compiler
saying the value will either be `True` or `False`, but it doesn't know which.
What we want is the compiler to be able to be precise when possible, so instead
of always saying `Bool` (or "I don't know"), it could say `True`, `False`, or
`Bool`. This gist shows how Hindley Milner already has this capability that can
be exercised by using Church or Scott encodings of simple data types.
> {-# LANGUAGE RankNTypes #-}
> import qualified Data.Maybe as M
import Control.Proxy
import Control.Proxy.TCP
main :: IO ()
main = serve (Host "0.0.0.0") "8000" $ \(socket,_) ->
runProxy $ socketReadS 4096 socket >-> socketWriteD socket
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le