Skip to content

Instantly share code, notes, and snippets.

@declank
declank / hello_triangle.cpp
Created February 1, 2019 14:34
bgfx + SDL starting point (proper threading)
#include <stdio.h>
//#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_syswm.h>
#include <bgfx/bgfx.h>
#include <bgfx/platform.h>
@declank
declank / bgfx_sdl_hello_triangle.cpp
Last active January 31, 2019 11:41
SDL + bgfx Starting Point (no threading)
#include <stdio.h>
//#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_syswm.h>
#include <bgfx/bgfx.h>
#include <bgfx/platform.h>
inline bool setPlatformData(SDL_Window* _window)
@declank
declank / go-play-music.go
Created June 10, 2015 22:19
[Golang] Simple music player that uses ffmpeg and portaudio
package main
import (
"code.google.com/p/portaudio-go/portaudio"
"encoding/binary"
"log"
"io"
"os"
"os/exec"
)
/**
* This file provided by Facebook is for non-commercial testing and evaluation purposes only.
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@declank
declank / gist:d19b0660e91dd4e4f088
Created January 8, 2015 20:19
Using the Google Client APIs for JavaScript (GAPI) with Mocha Test Framework
<script>
var handleClientLoad = function() {
gapi.client.setApiKey(API_KEY_GOES_HERE);
};
var googleApiScriptTag = document.createElement('script');
googleApiScriptTag.src = "https://apis.google.com/js/client.js?onload=handleClientLoad";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(googleApiScriptTag, firstScriptTag);
@declank
declank / sjcl.html
Last active August 29, 2015 14:12
Use of HMAC-SHA256 in the Stanford Javascript Crypto Library (view at http://rawgit.com/declank/689b972dbcbfd3ccc12c/raw/sjcl.html)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Demo of <a href="http://bitwiseshiftleft.github.io/sjcl/" target="_blank">Stanford Javascript Crypto Library</a></h1>
<p>Generates HMAC using SHA-256</p>
<input type="text" id="key" value="key"><br>
<input type="text" id="message" value="The quick brown fox jumps over the lazy dog"><br>
@declank
declank / Server.java
Created December 17, 2014 15:07
[Java] Simple multi-threaded ServerSocket implementation.
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Server implements Runnable {
private volatile boolean isStopped;
private ServerSocket serverSocket;
private final ExecutorService threadPool = Executors.newCachedThreadPool();
@declank
declank / red_black_tree_insertion.cpp
Created December 7, 2014 16:23
Basic red-black tree insertion implementation (C++) [NOTE: Missing destructors/delete, therefore causes memory leaks]
#include <iostream>
#include <string>
using namespace std;
typedef bool NodeColor;
const NodeColor RED = false;
const NodeColor BLACK = true;
inline void test(bool expression, string message) {
cout << message << (expression ? "\tTRUE" : "\tFALSE") << '\n';
@declank
declank / indexer.cpp
Last active August 29, 2015 14:10
Exploring boost::filesystem and C++11 features, a program that indexes and searches (ANSI) text files in a directory.
// File built using the following: (Boost required)
// g++ -std=c++11 indexer.cpp -o indexer -lboost_system -lboost_filesystem
#include <cstring>
#include <forward_list>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
@declank
declank / build_setup_emacs.sh
Created November 20, 2014 05:29
(For Debian distributions with deb-src added) Download, setup and build Emacs from Savannah.
#!/usr/bin/sh
$INITAL_PWD= #todo
# Install binary and source dependencies
sudo apt-get install build-essential checkinstall git-core ccache
sudo apt-get build-dep emacs24
# Install git-merge-changelog
git clone --depth 1 git://git.savannah.gnu.org/gnulib.git