Skip to content

Instantly share code, notes, and snippets.

# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = Cezar Neaga
email = hi@cezarneaga.eu
[branch]
autosetuprebase = always
[color "status"]
added = green
changed = yellow
@cezarneaga
cezarneaga / filterArraysRamda.md
Last active April 26, 2023 07:52
Filter array of objects by nested values using ramda: Sometimes you dont have access to backend and you want to filter the response from an endpoint based on certain criteria. While trivial on flat arrays, this gets a bit tricky if the property you want to query is deeply nested. This is where Ramda shines.

Say we have a prop.users of the shape:

const users = [
    {username: 'bob', age: 30, tags: [{name: 'work', id: 1}, {name: 'boring', id: 2}]},
    {username: 'jim', age: 25, tags: [{name: 'home', id: 3}, {name: 'fun', id: 4}]},
    {username: 'jane', age: 30, tags: [{name: 'vacation', id: 5}, {name: 'fun', id: 4}]}
];
@cezarneaga
cezarneaga / filterByDateCond.js
Created September 26, 2017 07:26
Filter an array by date condition and return certain props only with Ramda.
const array = [{id: 1, createdAt: '2016-09-22 15:55:08'}, {id: 2, createdAt: '2017-11-22 15:55:08'}]
const dateCheck = date =>
new Date(date).getFullYear() >= new Date().getFullYear()
R.pluck('id', R.filter(R.propSatisfies(dateCheck, 'createdAt'))(array))
@cezarneaga
cezarneaga / reasonReactChecklist.md
Last active November 5, 2017 19:17
setup checklist for ReasonReact

Check node and npm versions.

Ideally you should be on latest node v8.8 and npm 5.4.2.

If you use nvm make sure you are using the right version.

Initial setup

run npm install -g bs-platform

Editor setup

@cezarneaga
cezarneaga / Workshop Handout.md
Last active November 23, 2017 19:22
a sum-up of recorded knowhow

Reason Workshop @ReactiveConf 2017

by: Sean Grove, Jared Forsyth, Daniel Woelfel
support team: Cristiano Calcagno, @reasonvienna - @ryyppy @svensauleau @cezarneaga and @nikgraf in spirit, @matystl, @MyNaartjie

Support and Questions: Join discord channel

Workshop Presentation

  • workshop flow and exercises
const path = require('path')
module.exports = {
entry: {
subdomains: './src/index.js',
},
optimization: {
occurrenceOrder: true,
splitChunks: {
cacheGroups: {
@cezarneaga
cezarneaga / ReadingTime.js
Created July 9, 2018 20:16
display approximate reading time
countWords = text => {
return text.split(/\s+/).length
}
const words = this.countWords(article.body)
const readTime = Math.round(words / 250)
const minutes = readTime === 1 ? 'minute' : 'minutes'
//Render this
Aproximately {readTime} {minutes}
@cezarneaga
cezarneaga / arrayByArray.md
Created February 13, 2019 22:28
filter array by array
const array = [1, 2, 4]
const collection = [{ type: 1, eyes: 'blue'},{ type: 2, eyes: 'brown'}, { type: 3, eyes: 'green'}, { type: 4, eyes: 'blue'}]

const joinByType = R.innerJoin(
  (o, type) => o.type === type
)

const result = joinByType(collection, array)
@cezarneaga
cezarneaga / js-2-tsx.sh
Created March 22, 2019 09:20
changes files extensions to tsx
shopt -s globstar # enable ** globstar/recursivity
for i in **/*.js; do
[[ -d "$i" ]] && continue; # skip directories
mv "$i" "${i/%.js}.tsx";
done
@cezarneaga
cezarneaga / local-ssl-certificates-that-work.md
Last active October 17, 2019 21:20
ssl ceritificates that work

local ssl certificates that work

motivation

in web dev sometimes you are constrained to develop from behind a https:// local server. i spent two days making this work and i want to write it down here, so that next time apple upgrades OS X and i decide to do a clean install (forgetting to backup certain things) i dont waste this amount of time anymore (i hope).

maybe it helps someone else too. that would make me very happy too.

forget openssl

major pita to remember commands. i don't think there is anything better that makes your mom feel like you are a hacker, than showing her how to type: