Skip to content

Instantly share code, notes, and snippets.

@sergeyzenchenko
sergeyzenchenko / russia-ddos.md
Last active April 16, 2024 15:32
Russia DDOS list
@Slavenin
Slavenin / fields.ex
Last active October 20, 2022 06:52
Implementation protocol Jason.Encoder with a group of fields support
defmodule MyApp.Serializer.Fields do
defmacro __using__(fields) do
quote do
@json_group_fields unquote(fields)
def get_fields_for_group(group) do
group = MapSet.new(group)
Enum.reduce(@json_group_fields, [], fn {f, g}, acc ->
g = MapSet.new(g)
@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:

@kunicmarko20
kunicmarko20 / ImageProvider.php
Last active February 27, 2023 06:46
Sonata Media SVG Provider
<?php
namespace YourBundle\Provider;
use Sonata\MediaBundle\Provider\FileProvider;
class ImageProvider extends FileProvider
{
}
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {