Skip to content

Instantly share code, notes, and snippets.

View bluzky's full-sized avatar
🎯
Focusing

Dung Nguyen bluzky

🎯
Focusing
View GitHub Profile
@bluzky
bluzky / Create a Bootable MacOS Recovery USB with Linux.md
Created March 2, 2023 15:44 — forked from coolaj86/Create a Bootable MacOS Recovery USB with Linux.md
How to create Apple's Bootable MacOS Rescue Image from Linux

See bootableinstaller.com

How to create a Bootable MacOS Recovery USB from Linux

If your Mac is out-of-order or you otherwise cannot download macOS from the App Store, you can still create a bootable OS X recovery USB, and you can use that to create an Installer USB.

The downloads used in this process are legal and freely avaliable - including disk images directly from Apple's IT support pages, and open source utilities for extracting and converting pkg, dmg, and HFS+.

@bluzky
bluzky / fix.md
Created November 30, 2022 13:43
Fix Ubuntu wifi slow

This may fix Ubuntu wifi slow.

Sometimes, after update OS, this setting is reset, so you have to modify it again.

Copy from this thread on AskUbuntu

Check your WiFi MTU, using

ip link

also notice your WiFi interface's name.

@bluzky
bluzky / features.org
Created May 30, 2022 01:37
Web exercise

Bài tập extra improve khả năng thiết kế hệ thống

Xây dựng một website bán hàng cơ bản với các chức năng

Chức năng phần admin:

1. Quản lý người dùng

Người dùng yêu cầu bắt buộc email, password, các trường thông tin còn lại tùy define

  • Đăng nhập
@bluzky
bluzky / github_export.exs
Last active March 30, 2022 08:56
Export your github pull request with Elixir
Mix.install([
{:tesla, "~> 1.4.3"},
{:csv, "~> 2.4"},
{:jason, "~> 1.3"}
])
defmodule GithubPR do
require Logger
def exec(repo, token) do
@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`
@bluzky
bluzky / stream_download.ex
Created January 3, 2022 14:47
Stream download large file from URL in Elixir
defmodule Toolkit.DownloadHelper do
@moduledoc """
Stream download large file from url
"""
require Logger
def stream_download(url, save_path) do
Stream.resource(
fn -> begin_download(url) end,
&continue_download/1,
@bluzky
bluzky / datetime_parser.ex
Created December 11, 2021 16:19
Elixir datetime parser with regex
defmodule DateTimeParser do
@mapping %{
"H" => "(?<hour>\\d{2})",
"I" => "(?<hour12>\\d{2})",
"M" => "(?<minute>\\d{2})",
"S" => "(?<second>\\d{2})",
"d" => "(?<day>\\d{2})",
"m" => "(?<month>\\d{2})",
"y" => "(?<year2>\\d{2})",
"Y" => "(?<year>-?\\d{4})",
@bluzky
bluzky / cache.ex
Created November 12, 2021 13:39
Elixir redis cache
defmodule Toolkit.Cache do
@moduledoc """
Cache provide some helper method to do the cache thing
Backend could be any. Currently using Redis via :redix library
"""
# TODO: move this to config
@redix_conn :octosells_cache
# 512kb
@bluzky
bluzky / image.ex
Created November 9, 2021 09:09
hash image file name arc uploader
defmodule HeraCore.Uploader.AttachmentImage do
use Arc.Definition.Versioning
use Arc.Definition.Storage
# use Arc.Actions.Store
use Arc.Actions.Delete
use Arc.Actions.Url
use Arc.Ecto.Definition
@bluzky
bluzky / challenge.md
Last active October 12, 2021 09:33
Coding challenge Onpoint

Viết 1 module với 1 public function parse để parse chuỗi thời gian về struct DateTime hỗ trợ một số selector cơ bản của strptime

Support format

format description value example
H 24 hour 00 - 23
I 12 hour 00 - 12
m minute 00 - 59
S second 00 - 59
d day 01 - 31