Skip to content

Instantly share code, notes, and snippets.

@wpiekutowski
wpiekutowski / some_subscription_test.exs
Created August 7, 2020 13:34
Testing subscriptions: Elixir + Absinthe + Phoenix WebSocket
defmodule App.Schema.SomeSubscriptionTest do
use App.SubscriptionCase
test "subscription: someSubscription" do
subscription_query = """
subscription {
someSubscription {
someData
}
}
hass:account
hass:alert
hass:alert-circle
hass:altimeter
hass:apple-safari
hass:apps
hass:arrow-bottom-left
hass:arrow-down
hass:arrow-left
hass:arrow-right
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@cvan
cvan / webgl-detect-gpu.js
Last active January 19, 2024 02:54
use JavaScript to detect GPU used from within your browser
var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
}
@phansch
phansch / yardoc_cheatsheet.md
Last active July 18, 2024 15:02 — forked from chetan/yardoc_cheatsheet.md
Improved YARD cheatsheet
@manojpandey
manojpandey / rgb2lab.py
Created August 12, 2016 10:34
RGB to CIELab color space conversion
# RGB to Lab conversion
# Step 1: RGB to XYZ
# http://www.easyrgb.com/index.php?X=MATH&H=02#text2
# Step 2: XYZ to Lab
# http://www.easyrgb.com/index.php?X=MATH&H=07#text7
def rgb2lab(inputColor):
@sumerman
sumerman / escape_shell.ex
Created October 12, 2015 09:36
Escape shell arguments in elixir
defmodule Shell do
def escape_value(value), do: escape_value(value, "")
defp escape_value("", res), do: "\"#{res}\""
defp escape_value("\"" <> value, res), do: escape_value(value, res <> "\\\"")
defp escape_value("\\" <> value, res), do: escape_value(value, res <> "\\\\")
defp escape_value(<<char :: utf8, rest :: binary>>, res),
do: escape_value(rest, res <> <<char>>)
end
@bryanhunter
bryanhunter / bumper.exs
Created January 20, 2015 21:18
Example of Elixir and the bit-syntax to read a Bitmap image
defmodule Bumper do
@doc ~S"""
Reads a Bitmap (24-bit) and displays width, height, and the RGB of each pixel
"""
def show(filename) do
{:ok, bindata} = File.read(filename)
<< "BM",
_::size(64),
offset_to_pixels::size(32)-little,
@djo
djo / deploy.rb
Last active December 21, 2023 07:08
Rails, Nginx, XSendfile, and X-Accel-Mapping
# Symlink the shared protected folder
run "ln -nfs #{shared_path}/protected #{latest_release}/protected"
@mattetti
mattetti / multipart_upload.go
Last active July 18, 2024 17:31
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"