Skip to content

Instantly share code, notes, and snippets.

View miketahani's full-sized avatar

Mike Tahani miketahani

View GitHub Profile
/* post-fx pass by blending a solid white fullscreen quad, no texture required */
/*uniform*/ float fmin = 0.7;
void main(void)
{
float fmod = mod(gl_FragCoord.y, 2.0);
float fstep = fmin + (1.0 - fmin) * fmod;
gl_FragColor = vec4(1.0, 1.0, 1.0, fstep);
}

How to update Homebrew after using Migration Assistant to go from an Intel-based Mac to M1.

  1. Remove /usr/local/bin from your PATH (e.g. echo $PATH then export PATH=... without /usr/local/bin in it)
  • This was tricky because /usr/local/bin had been added to the path from multiple locations and by multiple processes (also had to check ~/.z* for e.g. .zprofile and .zenv)
  1. wget https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh (https://github.com/Homebrew/install#uninstall-homebrew)
  2. brew bundle dump to get a list of installed packages
  3. chmod +x uninstall.sh && sudo ./uninstall.sh --path=/usr/local
  4. rm -rf /usr/local/Caskroom && rm -rf /usr/local/Cellar (if the script didn't do it)
  5. brew bundle install --file Brewfile to reinstall old packages
@miketahani
miketahani / convert-mp4-to-gif.mkd
Created March 30, 2021 06:56 — forked from tomnomnom/convert-mp4-to-gif.mkd
Crop an mp4 and convert it to a gif

Because I'll forget how to do this...

Crop

crop=w:h:x:y

ffmpeg -i in.mp4 -filter:v "crop=900:700:0:50" out.mp4

convert mp4 to gif

$ ffmpeg -ss 61.0 -t 2.5 -i input.mp4 -filter_complex "[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif

  • -ss 61.0: start gif at 61.0 seconds into video
  • -t 2.5: gif duration of 2.5 seconds (starting at 61.0 seconds into video)

crop existing gif

convert input.gif -coalesce -repage 0x0 -crop 343x310+0+65 +repage output.gif

@miketahani
miketahani / DrawInstances.frag
Last active December 17, 2020 01:58 — forked from mantissa/DrawInstances.frag
Drawing instanced meshes using matrices contained in textures (OpenFrameworks)
#version 120
#extension GL_EXT_gpu_shader4 : require
void main(){
gl_FragColor = gl_Color;
}
@miketahani
miketahani / MakingGeometries.md
Created December 12, 2020 18:03 — forked from patriciogonzalezvivo/MakingGeometries.md
Creating Geometries in openFrameworks

Face by Face

void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) {
	ofVec3f normal = ((b - a).cross(c - a)).normalize();
	mesh.addNormal(normal);
	mesh.addVertex(a);
	mesh.addNormal(normal);
	mesh.addVertex(b);
	mesh.addNormal(normal);
@miketahani
miketahani / motion_vector.c
Created September 20, 2020 03:16 — forked from w495/motion_vector.c
Пример построения векторов движения с помощью libav. Выводит координаты точек и векторов на stdout. Проверялось на коротких mp4 (h264 / aac). Начальный вариант был взят тут: http://www.princeton.edu/~jiasic/cos435/motion_vector.c и переписан под современный ffmpeg.
/**
* MOTION_VECTOR
*
* Calculates motion vector using ffmpeg and libavcodec.
*
* @authors First modifications by Victor Hsieh.
* Second modifications by Jiasi Chen.
* Third modifications by Ilya Nikitin <w@w-495.ru>.
*
* @date: 2014.05.10 23:30:13
@miketahani
miketahani / rpi4-setup.md
Created August 11, 2020 18:29
Raspberry Pi 4 with external boot SSD

Raspberry Pi 4 setup

For barebones initial setup of a Pi to boot from an external, USB-connected SSD.

Follow instructions in this tutorial, reproduced below:

  1. Flash SD card using Raspberry Pi Imager

  2. touch /Volumes/<volume>/ssh to enable SSH on boot

@miketahani
miketahani / web-servers.md
Created May 26, 2020 03:31 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>single page react boilerplate</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="kokaneka">
</head>