Skip to content

Instantly share code, notes, and snippets.

View hopsor's full-sized avatar

Victor Viruete hopsor

View GitHub Profile
defmodule Zoquete.Mixfile do
use Mix.Project
...
defp deps do
[
{:phoenix, "~> 1.3.2"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_html, "~> 2.10"},
@hopsor
hopsor / v2.ex
Last active June 11, 2018 15:34
Phoenix Custom Socket Serializers
defmodule ZoqueteWeb.SocketSerializer.V2 do
@moduledoc false
@behaviour Phoenix.Transports.Serializer
alias Phoenix.Socket.{Reply, Message, Broadcast}
@doc """
Translates a `Phoenix.Socket.Broadcast` into a `Phoenix.Socket.Message`.
"""
@hopsor
hopsor / ftp.ex
Last active February 16, 2021 07:18
ftp download using elixir and erlang interop
defmodule Reporter do
def progress(last_data, file_name, {size_type, chunk_size}) do
IO.inspect({last_data[:downloaded], "#{last_data[:rate]} MB/s", file_name, size_type, chunk_size})
new_timestamp = :os.system_time(:milli_seconds)
timestamp_diff = new_timestamp - last_data[:last_timestamp]
case chunk_size do
:unknown ->
downloaded = 0
@hopsor
hopsor / Vagrantfile
Last active November 18, 2020 10:28
Vagrant provision script for Rails development environment
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.