Skip to content

Instantly share code, notes, and snippets.

View gyzerok's full-sized avatar
🏠
Working from home

Fedor Nezhivoi gyzerok

🏠
Working from home
View GitHub Profile
@kevinold
kevinold / immutable-js-flux-store.js
Created January 31, 2015 23:55
Immutable Flux Store example from Lee Byron (@leeb) from his React.js Conf 2015 talk
var Immutable = require('immutable');
var todos = OrderedMap();
var TodoStore = createStore({
getAll() { return todos; }
});
Dispatcher.register(function(action) {
if (action.actionType === "create") {
var id = createGUID();
@rattrayalex
rattrayalex / app.coffee
Last active September 11, 2018 23:46
Demo
Bacon = require('baconjs')
Imm = require('immutable')
React = require('react')
window.Actions =
changeFirstName: new Bacon.Bus()
changeLastName: new Bacon.Bus()
changeCountry: new Bacon.Bus()
addCountryBird: new Bacon.Bus()
addFriend: new Bacon.Bus()
@ericelliott
ericelliott / essential-javascript-links.md
Last active May 7, 2024 01:25
Essential JavaScript Links
@evancz
evancz / Guidelines.md
Last active October 17, 2023 05:36
Some thoughts on how to have nicer discussions online

Towards Discussion Guidelines

I personally like to have discussions in the spirit of the Socratic method. Instead of declaring my opinion, I ask a relevant question. How about this situation? What about this case? This has two possible outcomes.

  1. The other person explains to me how things work in that case. I realize that I misunderstood, and we both come out enriched and in agreement.
  2. The other person realizes that those situations are not covered. They realize they misunderstood, and we both come out enriched and in agreement.

In both cases, it could have been a conflict, egos crashing together. But by asking questions, it becomes a collaboration to find the best answer. Even the simple act of asking a question in the first place says, "I care what you have to say, we can agree on this." That said, I have noticed that it is definitely still possible for things to go wrong within this framework. How can this happen?

There was a passage from [The

/* Name of Gist */
@staltz
staltz / introrx.md
Last active May 10, 2024 12:08
The introduction to Reactive Programming you've been missing
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 10, 2024 16:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@igstan
igstan / anonymous-recursion.js
Created April 27, 2012 19:14
Anonymous recursion in JavaScript
(function privateName(i) {
if (i === 0)
return;
console.log(i);
privateName(i - 1);
})(5);
@jpoehls
jpoehls / node-cluster-messaging.js
Created March 29, 2012 01:48
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@igstan
igstan / fp.md
Created June 14, 2011 14:41
Patterns and idioms in functional languages

I'll throw my opinion in here, but take it with a pretty large grain of salt as I've done no professional development in a functional language yet. Just tinkering with (quite a few of) them in my spare time. Some of the patterns I spotted are irrespective of type systems (static, dynamic).

  • lists, sequences or similar primitives are ubiquitous
  • abstract away duplicate code using higher-order functions
  • no iteration constructs, recursion is the only way to traverse lists
  • watch out your recursion, be sure it's tail-recursive
  • abstract over this tail-recursive pattern with a higher-order function: foldLeft or foldRight. So, know your language's equivalent of foldLeft/foldRight and prefer these over explicit recursion.
  • abstract over folds in an even more general way and provide folding functions for arbitrary data structures, not just list, e.g., trees.
  • provide a few convenience higher-order functions (implementable using fold) like: map, filter, any/some, all/every, zip, `zipWith