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
@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);
module InputWithAddAction (Model, Action, view, update, init) where
import Html exposing (div, input, button, text)
import Html.Events exposing (onClick, on, targetValue)
import Html.Attributes exposing (value)
import Signal
type Action = UpdatedValue String
/* Name of Gist */
@igstan
igstan / state-monad.js
Created May 1, 2011 23:09
State Monad in JavaScript
var push = function (value) {
return function (stack) {
var newStack = [value].concat(stack);
return { value:undefined, stack:newStack };
};
};
var pop = function () {
return function (stack) {
var value = stack[0];
@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()
@igstan
igstan / state-monad.coffee
Created April 22, 2011 11:57
State Monad in CoffeeScript
push = (element) -> (stack) ->
newStack = [element].concat stack
{value: element, stack: newStack}
pop = (stack) ->
element = stack[0]
newStack = stack.slice 1
{value: element, stack: newStack}
bind = (stackOperation, continuation) -> (stack) ->
@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
@ykarikos
ykarikos / 0-aggregate-audio.md
Last active December 5, 2020 21:45
Aggregate live microphone and music in same audio output in MacOS

Aggregate live microphone and music in same audio output in MacOS

Here's how you can combine the audio output of some music software (e.g. Garageband) and microphone simultaneously as the input to a streaming software (e.g. Google Meet) and your headphones. I used this setup to be able to play music from Garageband and talk in Google Meet.

1. Install Soundflower

See https://github.com/mattingalls/Soundflower/releases/

2. Setup audio devices

The Why and When of Choosing Elm

What is Elm?

  • Language (and "framework") for building web frontend applications
  • Can be used in place of HTML, CSS and JavaScript
  • Compiles into the above