Skip to content

Instantly share code, notes, and snippets.

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

Yuri S. Fudoshiki

🏠
Working from home
View GitHub Profile
@Fudoshiki
Fudoshiki / drain_stop.ex
Created December 13, 2018 04:57 — forked from chrismccord/drain_stop.ex
Phoenix Drain Stop
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.
DrainStop should be installed in your supervision tree *after* the
EndPoint it is going to drain stop.
defp fetch_dev_server path do
case :gen_tcp.connect {:local, "/tmp/webpack"}, 0, [:binary, active: false, packet: 0] do
{:ok, socket} ->
:gen_tcp.send socket, "GET /#{path}.css HTTP/1.1\r\n\r\n"
{:ok, response} = :gen_tcp.recv socket, 0
length = List.last(Regex.run ~r{Content-Length: (\d+)}, response) |> String.to_integer
start_bin = Enum.slice String.split(response, "\r\n"), 7..-1
case length <= 1460 do
@Fudoshiki
Fudoshiki / sublime-command-line.md
Created September 12, 2017 20:32
Launch Sublime Text from the command line on OSX

Launch Sublime Text from the command line on OSX

Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.

Requirements

  • Sublime text 2 or 3 installed in your system within Applications folder

Setup

@Fudoshiki
Fudoshiki / mongod.conf
Created October 14, 2015 05:45
MongodDB 3.0, wiredTiger, zlib, unixDomainSocket, yml format
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log