Skip to content

Instantly share code, notes, and snippets.

View json2d's full-sized avatar
🙂
try your baz!

Jason Yung json2d

🙂
try your baz!
View GitHub Profile
@ryanguill
ryanguill / postgres-merge-arrays.sql
Created December 21, 2016 16:41
in postgres, there currently isnt a function to combine two arrays and remove duplicates - this will do that.
CREATE OR REPLACE FUNCTION mergeArrays (a1 ANYARRAY, a2 ANYARRAY) RETURNS ANYARRAY AS $$
SELECT ARRAY_AGG(x ORDER BY x)
FROM (
SELECT DISTINCT UNNEST($1 || $2) AS x
) s;
$$ LANGUAGE SQL STRICT;
@json2d
json2d / state-arg-reselect.js
Last active February 9, 2020 03:56
proposal to put state into callback scope through 'this'
const entryByIdSelector = (state) => state.todos.entrybyId
const recentIdsSelector = (state) => state.todos.recentIds
const entrySelector = _.memoize(
(id) => createSelector(
entryByIdSelector,
(entryById) => entryById[id]
)
)