Skip to content

Instantly share code, notes, and snippets.

@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@bertbalcaen
bertbalcaen / Extract all frames from a 24 fps movie using ffmpeg
Last active April 6, 2021 09:02
Extract all frames from a 24 fps movie using ffmpeg
ffmpeg -i shame-run.mov -r 24/1 test/output%03d.jpg
//Eigen::MatrixXd src = pointsToMatrix(pointsA[i]);
//Eigen::MatrixXd dst = pointsToMatrix(pointsB[j]);
//Eigen::Matrix4d cR_t = Eigen::umeyama(src, dst, true);
//Eigen::Matrix4d R_t = Eigen::umeyama(src, dst, false);
//Eigen::Matrix3d R = R_t.block(0,0,3,3);
//Eigen::Vector3d t = R_t.block(0,3,3,1);
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

@JesseScott
JesseScott / Leo !!!
Last active December 3, 2019 19:39
LEO !!!!
Leó Stefánsson
@prophetgoddess
prophetgoddess / pixelsort.py
Last active June 13, 2024 01:40
Python pixel sorting.
# The MIT License (MIT)
# Copyright (c) 2014 Lycaon (lycaon.me)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@bitchwhocodes
bitchwhocodes / gist:1b3297bd3dbf7be93f72
Created December 22, 2014 02:31
Arduino NeoPixels Animation without using Delay
#include <Adafruit_NeoPixel.h>
#define NUM_PIXELS 60
unsigned long interval=50; // the time we need to wait
unsigned long previousMillis=0;
uint32_t currentColor;// current Color in case we need it
uint16_t currentPixel = 0;// what pixel are we operating on
@johnpaulmanoza
johnpaulmanoza / GPUImageFourInputFilter.h
Created April 13, 2015 06:06
GPUImage Add Four Input Filter
#import <GPUImageThreeInputFilter.h>
extern NSString *const kGPUImageFourInputTextureVertexShaderString;
@interface GPUImageFourInputFilter : GPUImageThreeInputFilter
{
GPUImageFramebuffer *fourthInputFramebuffer;
GLint filterFourthTextureCoordinateAttribute;
GLint filterInputTextureUniform4;
@xoppa
xoppa / outline.fragment.glsl
Created October 12, 2015 20:42
very basic outline shader
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
const float offset = 1.0 / 128.0;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
@omarojo
omarojo / gist:934863e6f4ddf4bb3f0de7445da573cd
Last active January 19, 2017 20:58
GPUImage newFrameAvailable
self.rawG8OutputTarget = [[GPUImageRawDataOutput alloc] initWithImageSize: aspectSize resultsInBGRAFormat:YES];
[filterChain.output addTarget:self.rawG8OutputTarget];
__weak GPUImageRawDataOutput *weakRawOutput = self.rawG8OutputTarget;
[self.rawG8OutputTarget setNewFrameAvailableBlock:^{
GLubyte *outputBytes = [weakRawOutput rawBytesForImage];
NSInteger bytesPerRow = [weakRawOutput bytesPerRowInOutput];
//I use this variables to create the image to be streamed.
}];