Skip to content

Instantly share code, notes, and snippets.

View Laurian's full-sized avatar

Laurian Gridinoc Laurian

  • Creative Technologist ※ Knight-Mozilla OpenNews Fellow ※ Visual analytics × Computational Linguistics × Semantic Web
  • Cyberspace
  • X @gridinoc
View GitHub Profile
@Laurian
Laurian / chat_chain.py
Created March 23, 2024 06:09
using PostgresChatMessageHistory
from dotenv import dotenv_values
import os
from typing import List, Tuple
from langchain.callbacks.tracers import ConsoleCallbackHandler
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.runnables import (
RunnableParallel,
@Laurian
Laurian / gist:b814acc62e1a05b1b16c3636dac7a6fd
Created May 10, 2020 07:19
ffmpeg + mpv (@slifty iMac webcam to mini display port)
ffmpeg -f avfoundation -i "2" -f avi - | mpv - --screen=1
ffmpeg -f avfoundation -i "2:none" -vcodec libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv422p -f mpegts - | mpv - --fs --screen=1
ffmpeg -f avfoundation -i "2:none" -vcodec libx264 -fflags nobuffer -qp:v 26 -bf 0 -tune zerolatency -pix_fmt yuv422p -f mpegts - | mpv - demuxer-lavf-o-add=fflags=+nobuffer --fs --screen=1 --no-cache --untimed --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@Laurian
Laurian / ffmpeg.sh
Created April 24, 2020 19:13 — forked from crookm/ffmpeg.sh
FFmpeg commands to create DASH and HLS
mkdir dash && \
ffmpeg -hide_banner -i original.mkv -c:v libvpx-vp9 -row-mt 1 -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 \
-movflags faststart -f webm -dash 1 -speed 3 -threads 4 -an -vf scale=426:240 -b:v 400k -r 30 -dash 1 dash/426x240-30-400k.webm && \
ffmpeg -hide_banner -i original.mkv -c:v libvpx-vp9 -row-mt 1 -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 \
-movflags faststart -f webm -dash 1 -speed 3 -threads 4 -an -vf scale=426:240 -b:v 600k -r 30 -dash 1 dash/426x240-30-600k.webm && \
ffmpeg -hide_banner -i original.mkv -c:v libvpx-vp9 -row-mt 1 -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 \
-movflags faststart -f webm -dash 1 -speed 3 -threads 4 -an -vf scale=640:360 -b:v 700k -r 30 -dash 1 dash/640x360-30-700k.webm && \
ffmpeg -hide_banner -i original.mkv -c:v libvpx-vp9 -row-mt 1 -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 \
-movflags faststart -f webm -dash 1 -speed 3 -threads 4 -an -vf scale=640:360 -b:v 900k -r 30 -dash 1 dash/640x360-30-900k.we
@Laurian
Laurian / story.css
Created April 17, 2018 08:50
story.interviewjs.io CSS
@font-face{
font-family:icomoon;
src:url(/static/media/icomoon.5a607ab9.eot);
src:url(/static/media/icomoon.5a607ab9.eot#iefix) format("embedded-opentype"),url(/static/media/icomoon.cb4d6797.ttf) format("truetype"),url(/static/media/icomoon.ae37fc8e.woff) format("woff"),url(/static/media/icomoon.48533d8d.svg#icomoon) format("svg");
font-weight:400;
font-style:normal
}
[class*=" icon-"],[class^=icon-]{
font-family:icomoon!important;
speak:none;
@Laurian
Laurian / SOLON.txt
Created January 18, 2018 16:24
SOLON CR
SOLON CR is indicated for the short-term treatment of psychological unease grounded in obsession with thinking about the near future. By severing the link between the present moment and a patient’s perceived future state, researchers have found a pronounced and significant drop in all forms of anxiety. As well, researchers have found that disengagement with “the future” has allowed many patients complaining of persistent loneliness to live active and productive single lives with no fear or anxiety.
@Laurian
Laurian / database.cnf
Created November 16, 2017 17:31
Experimental: reading dpwe/audfprint signatures into mysql using worldveil/dejavu code
{
"database": {
"host": "127.0.0.1",
"user": "root",
"passwd": "",
"db": "dejavu"
}
}
@Laurian
Laurian / handlebars.tag
Created September 14, 2017 23:59
Handlebars.tag (JSP), `<h:handlebars template="example" context="${pageContext}" />`
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ tag import="java.util.*" %>
<%@ tag import="com.github.jknack.handlebars.io.TemplateLoader" %>
<%@ tag import="com.github.jknack.handlebars.io.ServletContextTemplateLoader" %>
<%@ tag import="com.github.jknack.handlebars.Handlebars" %>
<%@ tag import="com.github.jknack.handlebars.Template" %>
<%@ tag import="com.github.jknack.handlebars.Context" %>
<%@ attribute name="template" required="true" %>
<%@ attribute name="context" required="true" type="javax.servlet.jsp.PageContext" %>
<%
@Laurian
Laurian / Dockerfile
Last active October 13, 2016 01:36
Simple fix for local file changes for https://github.com/nypublicradio/audiogram
FROM ubuntu:16.04
# Install dependencies
RUN apt-get update --yes && apt-get upgrade --yes
RUN apt-get install git nodejs npm \
libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ \
ffmpeg \
libgroove-dev zlib1g-dev libpng-dev \
redis-server --yes
@Laurian
Laurian / README.md
Created August 19, 2016 18:31
VideoStitch with URLs (videos from PalestineRemix.com)

To allow URLs I had to modify https://github.com/ArsalanDotMe/VideoStitch/blob/master/lib/videoconcat.js#L48

let child = shelljs.exec(`ffmpeg -f concat -i ${args.fileList} -c copy ${outputFileName}`, { async: true, silent: spec.silent });

to

let child = shelljs.exec(`ffmpeg -f concat -safe 0 -protocol_whitelist file,http,https,tcp,tls -i ${args.fileList} -c copy ${outputFileName}`, { async: true, silent: spec.silent });