Skip to content

Instantly share code, notes, and snippets.

View cdave1's full-sized avatar
💭
I may be slow to respond.

David Petrie cdave1

💭
I may be slow to respond.
View GitHub Profile
@cdave1
cdave1 / gist:10563386
Created April 13, 2014 00:21
Play an mp3 with SDL2
#include "SDL2/SDL.h"
#include "SDL2/SDL_mixer.h"
static const char *MY_COOL_MP3 = "cool_tunes.mp3";
int main(int argc, char **argv) {
int result = 0;
int flags = MIX_INIT_MP3;
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
#define PRODUCTION_BUILD
#define SUPPRESS_LOGS
using System;
public class StringAllocTest {
public static void Main(string[] args) {
Random random = new Random();
var variable_here_so_runtime_allocation_needed = random.Next(0, 1000000);
Log("HERE IS A VERY LONG STRING, AND IT MIGHT " + variable_here_so_runtime_allocation_needed + " BE SO LONG THAT HEAP MEMORY MUST BE ALLOCATED TO STORE IT OMG!"); //, false);
}
@cdave1
cdave1 / gist:1b781d444bf45338be104f8fe5887db3
Created January 15, 2018 01:05 — forked from carlos8f/gist:b09a734cf626ffb9bb3bcb1ca35f3db4
zenbot sim result, BTC-USD, 90 days, 195.45% profit, 61.06% over buy/hold
2017-05-11 16:00:00 1832.97 USD -0.06% 619.75 + 0.0447 null 1.91% 0.031060 BTC 2897.41 USD 195.43% +61.48%
{ days: 90,
profit_stop_enable_pct: 10,
profit_stop_pct: 1,
sell_rate: -0.006,
trend_ema: 36,
period: '1h',
strategy: 'trend_ema_rate',
sell_stop_pct: 4,
buy_stop_pct: 0,
'use strict';
var paper = require('paper');
paper.setup(new paper.Size(2048, 1440));
function ShapeIntersection() {
var diamond0 = new paper.Path.RegularPolygon(new paper.Point(0, 0), 4, 100);
diamond0.rotate(45.0);
@cdave1
cdave1 / build-banana-pi.3.4.90.sh
Created September 27, 2014 04:24
Shell script for creating banana pi image with kernel 3.4.90
#!/bin/bash
rm -rf build
mkdir -p build
echo "[INFO] Creating u-boot for bananapi"
if [ ! -d u-boot-bananapi ]; then
git clone https://github.com/LeMaker/u-boot-bananapi.git
elif [ -d u-boot-bananapi ]; then
( cd u-boot-bananapi && git pull )
@cdave1
cdave1 / ftglesGlueAndroid.c
Created March 29, 2011 23:58
Changes to ftglBegin and ftglEnd on android...
GLvoid ftglBegin(GLenum prim)
{
if (!ftglesQuadIndicesInitted)
{
for (int i = 0; i < FTGLES_GLUE_MAX_VERTICES * 3 / 2; i += 6)
{
int q = i / 6 * 4;
ftglesGlueArrays.quadIndices[i + 0] = q + 0;
ftglesGlueArrays.quadIndices[i + 1] = q + 1;
ftglesGlueArrays.quadIndices[i + 2] = q + 2;
@cdave1
cdave1 / gist:801522
Created January 29, 2011 04:10
Dot product shadow intensity lookup table...completely broken and slow
static bool hasGeneratedLookup = false;
#define DOT_LOOKUP_SIZE 1024
#define DOT_LOOKUP_BITMASK 1023
static uint8 colorDotLookup[DOT_LOOKUP_SIZE];
/*
* Below code - waste of time; too slow.
*/
inline uint8 hdColorDot(float color, float normal)
{
unsigned i;
@cdave1
cdave1 / Poker tool pseudocode
Created November 26, 2010 07:14
Noodling around with an idea, code is unfinished...
struct card { short suit, short value }
struct player { card first, card second }
struct middle { card flop1, card flop2, card flop3, card turn, card river }
player players[ ]
int my_position
card cards[52]
CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y
CONFIG_MIGHT_HAVE_PCI=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
CONFIG_HAVE_PROC_CPU=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_HWEIGHT=y
ext2load mmc 0 0x48000000 uImage
ext2load mmc 0 0x43000000 sun7i-a20-bananapi.dtb
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait panic=10 ${extra}
bootm 0x48000000