This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install --cask anaconda | |
/opt/homebrew/anaconda3/bin/conda init zsh | |
source ~/.zshrc | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails: Is there a rails trick to adding commas to large numbers? | |
# https://stackoverflow.com/a/1078366/1399891 | |
123456.to_fs(:delimited) # => "123,456" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# This file is the source Rails uses to define your schema when running `bin/rails | |
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to | |
# be faster and is potentially less error prone than running all of your | |
# migrations from scratch. Old migrations may fail to apply correctly if those | |
# migrations use external dependencies or application code. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# This file is the source Rails uses to define your schema when running `bin/rails | |
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to | |
# be faster and is potentially less error prone than running all of your | |
# migrations from scratch. Old migrations may fail to apply correctly if those | |
# migrations use external dependencies or application code. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
after_action :track_action | |
protected | |
def track_action | |
ahoy.track "Called API", request.path_parameters.merge(log_request, log_response) | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
def is_owner user_id | |
unless user_id == current_user.id | |
render json: nil, status: :forbidden | |
return | |
end | |
end | |
def is_owner_object data | |
if data.nil? or data.user_id.nil? | |
return render status: :not_found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#EXTM3U | |
#EXT-X-VERSION:3 | |
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360 | |
360/360.m3u8 | |
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720 | |
720/720.m3u8 | |
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080 | |
1080/1080.m3u8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
start=$(date) | |
# source="trailer_1080p.ogg" | |
# target="trailer" | |
source=${1} | |
target=${2} | |
rm -rf ${target} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#EXTM3U | |
#EXT-X-VERSION:3 | |
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360 | |
360p.m3u8 | |
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=842x480 | |
480p.m3u8 | |
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720 | |
720p.m3u8 | |
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080 | |
1080p.m3u8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Usage create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME] | |
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1 | |
source="${1}" | |
target="${2}" | |
command="ffmpeg -hide_banner -y -i ${1} \ | |
-vf scale=w=640:h=360 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 800k -maxrate 856k -bufsize 1200k -b:a 96k -hls_segment_filename ${target}/360p_%03d.ts ${target}/360p.m3u8 \ | |
-vf scale=w=842:h=480 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 1400k -maxrate 1498k -bufsize 2100k -b:a 128k -hls_segment_filename ${target}/480p_%03d.ts ${target}/480p.m3u8 \ | |
-vf scale=w=1280:h=720 -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 2800k -maxrate 2996k -bufsize 4200k -b:a 128k -hls_segment_filename ${target}/720p_%03d.ts ${tar |
NewerOlder