This file contains 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
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0: | |
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html | |
defmodule DrainStop do | |
@moduledoc """ | |
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown | |
occurs. It first shuts down the acceptor, ensuring that no new requests can be | |
made. It then waits for all pending requests to complete. If the timeout | |
expires before this happens, it stops waiting, allowing the supervision tree | |
to continue its shutdown order. |
This file contains 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 ID3Parser do | |
@id3_tag_size 128 | |
def parse(file_name, io_input \\ &File.read/1, io_output \\ &IO.puts/1) do | |
case io_input.(file_name) do | |
{:ok, binary} -> | |
{title, artist, album, year, comment} = parse_binary(binary) | |
io_output.(title) |
This file contains 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 Kmeans do | |
def test_points do | |
# This just outputs 100 random points for testing purposes | |
Stream.repeatedly(fn -> :random.uniform(100) end) | |
|> Stream.chunk(3) | |
|> Enum.take(100) | |
|> Enum.map(&List.to_tuple/1) | |
end | |
def point_range(list) when is_list(list) do |
This file contains 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
How to load page-specific JS functions and pass values to those functions when JS is loaded below your views. |
This file contains 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
(ns om-routing.core | |
(:require-macros [secretary.core :refer [defroute]] | |
[cljs.core.async.macros :refer [go go-loop]]) | |
(:require [om.core :as om :include-macros true] | |
[om-tools.core :refer-macros [defcomponent]] | |
[sablono.core :as h :refer-macros [html]] | |
[secretary.core :as secretary :include-macros true] | |
[goog.events :as events] | |
[goog.history.EventType :as EventType] | |
[cljs.core.async :refer [put! chan <! pub sub]]) |
This file contains 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
#!/usr/local/bin/python | |
""" | |
To use this script, you must be in the root directory of a Rails project that | |
is using git. You should also make sure that your directory does not contain any | |
uncommitted changes. Then run: | |
$ python rails_switch_branch.py name_of_another_branch | |
Running the above will do the following: |
This file contains 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
This playbook has been removed as it is now very outdated. |