Skip to content

Instantly share code, notes, and snippets.

// Pointers can be easily used to create a 2D array in C using malloc. The idea is to first create a one dimensional array of pointers, and then, for each array entry, // create another one dimensional array. Here's a sample code:
double** theArray;
theArray = (double**) malloc(arraySizeX*sizeof(double*));
for (int i = 0; i < arraySizeX; i++)
theArray[i] = (double*) malloc(arraySizeY*sizeof(double));
// What I usually do is create a function called Make2DDoubleArray that returns a (double**) and then use it in my code to declare 2D arrays here and there
double** Make2DDoubleArray(int arraySizeX, int arraySizeY) {
double** theArray;
theArray = (double**) malloc(arraySizeX*sizeof(double*));
@0xjac
0xjac / private_fork.md
Last active November 2, 2025 13:27
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@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");}
@dpryden
dpryden / ClassLoaderLeakExample.java
Created October 20, 2014 00:01
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
@dermesser
dermesser / rope.cpp
Last active November 5, 2023 00:10
A simple rope implementation in C++ – should work well enough.
// Licensed under MIT license.
// (c) Lewin Bormann 2014
# include <string>
# include <iostream>
# include <list>
# include <cstring>
# include <algorithm>
using std::string;