Skip to content

Instantly share code, notes, and snippets.

@chrisvaughn
chrisvaughn / install_ffmpeg_libfdkaac.sh
Last active January 6, 2024 04:35 — forked from rafaelbiriba/install_ffmpeg_libfdkaac.sh
Install FFmpeg with libfdk_aac support (For Ubuntu)
# Criando um script .sh para executar todos os comandos:
#root@servidor:~# vi script.sh
#root@servidor:~# chmod +x script.sh
#root@servidor:~# ./script.sh
apt-get update
apt-get -y install autoconf automake build-essential git-core libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev nasm gcc yasm && true
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
Chicken and Sausage Gumbo
★★★★★
Cold Weather Recipes, Main Dish, Soups
Prep Time: 20 | Cook Time: 2 hr 15 min | Difficulty: Hard | Servings: 8
Ingredients:
3 lbs chicken legs (any bone-in pieces work, but I use all chicken legs so it's easy to pick the bones out.)
1 lb smoked sausage (I think pork gives the most flavor)
3/4 cup vegetable or canola oil
1 cup all-purpose flour
-- takes a 2d array of checkins sorted by year desc.
-- it is assumed that the first elem in the array is the
-- checkins for the same year in the as_of. it will continue to
-- call current_streak for the year data until it finds a break in the streak
CREATE OR REPLACE FUNCTION current_streak_all_years(arr integer[][], as_of date) RETURNS INTEGER AS
$$
DECLARE
total_streak integer := 0;
year_streak integer;
dt date;
CREATE OR REPLACE FUNCTION current_streak_single_year(arr integer[], as_of date) RETURNS INTEGER AS
$$
DECLARE
total_streak integer := 0;
month_streak integer;
dt date;
BEGIN
FOR i IN REVERSE month_index(as_of)..1 LOOP
IF date_part('month', as_of) = i THEN
dt := as_of;
shifted_checkin = 0000100111011111, computed streak should equal 5
0. starting value
0000100111011111
1. invert (~shifted_checkin)
1111011000100000
2. compute "shifted_checkin + 1"
0000100111011111 + 1 = 0000100111100000
3. AND step 1 & 2 (~shifted_checkin & (shifted_checkin + 1))
1111011000100000 & 0000100111100000 = 0000000000100000 = 32
CREATE OR REPLACE FUNCTION current_streak_for_month(x integer, as_of date) RETURNS INTEGER AS
$$
DECLARE
shifted_checkin bigint;
rightmost_zero bigint;
BEGIN
shifted_checkin := x >> 31 - day_of_month(as_of);
rightmost_zero := ~shifted_checkin & (shifted_checkin + 1);
RETURN log(2, rightmost_zero)::INTEGER;
-- HELPER FUNCTIONS
-- returns the day of the month from a date
CREATE OR REPLACE FUNCTION day_of_month(dt date) RETURNS INTEGER AS
$$
SELECT DATE_PART('days', dt)::INTEGER
$$ LANGUAGE SQL;
-- returns the numeric (1-12) value for a month from a date
CREATE OR REPLACE FUNCTION month_index(dt date) RETURNS INTEGER AS
CREATE TABLE "public"."streaks_checkins" (
"user_id" int4 NOT NULL,
"year" int2 NOT NULL,
"checkins" int4[] NOT NULL DEFAULT '{0,0,0,0,0,0,0,0,0,0,0,0}'::integer[],
CONSTRAINT "streaks_checkins_pkey" PRIMARY KEY ("user_id", "year") NOT DEFERRABLE INITIALLY IMMEDIATE
)
CREATE TABLE "public"."streaks" (
"user_id" int4 NOT NULL,
"current_streak" int4 NOT NULL DEFAULT 0,
"longest_streak" int4 NOT NULL DEFAULT 0,
"last_checkin_dt" date NOT NULL,
CONSTRAINT "streaks_pkey" PRIMARY KEY ("user_id") NOT DEFERRABLE INITIALLY IMMEDIATE
)
-- update query
UPDATE streaks
UPDATE streaks
SET current_streak = (
CASE
WHEN %(date)s - last_checkin_dt = 1 THEN current_streak + 1
ELSE 1
END
),
longest_streak = GREATEST(longest_streak, (
CASE
WHEN %(date)s - last_checkin_dt = 1 THEN current_streak + 1