Skip to content

Instantly share code, notes, and snippets.

@sebasten
sebasten / E32017.md
Last active August 12, 2019 22:52
E3 2017
@insaneyilin
insaneyilin / show_opencv_image_in_opengl.cpp
Last active July 24, 2024 02:37
Show opencv cv::Mat image in an OpenGL window(use GLFW)
/*
# Released under MIT License
Copyright (c) 2017 insaneyilin.
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:
@wngreene
wngreene / ogre_shaders.cpp
Created March 24, 2017 15:49
How to manually load shaders in Ogre. Copied from http://www.ogre3d.org/forums/viewtopic.php?f=2&t=73197
Ogre::HighLevelGpuProgramPtr vertex = Ogre::HighLevelGpuProgramManager::getSingletonPtr()->createProgram( "basicVS", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GpuProgramType::GPT_VERTEX_PROGRAM);
vertex->setSourceFile( "basic.vert" );
Ogre::HighLevelGpuProgramPtr fragment = Ogre::HighLevelGpuProgramManager::getSingletonPtr()->createProgram( "basicFS", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GpuProgramType::GPT_FRAGMENT_PROGRAM);
fragment->setSourceFile( "basic.frag" );
//Creating new material
Ogre::MaterialPtr matPtr = Ogre::MaterialManager::getSingletonPtr()->create( "ProgramShader", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
Ogre::Pass* pass = matPtr->getTechnique(0)->getPass(0);
@simonw
simonw / recover_source_code.md
Last active September 28, 2024 08:10
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@tayvano
tayvano / gist:6e2d456a9897f55025e25035478a3a50
Created February 19, 2017 05:29
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)

Real depth in OpenGL / GLSL

http://olivers.posterous.com/linear-depth-in-glsl-for-real

So, many places will give you clues how to get linear depth from the OpenGL depth buffer, or visualise it, or other things. This, however, is what I believe to be the definitive answer:

This link http://www.songho.ca/opengl/gl_projectionmatrix.html gives a good run-down of the projection matrix, and the link between eye-space Z (z_e below) and normalised device coordinates (NDC) Z (z_n below). From there, we have

A   = -(zFar + zNear) / (zFar - zNear);

B = -2zFarzNear / (zFar - zNear);

@alexlee-gk
alexlee-gk / configure_cuda_p70.md
Last active May 21, 2025 22:43
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@Rob--W
Rob--W / README.md
Last active August 8, 2020 03:02
Analysis of WOT 20151208
@cyhsutw
cyhsutw / MathJax.ipynb
Last active May 26, 2025 01:55
Grabbed from https://github.com/odewahn/ipynb-examples, converted to v3 for GitHub to render.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.