Skip to content

Instantly share code, notes, and snippets.

View kutyel's full-sized avatar
🌊
数学者に俺は成る!

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
@kutyel
kutyel / unfollow.fp.js
Created December 19, 2017 13:48
Twitter Unfollow Bot
'use strict'
require('now-env')
const Twit = require('twit')
const Task = require('data.task')
const Maybe = require('data.maybe')
const bot = new Twit({
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token: process.env.ACCESS_TOKEN,
@kutyel
kutyel / curry.js
Last active August 5, 2019 20:51
My own implementation of curry 🍛
// Ultimate version
const curry = (f, ...args) =>
f.length <= args.length
? f(...args)
: x => curry(f, ...args, x)
@kutyel
kutyel / fp.js
Last active July 17, 2019 17:13
Flavio's functional programming test
/*
* Implement the following classic FP functions using
* _only_ Array.prototype.{reduce|reduceRight}(). 🤓
*/
const filter = f => xs => xs
const map = f => xs => xs
const every = f => xs => xs
@evancz
evancz / data-interchange.md
Last active December 31, 2024 01:04
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@kutyel
kutyel / .editorconfig
Last active November 17, 2017 10:30
Fla's favourite setup!
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@robinpokorny
robinpokorny / 1-info.md
Last active January 17, 2017 13:43
📢 Dead simple tweetable JavaScript Emitter pattern module using Map (ES2015)
@kutyel
kutyel / facebook.js
Last active October 11, 2020 17:31
Question for my Frontend Interview at Facebook
/*
* Create an event emitter that goes like this
* emitter = new Emitter();
*
* Allows you to subscribe to some event
* sub1 = emitter.subscribe('function_name', callback1);
* (you can have multiple callbacks to the same event)
* sub2 = emitter.subscribe('function_name', callback2);
*
* You can emit the event you want with this api
@robinpokorny
robinpokorny / 1-info.md
Last active September 4, 2022 17:27
📰 Dead simple tweetable JavaScript PubSub pattern module using Set (ES2015)
@beaucharman
beaucharman / debounce.js
Last active February 25, 2022 20:35
An ES6 implementation of the debounce function. "Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in 'execute this function only if 100 milliseconds have passed without it being called.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debounc…
function debounce(callback, wait, immediate = false) {
let timeout = null
return function() {
const callNow = immediate && !timeout
const next = () => callback.apply(this, arguments)
clearTimeout(timeout)
timeout = setTimeout(next, wait)
@aarongarciah
aarongarciah / sass-mixins.md
Last active August 17, 2017 08:34
Some useful Sass mixins

###Fluid properties (via)

@mixin fp($property, $min, $max, $start: 320, $end: breakpoint('desktop'), $clip: true, $clipAtStart: true, $clipAtEnd: true) {
	$start: $start / ($start * 0 + 1);
	$end: $end / ($end * 0 + 1);
	$multiplier: ($max - $min) / ($end - $start) * 100;
	$adder: ($min * $end - $max * $start) / ($end - $start);
	$formula: calc(#{$multiplier + 0vw} + #{$adder + 0px});
	@if $clip and $clipAtStart {
		@media (max-width: #{$start + 0px}) {