Skip to content

Instantly share code, notes, and snippets.

View bruceoutdoors's full-sized avatar
🧗

Lee Zhen Yong bruceoutdoors

🧗
View GitHub Profile
@bruceoutdoors
bruceoutdoors / 2014_02_24_135909_add_permissions.php
Created February 24, 2014 14:32
Laravel 4 Entrust boilerplate migration file for adding predefined permissions - https://github.com/Zizaco/entrust
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddPermissions extends Migration
{
/**
* Run the migrations.
@bruceoutdoors
bruceoutdoors / sine_anim.cpp
Created April 2, 2014 13:00
A tiny console program that plots a sine graph animation. Runs in VC++.
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <windows.h>
using namespace std;
int main()
{
for (int i = 0; i < 100000; i++) {
@bruceoutdoors
bruceoutdoors / makefile
Created July 2, 2014 15:53
Custom GLUI makefile to build in it windows (MinGW).
.SUFFIXES: .cpp
#for sgi -- comment out the lines below to use on HP
#CC=CC -g0 -o32
#CC=gcc
# Compiler options
#OPTS=-g
#OPTS=-O0
#OPTS=-O3
#pragma once
#include <sstream>
#include <iostream>
class Point
{
public:
typedef std::shared_ptr<Point> SPtr;
typedef std::unique_ptr<Point> UPtr;
#include <iostream>
#include <memory>
#include <string>
#include "Point.hpp"
class PointMan
{
public:
PointMan() : q(new Point("q")) {
q->set(6, 12);
#include <iostream>
#include <memory>
#include <string>
#include <cassert>
#include "Point.hpp"
class PointMan
{
public:
static const size_t SIZE = 3;
#include <iostream>
#include <memory>
#include <string>
#include "Point.hpp"
class PointMan
{
public:
static const size_t SIZE = 3;
PointMan() {
@bruceoutdoors
bruceoutdoors / double-precision-fix.cpp
Created November 17, 2014 07:39
when using double, take note of its precision problem (float and double only store decimal estimates) if you find certain values does not match. A possible solution is to use a custom Round function.
#include <iostream>
#include <cmath>
using namespace std;
// rounds a double variable to nPlaces decimal places
double Round(double dbVal, int nPlaces /* = 0 */)
{
const double dbShift = pow(10.0, nPlaces);
return floor(dbVal * dbShift + 0.5) / dbShift;
@bruceoutdoors
bruceoutdoors / HeapPermute.cpp
Last active August 29, 2015 14:10 — forked from ishikawa/HeapPermute.java
Heap's algorithm is an algorithm used for generating all possible permutations of some given length.
#include <iostream>
using namespace std;
const int SIZE = 4;
void printArray(int arr[], int size)
{
for ( int i = 0; i < size; i++ )
cout << arr[i] << ' ';
@bruceoutdoors
bruceoutdoors / TableToTree.txt
Created March 8, 2015 12:47
Table To Tree Algorithm Pseudocode
TABLE TO TREE ALGORITHM PSEUDOCODE
The algorithm can traverse and read an infinite number of cells of an
infinite number of depth, as it reads the cells in a recursive fashion
with the base case as the leaf of the cells. Note that you should not
think this will work for graphs (there's simply no way you could
represent graphs in a table structure anyway).
Some Notes:
- A cell is either a leaf or a branch.