Skip to content

Instantly share code, notes, and snippets.

@bluzky
bluzky / request_helper.ex
Last active July 21, 2023 05:01
Elixir download/stream large file with hackney
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`
@io-st
io-st / index.html
Last active July 20, 2023 09:51
plyr.io HLS/.m3u8 Stream with video qualities
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/plyr@3/dist/plyr.css">
<link rel="stylesheet" href="./style.ccs">
<script src="https://cdn.jsdelivr.net/npm/hls.js"></script>
<script src="https://unpkg.com/plyr@3"></script>
<script src="./plyr-hls.js"></script>
<div class="container">
<video controls crossorigin playsinline>
@code4you2021
code4you2021 / notification.swift
Created November 8, 2021 02:18
Deliver an OSX notification with Swift
// Remember: import UserNotifications
func sendNotification(title: String, body: String = "") {
let content = UNMutableNotificationContent()
content.title = title
if body.count > 0 {
content.body = body
}
@arpitdsoni
arpitdsoni / PlaceHolderTextEditor.swift
Created February 22, 2021 01:03
SwiftUI TextEditor with placeholder and border.
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
<%= 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
# 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
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
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
@stokito
stokito / create_patch.sh
Last active February 16, 2024 07:44
git: create a single patch file with multiple commits
# last three commits
git format-patch -3 --stdout > multi_commit.patch
# all commits that are in your branch and not in master into a single patch file multi_commit.patch
git format-patch --signoff master --stdout > multi_commit.patch
# create patches in the folder ~/output/directory/ for all commits that are in your branch and not in master
git format-patch -o ~/output/directory/ --signoff master
@leonid-s-usov
leonid-s-usov / RecordAudio.swift
Last active March 20, 2024 09:12 — forked from hotpaw2/RecordAudio.swift
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// 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.