Skip to content

Instantly share code, notes, and snippets.

@allenk
allenk / capture_raw_frames.c
Created December 11, 2018 23:37 — forked from maxlapshin/capture_raw_frames.c
v4l2 capture example
/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see http://linuxtv.org/docs.php for more information
*/
#include <stdio.h>
@allenk
allenk / ordered_dithering.txt
Created November 16, 2018 23:31 — forked from MehdiNS/ordered_dithering.txt
Ordered dithering explanation
(Written as a way to stop forgetting these things.
May be wrong sometimes, as it's just the result of my research here and there.
If it helps you, give me a shout!)
Ordered dithering is a technique used to reduce - deliberately! - the precision of an image.
Motivation : artistic (mainly ?), color quantization --> reduce the number of color in an image
----------------------------------------------------------------
INTRODUCTION
@allenk
allenk / encoding-video.md
Created October 31, 2018 14:36 — forked from glen-cheney/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@allenk
allenk / bresenham.c
Created October 19, 2017 16:19 — forked from lyjia/bresenham.c
bresenham.c
/********************************************************************
* *
* Curve Rasterizing Algorithm *
* *
********************************************************************/
/**
* @author Zingl Alois
* @date 22.08.2016
* @version 1.2
@allenk
allenk / getline.c
Created October 17, 2017 10:15 — forked from mrkline/getline.c
// MSVC apparently doesn't have C's getline
// This is a poor man's implementation of it using fgets.
// See the man page at
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html
size_t getline(char** buf, size_t* bufLen, FILE* f)
{
if (buf == nullptr || bufLen == nullptr)
{
errno = EINVAL;
return -1;
/**
* Bresenham Curve Rasterizing Algorithms
* @author Zingl Alois
* @date 17.12.2014
* @version 1.3
* @url http://members.chello.at/easyfilter/bresenham.html
*/
function assert(a) {
if (!a) console.log("Assertion failed in bresenham.js "+a);
@allenk
allenk / stb.c
Created September 27, 2017 21:50 — forked from urraka/stb.c
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define STBI_ONLY_PNG
#define STBI_ONLY_JPEG
#define STBI_ONLY_BMP
#define STBI_ONLY_GIF
#include "stb_image.h"
#include "stb_image_write.h"
@allenk
allenk / gist:92fd31bb63172fff57b839d4d9b45600
Created September 16, 2017 21:12 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
@allenk
allenk / slackpost
Created September 16, 2017 16:59 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@allenk
allenk / Free O'Reilly Books.md
Created August 17, 2017 21:35 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.