Skip to content

Instantly share code, notes, and snippets.

@CrossEye
CrossEye / permutations.js
Last active October 23, 2018 04:26
Find permutations of a list of (distinct) values. Uses Ramda
const R = require('ramda');
const permutations = (tokens, subperms = [[]]) =>
R.isEmpty(tokens) ?
subperms :
R.addIndex(R.chain)((token, idx) => permutations(
R.remove(idx, 1, tokens),
R.map(R.append(token), subperms)
), tokens);
@manabuyasuda
manabuyasuda / GitHubの使い方.md
Last active December 15, 2023 06:50
GitHubの基本操作や用語、便利な機能などをまとめたドキュメントです。

GitHub

用語集

  • repository(リポジトリ):ファイルや変更内容が保存される場所のことで、パソコン内にあるものをローカルリポジトリ、GitHubなどローカル以外のサーバ上にあるものをリモートリポジトリと呼ぶ
  • 作業ディレクトリ:リモートリポジトリをclone(複製)したディレクトリ(ローカルリポジトリ)のことで、作業中のファイルが含まれる
  • ステージングエリア:ローカルリポジトリのなかにあるコミットをする予定のファイルを仮置きしておく場所のこと
  • Gitディレクトリ:ステージングエリアにあるファイルをコミット(登録)して、変更が確定したディレクトリ
  • branch(ブランチ):並行して作業を進めるためにmasterブランチからコミットの流れを分岐すること(最終的にmasterブランチにマージ(合体)される)

@plugnburn
plugnburn / README.md
Last active January 31, 2023 15:02
DaBi - live two-way DOM-to-data binding in 25 lines of JS

DaBi: data binding library that keeps it simple

DaBi (short for Data Binding) is a dead simple yet complete and self-contained DOM-to-JS and JS-to-DOM data binding library in just 25 lines of pure ES5 and 454 bytes when minified.

How to obtain

Download it right here or include it into your HTML:

@orther
orther / index.js
Created January 27, 2017 17:34
A few simple examples of sorting with Ramda's sortBy function.
import R from 'ramda';
const items = [
{id: 1, name: 'Al', country: 'AA'},
{id: 2, name: 'Connie', country: 'BB'},
{id: 3, name: 'Doug', country: 'CC'},
{id: 4, name: 'Zen', country: 'BB'},
{id: 5, name: 'DatGGboi', country: 'AA'},
{id: 6, name: 'Connie', country: 'AA'},
];
@voluntas
voluntas / shiguredo_product.rst
Last active May 21, 2024 13:17
時雨堂自社製品コトハジメ
// include ramda library
var users = [
{id:1, name: 'papas', is_published:true},
{id:2, name: 'nick', is_published:false},
{id:3, name: 'Jopahn', is_published:true}
];
<div id=root />
<script type=module>
import React from 'https://dev.jspm.io/react@16'
import ReactDOM from 'https://dev.jspm.io/react-dom@16'
ReactDOM.render(
React.createElement('h1', null, 'hello'),
document.querySelector('#root')
)
</script>
@sebabouche
sebabouche / ramda0.js
Created June 22, 2018 20:15
ramda: compose, bboth, either, gte, prop, equals, __
import { compose, both, either, gte, prop, equals, __ } from "ramda"
const OUR_COUNTRY = "France"
const wasBornInCountry = compose(
equals(OUR_COUNTRY),
prop("birthCountry"),
)
const wasNaturalized = compose(
Boolean,
@sebabouche
sebabouche / ramda1.js
Created June 22, 2018 20:16
ramda: map, filter, partial, partialRight, curry, __, pipe
import { map, filter, partial, partialRight, curry, __, pipe } from "ramda"
const publishedInYear = curry((year, book) => book.year === year)
const titlesForYear = curry((year, books) =>
pipe(
filter(publishedInYear(year)),
map(book => book.title),
)(books),
)
@sebabouche
sebabouche / ramda2.js
Created June 22, 2018 20:16
ramda: ifElse, gte, lt, always, identity, whn, unless
import { ifElse, gte, lt, __, always, identity, when, unless } from "ramda"
// const forever21 = age => (age >= 21 ? 21 : age)
// const forever21 = ifElse(gte(__, 21), always(21), identity)
// const forever21 = unless(lt(__, 21), always(21))
const forever21 = when(gte(__, 21), always(21))
console.log("forever21(24)", forever21(24))
console.log("forever21(16)", forever21(16))