Skip to content

Instantly share code, notes, and snippets.

View ravicious's full-sized avatar

Maja Cieślak ravicious

View GitHub Profile
@ravicious
ravicious / post.md
Created March 30, 2020 11:37
Fixing problem with libruby-static.a when installing older Ruby versions on macOS

For a long time I had this problem where installing a Ruby through ruby-build or ruby-install would fail with an error saying "Undefined symbols for architecture x86_64".

linking static-library libruby-static.a
ar: `u' modifier ignored since `D' is the default (see `U')
verifying static-library libruby-static.a
ld: warning: ignoring file libruby-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
  "_ruby_init", referenced from:
      _main in main.o
@ravicious
ravicious / elm-workshop.md
Last active February 4, 2020 09:41
Elm workshop

Before you start

This document assumes you have some basic knowledge of Elm. I recommend reading "Welcome to Elm", the first chapter from "Elm in Action" by Richard Feldman.

Session 1

Setup

Create a folder for the project and create package.json with the following contents.

@ravicious
ravicious / .zshrc
Created July 8, 2019 17:20
Time in ZSH prompt
RPROMPT="%{$fg[white]%}[%*]%{$reset_color%}"
# Reset the prompt before accepting the line.
# https://stackoverflow.com/a/35051172
function _reset-prompt-and-accept-line {
zle reset-prompt
zle .accept-line # Note the . meaning the built-in accept-line.
}
zle -N accept-line _reset-prompt-and-accept-line
[alias]
# Undoes last commit and leaves the files commited by it in the staging area.
undo-commit = reset --soft HEAD^
today = !git log --since=midnight --author=\"$(git config user.name)\" --color --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr)%Creset' --abbrev-commit
yesterday = !git log --since="yesterday.midnight" --until=midnight --author=\"$(git config user.name)\" --color --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr)%Creset' --abbrev-commit
# More succint version of `git status`.
st = status -sb
# It takes ages to type `rebase --continue`.
rc = rebase --continue
# My preffered version of `git log`.
@ravicious
ravicious / _index.js
Created April 15, 2017 10:51
Flow JSON output example where the first message doesn't point to the current file
// @flow
import ReactDOM from 'react-dom'
var Foo = require('./foo.js')
// Foo is missing the `bar` prop here.
//
// When you open this file in vim-ale v1.2.0, it'll highlight the wrong line,
// since it takes the loc information of the first message
// under errors[0].message[0], which in this case points to `foo.js`,
// which is not the file opened in the current buffer.
@ravicious
ravicious / AutoSavingForm.md
Last active March 31, 2017 12:24 — forked from oyeanuj/AutoSavingForm.md
Auto-saving forms using Redux-Form – @oyeanuj solution piped through prettier

Here is how I ended up making this work. For more context and background on the discussion, I recommend reading conversation in ReduxForm#2169 (and chiming in with your learnings, etc).

So, as per the conversation there, I tried the 'many little forms' approach. I am sharing both my approach, and a crude abstracted out gist that can hopefully help out y'all.

Essentially, with this approach:

  1. You want to use each field as a little form which submits debounced onChange.
  2. For each field as a little form, you want to abstract that into a component which can be provided an input, as much as possible.
  3. Set autofocus for the first form.
  4. For debounced onChange, I used react-debounced-input.
// @flow
// https://flowtype.org/try/#0PTAEAEDMBsHsHcBQiCmAPADrATgF1LgJ4YqgBKKAtrLigCICGuDAPAKLbY4AqxKANKABqDaAFcUvEgD5QAXkShQAH1ABvUAGdmtAFygA5ADsaAQU0BrFABMDoAL6KV6rTpT6DcBtYCWRgOZ2jkqqGtpM7oaQDD7i2CgGgiicOPocXNhSpMHOYW4emmIAxkUompqJoABuohL6IuKSfA4A3MjoWHigkGJGRbg+sEagJrjmVtbsKZl8gg0SWdIAFACU+hTUtIzMUxlZc7VNMupO8bhi2MN5ER6j4zZBbY6omDj4PX0DQ6BevgG7PFmwkOi1W6yoNHoTFY6UBJAOjUWJyUZwuV1cN0Mvz8gVaiGeHTe3V6-UGw2isQuKABM3hwMRfGWyQyaWmWTW5AhW2hNP29IWjORoFRlxc4T0URicQSSWmeIJry6H1J30KJTKml5QPmRxQyxqjXqIL4HI2kO2MLZ2uNxzUpxQ51F1wlBjVpXKlQNEnlyGgDu6sFg4M2UJ22mwOME4ZxsjkWmK7s0SwMDHg8FAhBQDAAFgYVm1IIH5N0pVTk7BsyNA3mC0W49iAqta7Bi3dLDYm0A
export type RemoteData<ErrorType, ValueType> =
| { state: 'notAsked' }
| { state: 'loading' }
| { state: 'failure', error: ErrorType }
| { state: 'success', value: ValueType };
export function notAsked<ErrorType, ValueType>(): RemoteData<ErrorType, ValueType> {
@ravicious
ravicious / SSCCE.elm
Created November 13, 2016 19:00
A SSCCE for an issue with elm-lang/html. You can paste it to http://elm-lang.org/try.
import Html exposing (..)
import Html.Attributes exposing (..)
import Json.Encode
valueAttributes =
[ value ""
, property "value" (Json.Encode.string "")
, attribute "value" ""
]