Skip to content

Instantly share code, notes, and snippets.

@bluzky
bluzky / request_helper.ex
Last active July 17, 2022 15:21
Elixir download/stream large file with hackney
View request_helper.ex
defmodule RequestHelper do
@moduledoc """
Reference from https://gist.github.com/avdi/7990684
Stream download large file from url
"""
require Logger
@doc """
Get stream data from url
mode could be `:binary` or `:line`
@arpitdsoni
arpitdsoni / PlaceHolderTextEditor.swift
Created February 22, 2021 01:03
SwiftUI TextEditor with placeholder and border.
View PlaceHolderTextEditor.swift
struct PlaceHolderTextEditor: View {
let placeholder: String
@Binding var text: String
var body: some View {
ZStack(alignment: Alignment(horizontal: .leading, vertical: .top)) {
if text.isEmpty {
Text(placeholder)
.foregroundColor(Color(.label))
.padding(.top, 10)
}
@andreaseriksson
andreaseriksson / _user_menu.html.eex
Created January 27, 2021 07:33
Use phoenix_live_session to communicate bewteen live views
View _user_menu.html.eex
<%= live_render @conn, EcommerceWeb.CartLive %>
@LordotU
LordotU / acme.json
Created December 20, 2019 22:14
Traefik 1.7.* as Reverse Proxy And Let's Encrypt
View acme.json
# This file should be empty and its permission should be 600
@alvises
alvises / app.exs
Created November 22, 2019 17:42
app.exs test script which connects two Elixir nodes running in two containers
View app.exs
IO.puts("I'm here! Sleeping for 2 seconds")
Process.sleep 2_000 # waiting for the other node
nodes = MapSet.new([:app@app1, :app@app2])
other_node =
nodes
|> MapSet.delete(Node.self())
|> MapSet.to_list()
|> List.first()
@christopherlai
christopherlai / Dockerfile
Created September 16, 2019 22:57
Example Dockerfile for Elixir 1.9.1 umbrella project
View Dockerfile
FROM elixir:1.9.1-alpine as build
ENV MIX_ENV=prod
WORKDIR /build
RUN apk add --no-cache build-base nodejs yarn && \
mix local.hex --force && \
mix local.rebar --force
@leonid-s-usov
leonid-s-usov / RecordAudio.swift
Last active December 20, 2022 04:14 — forked from hotpaw2/RecordAudio.swift
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
View RecordAudio.swift
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.
View webpack.config.js
const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const css_loaders = [
@Kyle2142
Kyle2142 / Userbot admin scripts.md
Last active July 2, 2021 11:52
Some helper scripts that might be of use, for multi-userbot, multi-group administration
View Userbot admin scripts.md

All of these were created to work with multiple client situations, but you can easily pass [client] to work on one.

Note that in most cases, you will need to tweak the instructions (e.g. by adding exception handling) if the clients you run it on are not admins, or other things that happen in "less-than-perfect" situations

@anildigital
anildigital / dynamic_supervisor_example.ex
Created February 18, 2018 12:36
Simple Example for Dynamic Supervisor
View dynamic_supervisor_example.ex
defmodule Worker1 do
def start_link() do
Task.start_link(fn ->
Stream.repeatedly(fn -> :rand.uniform(1000) end)
|> Stream.each(&:timer.sleep/1)
|> Stream.each(fn _ -> IO.puts("worker 1") end)
|> Stream.run()
end)
end
end