Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mike</title>
<link rel="stylesheet" href="../styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<header>
struct Vector3_A {
float x;
float y;
float z;
};
class Vector3_B {
Vector3_B(float x, float y, float x);
float getX();
The "right-left" rule is a completely regular rule for deciphering C
declarations. It can also be useful in creating them.
First, symbols. Read
* as "pointer to" - always on the left side
[] as "array of" - always on the right side
() as "function returning" - always on the right side
as you encounter them in the declaration.
@mrmikejones
mrmikejones / PrimeSieve.cs
Created March 13, 2013 14:36
Make a list of the prime numbers below a given limit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PrimeSieve
{
class Program
{
static void Main(string[] args)
@mrmikejones
mrmikejones / CollatzChainLength.cs
Created March 5, 2013 10:05
Find the longest Collatz chain below the input number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static uint CollatzNumber(uint number)
@mrmikejones
mrmikejones / IsPrime.cpp
Last active December 14, 2015 05:59
Check if a number is a prime number
#include <stdio.h>
bool IsPrime(int number)
{
if(number == 2) return true;
if(number % 2 == 0 || number == 1) return false;
bool isPrime = true;
int n = 3;
@mrmikejones
mrmikejones / ReverseNumber.cpp
Created February 26, 2013 15:48
Reverse the digits in a number
#include <stdio.h>
int Reverse(int number)
{
int reversed = 0;
while(number > 0)
{
reversed = (reversed * 10) + number%10;
number /= 10;
@mrmikejones
mrmikejones / main.cpp
Created February 13, 2013 10:28
How to add file drag and drop support to a wxWidgets application
#include "main.hpp"
#include "wx/dnd.h"
#include "wx/filename.h"
#define APP_NAME wxString("Drag 'n' Drop Example")
class MyApp: public wxApp
{
virtual bool OnInit();
@mrmikejones
mrmikejones / wxFileHistory.cpp
Created February 12, 2013 11:27
How to set up an "Open Recent" menu in wxWidgets
#include "wx/wx.h"
#include "wx/filename.h"
#include "wx/filehistory.h"
#include "wx/config.h"
#define APP_NAME wxString("File History Example")
class MyApp: public wxApp
{
virtual bool OnInit();
@mrmikejones
mrmikejones / Delegate.cs
Created February 12, 2013 11:26
Example of using delegates in C#
using System;
namespace DelegateExample
{
public class MyClass
{
delegate float MyDelegate(float input);
MyDelegate DelegateFunction;
public void Initialise(bool square)