Skip to content

Instantly share code, notes, and snippets.

@sergeyzenchenko
sergeyzenchenko / russia-ddos.md
Last active October 14, 2024 20:06
Russia DDOS list
@mudssrali
mudssrali / elixir-crypto-one-time.ex
Last active December 10, 2024 09:37
Elixir implementation of AES encryption and decryption using erlang's :crypto.crypto_one_time with initialization vector
defmodule Cipher.AES do
@moduledoc """
Functions related to encrypting and decrypting data using the Advanced
Encryption Standard (AES).
"""
@block_size 16
@secret_key "put something secret here"
@doc """
@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 October 14, 2024 09:32
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 May 22, 2024 12:30
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 => {