This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Stack | |
| def self.start_link(state) | |
| GenServer.start_link(new(state)) | |
| end | |
| def self.push(ractor, value) | |
| GenServer.cast(ractor, [:push, value]) | |
| end | |
| def self.pop(ractor) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| old="$IFS" | |
| IFS='_' | |
| notes_dir="~/Documents/notes" | |
| filename="$*" | |
| sep="" | |
| date=$(date +'%Y-%m-%d') | |
| IFS=$old | |
| if [ $filename != "" ]; then | |
| sep="-" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Reducer do | |
| use GenServer | |
| def start_link(state_pid, options \\ []) do | |
| GenServer.start_link(__MODULE__, state_pid, options) | |
| end | |
| def init(state_pid) do | |
| {:ok, %{state_pid: state_pid}} | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Store do | |
| @initializer_action %{type: "@@INIT"} | |
| # Code your Mom calls | |
| def start_link(reducer, initial_state \\ nil) do | |
| GenServer.start_link(__MODULE__, [reducer, initial_state]) | |
| end | |
| def get_state(store) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pry' | |
| def r_count(list) | |
| return 0 if list.empty? | |
| _head, *tail = list | |
| 1 + r_count(tail) | |
| end | |
| def r_sum(list) | |
| return 0 if list.empty? | |
| head, *tail = list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // function showVideo(localMediaStream) { | |
| // var video = document.querySelector('video'); | |
| // video.src = window.URL.createObjectURL(localMediaStream); | |
| // } | |
| // | |
| // navigator.webkitGetUserMedia({video: true, audio: true}, function(localMediaStream) { | |
| // showVideo(localMediaStream) | |
| // }, function(e){ | |
| // console.log("Noooope"); | |
| // }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Person = (function() { | |
| 'use strict'; | |
| // using named expressions for no special reason | |
| var sayHi = function(){ | |
| console.log(`Hi, it's ${this.name}`); | |
| } | |
| var addFriend = function (friendName) { | |
| this.friends.push(friendName) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // // var me = { | |
| // // name: "Steven", | |
| // // sayHi: function(){ | |
| // // console.log(`Hi, my name is chicka chicka ${this.name}`); | |
| // // } | |
| // // } | |
| // | |
| // function Person(name){ | |
| // this.name = name | |
| // this.friends = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create(%{req_headers: headers, remote_ip: remote_ip, request_path: path, body_params: payload, query_params: query_params} = conn, %{"source" => source }) do | |
| Task.async fn -> | |
| merged_headers = headers | |
| |> add_path(path) | |
| |> add_ip(remote_ip) | |
| |> Enum.into(%{}) | |
| changeset = Event.validate(%Event{}, source, merged_headers, payload, query_params) | |
| case Repo.insert(changeset) do | |
| {:ok, event} -> |
NewerOlder