Skip to content

Instantly share code, notes, and snippets.

View 3v0k4's full-sized avatar

Riccardo 3v0k4

View GitHub Profile
mysql> SELECT title, genre, count(*) FROM films GROUP BY genre;
+-------------------+----------+----------+
| title | genre | count(*) |
+-------------------+----------+----------+
| Arrival | scifi | 1 |
| Blade Runner 2049 | thriller | 2 |
+-------------------+----------+----------+
mysql> SELECT title, genre, count(*) FROM films GROUP BY genre;
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'some_database.films.title' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
const procedural = s => {
try {
const parsed = JSON.parse(s);
if (parsed.length > 0) {
const first = parsed[0]
const upperCased = first.toUpperCase()
return upperCased.concat('!')
} else {
return "empty array"
}
const format = s => Right(s).map(upper).map(shout)
const functional = s => Right(s).chain(parse).chain(first).chain(format)
functional('["hello", "world"]')
// Right(HELLO!)
const format = array => {
if (array.length > 0) {
return array[0].toUpperCase().concat('!')
} else {
return "empty array"
}
}
const procedural = s => {
try {
const format = array => {
if (array.length > 0) {
return array[0].toUpperCase().concat('!')
} else {
return "empty array"
}
}
const procedural = (s, callback) => {
try {
const Box = x =>
({
x
})
const primitive = 1
const boxedPrimitive = Box(1)
const Box = x =>
({
x,
map: f => Box(f(x))
})
const primitive = 1
const sum1 = primitive + 2 // 3
const boxedPrimitive = Box(1)
const Box = x =>
({
x,
map: f => Box(f(x)),
chain: f => f(x)
})
const boxedPrimitive = Box(1)
const sum = boxedPrimitive.chain(x => x + 2) // 3
const Right = x =>
({
x,
map: f => Right(f(x)),
chain: f => f(x)
})
const Left = x =>
({
x,