Skip to content

Instantly share code, notes, and snippets.

@gregkepler
gregkepler / AnimatedGif.cpp
Last active December 7, 2015 20:46
Cinder Simple Animated Gif Player class
#include "AnimatedGif.h"
using namespace ci;
using namespace ci::app;
using namespace std;
void AnimatedGif::init( ci::DataSourceRef filePath, int frameRate ){
if( filePath ){
load( filePath );
}
//
// Music Player
// This class will stream an MP3 file over HTTP using the Direct Show API
//
//////////////////////////////
//
// MusicPlayer.h
//
@shahpoojan
shahpoojan / usb.cpp
Created July 6, 2011 12:57
A code to send data on the USB port for Windows
#include <iostream>
#include <string>
#include <Windows.h>
#include <tchar.h>
#include <stdio.h>
#include <Winbase.h>
HANDLE hCom;
DWORD sendData (const char* data, DWORD size)
@roxlu
roxlu / fun.cpp
Last active January 5, 2021 08:52 — forked from kizzx2/fun.cpp
Using lua 5.2 with C++
// fun.cpp
// This is for Lua 5.2, for Lua 5.1, see https://gist.github.com/kizzx2/1594905
#include <lua.hpp>
#include <iostream>
#include <sstream>
class Foo
{
@douglas-vaz
douglas-vaz / graph_search.cpp
Created March 2, 2013 19:57
Breadth First Search and Depth First Search in C++
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
class Node{
@hosaka
hosaka / jump_table.cpp
Created August 10, 2015 16:34
Jump table example using function pointers in C++
#include <cstdio>
using namespace std;
// function table/jump table example
// various functions that need to be jumped to
void fa() {printf("function a\n");}
void fb() {printf("function b\n");}
void fc() {printf("function c\n");}
void fd() {printf("function d\n");}
@Lerg
Lerg / utils.lua
Last active August 23, 2022 20:09
local mRandom = math.random
local tInsert = table.insert
local app = require('lib.app')
-------------------------------------------
-- Shuffle a table
-------------------------------------------
table.shuffle = function (t)
local n = #t
while n > 2 do
-- n is now the last pertinent index
@taxilian
taxilian / USBNotify.cpp
Created December 16, 2011 18:24
Example of receiving WM_DEVICECHANGE in a plugin
#include <set>
#include "USBNotify.h"
USBNotify::USBNotify()
{
}
USBNotify::~USBNotify()
{
@arrieta
arrieta / lexer.cpp
Last active March 6, 2024 02:41
Simple C++ Lexer
// A simple Lexer meant to demonstrate a few theoretical concepts. It can
// support several parser concepts and is very fast (though speed is not its
// design goal).
//
// J. Arrieta, Nabla Zero Labs
//
// This code is released under the MIT License.
//
// Copyright 2018 Nabla Zero Labs
//
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 21, 2024 23:26
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);